* [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm
@ 2017-09-26 12:52 Quentin Schulz
2017-09-26 12:52 ` [PATCH 2/2] iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node Quentin Schulz
2017-09-30 17:45 ` [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Jonathan Cameron
0 siblings, 2 replies; 4+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:52 UTC (permalink / raw)
To: linux-arm-kernel
This driver has a get_temp function used by the thermal framework that
uses pm functions.
However, the driver isn't registered in pm before it is registered in
thermal framework, resulting in the pm_resume not being called and thus
the IP not enabled.
When the IP is disabled, the raw temp value is always 0. With the
devices currently supported, it isn't a problem since with their
respective formula, they return a really cold SoC temperature which
isn't a problem for the thermal framework. But for future SoC that have
a different formula, it could return a critically hot temperature,
forcing the thermal framework to shutdown the board.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
drivers/iio/adc/sun4i-gpadc-iio.c | 34 ++++++++++++++------------------
1 file changed, 15 insertions(+), 19 deletions(-)
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 137f577..392d47f 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -529,17 +529,10 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
return ret;
}
- if (!IS_ENABLED(CONFIG_THERMAL_OF))
- return 0;
+ if (IS_ENABLED(CONFIG_THERMAL_OF))
+ info->sensor_device = &pdev->dev;
- info->sensor_device = &pdev->dev;
- info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0,
- info, &sun4i_ts_tz_ops);
- if (IS_ERR(info->tzd))
- dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
- PTR_ERR(info->tzd));
-
- return PTR_ERR_OR_ZERO(info->tzd);
+ return 0;
}
static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
@@ -586,15 +579,6 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
* return the temperature.
*/
info->sensor_device = pdev->dev.parent;
- info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
- 0, info,
- &sun4i_ts_tz_ops);
- if (IS_ERR(info->tzd)) {
- dev_err(&pdev->dev,
- "could not register thermal sensor: %ld\n",
- PTR_ERR(info->tzd));
- return PTR_ERR(info->tzd);
- }
} else {
indio_dev->num_channels =
ARRAY_SIZE(sun4i_gpadc_channels_no_temp);
@@ -664,6 +648,18 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
pm_runtime_set_suspended(&pdev->dev);
pm_runtime_enable(&pdev->dev);
+ if (IS_ENABLED(CONFIG_THERMAL_OF)) {
+ info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
+ 0, info,
+ &sun4i_ts_tz_ops);
+ if (IS_ERR(info->tzd)) {
+ dev_err(&pdev->dev,
+ "could not register thermal sensor: %ld\n",
+ PTR_ERR(info->tzd));
+ return PTR_ERR(info->tzd);
+ }
+ }
+
ret = devm_iio_device_register(&pdev->dev, indio_dev);
if (ret < 0) {
dev_err(&pdev->dev, "could not register the device\n");
base-commit: 1f183459b5144384e2669a3f757d36bacab108cf
--
git-series 0.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node
2017-09-26 12:52 [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Quentin Schulz
@ 2017-09-26 12:52 ` Quentin Schulz
2017-09-26 13:20 ` Maxime Ripard
2017-09-30 17:45 ` [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Jonathan Cameron
1 sibling, 1 reply; 4+ messages in thread
From: Quentin Schulz @ 2017-09-26 12:52 UTC (permalink / raw)
To: linux-arm-kernel
Before this patch, forgetting to put a thermal-zones DT node would
result in the driver failing to probe.
It should be perfectly acceptable to have the driver probe even if no
thermal-zones DT is found. However, it shouldn't want to fail if the
thermal registering fail for any other reason (waiting for other drivers
for example) so check on ENODEV only.
Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
drivers/iio/adc/sun4i-gpadc-iio.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
index 392d47f..46fe0b5 100644
--- a/drivers/iio/adc/sun4i-gpadc-iio.c
+++ b/drivers/iio/adc/sun4i-gpadc-iio.c
@@ -652,7 +652,11 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
0, info,
&sun4i_ts_tz_ops);
- if (IS_ERR(info->tzd)) {
+ /*
+ * Do not fail driver probing when failing to register in
+ * thermal because no thermal DT node is found.
+ */
+ if (IS_ERR(info->tzd) && PTR_ERR(info->tzd) != -ENODEV) {
dev_err(&pdev->dev,
"could not register thermal sensor: %ld\n",
PTR_ERR(info->tzd));
--
git-series 0.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm
2017-09-26 12:52 [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Quentin Schulz
2017-09-26 12:52 ` [PATCH 2/2] iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node Quentin Schulz
@ 2017-09-30 17:45 ` Jonathan Cameron
1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Cameron @ 2017-09-30 17:45 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, 26 Sep 2017 14:52:18 +0200
Quentin Schulz <quentin.schulz@free-electrons.com> wrote:
> This driver has a get_temp function used by the thermal framework that
> uses pm functions.
>
> However, the driver isn't registered in pm before it is registered in
> thermal framework, resulting in the pm_resume not being called and thus
> the IP not enabled.
>
> When the IP is disabled, the raw temp value is always 0. With the
> devices currently supported, it isn't a problem since with their
> respective formula, they return a really cold SoC temperature which
> isn't a problem for the thermal framework. But for future SoC that have
> a different formula, it could return a critically hot temperature,
> forcing the thermal framework to shutdown the board.
>
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
Hmm. I wondered about sending this as a fix, but decided in the end
that your argument convinced me we could let this go the slow way.
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with.
Thanks,
Jonathan
> ---
> drivers/iio/adc/sun4i-gpadc-iio.c | 34 ++++++++++++++------------------
> 1 file changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index 137f577..392d47f 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -529,17 +529,10 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev,
> return ret;
> }
>
> - if (!IS_ENABLED(CONFIG_THERMAL_OF))
> - return 0;
> + if (IS_ENABLED(CONFIG_THERMAL_OF))
> + info->sensor_device = &pdev->dev;
>
> - info->sensor_device = &pdev->dev;
> - info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0,
> - info, &sun4i_ts_tz_ops);
> - if (IS_ERR(info->tzd))
> - dev_err(&pdev->dev, "could not register thermal sensor: %ld\n",
> - PTR_ERR(info->tzd));
> -
> - return PTR_ERR_OR_ZERO(info->tzd);
> + return 0;
> }
>
> static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> @@ -586,15 +579,6 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev,
> * return the temperature.
> */
> info->sensor_device = pdev->dev.parent;
> - info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
> - 0, info,
> - &sun4i_ts_tz_ops);
> - if (IS_ERR(info->tzd)) {
> - dev_err(&pdev->dev,
> - "could not register thermal sensor: %ld\n",
> - PTR_ERR(info->tzd));
> - return PTR_ERR(info->tzd);
> - }
> } else {
> indio_dev->num_channels =
> ARRAY_SIZE(sun4i_gpadc_channels_no_temp);
> @@ -664,6 +648,18 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
> pm_runtime_set_suspended(&pdev->dev);
> pm_runtime_enable(&pdev->dev);
>
> + if (IS_ENABLED(CONFIG_THERMAL_OF)) {
> + info->tzd = thermal_zone_of_sensor_register(info->sensor_device,
> + 0, info,
> + &sun4i_ts_tz_ops);
> + if (IS_ERR(info->tzd)) {
> + dev_err(&pdev->dev,
> + "could not register thermal sensor: %ld\n",
> + PTR_ERR(info->tzd));
> + return PTR_ERR(info->tzd);
> + }
> + }
> +
> ret = devm_iio_device_register(&pdev->dev, indio_dev);
> if (ret < 0) {
> dev_err(&pdev->dev, "could not register the device\n");
>
> base-commit: 1f183459b5144384e2669a3f757d36bacab108cf
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-09-30 17:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-26 12:52 [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Quentin Schulz
2017-09-26 12:52 ` [PATCH 2/2] iio: adc: sun4i-gpadc-iio: do not fail probing when no thermal DT node Quentin Schulz
2017-09-26 13:20 ` Maxime Ripard
2017-09-30 17:45 ` [PATCH 1/2] iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).