From 6d4fecae076a2878ebad9b479fba5b7b8d2af3eb Mon Sep 17 00:00:00 2001 From: David Collins Date: Tue, 21 Jun 2022 18:00:47 -0700 Subject: [PATCH 1/2] spmi: spmi-pmic-arb: add platform_get_resource_byname() null checks Add null checks for the output of platform_get_resource_byname() calls to avoid the possibility of a null pointer dereference. Change-Id: I7499933f4b6971233a04730e3e1512949fd7540b Signed-off-by: David Collins --- drivers/spmi/spmi-pmic-arb.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c index feaa7a9e9121..f47633f85848 100644 --- a/drivers/spmi/spmi-pmic-arb.c +++ b/drivers/spmi/spmi-pmic-arb.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ +/* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. */ #include #include @@ -1707,6 +1708,11 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) * which does not result in a devm_request_mem_region() call. */ res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "core"); + if (!res) { + err = -EINVAL; + goto err_put_ctrl; + } + core = devm_ioremap(&ctrl->dev, res->start, resource_size(res)); if (IS_ERR(core)) { err = PTR_ERR(core); @@ -1744,6 +1750,11 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "obsrvr"); + if (!res) { + err = -EINVAL; + goto err_put_ctrl; + } + pmic_arb->rd_base = devm_ioremap(&ctrl->dev, res->start, resource_size(res)); if (IS_ERR(pmic_arb->rd_base)) { @@ -1753,6 +1764,11 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "chnls"); + if (!res) { + err = -EINVAL; + goto err_put_ctrl; + } + pmic_arb->wr_base = devm_ioremap(&ctrl->dev, res->start, resource_size(res)); if (IS_ERR(pmic_arb->wr_base)) { @@ -1822,6 +1838,11 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) pmic_arb->ver_ops->ver_str, hw_ver); res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "intr"); + if (!res) { + err = -EINVAL; + goto err_put_ctrl; + } + pmic_arb->intr = devm_ioremap_resource(&ctrl->dev, res); if (IS_ERR(pmic_arb->intr)) { err = PTR_ERR(pmic_arb->intr); @@ -1829,6 +1850,11 @@ static int spmi_pmic_arb_probe(struct platform_device *pdev) } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cnfg"); + if (!res) { + err = -EINVAL; + goto err_put_ctrl; + } + pmic_arb->cnfg = devm_ioremap_resource(&ctrl->dev, res); if (IS_ERR(pmic_arb->cnfg)) { err = PTR_ERR(pmic_arb->cnfg); From ec6dcfacd3d596086c49b4c9f23958fcdaf1713a Mon Sep 17 00:00:00 2001 From: Subbaraman Narayanamurthy Date: Mon, 8 Aug 2022 19:47:46 -0700 Subject: [PATCH 2/2] iio: adc: qcom-spmi-adc5-gen3: Increase HS_READY poll wait time to 15 ms Currently, before configuring ADC/ADC_TM, we poll for HS_READY bit to be set which has a max poll wait time of 2 ms. As per the recent hardware guidelines, increase this to 15 ms as HS_READY won't be set within 2 ms in some circumstances. Change-Id: I1cafa5052c80c2ef9512e794afd7e01eb39a53f4 Signed-off-by: Subbaraman Narayanamurthy --- drivers/iio/adc/qcom-spmi-adc5-gen3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c index b0c13efc0797..5560625e462d 100644 --- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c @@ -400,7 +400,7 @@ static int adc5_gen3_configure(struct adc5_chip *adc, #define ADC5_GEN3_HS_DELAY_MIN_US 100 #define ADC5_GEN3_HS_DELAY_MAX_US 110 -#define ADC5_GEN3_HS_RETRY_COUNT 20 +#define ADC5_GEN3_HS_RETRY_COUNT 150 static int adc5_gen3_poll_wait_hs(struct adc5_chip *adc, struct adc5_channel_prop *prop) {