hwmon: Fix WARN_ON() always called from devm_hwmon_device_unregister()
PATCH 1/1 hwmon: Fix WARN_ON() always called from devm_hwmon_device_unregister()
devm_hwmon_device_unregister() only takes parent of a devres-managed hwmon device as an argument. This always fails, as devres can't find the hwmon device it needs to unregister with the parent device alone. Without this patch, the WARN_ON() in devm_hwmon_device_unregister() will always be displayed unconditionally:
[ 7.969746] WARNING: CPU: 1 PID: 224 at drivers/hwmon/hwmon.c:1205 devm_hwmon_device_unregister+0x28/0x30
This patch adds an extra argument to devm_hwmon_device_unregister(), a pointer to a hwmon device which was previously registered to the parent using devres.
There aren't any drivers which currently make use of this function, so any existing users of devm_hwmon_* shouldn't require any changes as a result of this patch.
--- drivers/hwmon/hwmon.c | 6 ++++-- include/linux/hwmon.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/hwmon/hwmon.c +4 -2
@@ -1199,10 +1199,12 @@ static int devm_hwmon_match(struct device *dev, void *res, void *data)* devm_hwmon_device_unregister - removes a previously registered hwmon device * * @dev: the parent device of the device to unregister +* @hwdev: the hwmon device to unregister */ -void devm_hwmon_device_unregister (struct device *dev) +void devm_hwmon_device_unregister (struct device *dev,struct device *hwdev) { -WARN_ON (devres_release (dev, devm_hwmon_release, devm_hwmon_match, dev)); +WARN_ON (devres_release (dev, devm_hwmon_release, devm_hwmon_match, + hwdev)); }EXPORT_SYMBOL_GPL (devm_hwmon_device_unregister);
include/linux/hwmon.h +1 -1
@@ -481,7 +481,7 @@ devm_hwmon_device_register_with_info(struct device *dev, const struct attribute_group **extra_groups);void hwmon_device_unregister (struct device *dev); -void devm_hwmon_device_unregister (struct device *dev); +void devm_hwmon_device_unregister (struct device *dev,struct device *hwdev);int hwmon_notify_event (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel);
Signature · 1 line
2.46.0
Guenter Roeck
maintainerQuoted 8 lines · Matthew Sanders
devm_hwmon_device_unregister()only takes parent of a devres-managed hwmon device as an argument. This always fails, as devres can't find the hwmon device it needs to unregister with the parent device alone. Without this patch, theWARN_ON()indevm_hwmon_device_unregister()will always be displayed unconditionally:[ 7.969746] WARNING: CPU: 1 PID: 224 at drivers/hwmon/hwmon.c:1205 devm_hwmon_device_unregister+0x28/0x30
Quoted 7 lines
This patch adds an extra argument to
devm_hwmon_device_unregister(), a pointer to a hwmon device which was previously registered to the parent using devres.There aren't any drivers which currently make use of this function, so any existing users of devm_hwmon_* shouldn't require any changes as a result of this patch.
If there are no users, there is no need to keep the function. We should drop it instead.
Also, your patch is not signed and therefore can not be applied.
Guenter
Quoted 37 lines
--- drivers/hwmon/hwmon.c | 6 ++++-- include/linux/hwmon.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)drivers/hwmon/hwmon.c +4
-2@@ -1199,10 +1199,12 @@ static int devm_hwmon_match(struct device *dev, void *res, void *data)* devm_hwmon_device_unregister - removes a previously registered hwmon device * * @dev: the parent device of the device to unregister +* @hwdev: the hwmon device to unregister */ -void devm_hwmon_device_unregister (struct device *dev) +void devm_hwmon_device_unregister (struct device *dev,struct device *hwdev) { -WARN_ON (devres_release (dev, devm_hwmon_release, devm_hwmon_match, dev)); +WARN_ON (devres_release (dev, devm_hwmon_release, devm_hwmon_match, + hwdev)); }EXPORT_SYMBOL_GPL (devm_hwmon_device_unregister);include/linux/hwmon.h +1
-1@@ -481,7 +481,7 @@ devm_hwmon_device_register_with_info(struct device *dev, const struct attribute_group **extra_groups);void hwmon_device_unregister (struct device *dev); -void devm_hwmon_device_unregister (struct device *dev); +void devm_hwmon_device_unregister (struct device *dev,struct device *hwdev);int hwmon_notify_event (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel);
Quoted 25 lines · Guenter Roeck
Quoted 18 lines · Matthew Sanders
devm_hwmon_device_unregister()only takes parent of a devres- managed
hwmon device as an argument. This always fails, as devres can't find
the hwmon device it needs to unregister with the parent device alone.
Without this patch, theWARN_ON()indevm_hwmon_device_unregister()will
always be displayed unconditionally:[ 7.969746] WARNING: CPU: 1 PID: 224 at
drivers/hwmon/hwmon.c:1205devm_hwmon_device_unregister+0x28/0x30This patch adds an extra argument to
devm_hwmon_device_unregister(), a
pointer to a hwmon device which was previously registered to the parent using devres.Quoted 5 lines
There aren't any drivers which currently make use of this function, so
any existing users of devm_hwmon_* shouldn't require any changes as a
result of this patch.
Quoted 3 lines
If there are no users, there is no need to keep the function. We should drop
it instead.
There aren't any direct in-tree users of the function. But some out- of-tree drivers can find it useful to use, hence Matt hitting this issue.
If there's a desire to just remove it, that's fine. But it would remove a handy hook for out-of-tree stuff.
-PJ
Quoted 52 lines
Also, your patch is not signed and therefore can not be applied.
Guenter
Quoted 46 lines
---
drivers/hwmon/hwmon.c| 6 ++++--
include/linux/hwmon.h| 2 +-2 files changed, 5 insertions(+), 3 deletions(-)drivers/hwmon/hwmon.c +0
-0@@ -1199,10 +1199,12 @@ static int devm_hwmon_match(struct device *dev, void *res, void *data) * devm_hwmon_device_unregister - removes a previously registeredhwmon device
*
* @dev: the parent device of the device to unregister
+ * @hwdev: the hwmon device to unregister
*/drivers/hwmon/hwmon.c +1
-1-void devm_hwmon_device_unregister (struct device *dev) +void devm_hwmon_device_unregister(struct device *dev, structdevice *hwdev)
{drivers/hwmon/hwmon.c +0
-1- WARN_ON(devres_release(dev, devm_hwmon_release,
devm_hwmon_match, dev));drivers/hwmon/hwmon.c +1
-0+ WARN_ON(devres_release(dev, devm_hwmon_release,
devm_hwmon_match,drivers/hwmon/hwmon.c +1
-0+ hwdev));}
EXPORT_SYMBOL_GPL(devm_hwmon_device_unregister);include/linux/hwmon.h +0
-0@@ -481,7 +481,7 @@ devm_hwmon_device_register_with_info(struct device *dev,const struct
attribute_group**extra_groups);
voidhwmon_device_unregister(struct device *dev);include/linux/hwmon.h +1
-1-void devm_hwmon_device_unregister (struct device *dev); +void devm_hwmon_device_unregister(struct device *dev, structdevice *hwdev);
int hwmon_notify_event(struct device *dev, enumhwmon_sensor_typestype,
u32 attr, int channel);
Guenter Roeck
maintainerQuoted 30 lines · PJ Waskiewicz
Quoted 25 lines · Guenter Roeck
Quoted 18 lines · Matthew Sanders
devm_hwmon_device_unregister()only takes parent of a devres- managed
hwmon device as an argument. This always fails, as devres can't find
the hwmon device it needs to unregister with the parent device alone.
Without this patch, theWARN_ON()indevm_hwmon_device_unregister()will
always be displayed unconditionally:[ 7.969746] WARNING: CPU: 1 PID: 224 at
drivers/hwmon/hwmon.c:1205devm_hwmon_device_unregister+0x28/0x30This patch adds an extra argument to
devm_hwmon_device_unregister(), a
pointer to a hwmon device which was previously registered to the parent using devres.Quoted 5 lines
There aren't any drivers which currently make use of this function, so
any existing users of devm_hwmon_* shouldn't require any changes as a
result of this patch.Quoted 3 lines
If there are no users, there is no need to keep the function. We should drop
it instead.
Quoted 7 lines
There aren't any direct in-tree users of the function. But some out- of-tree drivers can find it useful to use, hence Matt hitting this issue.
If there's a desire to just remove it, that's fine. But it would remove a handy hook for out-of-tree stuff.
Any use of this function is most likely wrong. Out-of-tree code is completely irrelevant for the upstream kernel. On the contrary - it is another reason for removing this function. I'll do that myself.
Guenter