From bb50d6564d76fd60eb81420f4a62ad948c0d4011 Mon Sep 17 00:00:00 2001 From: Anjelique Melendez Date: Tue, 15 Feb 2022 10:39:40 -0800 Subject: [PATCH] iio: adc: qcom-spmi-adc5-gen3: Fix order of adc5_gen3_probe() Currently adc5_gen3_probe() registers thermal zone devices and then registers interrupt handlers. While registering the thermal zones the ADC5 GEN3 TM get/set callbacks are called by thermal framework that relies on interrupt completion. Since interrupts have not been registered the callbacks will time out. Fix this and add error handling for thermal zone registration. Change-Id: I3ad94211f7831c94b0847fda549295ecfebcb90b Signed-off-by: Anjelique Melendez --- drivers/iio/adc/qcom-spmi-adc5-gen3.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/iio/adc/qcom-spmi-adc5-gen3.c b/drivers/iio/adc/qcom-spmi-adc5-gen3.c index 9916c01c48ad..e1eb6a96b667 100644 --- a/drivers/iio/adc/qcom-spmi-adc5-gen3.c +++ b/drivers/iio/adc/qcom-spmi-adc5-gen3.c @@ -1300,13 +1300,13 @@ static int adc_tm_register_tzd(struct adc5_chip *adc) default: pr_err("Invalid ADC_TM type:%d for dt_ch:%d\n", adc->chan_props[i].adc_tm, adc->chan_props[i].channel); - continue; + return -EINVAL; } if (IS_ERR(tzd)) { pr_err("Error registering TZ zone:%ld for dt_ch:%d\n", PTR_ERR(tzd), adc->chan_props[i].channel); - continue; + return PTR_ERR(tzd); } adc->chan_props[i].tzd = tzd; } @@ -1700,8 +1700,6 @@ static int adc5_gen3_probe(struct platform_device *pdev) goto fail; } - adc_tm_register_tzd(adc); - for (i = 0; i < adc->num_sdams; i++) { ret = devm_request_irq(dev, adc->base[i].irq, adc5_gen3_isr, 0, adc->base[i].irq_name, adc); @@ -1709,6 +1707,10 @@ static int adc5_gen3_probe(struct platform_device *pdev) goto fail; } + ret = adc_tm_register_tzd(adc); + if (ret < 0) + goto fail; + if (adc->n_tm_channels) INIT_WORK(&adc->tm_handler_work, tm_handler_work);