hwmon: Make chip parameter for with_info API mandatory
Various attempts were made recently to "convert" the old hwmon_device_register() API to devm_hwmon_device_register_with_info() by just changing the function name without actually converting the driver. Prevent this from happening by making the 'chip' parameter of devm_hwmon_device_register_with_info() mandatory. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
87743bcf08
commit
ddaefa209c
|
@ -76,7 +76,7 @@ hwmon_device_register_with_info is the most comprehensive and preferred means
|
||||||
to register a hardware monitoring device. It creates the standard sysfs
|
to register a hardware monitoring device. It creates the standard sysfs
|
||||||
attributes in the hardware monitoring core, letting the driver focus on reading
|
attributes in the hardware monitoring core, letting the driver focus on reading
|
||||||
from and writing to the chip instead of having to bother with sysfs attributes.
|
from and writing to the chip instead of having to bother with sysfs attributes.
|
||||||
The parent device parameter cannot be NULL with non-NULL chip info. Its
|
The parent device parameter as well as the chip parameter must not be NULL. Its
|
||||||
parameters are described in more detail below.
|
parameters are described in more detail below.
|
||||||
|
|
||||||
devm_hwmon_device_register_with_info is similar to
|
devm_hwmon_device_register_with_info is similar to
|
||||||
|
|
|
@ -886,11 +886,12 @@ EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hwmon_device_register_with_info - register w/ hwmon
|
* hwmon_device_register_with_info - register w/ hwmon
|
||||||
* @dev: the parent device
|
* @dev: the parent device (mandatory)
|
||||||
* @name: hwmon name attribute
|
* @name: hwmon name attribute (mandatory)
|
||||||
* @drvdata: driver data to attach to created device
|
* @drvdata: driver data to attach to created device (optional)
|
||||||
* @chip: pointer to hwmon chip information
|
* @chip: pointer to hwmon chip information (mandatory)
|
||||||
* @extra_groups: pointer to list of additional non-standard attribute groups
|
* @extra_groups: pointer to list of additional non-standard attribute groups
|
||||||
|
* (optional)
|
||||||
*
|
*
|
||||||
* hwmon_device_unregister() must be called when the device is no
|
* hwmon_device_unregister() must be called when the device is no
|
||||||
* longer needed.
|
* longer needed.
|
||||||
|
@ -903,13 +904,10 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
|
||||||
const struct hwmon_chip_info *chip,
|
const struct hwmon_chip_info *chip,
|
||||||
const struct attribute_group **extra_groups)
|
const struct attribute_group **extra_groups)
|
||||||
{
|
{
|
||||||
if (!name)
|
if (!dev || !name || !chip)
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
|
if (!chip->ops || !chip->ops->is_visible || !chip->info)
|
||||||
return ERR_PTR(-EINVAL);
|
|
||||||
|
|
||||||
if (chip && !dev)
|
|
||||||
return ERR_PTR(-EINVAL);
|
return ERR_PTR(-EINVAL);
|
||||||
|
|
||||||
return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);
|
return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);
|
||||||
|
|
Loading…
Reference in New Issue