Lines Matching +refs:dev +refs:id +refs:attrs
36 struct device dev; member
43 #define to_hwmon_device(d) container_of(d, struct hwmon_device, dev)
65 struct device *dev; /* Reference to hwmon device */ member
71 name_show(struct device *dev, struct device_attribute *attr, char *buf) in name_show() argument
73 return sprintf(buf, "%s\n", to_hwmon_device(dev)->name); in name_show()
78 label_show(struct device *dev, struct device_attribute *attr, char *buf) in label_show() argument
80 return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->label); in label_show()
93 struct device *dev = kobj_to_dev(kobj); in hwmon_dev_attr_is_visible() local
94 struct hwmon_device *hdev = to_hwmon_device(dev); in hwmon_dev_attr_is_visible()
106 .attrs = hwmon_dev_attrs,
115 static void hwmon_free_attrs(struct attribute **attrs) in hwmon_free_attrs() argument
119 for (i = 0; attrs[i]; i++) { in hwmon_free_attrs()
120 struct device_attribute *dattr = to_dev_attr(attrs[i]); in hwmon_free_attrs()
125 kfree(attrs); in hwmon_free_attrs()
128 static void hwmon_dev_release(struct device *dev) in hwmon_dev_release() argument
130 struct hwmon_device *hwdev = to_hwmon_device(dev); in hwmon_dev_release()
132 if (hwdev->group.attrs) in hwmon_dev_release()
133 hwmon_free_attrs(hwdev->group.attrs); in hwmon_dev_release()
157 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); in hwmon_thermal_get_temp()
161 ret = hwdev->chip->ops->read(tdata->dev, hwmon_temp, hwmon_temp_input, in hwmon_thermal_get_temp()
174 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev); in hwmon_thermal_set_trips()
190 err = chip->ops->write(tdata->dev, hwmon_temp, in hwmon_thermal_set_trips()
197 err = chip->ops->write(tdata->dev, hwmon_temp, in hwmon_thermal_set_trips()
216 static int hwmon_thermal_add_sensor(struct device *dev, int index) in hwmon_thermal_add_sensor() argument
218 struct hwmon_device *hwdev = to_hwmon_device(dev); in hwmon_thermal_add_sensor()
223 tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL); in hwmon_thermal_add_sensor()
227 tdata->dev = dev; in hwmon_thermal_add_sensor()
230 tzd = devm_thermal_of_zone_register(dev, index, tdata, in hwmon_thermal_add_sensor()
235 dev_info(dev, "temp%d_input not attached to any thermal zone\n", in hwmon_thermal_add_sensor()
237 devm_kfree(dev, tdata); in hwmon_thermal_add_sensor()
241 err = devm_add_action(dev, hwmon_thermal_remove_sensor, &tdata->node); in hwmon_thermal_add_sensor()
251 static int hwmon_thermal_register_sensors(struct device *dev) in hwmon_thermal_register_sensors() argument
253 struct hwmon_device *hwdev = to_hwmon_device(dev); in hwmon_thermal_register_sensors()
256 void *drvdata = dev_get_drvdata(dev); in hwmon_thermal_register_sensors()
273 err = hwmon_thermal_add_sensor(dev, j); in hwmon_thermal_register_sensors()
282 static void hwmon_thermal_notify(struct device *dev, int index) in hwmon_thermal_notify() argument
284 struct hwmon_device *hwdev = to_hwmon_device(dev); in hwmon_thermal_notify()
296 static int hwmon_thermal_register_sensors(struct device *dev) in hwmon_thermal_register_sensors() argument
301 static void hwmon_thermal_notify(struct device *dev, int index) { } in hwmon_thermal_notify() argument
314 static ssize_t hwmon_attr_show(struct device *dev, in hwmon_attr_show() argument
321 ret = hattr->ops->read(dev, hattr->type, hattr->attr, hattr->index, in hwmon_attr_show()
332 static ssize_t hwmon_attr_show_string(struct device *dev, in hwmon_attr_show_string() argument
341 ret = hattr->ops->read_string(dev, hattr->type, hattr->attr, in hwmon_attr_show_string()
352 static ssize_t hwmon_attr_store(struct device *dev, in hwmon_attr_store() argument
364 ret = hattr->ops->write(dev, hattr->type, hattr->attr, hattr->index, in hwmon_attr_store()
646 int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type, in hwmon_notify_event() argument
668 sysfs_notify(&dev->kobj, NULL, sattr); in hwmon_notify_event()
669 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp); in hwmon_notify_event()
672 hwmon_thermal_notify(dev, channel); in hwmon_notify_event()
689 struct attribute **attrs, in hwmon_genattrs() argument
721 attrs[aindex++] = a; in hwmon_genattrs()
731 struct attribute **attrs; in __hwmon_create_attrs() local
739 attrs = kcalloc(nattrs + 1, sizeof(*attrs), GFP_KERNEL); in __hwmon_create_attrs()
740 if (!attrs) in __hwmon_create_attrs()
744 ret = hwmon_genattrs(drvdata, &attrs[aindex], chip->ops, in __hwmon_create_attrs()
747 hwmon_free_attrs(attrs); in __hwmon_create_attrs()
753 return attrs; in __hwmon_create_attrs()
757 __hwmon_device_register(struct device *dev, const char *name, void *drvdata, in __hwmon_device_register() argument
764 struct device *tdev = dev; in __hwmon_device_register()
765 int i, err, id; in __hwmon_device_register() local
769 dev_warn(dev, in __hwmon_device_register()
773 id = ida_alloc(&hwmon_ida, GFP_KERNEL); in __hwmon_device_register()
774 if (id < 0) in __hwmon_device_register()
775 return ERR_PTR(id); in __hwmon_device_register()
783 hdev = &hwdev->dev; in __hwmon_device_register()
786 struct attribute **attrs; in __hwmon_device_register() local
799 attrs = __hwmon_create_attrs(drvdata, chip); in __hwmon_device_register()
800 if (IS_ERR(attrs)) { in __hwmon_device_register()
801 err = PTR_ERR(attrs); in __hwmon_device_register()
805 hwdev->group.attrs = attrs; in __hwmon_device_register()
819 if (dev && device_property_present(dev, "label")) { in __hwmon_device_register()
820 err = device_property_read_string(dev, "label", &label); in __hwmon_device_register()
833 hdev->parent = dev; in __hwmon_device_register()
839 dev_set_name(hdev, HWMON_ID_FORMAT, id); in __hwmon_device_register()
867 ida_free(&hwmon_ida, id); in __hwmon_device_register()
884 hwmon_device_register_with_groups(struct device *dev, const char *name, in hwmon_device_register_with_groups() argument
891 return __hwmon_device_register(dev, name, drvdata, NULL, groups); in hwmon_device_register_with_groups()
910 hwmon_device_register_with_info(struct device *dev, const char *name, in hwmon_device_register_with_info() argument
915 if (!dev || !name || !chip) in hwmon_device_register_with_info()
921 return __hwmon_device_register(dev, name, drvdata, chip, extra_groups); in hwmon_device_register_with_info()
940 hwmon_device_register_for_thermal(struct device *dev, const char *name, in hwmon_device_register_for_thermal() argument
943 if (!name || !dev) in hwmon_device_register_for_thermal()
946 return __hwmon_device_register(dev, name, drvdata, NULL, NULL); in hwmon_device_register_for_thermal()
959 struct device *hwmon_device_register(struct device *dev) in hwmon_device_register() argument
961 dev_warn(dev, in hwmon_device_register()
964 return __hwmon_device_register(dev, NULL, NULL, NULL, NULL); in hwmon_device_register()
973 void hwmon_device_unregister(struct device *dev) in hwmon_device_unregister() argument
975 int id; in hwmon_device_unregister() local
977 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) { in hwmon_device_unregister()
978 device_unregister(dev); in hwmon_device_unregister()
979 ida_free(&hwmon_ida, id); in hwmon_device_unregister()
981 dev_dbg(dev->parent, in hwmon_device_unregister()
986 static void devm_hwmon_release(struct device *dev, void *res) in devm_hwmon_release() argument
1004 devm_hwmon_device_register_with_groups(struct device *dev, const char *name, in devm_hwmon_device_register_with_groups() argument
1010 if (!dev) in devm_hwmon_device_register_with_groups()
1017 hwdev = hwmon_device_register_with_groups(dev, name, drvdata, groups); in devm_hwmon_device_register_with_groups()
1022 devres_add(dev, ptr); in devm_hwmon_device_register_with_groups()
1043 devm_hwmon_device_register_with_info(struct device *dev, const char *name, in devm_hwmon_device_register_with_info() argument
1050 if (!dev) in devm_hwmon_device_register_with_info()
1057 hwdev = hwmon_device_register_with_info(dev, name, drvdata, chip, in devm_hwmon_device_register_with_info()
1063 devres_add(dev, ptr); in devm_hwmon_device_register_with_info()
1073 static int devm_hwmon_match(struct device *dev, void *res, void *data) in devm_hwmon_match() argument
1085 void devm_hwmon_device_unregister(struct device *dev) in devm_hwmon_device_unregister() argument
1087 WARN_ON(devres_release(dev, devm_hwmon_release, devm_hwmon_match, dev)); in devm_hwmon_device_unregister()
1091 static char *__hwmon_sanitize_name(struct device *dev, const char *old_name) in __hwmon_sanitize_name() argument
1095 if (dev) in __hwmon_sanitize_name()
1096 name = devm_kstrdup(dev, old_name, GFP_KERNEL); in __hwmon_sanitize_name()
1135 char *devm_hwmon_sanitize_name(struct device *dev, const char *name) in devm_hwmon_sanitize_name() argument
1137 if (!dev) in devm_hwmon_sanitize_name()
1140 return __hwmon_sanitize_name(dev, name); in devm_hwmon_sanitize_name()
1160 dev_info(&sb->dev, in hwmon_pci_quirks()