Linux Power Management development
 help / color / mirror / Atom feed
From: Lukasz Luba <lukasz.luba@arm.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: linux-pm@vger.kernel.org, Conor Dooley <conor+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Rob Herring <robh@kernel.org>,
	devicetree@vger.kernel.org, Zhang Rui <rui.zhang@intel.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] thermal: thermal-generic-adc: add temperature sensor channel
Date: Fri, 28 Feb 2025 13:11:52 +0000	[thread overview]
Message-ID: <99ee61dc-abd5-45d9-8d26-a8f0ae94c8eb@arm.com> (raw)
In-Reply-To: <20250219082817.56339-3-clamor95@gmail.com>

Hi Svyatoslav,

On 2/19/25 08:28, Svyatoslav Ryhel wrote:
> Add IIO sensor channel along with existing thermal sensor cell. This
> would benefit devices that use adc sensors to detect temperature and
> need a custom conversion table.
> 
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
>   drivers/thermal/thermal-generic-adc.c | 54 ++++++++++++++++++++++++++-
>   1 file changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c
> index ee3d0aa31406..a8f3b965b39b 100644
> --- a/drivers/thermal/thermal-generic-adc.c
> +++ b/drivers/thermal/thermal-generic-adc.c
> @@ -7,6 +7,7 @@
>    * Author: Laxman Dewangan <ldewangan@nvidia.com>
>    */
>   #include <linux/iio/consumer.h>
> +#include <linux/iio/iio.h>
>   #include <linux/kernel.h>
>   #include <linux/module.h>
>   #include <linux/platform_device.h>
> @@ -73,6 +74,57 @@ static const struct thermal_zone_device_ops gadc_thermal_ops = {
>   	.get_temp = gadc_thermal_get_temp,
>   };
>   
> +static const struct iio_chan_spec gadc_thermal_iio_channel[] = {
> +	{
> +		.type = IIO_TEMP,
> +		.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
> +	}
> +};
> +
> +static int gadc_thermal_read_raw(struct iio_dev *indio_dev,
> +				 struct iio_chan_spec const *chan,
> +				 int *temp, int *val2, long mask)
> +{
> +	struct gadc_thermal_info *gtinfo = iio_priv(indio_dev);
> +	int ret;
> +
> +	if (mask != IIO_CHAN_INFO_PROCESSED)
> +		return -EINVAL;
> +
> +	ret = gadc_thermal_get_temp(gtinfo->tz_dev, temp);
> +	if (ret < 0)
> +		return ret;
> +
> +	*temp /= 1000;
> +
> +	return IIO_VAL_INT;
> +}
> +
> +static const struct iio_info gadc_thermal_iio_info = {
> +	.read_raw = gadc_thermal_read_raw,
> +};
> +
> +static int gadc_iio_register(struct device *dev, struct gadc_thermal_info *gti)
> +{
> +	struct gadc_thermal_info *gtinfo;
> +	struct iio_dev *indio_dev;
> +
> +	indio_dev = devm_iio_device_alloc(dev, sizeof(struct gadc_thermal_info));
> +	if (!indio_dev)
> +		return -ENOMEM;
> +
> +	gtinfo = iio_priv(indio_dev);
> +	memcpy(gtinfo, gti, sizeof(struct gadc_thermal_info));
> +
> +	indio_dev->name = dev_name(dev);
> +	indio_dev->info = &gadc_thermal_iio_info;
> +	indio_dev->modes = INDIO_DIRECT_MODE;
> +	indio_dev->channels = gadc_thermal_iio_channel;
> +	indio_dev->num_channels = ARRAY_SIZE(gadc_thermal_iio_channel);
> +
> +	return devm_iio_device_register(dev, indio_dev);

I don't get the idea why we need iio device, while we already have the
hwmon.

Could you explain this a bit more, the cover letter also misses
such justification and details.

Regards,
Lukasz

  reply	other threads:[~2025-02-28 13:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19  8:28 [PATCH v2 0/2] thermal: thermal-generic-adc: add temp sensor function Svyatoslav Ryhel
2025-02-19  8:28 ` [PATCH v2 1/2] dt-bindings: thermal: generic-adc: Add optional io-channel-cells property Svyatoslav Ryhel
2025-02-21 21:13   ` Rob Herring
2025-02-22  7:12     ` Svyatoslav Ryhel
2025-02-19  8:28 ` [PATCH v2 2/2] thermal: thermal-generic-adc: add temperature sensor channel Svyatoslav Ryhel
2025-02-28 13:11   ` Lukasz Luba [this message]
2025-02-28 13:22     ` Svyatoslav Ryhel
2025-03-03 10:53       ` Lukasz Luba
2025-03-03 11:08         ` Svyatoslav Ryhel

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=99ee61dc-abd5-45d9-8d26-a8f0ae94c8eb@arm.com \
    --to=lukasz.luba@arm.com \
    --cc=clamor95@gmail.com \
    --cc=conor+dt@kernel.org \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robh@kernel.org \
    --cc=rui.zhang@intel.com \
    /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