All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors
@ 2022-01-14  9:55 Dmitry Baryshkov
  2022-01-20  7:12 ` Amit Kucheria
  2022-01-20 10:46 ` Amit Kucheria
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2022-01-14  9:55 UTC (permalink / raw)
  To: Amit Kucheria, Thara Gopinath, Andy Gross, Bjorn Andersson,
	Rafael J. Wysocki, Daniel Lezcano, Zhang Rui
  Cc: linux-pm, linux-arm-msm

Register thermal zones as hwmon sensors to let userspace read
temperatures using standard hwmon interface.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
---
 drivers/thermal/qcom/tsens.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
index 99a8d9f3e03c..c13093e8a642 100644
--- a/drivers/thermal/qcom/tsens.c
+++ b/drivers/thermal/qcom/tsens.c
@@ -19,6 +19,7 @@
 #include <linux/slab.h>
 #include <linux/thermal.h>
 #include "tsens.h"
+#include "../thermal_hwmon.h"
 
 /**
  * struct tsens_irq_data - IRQ status and temperature violations
@@ -1060,6 +1061,10 @@ static int tsens_register(struct tsens_priv *priv)
 		priv->sensor[i].tzd = tzd;
 		if (priv->ops->enable)
 			priv->ops->enable(priv, i);
+
+		if (devm_thermal_add_hwmon_sysfs(tzd))
+			dev_warn(priv->dev,
+				 "Failed to add hwmon sysfs attributes\n");
 	}
 
 	/* VER_0 require to set MIN and MAX THRESH
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors
  2022-01-14  9:55 [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors Dmitry Baryshkov
@ 2022-01-20  7:12 ` Amit Kucheria
  2022-01-20  8:09   ` Dmitry Baryshkov
  2022-01-20 10:46 ` Amit Kucheria
  1 sibling, 1 reply; 4+ messages in thread
From: Amit Kucheria @ 2022-01-20  7:12 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Thara Gopinath, Andy Gross, Bjorn Andersson, Rafael J. Wysocki,
	Daniel Lezcano, Zhang Rui, Linux PM list, linux-arm-msm

On Fri, Jan 14, 2022 at 3:25 PM Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> Register thermal zones as hwmon sensors to let userspace read
> temperatures using standard hwmon interface.

What is the usecase for this? Simply to use existing hwmon tools to
read temperatures of the various thermal zones?

> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>  drivers/thermal/qcom/tsens.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 99a8d9f3e03c..c13093e8a642 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -19,6 +19,7 @@
>  #include <linux/slab.h>
>  #include <linux/thermal.h>
>  #include "tsens.h"
> +#include "../thermal_hwmon.h"
>
>  /**
>   * struct tsens_irq_data - IRQ status and temperature violations
> @@ -1060,6 +1061,10 @@ static int tsens_register(struct tsens_priv *priv)
>                 priv->sensor[i].tzd = tzd;
>                 if (priv->ops->enable)
>                         priv->ops->enable(priv, i);
> +
> +               if (devm_thermal_add_hwmon_sysfs(tzd))
> +                       dev_warn(priv->dev,
> +                                "Failed to add hwmon sysfs attributes\n");
>         }
>
>         /* VER_0 require to set MIN and MAX THRESH
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors
  2022-01-20  7:12 ` Amit Kucheria
@ 2022-01-20  8:09   ` Dmitry Baryshkov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2022-01-20  8:09 UTC (permalink / raw)
  To: Amit Kucheria
  Cc: Thara Gopinath, Andy Gross, Bjorn Andersson, Rafael J. Wysocki,
	Daniel Lezcano, Zhang Rui, Linux PM list, linux-arm-msm

On Thu, 20 Jan 2022 at 10:12, Amit Kucheria <amitk@kernel.org> wrote:
>
> On Fri, Jan 14, 2022 at 3:25 PM Dmitry Baryshkov
> <dmitry.baryshkov@linaro.org> wrote:
> >
> > Register thermal zones as hwmon sensors to let userspace read
> > temperatures using standard hwmon interface.
>
> What is the usecase for this? Simply to use existing hwmon tools to
> read temperatures of the various thermal zones?

Yes. To be able to monitor CPU temperatures using the common sensor
interface (like we do on e.g. x86).
Several other thermal drivers also register their thermal zones as
hwmon (QorIQ, Mediatek, Allwinner, Tegra30, etc).

>
> > Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > ---
> >  drivers/thermal/qcom/tsens.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> > index 99a8d9f3e03c..c13093e8a642 100644
> > --- a/drivers/thermal/qcom/tsens.c
> > +++ b/drivers/thermal/qcom/tsens.c
> > @@ -19,6 +19,7 @@
> >  #include <linux/slab.h>
> >  #include <linux/thermal.h>
> >  #include "tsens.h"
> > +#include "../thermal_hwmon.h"
> >
> >  /**
> >   * struct tsens_irq_data - IRQ status and temperature violations
> > @@ -1060,6 +1061,10 @@ static int tsens_register(struct tsens_priv *priv)
> >                 priv->sensor[i].tzd = tzd;
> >                 if (priv->ops->enable)
> >                         priv->ops->enable(priv, i);
> > +
> > +               if (devm_thermal_add_hwmon_sysfs(tzd))
> > +                       dev_warn(priv->dev,
> > +                                "Failed to add hwmon sysfs attributes\n");
> >         }
> >
> >         /* VER_0 require to set MIN and MAX THRESH
> > --
> > 2.34.1
> >



-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors
  2022-01-14  9:55 [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors Dmitry Baryshkov
  2022-01-20  7:12 ` Amit Kucheria
@ 2022-01-20 10:46 ` Amit Kucheria
  1 sibling, 0 replies; 4+ messages in thread
From: Amit Kucheria @ 2022-01-20 10:46 UTC (permalink / raw)
  To: Dmitry Baryshkov
  Cc: Andy Gross, Bjorn Andersson, Rafael J. Wysocki, Daniel Lezcano,
	Zhang Rui, Linux PM list, linux-arm-msm

On Fri, Jan 14, 2022 at 3:25 PM Dmitry Baryshkov
<dmitry.baryshkov@linaro.org> wrote:
>
> Register thermal zones as hwmon sensors to let userspace read
> temperatures using standard hwmon interface.
>
> Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> ---
>  drivers/thermal/qcom/tsens.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/thermal/qcom/tsens.c b/drivers/thermal/qcom/tsens.c
> index 99a8d9f3e03c..c13093e8a642 100644
> --- a/drivers/thermal/qcom/tsens.c
> +++ b/drivers/thermal/qcom/tsens.c
> @@ -19,6 +19,7 @@
>  #include <linux/slab.h>
>  #include <linux/thermal.h>
>  #include "tsens.h"
> +#include "../thermal_hwmon.h"

Just a nit, but can you move this above the tsen.h along with other
system headers?

With that, feel free to add

Acked-by: Amit Kucheria <amitk@kernel.org>

>
>  /**
>   * struct tsens_irq_data - IRQ status and temperature violations
> @@ -1060,6 +1061,10 @@ static int tsens_register(struct tsens_priv *priv)
>                 priv->sensor[i].tzd = tzd;
>                 if (priv->ops->enable)
>                         priv->ops->enable(priv, i);
> +
> +               if (devm_thermal_add_hwmon_sysfs(tzd))
> +                       dev_warn(priv->dev,
> +                                "Failed to add hwmon sysfs attributes\n");
>         }
>
>         /* VER_0 require to set MIN and MAX THRESH
> --
> 2.34.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-01-20 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14  9:55 [PATCH] thermal/drivers/tsens: register thermal zones as hwmon sensors Dmitry Baryshkov
2022-01-20  7:12 ` Amit Kucheria
2022-01-20  8:09   ` Dmitry Baryshkov
2022-01-20 10:46 ` Amit Kucheria

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.