hwmon.c (0fdc50dfab47d525b71a9f0d8310746cdc0c09c5) | hwmon.c (44e3ad882bb268563766c45cd842a229dd3a4902) |
---|---|
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 */ --- 165 unchanged lines hidden (view full) --- 174 * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, 175 * so ignore that error but forward any other error. 176 */ 177 if (IS_ERR(tzd) && (PTR_ERR(tzd) != -ENODEV)) 178 return PTR_ERR(tzd); 179 180 return 0; 181} | 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 */ --- 165 unchanged lines hidden (view full) --- 174 * If CONFIG_THERMAL_OF is disabled, this returns -ENODEV, 175 * so ignore that error but forward any other error. 176 */ 177 if (IS_ERR(tzd) && (PTR_ERR(tzd) != -ENODEV)) 178 return PTR_ERR(tzd); 179 180 return 0; 181} |
182 183static int hwmon_thermal_register_sensors(struct device *dev) 184{ 185 struct hwmon_device *hwdev = to_hwmon_device(dev); 186 const struct hwmon_chip_info *chip = hwdev->chip; 187 const struct hwmon_channel_info **info = chip->info; 188 void *drvdata = dev_get_drvdata(dev); 189 int i; 190 191 for (i = 1; info[i]; i++) { 192 int j; 193 194 if (info[i]->type != hwmon_temp) 195 continue; 196 197 for (j = 0; info[i]->config[j]; j++) { 198 int err; 199 200 if (!(info[i]->config[j] & HWMON_T_INPUT) || 201 !chip->ops->is_visible(drvdata, hwmon_temp, 202 hwmon_temp_input, j)) 203 continue; 204 205 err = hwmon_thermal_add_sensor(dev, j); 206 if (err) 207 return err; 208 } 209 } 210 211 return 0; 212} 213 |
|
182#else | 214#else |
183static int hwmon_thermal_add_sensor(struct device *dev, int index) | 215static int hwmon_thermal_register_sensors(struct device *dev) |
184{ 185 return 0; 186} 187#endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */ 188 189static int hwmon_attr_base(enum hwmon_sensor_types type) 190{ 191 if (type == hwmon_in || type == hwmon_intrusion) --- 399 unchanged lines hidden (view full) --- 591 592static struct device * 593__hwmon_device_register(struct device *dev, const char *name, void *drvdata, 594 const struct hwmon_chip_info *chip, 595 const struct attribute_group **groups) 596{ 597 struct hwmon_device *hwdev; 598 struct device *hdev; | 216{ 217 return 0; 218} 219#endif /* IS_REACHABLE(CONFIG_THERMAL) && ... */ 220 221static int hwmon_attr_base(enum hwmon_sensor_types type) 222{ 223 if (type == hwmon_in || type == hwmon_intrusion) --- 399 unchanged lines hidden (view full) --- 623 624static struct device * 625__hwmon_device_register(struct device *dev, const char *name, void *drvdata, 626 const struct hwmon_chip_info *chip, 627 const struct attribute_group **groups) 628{ 629 struct hwmon_device *hwdev; 630 struct device *hdev; |
599 int i, j, err, id; | 631 int i, err, id; |
600 601 /* Complain about invalid characters in hwmon name attribute */ 602 if (name && (!strlen(name) || strpbrk(name, "-* \t\n"))) 603 dev_warn(dev, 604 "hwmon: '%s' is not a valid name attribute, please fix\n", 605 name); 606 607 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); --- 51 unchanged lines hidden (view full) --- 659 dev_set_name(hdev, HWMON_ID_FORMAT, id); 660 err = device_register(hdev); 661 if (err) 662 goto free_hwmon; 663 664 if (dev && dev->of_node && chip && chip->ops->read && 665 chip->info[0]->type == hwmon_chip && 666 (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { | 632 633 /* Complain about invalid characters in hwmon name attribute */ 634 if (name && (!strlen(name) || strpbrk(name, "-* \t\n"))) 635 dev_warn(dev, 636 "hwmon: '%s' is not a valid name attribute, please fix\n", 637 name); 638 639 id = ida_simple_get(&hwmon_ida, 0, 0, GFP_KERNEL); --- 51 unchanged lines hidden (view full) --- 691 dev_set_name(hdev, HWMON_ID_FORMAT, id); 692 err = device_register(hdev); 693 if (err) 694 goto free_hwmon; 695 696 if (dev && dev->of_node && chip && chip->ops->read && 697 chip->info[0]->type == hwmon_chip && 698 (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { |
667 const struct hwmon_channel_info **info = chip->info; 668 669 for (i = 1; info[i]; i++) { 670 if (info[i]->type != hwmon_temp) 671 continue; 672 673 for (j = 0; info[i]->config[j]; j++) { 674 if (!chip->ops->is_visible(drvdata, hwmon_temp, 675 hwmon_temp_input, j)) 676 continue; 677 if (info[i]->config[j] & HWMON_T_INPUT) { 678 err = hwmon_thermal_add_sensor(hdev, j); 679 if (err) { 680 device_unregister(hdev); 681 /* 682 * Don't worry about hwdev; 683 * hwmon_dev_release(), called 684 * from device_unregister(), 685 * will free it. 686 */ 687 goto ida_remove; 688 } 689 } 690 } | 699 err = hwmon_thermal_register_sensors(hdev); 700 if (err) { 701 device_unregister(hdev); 702 /* 703 * Don't worry about hwdev; hwmon_dev_release(), called 704 * from device_unregister(), will free it. 705 */ 706 goto ida_remove; |
691 } 692 } 693 694 return hdev; 695 696free_hwmon: 697 hwmon_dev_release(hdev); 698ida_remove: --- 255 unchanged lines hidden --- | 707 } 708 } 709 710 return hdev; 711 712free_hwmon: 713 hwmon_dev_release(hdev); 714ida_remove: --- 255 unchanged lines hidden --- |