From: Chanwoo Choi <cw00.choi@samsung.com>
To: Jonghwa Lee <jonghwa3.lee@samsung.com>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
jdelvare@suse.de, linux@roeck-us.net
Subject: Re: [lm-sensors] [PATCH] hwmon: ntc_thermistor: Add ntc thermistor to thermal subsystem as a sensor.
Date: Tue, 26 Aug 2014 10:12:11 +0000 [thread overview]
Message-ID: <53FC5D7B.4040506@samsung.com> (raw)
In-Reply-To: <1409031220-25922-1-git-send-email-jonghwa3.lee@samsung.com>
Hi Jonghwa,
On 08/26/2014 02:33 PM, Jonghwa Lee wrote:
> To get more comprehensive and integrated thermal management, it adds ntc
> thermistor to thermal framework as a thermal sensor. It's governed thermal
> susbsystem only if it is described in DT node. Otherwise, it just notifies
> temperature to userspace via sysfs as it used to be.
>
> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
> ---
> .../devicetree/bindings/hwmon/ntc_thermistor.txt | 3 +++
> drivers/hwmon/ntc_thermistor.c | 26 ++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> index 2391e5c..fcca8e7 100644
> --- a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> +++ b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> @@ -25,6 +25,9 @@ Requires node properties:
> - "io-channels" Channel node of ADC to be used for
> conversion.
>
> +Optional node properties:
> +- "#thermal-sensor-cells" Used to expose itself to thermal fw.
> +
> Read more about iio bindings at
> Documentation/devicetree/bindings/iio/iio-bindings.txt
>
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index bd41072..369dc8c 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -38,6 +38,7 @@
>
> #include <linux/hwmon.h>
> #include <linux/hwmon-sysfs.h>
> +#include <linux/thermal.h>
>
> struct ntc_compensation {
> int temp_c;
> @@ -182,6 +183,7 @@ struct ntc_data {
> struct device *dev;
> int n_comp;
> char name[PLATFORM_NAME_SIZE];
> + struct thermal_zone_device *tz;
> };
>
> #if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO)
> @@ -428,6 +430,20 @@ static int ntc_thermistor_get_ohm(struct ntc_data *data)
> return -EINVAL;
> }
>
> +static int ntc_read_temp(void *dev, long *temp)
> +{
> + struct ntc_data *data = dev_get_drvdata(dev);
> + int ohm;
> +
> + ohm = ntc_thermistor_get_ohm(data);
> + if (ohm < 0)
> + return ohm;
> +
> + *temp = get_temp_mc(data, ohm);
> +
> + return 0;
> +}
> +
> static ssize_t ntc_show_name(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> @@ -562,6 +578,13 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
> dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n",
> pdev_id->name);
>
> + data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
> + ntc_read_temp, NULL);
> + if (IS_ERR(data->tz)) {
> + dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
> + data->tz = NULL;
> + }
> +
> return 0;
> err_after_sysfs:
> sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
> @@ -578,6 +601,9 @@ static int ntc_thermistor_remove(struct platform_device *pdev)
> sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
> ntc_iio_channel_release(pdata);
>
> + if (data->tz)
> + thermal_zone_of_sensor_unregister(data->dev, data->tz);
thermal_zone_of_sensor_unregister just return without operation if data->tz is NULL.
So, don't need to check the value of data->tz with if statement.
Thanks,
Chanwoo Choi
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: Chanwoo Choi <cw00.choi@samsung.com>
To: Jonghwa Lee <jonghwa3.lee@samsung.com>
Cc: linux-kernel@vger.kernel.org, lm-sensors@lm-sensors.org,
jdelvare@suse.de, linux@roeck-us.net
Subject: Re: [PATCH] hwmon: ntc_thermistor: Add ntc thermistor to thermal subsystem as a sensor.
Date: Tue, 26 Aug 2014 19:12:11 +0900 [thread overview]
Message-ID: <53FC5D7B.4040506@samsung.com> (raw)
In-Reply-To: <1409031220-25922-1-git-send-email-jonghwa3.lee@samsung.com>
Hi Jonghwa,
On 08/26/2014 02:33 PM, Jonghwa Lee wrote:
> To get more comprehensive and integrated thermal management, it adds ntc
> thermistor to thermal framework as a thermal sensor. It's governed thermal
> susbsystem only if it is described in DT node. Otherwise, it just notifies
> temperature to userspace via sysfs as it used to be.
>
> Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
> ---
> .../devicetree/bindings/hwmon/ntc_thermistor.txt | 3 +++
> drivers/hwmon/ntc_thermistor.c | 26 ++++++++++++++++++++
> 2 files changed, 29 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> index 2391e5c..fcca8e7 100644
> --- a/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> +++ b/Documentation/devicetree/bindings/hwmon/ntc_thermistor.txt
> @@ -25,6 +25,9 @@ Requires node properties:
> - "io-channels" Channel node of ADC to be used for
> conversion.
>
> +Optional node properties:
> +- "#thermal-sensor-cells" Used to expose itself to thermal fw.
> +
> Read more about iio bindings at
> Documentation/devicetree/bindings/iio/iio-bindings.txt
>
> diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
> index bd41072..369dc8c 100644
> --- a/drivers/hwmon/ntc_thermistor.c
> +++ b/drivers/hwmon/ntc_thermistor.c
> @@ -38,6 +38,7 @@
>
> #include <linux/hwmon.h>
> #include <linux/hwmon-sysfs.h>
> +#include <linux/thermal.h>
>
> struct ntc_compensation {
> int temp_c;
> @@ -182,6 +183,7 @@ struct ntc_data {
> struct device *dev;
> int n_comp;
> char name[PLATFORM_NAME_SIZE];
> + struct thermal_zone_device *tz;
> };
>
> #if defined(CONFIG_OF) && IS_ENABLED(CONFIG_IIO)
> @@ -428,6 +430,20 @@ static int ntc_thermistor_get_ohm(struct ntc_data *data)
> return -EINVAL;
> }
>
> +static int ntc_read_temp(void *dev, long *temp)
> +{
> + struct ntc_data *data = dev_get_drvdata(dev);
> + int ohm;
> +
> + ohm = ntc_thermistor_get_ohm(data);
> + if (ohm < 0)
> + return ohm;
> +
> + *temp = get_temp_mc(data, ohm);
> +
> + return 0;
> +}
> +
> static ssize_t ntc_show_name(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> @@ -562,6 +578,13 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
> dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n",
> pdev_id->name);
>
> + data->tz = thermal_zone_of_sensor_register(data->dev, 0, data->dev,
> + ntc_read_temp, NULL);
> + if (IS_ERR(data->tz)) {
> + dev_dbg(&pdev->dev, "Failed to register to thermal fw.\n");
> + data->tz = NULL;
> + }
> +
> return 0;
> err_after_sysfs:
> sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
> @@ -578,6 +601,9 @@ static int ntc_thermistor_remove(struct platform_device *pdev)
> sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
> ntc_iio_channel_release(pdata);
>
> + if (data->tz)
> + thermal_zone_of_sensor_unregister(data->dev, data->tz);
thermal_zone_of_sensor_unregister just return without operation if data->tz is NULL.
So, don't need to check the value of data->tz with if statement.
Thanks,
Chanwoo Choi
next prev parent reply other threads:[~2014-08-26 10:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-26 5:33 [lm-sensors] [PATCH] hwmon: ntc_thermistor: Add ntc thermistor to thermal subsystem as a sensor Jonghwa Lee
2014-08-26 5:33 ` Jonghwa Lee
2014-08-26 10:12 ` Chanwoo Choi [this message]
2014-08-26 10:12 ` Chanwoo Choi
2014-08-26 13:51 ` [lm-sensors] " Guenter Roeck
2014-08-26 13:51 ` Guenter Roeck
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=53FC5D7B.4040506@samsung.com \
--to=cw00.choi@samsung.com \
--cc=jdelvare@suse.de \
--cc=jonghwa3.lee@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.