hwmon.c (ddaefa209c4ac791c1262e97c9b2d0440c8ef1d5) hwmon.c (718fbfa5da5da0b4d030e14ed737c228ca6a7cbf)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * hwmon.c - part of lm_sensors, Linux kernel modules for hardware monitoring
4 *
5 * This file defines the sysfs class "hwmon", for use by sensors drivers.
6 *
7 * Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
8 */

--- 750 unchanged lines hidden (view full) ---

759 int i, err, id;
760
761 /* Complain about invalid characters in hwmon name attribute */
762 if (name && (!strlen(name) || strpbrk(name, "-* \t\n")))
763 dev_warn(dev,
764 "hwmon: '%s' is not a valid name attribute, please fix\n",
765 name);
766
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * hwmon.c - part of lm_sensors, Linux kernel modules for hardware monitoring
4 *
5 * This file defines the sysfs class "hwmon", for use by sensors drivers.
6 *
7 * Copyright (C) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
8 */

--- 750 unchanged lines hidden (view full) ---

759 int i, err, id;
760
761 /* Complain about invalid characters in hwmon name attribute */
762 if (name && (!strlen(name) || strpbrk(name, "-* \t\n")))
763 dev_warn(dev,
764 "hwmon: '%s' is not a valid name attribute, please fix\n",
765 name);
766
767 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL);
767 id = ida_alloc(&hwmon_ida, GFP_KERNEL);
768 if (id < 0)
769 return ERR_PTR(id);
770
771 hwdev = kzalloc(sizeof(*hwdev), GFP_KERNEL);
772 if (hwdev == NULL) {
773 err = -ENOMEM;
774 goto ida_remove;
775 }

--- 75 unchanged lines hidden (view full) ---

851 }
852 }
853
854 return hdev;
855
856free_hwmon:
857 hwmon_dev_release(hdev);
858ida_remove:
768 if (id < 0)
769 return ERR_PTR(id);
770
771 hwdev = kzalloc(sizeof(*hwdev), GFP_KERNEL);
772 if (hwdev == NULL) {
773 err = -ENOMEM;
774 goto ida_remove;
775 }

--- 75 unchanged lines hidden (view full) ---

851 }
852 }
853
854 return hdev;
855
856free_hwmon:
857 hwmon_dev_release(hdev);
858ida_remove:
859 ida_simple_remove(&hwmon_ida, id);
859 ida_free(&hwmon_ida, id);
860 return ERR_PTR(err);
861}
862
863/**
864 * hwmon_device_register_with_groups - register w/ hwmon
865 * @dev: the parent device
866 * @name: hwmon name attribute
867 * @drvdata: driver data to attach to created device

--- 95 unchanged lines hidden (view full) ---

963 * @dev: the class device to destroy
964 */
965void hwmon_device_unregister(struct device *dev)
966{
967 int id;
968
969 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) {
970 device_unregister(dev);
860 return ERR_PTR(err);
861}
862
863/**
864 * hwmon_device_register_with_groups - register w/ hwmon
865 * @dev: the parent device
866 * @name: hwmon name attribute
867 * @drvdata: driver data to attach to created device

--- 95 unchanged lines hidden (view full) ---

963 * @dev: the class device to destroy
964 */
965void hwmon_device_unregister(struct device *dev)
966{
967 int id;
968
969 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) {
970 device_unregister(dev);
971 ida_simple_remove(&hwmon_ida, id);
971 ida_free(&hwmon_ida, id);
972 } else
973 dev_dbg(dev->parent,
974 "hwmon_device_unregister() failed: bad class ID!\n");
975}
976EXPORT_SYMBOL_GPL(hwmon_device_unregister);
977
978static void devm_hwmon_release(struct device *dev, void *res)
979{

--- 210 unchanged lines hidden ---
972 } else
973 dev_dbg(dev->parent,
974 "hwmon_device_unregister() failed: bad class ID!\n");
975}
976EXPORT_SYMBOL_GPL(hwmon_device_unregister);
977
978static void devm_hwmon_release(struct device *dev, void *res)
979{

--- 210 unchanged lines hidden ---