Skip to content

Commit

Permalink
hwmon: Make name attribute mandatory for new APIs
Browse files Browse the repository at this point in the history
It does not make sense to use one of the the new APIs when not
even providing a name attribute. Make it mandatory.

Reviewed-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
  • Loading branch information
Guenter Roeck committed Jan 25, 2017
1 parent 68f0c8c commit 8353863
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion drivers/hwmon/hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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);

Expand Down

0 comments on commit 8353863

Please sign in to comment.