drivers: thermal: tsens: Work with old DTBs
Subsystems (3)
PATCH 1/1 drivers: thermal: tsens: Work with old DTBs
In reply to a message not in the archiveIn order for the old DTBs to continue working, the new interrupt code must not return an error if interrupts are not defined.
--- drivers/thermal/qcom/tsens.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/thermal/qcom/tsens.c +3 -2
@@ -109,7 +109,7 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { - ret = irq; +dev_warn (&pdev->dev,"Missing uplow irq in DT\n" ); goto err_put_device; }
@@ -118,7 +118,8 @@ static int tsens_register(struct tsens_priv *priv)IRQF_TRIGGER_HIGH |IRQF_ONESHOT , dev_name(&pdev->dev), priv);if (ret) { -dev_err (&pdev->dev,"%s: failed to get irq\n" , __func__); +dev_warn (&pdev->dev,"%s: failed to get uplow irq\n" , __func__); + ret =0 ; goto err_put_device; }
Signature · 1 line
2.20.1
Quoted 14 lines · Amit Kucheria
In order for the old DTBs to continue working, the new interrupt code must not return an error if interrupts are not defined.
Fixes 634e11d5b450a ("drivers: thermal: tsens: Add interrupt support")Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/thermal/qcom/tsens.c +0
-0
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 112
Quoted 4 lines
drivers/thermal/qcom/tsens.c +0
-1@@ -109,7 +109,7 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { - ret = irq;
'ret' remains uninitialized here.
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 124
Quoted 13 lines
drivers/thermal/qcom/tsens.c +3
-1+dev_warn (&pdev->dev,"Missing uplow irq in DT\n" ); goto err_put_device; }@@ -118,7 +118,8 @@ static int tsens_register(struct tsens_priv *priv)IRQF_TRIGGER_HIGH |IRQF_ONESHOT , dev_name(&pdev->dev), priv);if (ret) { -dev_err (&pdev->dev,"%s: failed to get irq\n" , __func__); +dev_warn (&pdev->dev,"%s: failed to get uplow irq\n" , __func__); + ret =0 ; goto err_put_device; }
The code now is unable to make a distinction between an error in the DT and the old DT :/
Why not version the DT?
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
Hi Amit,
Thanks for the patch!
Quoted 14 lines · Amit Kucheria
In order for the old DTBs to continue working, the new interrupt code must not return an error if interrupts are not defined.
Fixes 634e11d5b450a ("drivers: thermal: tsens: Add interrupt support")Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/thermal/qcom/tsens.c +0
-0
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 114
Quoted 7 lines
drivers/thermal/qcom/tsens.c +1
-1@@ -109,7 +109,7 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { - ret = irq; +dev_warn (&pdev->dev,"Missing uplow irq in DT\n" ); goto err_put_device; }
platform_get_irq_byname() already logs an error if the IRQ cannot be
found: qcom-tsens 4a9000.thermal-sensor: IRQ uplow not found
To replace that error with a warning (not sure if that is worth it), we would need to replace the call with platform_get_irq_byname_optional().
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 123
Quoted 9 lines
drivers/thermal/qcom/tsens.c +2
-1@@ -118,7 +118,8 @@ static int tsens_register(struct tsens_priv *priv)IRQF_TRIGGER_HIGH |IRQF_ONESHOT , dev_name(&pdev->dev), priv);if (ret) { -dev_err (&pdev->dev,"%s: failed to get irq\n" , __func__); +dev_warn (&pdev->dev,"%s: failed to get uplow irq\n" , __func__); + ret =0 ; goto err_put_device;
In case of the old DT, platform_get_irq_byname() will return -ENXIO, because no interrupt is specified in the device tree.
So we should have already run into the error earlier,
and jumped to "err_put_device".
Is this hunk really necessary?
In other words, wouldn't it be enough to do something like
@@ -110,6 +110,8 @@ static int tsens_register(struct tsens_priv *priv)
irq = platform_get_irq_byname(pdev, "uplow");
if (irq < 0) {
ret = irq;
+ if (ret == -ENXIO)
+ ret = 0;
goto err_put_device;
}
... to essentially ignore only the "IRQ does not exist" condition for old device trees?
Thanks,
Stephan
Quoted 31 lines · Stephan Gerhold
Hi Amit,
Thanks for the patch!
Quoted 14 lines · Amit Kucheria
In order for the old DTBs to continue working, the new interrupt code must not return an error if interrupts are not defined.
Fixes 634e11d5b450a ("drivers: thermal: tsens: Add interrupt support")Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/thermal/qcom/tsens.c +0
-0drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 114
Quoted 7 lines
drivers/thermal/qcom/tsens.c +1
-1@@ -109,7 +109,7 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { - ret = irq; +dev_warn (&pdev->dev,"Missing uplow irq in DT\n" ); goto err_put_device; }
platform_get_irq_byname()already logs an error if the IRQ cannot be
found: qcom-tsens 4a9000.thermal-sensor: IRQ uplow not found
Quoted 2 lines
To replace that error with a warning (not sure if that is worth it), we would need to replace the call with
platform_get_irq_byname_optional().
I didn't know about optional, interesting.
Quoted 15 lines
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 123
Quoted 9 lines
drivers/thermal/qcom/tsens.c +2
-1@@ -118,7 +118,8 @@ static int tsens_register(struct tsens_priv *priv)IRQF_TRIGGER_HIGH |IRQF_ONESHOT , dev_name(&pdev->dev), priv);if (ret) { -dev_err (&pdev->dev,"%s: failed to get irq\n" , __func__); +dev_warn (&pdev->dev,"%s: failed to get uplow irq\n" , __func__); + ret =0 ; goto err_put_device;In case of the old DT,
platform_get_irq_byname()will return-ENXIO, because no interrupt is specified in the device tree.
So we should have already run into the error earlier,
and jumped to "err_put_device".
Quoted 1 line
Is this hunk really necessary?
You're right. Just checking for ENXIO should be enough for old DTs.
Quoted 11 lines
In other words, wouldn't it be enough to do something like
drivers/thermal/qcom/tsens.c +2
-0@@ -110,6 +110,8 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { ret = irq; +if (ret == -ENXIO ) + ret =0 ; goto err_put_device; }
Quoted 2 lines
... to essentially ignore only the "IRQ does not exist" condition for old device trees?
Thanks for the review.
Quoted 40 lines · Daniel Lezcano
Quoted 14 lines · Amit Kucheria
In order for the old DTBs to continue working, the new interrupt code must not return an error if interrupts are not defined.
Fixes 634e11d5b450a ("drivers: thermal: tsens: Add interrupt support")Signed-off-by Amit Kucheria <[email protected]>--- drivers/thermal/qcom/tsens.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/thermal/qcom/tsens.c +0
-0drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 112
Quoted 4 lines
drivers/thermal/qcom/tsens.c +0
-1@@ -109,7 +109,7 @@ static int tsens_register(struct tsens_priv *priv) irq =platform_get_irq_byname (pdev,"uplow" );if (irq <0 ) { - ret = irq;'ret' remains uninitialized here.
drivers/thermal/qcom/tsens.c static int tsens_register(struct tsens_priv *priv) · line 124
Quoted 13 lines
drivers/thermal/qcom/tsens.c +3
-1+dev_warn (&pdev->dev,"Missing uplow irq in DT\n" ); goto err_put_device; }@@ -118,7 +118,8 @@ static int tsens_register(struct tsens_priv *priv)IRQF_TRIGGER_HIGH |IRQF_ONESHOT , dev_name(&pdev->dev), priv);if (ret) { -dev_err (&pdev->dev,"%s: failed to get irq\n" , __func__); +dev_warn (&pdev->dev,"%s: failed to get uplow irq\n" , __func__); + ret =0 ; goto err_put_device; }The code now is unable to make a distinction between an error in the DT and the old DT :/
Quoted 1 line
Why not version the DT?
Versioning the DT is probably overkill for this driver. Just checking for ENXIO as suggested by Stephan seems to be enough. We don't lose the error checking for devm_request_threaded_irq either.
Regards,
Amit