diff mbox series

[4.19,v1,1/2] hwmon: Introduce hwmon_device_register_for_thermal

Message ID 20220629225843.332453-2-willmcvicker@google.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Fixes for thermal hwmon registration | expand

Commit Message

William McVicker June 29, 2022, 10:58 p.m. UTC
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(+)

Comments

Guenter Roeck June 29, 2022, 11:15 p.m. UTC | #1
On 6/29/22 15:58, Will McVicker 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>

NACK. The patch introducing the problem needs to be reverted.

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 c4051a3e63c2..412a5e39fc14 100644
> --- a/drivers/hwmon/hwmon.c
> +++ b/drivers/hwmon/hwmon.c
> @@ -725,6 +725,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 8fde789f2eff..5ff3db6eb9f1 100644
> --- a/include/linux/hwmon.h
> +++ b/include/linux/hwmon.h
> @@ -390,6 +390,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,
William McVicker June 29, 2022, 11:18 p.m. UTC | #2
On 06/29/2022, Guenter Roeck wrote:
> On 6/29/22 15:58, Will McVicker 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>
> 
> NACK. The patch introducing the problem needs to be reverted.

I'm fine with that as well. I've already verified that fixes the issue. I'll go
ahead and send the revert.

Thanks,
Will

> 
> 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 c4051a3e63c2..412a5e39fc14 100644
> > --- a/drivers/hwmon/hwmon.c
> > +++ b/drivers/hwmon/hwmon.c
> > @@ -725,6 +725,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 8fde789f2eff..5ff3db6eb9f1 100644
> > --- a/include/linux/hwmon.h
> > +++ b/include/linux/hwmon.h
> > @@ -390,6 +390,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,
>
Guenter Roeck June 30, 2022, 2:31 a.m. UTC | #3
On 6/29/22 16:18, William McVicker wrote:
> On 06/29/2022, Guenter Roeck wrote:
>> On 6/29/22 15:58, Will McVicker 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>
>>
>> NACK. The patch introducing the problem needs to be reverted.
> 
> I'm fine with that as well. I've already verified that fixes the issue. I'll go
> ahead and send the revert.
> 

My understanding is that it is already queued up.

Guenter
Greg KH June 30, 2022, 6:34 a.m. UTC | #4
On Wed, Jun 29, 2022 at 07:31:10PM -0700, Guenter Roeck wrote:
> On 6/29/22 16:18, William McVicker wrote:
> > On 06/29/2022, Guenter Roeck wrote:
> > > On 6/29/22 15:58, Will McVicker 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>
> > > 
> > > NACK. The patch introducing the problem needs to be reverted.
> > 
> > I'm fine with that as well. I've already verified that fixes the issue. I'll go
> > ahead and send the revert.
> > 
> 
> My understanding is that it is already queued up.

Yes it is, sorry for the delay, will try to push out -rc releases later
today...

greg k-h
diff mbox series

Patch

diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c
index c4051a3e63c2..412a5e39fc14 100644
--- a/drivers/hwmon/hwmon.c
+++ b/drivers/hwmon/hwmon.c
@@ -725,6 +725,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 8fde789f2eff..5ff3db6eb9f1 100644
--- a/include/linux/hwmon.h
+++ b/include/linux/hwmon.h
@@ -390,6 +390,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,