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 <quic_amelende@quicinc.com>
This commit is contained in:
Anjelique Melendez 2022-02-15 10:39:40 -08:00 committed by David Collins
parent 2d1c9eacee
commit bb50d6564d

View File

@ -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);