]> git.baikalelectronics.ru Git - kernel.git/commitdiff
Revert "hwmon: Make chip parameter for with_info API mandatory"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 23 Jun 2022 16:19:35 +0000 (18:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2022 10:44:36 +0000 (12:44 +0200)
This reverts commit 783ca0cbf7cb647b2da6a379007b8f728a4f0604 which is
commit 9747bbd954a00781b8c598de0e12dba6e94a8fbc upstream.  It should not
have been applied to the stable trees.

Link: https://lore.kernel.org/r/20220622154454.GA1864037@roeck-us.net
Reported-by: Julian Haller <julian.haller@philips.com>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Cc: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Documentation/hwmon/hwmon-kernel-api.rst
drivers/hwmon/hwmon.c

index 23f27fe78e37911746b84027be4491b20b5b1610..c41eb61081036d05c13aefaa6ec7387eff87dc33 100644 (file)
@@ -72,7 +72,7 @@ hwmon_device_register_with_info is the most comprehensive and preferred means
 to register a hardware monitoring device. It creates the standard sysfs
 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.
-The parent device parameter as well as the chip parameter must not be NULL. Its
+The parent device parameter cannot be NULL with non-NULL chip info. Its
 parameters are described in more detail below.
 
 devm_hwmon_device_register_with_info is similar to
index c73b93b9bb87d41354ec0240f0e6a177ef5b6f53..a2175394cd253f7c443f1d874404db6ca96b8fc2 100644 (file)
@@ -715,12 +715,11 @@ EXPORT_SYMBOL_GPL(hwmon_device_register_with_groups);
 
 /**
  * hwmon_device_register_with_info - register w/ hwmon
- * @dev: the parent device (mandatory)
- * @name: hwmon name attribute (mandatory)
- * @drvdata: driver data to attach to created device (optional)
- * @chip: pointer to hwmon chip information (mandatory)
+ * @dev: the parent device
+ * @name: hwmon name attribute
+ * @drvdata: driver data to attach to created device
+ * @chip: pointer to hwmon chip information
  * @extra_groups: pointer to list of additional non-standard attribute groups
- *     (optional)
  *
  * hwmon_device_unregister() must be called when the device is no
  * longer needed.
@@ -733,10 +732,13 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
                                const struct hwmon_chip_info *chip,
                                const struct attribute_group **extra_groups)
 {
-       if (!dev || !name || !chip)
+       if (!name)
+               return ERR_PTR(-EINVAL);
+
+       if (chip && (!chip->ops || !chip->ops->is_visible || !chip->info))
                return ERR_PTR(-EINVAL);
 
-       if (!chip->ops || !chip->ops->is_visible || !chip->info)
+       if (chip && !dev)
                return ERR_PTR(-EINVAL);
 
        return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);