hwmon: Make name attribute mandatory for new APIs
Guenter Roeck
maintainerPATCH v3 1/1 hwmon: Make name attribute mandatory for new APIs
It does not make sense to use one of the the new APIs when not even providing a name attribute. Make it mandatory.
Signed-off-by Guenter Roeck <[email protected]>
---
v3: hwmon_device_register() needs to call __hwmon_device_register() directly.
v2: One should use ERR_PTR where appropriate
drivers/hwmon/hwmon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/hwmon/hwmon.c +7 -1
@@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, const struct attribute_group **groups) { +if (!name) +return ERR_PTR (-EINVAL ); +return __hwmon_device_register (dev, name, drvdata,NULL , groups); }EXPORT_SYMBOL_GPL (hwmon_device_register_with_groups);
@@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name, const struct hwmon_chip_info *chip, const struct attribute_group **extra_groups) { + if (!name) + return ERR_PTR(-EINVAL); +if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))return ERR_PTR (-EINVAL );
@@ -695,7 +701,7 @@ struct device *hwmon_device_register(struct device *dev)dev_warn (dev,"hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().\n" ); -return hwmon_device_register_with_groups (dev,NULL ,NULL ,NULL ); +return __hwmon_device_register (dev,NULL ,NULL ,NULL ,NULL ); }EXPORT_SYMBOL_GPL (hwmon_device_register);
Signature · 1 line
2.7.4
Quoted 36 lines · Guenter Roeck
It does not make sense to use one of the the new APIs when not even providing a name attribute. Make it mandatory.
Signed-off-by Guenter Roeck <[email protected]>---
v3:hwmon_device_register()needs to call__hwmon_device_register()directly.
v2: One should useERR_PTRwhere appropriatedrivers/hwmon/hwmon.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)drivers/hwmon/hwmon.c +6
-0@@ -651,6 +651,9 @@ hwmon_device_register_with_groups(struct device *dev, const char *name, void *drvdata, const struct attribute_group **groups) { +if (!name) +return ERR_PTR (-EINVAL ); +return __hwmon_device_register (dev, name, drvdata,NULL , groups); }EXPORT_SYMBOL_GPL (hwmon_device_register_with_groups);@@ -674,6 +677,9 @@ hwmon_device_register_with_info(struct device *dev, const char *name, const struct hwmon_chip_info *chip, const struct attribute_group **extra_groups) { + if (!name) + return ERR_PTR(-EINVAL); +if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))return ERR_PTR (-EINVAL );
drivers/hwmon/hwmon.c struct device *hwmon_device_register(struct device *dev) · line 707
Quoted 8 lines
drivers/hwmon/hwmon.c +1
-1@@ -695,7 +701,7 @@ struct device *hwmon_device_register(struct device *dev)dev_warn (dev,"hwmon_device_register() is deprecated. Please convert the driver to use hwmon_device_register_with_info().\n" ); -return hwmon_device_register_with_groups (dev,NULL ,NULL ,NULL ); +return __hwmon_device_register (dev,NULL ,NULL ,NULL ,NULL ); }EXPORT_SYMBOL_GPL (hwmon_device_register);
Reviewed-by Jean Delvare <[email protected]>
Signature · 2 lines
Jean Delvare SUSE L3 Support