mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Luca Weiss <luca.weiss@fairphone.com>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Zhang Rui" <rui.zhang@intel.com>,
	"Lukasz Luba" <lukasz.luba@arm.com>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Laxman Dewangan" <ldewangan@nvidia.com>,
	"Bjorn Andersson" <andersson@kernel.org>,
	"Konrad Dybcio" <konradybcio@kernel.org>,
	"Hans de Goede" <hansg@kernel.org>,
	"Jens Reidel" <adrian@mainlining.org>,
	"Casey Connolly" <casey.connolly@linaro.org>,
	"Val Packett" <val@packett.cool>,
	"Daniel Lezcano" <daniel.lezcano@kernel.org>,
	~postmarketos/upstreaming@lists.sr.ht,
	phone-devel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pm@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration
Date: Sat, 14 Nov 2026 00:15:52 +0000	[thread overview]
Message-ID: <20261114001552.3ae8f05e@jic23-hlaptop> (raw)
In-Reply-To: <20261113-bat-temp-adc-v3-3-743979a8fd90@fairphone.com>

On Fri, 13 Nov 2026 16:56:44 +0100
Luca Weiss <luca.weiss@fairphone.com> wrote:

> If the devicetree node is not referenced in a zone under /thermal-zones,
> devm_thermal_of_zone_register() will fail with -ENODEV.
> 
> Since the driver is now also registering as an IIO device[0], allow the
> probe to continue without the thermal zone.

Papering over problems, or expected path for some devices?  If it's
expected path we probably don't want to print a message with the
word failed in it.

> 
> We also can't use gadc_thermal_get_temp() anymore because we haven't
> necessarily initialized tz_dev.
> 
> Link: https://git.kernel.org/torvalds/c/3762f5851ac5 [0]
> Signed-off-by: Luca Weiss <luca.weiss@fairphone.com>
> ---
>  drivers/thermal/thermal-generic-adc.c | 20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
> index c6a7a65aa6a6..40a34e97a515 100644
> --- a/drivers/thermal/thermal-generic-adc.c
> +++ b/drivers/thermal/thermal-generic-adc.c
> @@ -86,14 +86,16 @@ static int gadc_thermal_read_raw(struct iio_dev *indio_dev,
>  				 int *val, int *val2, long mask)
>  {
>  	struct gadc_thermal_info *gtinfo = iio_priv(indio_dev);
> +	int iio_val;
>  	int ret;
>  
>  	switch (mask) {
>  	case IIO_CHAN_INFO_PROCESSED:
> -		ret = gadc_thermal_get_temp(gtinfo->tz_dev, val);
> -		if (ret)
> +		ret = iio_read_channel_processed(gtinfo->channel, &iio_val);
> +		if (ret < 0)
>  			return ret;
>  
> +		*val = gadc_thermal_adc_to_temp(gtinfo, iio_val);

Maybe spin a helper that is used both in adc_thermal_get_get_temp()
and here?  Whilst it won't save much code (may actually be a touch longer)
it will put the two relevant steps in one place.


>  		return IIO_VAL_INT;
>  
>  	default:
> @@ -195,14 +197,14 @@ static int gadc_thermal_probe(struct platform_device *pdev)
>  						    &gadc_thermal_ops);
>  	if (IS_ERR(gti->tz_dev)) {
>  		ret = PTR_ERR(gti->tz_dev);
> -		if (ret != -EPROBE_DEFER)
> -			dev_err(dev,
> -				"Thermal zone sensor register failed: %d\n",
> -				ret);
> -		return ret;
> -	}
> +		if (ret != -ENODEV)
> +			return ret;
>  
> -	devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev);
> +		dev_info(dev, "Thermal zone sensor register failed: %d\n",
> +			 ret);
> +	} else {
> +		devm_thermal_add_hwmon_sysfs(dev, gti->tz_dev);
> +	}
>  
>  	return gadc_iio_register(&pdev->dev, gti);
>  }
> 


  parent reply	other threads:[~2026-11-14  0:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13 15:56 [PATCH v3 0/5] Battery temperature ADC plumbing on Qualcomm platforms Luca Weiss
2026-11-13 15:56 ` [PATCH v3 1/5] iio: adc: qcom-spmi-adc5: Add battery thermal channels Luca Weiss
2026-11-13 16:24   ` Andy Shevchenko
2026-11-13 15:56 ` [PATCH v3 2/5] dt-bindings: thermal: generic-adc: Document #io-channel-cells Luca Weiss
2026-11-13 15:56 ` [PATCH v3 3/5] thermal/drivers/generic-adc: Allow probe without TZ registration Luca Weiss
2026-11-13 16:28   ` Andy Shevchenko
2026-11-14  0:15   ` Jonathan Cameron [this message]
2026-11-13 15:56 ` [PATCH v3 4/5] arm64: dts: qcom: pm7250b: Define battery temperature ADC channels Luca Weiss
2026-11-13 15:56 ` [PATCH v3 5/5] arm64: dts: qcom: sm7225-fairphone-fp4: Add battery temperature node Luca Weiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261114001552.3ae8f05e@jic23-hlaptop \
    --to=jic23@kernel.org \
    --cc=adrian@mainlining.org \
    --cc=andersson@kernel.org \
    --cc=andy@kernel.org \
    --cc=casey.connolly@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=hansg@kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=ldewangan@nvidia.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=luca.weiss@fairphone.com \
    --cc=lukasz.luba@arm.com \
    --cc=nuno.sa@analog.com \
    --cc=phone-devel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=val@packett.cool \
    --cc=~postmarketos/upstreaming@lists.sr.ht \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®