linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
@ 2022-06-22 14:49 Julian Haller
  2022-06-22 14:49 ` [PATCH 5.4 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal() Julian Haller
  2022-06-22 15:02 ` [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Guenter Roeck
  0 siblings, 2 replies; 7+ messages in thread
From: Julian Haller @ 2022-06-22 14:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Julian Haller, Guenter Roeck, Rafael J . Wysocki

From: Guenter Roeck <linux@roeck-us.net>

[ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]

The thermal subsystem registers a hwmon driver without providing
chip or sysfs group information. This is for legacy reasons and
would be difficult to change. At the same time, we want to enforce
that chip information is provided when registering a hwmon device
using hwmon_device_register_with_info(). To enable this, introduce
a special API for use only by the thermal subsystem.

Acked-by: Rafael J . Wysocki <rafael@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
 include/linux/hwmon.h |  3 +++
 2 files changed, 28 insertions(+)

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index c73b93b9bb87..e8a9955e3683 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -743,6 +743,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
 }
 EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
 
+/**
+ * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
+ * @dev: the parent device
+ * @name: hwmon name attribute
+ * @drvdata: driver data to attach to created device
+ *
+ * The use of this function is restricted. It is provided for legacy reasons
+ * and must only be called from the thermal subsystem.
+ *
+ * hwmon_device_unregister() must be called when the device is no
+ * longer needed.
+ *
+ * Returns the pointer to the new device.
+ */
+struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+				  void *drvdata)
+{
+	if (!name || !dev)
+		return ERR_PTR(-EINVAL);
+
+	return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
+}
+EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
+
 /**
  * hwmon_device_register - register w/ hwmon
  * @dev: the device to register
diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
index 72579168189d..104c492959b9 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -408,6 +408,9 @@ hwmon_device_register_with_info(struct device *dev,
 				const struct hwmon_chip_info *info,
 				const struct attribute_group **extra_groups);
 struct device *
+hwmon_device_register_for_thermal(struct device *dev, const char *name,
+				  void *drvdata);
+struct device *
 devm_hwmon_device_register_with_info(struct device *dev,
 				const char *name, void *drvdata,
 				const struct hwmon_chip_info *info,
-- 
2.25.1


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

* [PATCH 5.4 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal()
  2022-06-22 14:49 [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Julian Haller
@ 2022-06-22 14:49 ` Julian Haller
  2022-06-22 15:02 ` [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Guenter Roeck
  1 sibling, 0 replies; 7+ messages in thread
From: Julian Haller @ 2022-06-22 14:49 UTC (permalink / raw)
  To: linux-kernel, stable; +Cc: Julian Haller, Guenter Roeck, Rafael J . Wysocki

From: Guenter Roeck <linux@roeck-us.net>

[ upstream commit 87743bcf08072b3e1952a0bf5524b2833e667b4c ]

The thermal subsystem registers a hwmon device without providing chip
information or sysfs attribute groups. While undesirable, it would be
difficult to change. On the other side, it abuses the
hwmon_device_register_with_info API by not providing that information.
Use new API specifically created for the thermal subsystem instead to
let us enforce the 'chip' parameter for other callers of
hwmon_device_register_with_info().

Acked-by: Rafael J . Wysocki <rafael@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/thermal/thermal_hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index dd5d8ee37928..b3b229421936 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -147,8 +147,8 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
 	INIT_LIST_HEAD(&hwmon->tz_list);
 	strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
 	strreplace(hwmon->type, '-', '_');
-	hwmon->device = hwmon_device_register_with_info(&tz->device, hwmon->type,
-							hwmon, NULL, NULL);
+	hwmon->device = hwmon_device_register_for_thermal(&tz->device,
+							  hwmon->type, hwmon);
 	if (IS_ERR(hwmon->device)) {
 		result = PTR_ERR(hwmon->device);
 		goto free_mem;
-- 
2.25.1


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

* Re: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
  2022-06-22 14:49 [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Julian Haller
  2022-06-22 14:49 ` [PATCH 5.4 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal() Julian Haller
@ 2022-06-22 15:02 ` Guenter Roeck
  2022-06-22 15:39   ` Julian Haller
  1 sibling, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2022-06-22 15:02 UTC (permalink / raw)
  To: Julian Haller; +Cc: linux-kernel, stable, Rafael J . Wysocki

On Wed, Jun 22, 2022 at 04:49:01PM +0200, Julian Haller wrote:
> From: Guenter Roeck <linux@roeck-us.net>
> 
> [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> 
> The thermal subsystem registers a hwmon driver without providing
> chip or sysfs group information. This is for legacy reasons and
> would be difficult to change. At the same time, we want to enforce
> that chip information is provided when registering a hwmon device
> using hwmon_device_register_with_info(). To enable this, introduce
> a special API for use only by the thermal subsystem.
> 
> Acked-by: Rafael J . Wysocki <rafael@kernel.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

What is the point of applying those patches to the 5.4 kernel ?
This was intended for use with new code, not for stable releases.

Guenter

> ---
>  drivers/hwmon/hwmon.c | 25 +++++++++++++++++++++++++
>  include/linux/hwmon.h |  3 +++
>  2 files changed, 28 insertions(+)
> 
> diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
> index c73b93b9bb87..e8a9955e3683 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -743,6 +743,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
>  }
>  EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
>  
> +/**
> + * hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
> + * @dev: the parent device
> + * @name: hwmon name attribute
> + * @drvdata: driver data to attach to created device
> + *
> + * The use of this function is restricted. It is provided for legacy reasons
> + * and must only be called from the thermal subsystem.
> + *
> + * hwmon_device_unregister() must be called when the device is no
> + * longer needed.
> + *
> + * Returns the pointer to the new device.
> + */
> +struct device *
> +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> +				  void *drvdata)
> +{
> +	if (!name || !dev)
> +		return ERR_PTR(-EINVAL);
> +
> +	return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
> +}
> +EXPORT_SYMBOL_GPL(hwmon_device_register_for_thermal);
> +
>  /**
>   * hwmon_device_register - register w/ hwmon
>   * @dev: the device to register
> diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h
> index 72579168189d..104c492959b9 100644
> --- a/include/linux/hwmon.h
> +++ b/include/linux/hwmon.h
> @@ -408,6 +408,9 @@ hwmon_device_register_with_info(struct device *dev,
>  				const struct hwmon_chip_info *info,
>  				const struct attribute_group **extra_groups);
>  struct device *
> +hwmon_device_register_for_thermal(struct device *dev, const char *name,
> +				  void *drvdata);
> +struct device *
>  devm_hwmon_device_register_with_info(struct device *dev,
>  				const char *name, void *drvdata,
>  				const struct hwmon_chip_info *info,
> -- 
> 2.25.1
> 

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

* Re: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
  2022-06-22 15:02 ` [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Guenter Roeck
@ 2022-06-22 15:39   ` Julian Haller
  2022-06-22 15:44     ` Guenter Roeck
  0 siblings, 1 reply; 7+ messages in thread
From: Julian Haller @ 2022-06-22 15:39 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: linux-kernel, stable, Julian Haller

> On Wed, Jun 22, 2022 at 04:49:01PM +0200, Julian Haller wrote:
> > From: Guenter Roeck <linux@roeck-us.net>
> > 
> > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> > 
> > The thermal subsystem registers a hwmon driver without providing
> > chip or sysfs group information. This is for legacy reasons and
> > would be difficult to change. At the same time, we want to enforce
> > that chip information is provided when registering a hwmon device
> > using hwmon_device_register_with_info(). To enable this, introduce
> > a special API for use only by the thermal subsystem.
> > 
> > Acked-by: Rafael J . Wysocki <rafael@kernel.org>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> 
> What is the point of applying those patches to the 5.4 kernel ?
> This was intended for use with new code, not for stable releases.
> 
> Guenter

The upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ("hwmon: Make chip
parameter for with_info API mandatory") was backported to the 5.4 kernel as
part of v5.4.198, see commit 1ec0bc72f5dab3ab367ae5230cf6f212d805a225. This
breaks the hwmon device registration in the thermal drivers as these two
patches here have been left out. We either need to include them as well or
revert the original commit.

I'm also not sure why the original commit found its way into the 5.4 stable
branch.

- Julian

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

* Re: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
  2022-06-22 15:39   ` Julian Haller
@ 2022-06-22 15:44     ` Guenter Roeck
  2022-06-22 16:09       ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Guenter Roeck @ 2022-06-22 15:44 UTC (permalink / raw)
  To: Julian Haller; +Cc: linux-kernel, stable

On Wed, Jun 22, 2022 at 05:39:50PM +0200, Julian Haller wrote:
> > On Wed, Jun 22, 2022 at 04:49:01PM +0200, Julian Haller wrote:
> > > From: Guenter Roeck <linux@roeck-us.net>
> > > 
> > > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> > > 
> > > The thermal subsystem registers a hwmon driver without providing
> > > chip or sysfs group information. This is for legacy reasons and
> > > would be difficult to change. At the same time, we want to enforce
> > > that chip information is provided when registering a hwmon device
> > > using hwmon_device_register_with_info(). To enable this, introduce
> > > a special API for use only by the thermal subsystem.
> > > 
> > > Acked-by: Rafael J . Wysocki <rafael@kernel.org>
> > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > What is the point of applying those patches to the 5.4 kernel ?
> > This was intended for use with new code, not for stable releases.
> > 
> > Guenter
> 
> The upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ("hwmon: Make chip
> parameter for with_info API mandatory") was backported to the 5.4 kernel as
> part of v5.4.198, see commit 1ec0bc72f5dab3ab367ae5230cf6f212d805a225. This
> breaks the hwmon device registration in the thermal drivers as these two
> patches here have been left out. We either need to include them as well or
> revert the original commit.
> 
> I'm also not sure why the original commit found its way into the 5.4 stable
> branch.
> 

I had complained about this backport to other branches before. That patch
was not a bug fix, it was neither intended nor marked for stable releases,
and it should be reverted from all stable branches.

Guenter

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

* Re: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
  2022-06-22 15:44     ` Guenter Roeck
@ 2022-06-22 16:09       ` Greg KH
  2022-06-22 16:12         ` Sasha Levin
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2022-06-22 16:09 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Julian Haller, linux-kernel, stable

On Wed, Jun 22, 2022 at 08:44:54AM -0700, Guenter Roeck wrote:
> On Wed, Jun 22, 2022 at 05:39:50PM +0200, Julian Haller wrote:
> > > On Wed, Jun 22, 2022 at 04:49:01PM +0200, Julian Haller wrote:
> > > > From: Guenter Roeck <linux@roeck-us.net>
> > > > 
> > > > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
> > > > 
> > > > The thermal subsystem registers a hwmon driver without providing
> > > > chip or sysfs group information. This is for legacy reasons and
> > > > would be difficult to change. At the same time, we want to enforce
> > > > that chip information is provided when registering a hwmon device
> > > > using hwmon_device_register_with_info(). To enable this, introduce
> > > > a special API for use only by the thermal subsystem.
> > > > 
> > > > Acked-by: Rafael J . Wysocki <rafael@kernel.org>
> > > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > > 
> > > What is the point of applying those patches to the 5.4 kernel ?
> > > This was intended for use with new code, not for stable releases.
> > > 
> > > Guenter
> > 
> > The upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ("hwmon: Make chip
> > parameter for with_info API mandatory") was backported to the 5.4 kernel as
> > part of v5.4.198, see commit 1ec0bc72f5dab3ab367ae5230cf6f212d805a225. This
> > breaks the hwmon device registration in the thermal drivers as these two
> > patches here have been left out. We either need to include them as well or
> > revert the original commit.
> > 
> > I'm also not sure why the original commit found its way into the 5.4 stable
> > branch.
> > 
> 
> I had complained about this backport to other branches before. That patch
> was not a bug fix, it was neither intended nor marked for stable releases,
> and it should be reverted from all stable branches.

Yes, that's not right, let me go revert that.  Odd that it only went
into 4.19 and 5.4, I think Sasha's scripts went wonky there...

thanks,

greg k-h

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

* Re: [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal
  2022-06-22 16:09       ` Greg KH
@ 2022-06-22 16:12         ` Sasha Levin
  0 siblings, 0 replies; 7+ messages in thread
From: Sasha Levin @ 2022-06-22 16:12 UTC (permalink / raw)
  To: Greg KH; +Cc: Guenter Roeck, Julian Haller, linux-kernel, stable

On Wed, Jun 22, 2022 at 06:09:39PM +0200, Greg KH wrote:
>On Wed, Jun 22, 2022 at 08:44:54AM -0700, Guenter Roeck wrote:
>> On Wed, Jun 22, 2022 at 05:39:50PM +0200, Julian Haller wrote:
>> > > On Wed, Jun 22, 2022 at 04:49:01PM +0200, Julian Haller wrote:
>> > > > From: Guenter Roeck <linux@roeck-us.net>
>> > > >
>> > > > [ upstream commit e5d21072054fbadf41cd56062a3a14e447e8c22b ]
>> > > >
>> > > > The thermal subsystem registers a hwmon driver without providing
>> > > > chip or sysfs group information. This is for legacy reasons and
>> > > > would be difficult to change. At the same time, we want to enforce
>> > > > that chip information is provided when registering a hwmon device
>> > > > using hwmon_device_register_with_info(). To enable this, introduce
>> > > > a special API for use only by the thermal subsystem.
>> > > >
>> > > > Acked-by: Rafael J . Wysocki <rafael@kernel.org>
>> > > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
>> > >
>> > > What is the point of applying those patches to the 5.4 kernel ?
>> > > This was intended for use with new code, not for stable releases.
>> > >
>> > > Guenter
>> >
>> > The upstream commit ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5 ("hwmon: Make chip
>> > parameter for with_info API mandatory") was backported to the 5.4 kernel as
>> > part of v5.4.198, see commit 1ec0bc72f5dab3ab367ae5230cf6f212d805a225. This
>> > breaks the hwmon device registration in the thermal drivers as these two
>> > patches here have been left out. We either need to include them as well or
>> > revert the original commit.
>> >
>> > I'm also not sure why the original commit found its way into the 5.4 stable
>> > branch.
>> >
>>
>> I had complained about this backport to other branches before. That patch
>> was not a bug fix, it was neither intended nor marked for stable releases,
>> and it should be reverted from all stable branches.
>
>Yes, that's not right, let me go revert that.  Odd that it only went
>into 4.19 and 5.4, I think Sasha's scripts went wonky there...

Yes, I definitely remember dropping it - not sure how it ended up on
those two kernels. I'll dig into what happened here. sorry :(

-- 
Thanks,
Sasha

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

end of thread, other threads:[~2022-06-22 16:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22 14:49 [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Julian Haller
2022-06-22 14:49 ` [PATCH 5.4 2/2] thermal/drivers/thermal_hwmon: Use hwmon_device_register_for_thermal() Julian Haller
2022-06-22 15:02 ` [PATCH 5.4 1/2] hwmon: Introduce hwmon_device_register_for_thermal Guenter Roeck
2022-06-22 15:39   ` Julian Haller
2022-06-22 15:44     ` Guenter Roeck
2022-06-22 16:09       ` Greg KH
2022-06-22 16:12         ` Sasha Levin

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).