Lines Matching +defs:dev +defs:id +defs:attrs

37 	struct device dev;
44 #define to_hwmon_device(d) container_of(d, struct hwmon_device, dev)
66 struct device *dev; /* Reference to hwmon device */
72 name_show(struct device *dev, struct device_attribute *attr, char *buf)
74 return sprintf(buf, "%s\n", to_hwmon_device(dev)->name);
79 label_show(struct device *dev, struct device_attribute *attr, char *buf)
81 return sysfs_emit(buf, "%s\n", to_hwmon_device(dev)->label);
94 struct device *dev = kobj_to_dev(kobj);
95 struct hwmon_device *hdev = to_hwmon_device(dev);
107 .attrs = hwmon_dev_attrs,
116 static void hwmon_free_attrs(struct attribute **attrs)
120 for (i = 0; attrs[i]; i++) {
121 struct device_attribute *dattr = to_dev_attr(attrs[i]);
126 kfree(attrs);
129 static void hwmon_dev_release(struct device *dev)
131 struct hwmon_device *hwdev = to_hwmon_device(dev);
133 if (hwdev->group.attrs)
134 hwmon_free_attrs(hwdev->group.attrs);
164 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
168 ret = hwdev->chip->ops->read(tdata->dev, hwmon_temp, hwmon_temp_input,
181 struct hwmon_device *hwdev = to_hwmon_device(tdata->dev);
197 err = chip->ops->write(tdata->dev, hwmon_temp,
204 err = chip->ops->write(tdata->dev, hwmon_temp,
223 static int hwmon_thermal_add_sensor(struct device *dev, int index)
225 struct hwmon_device *hwdev = to_hwmon_device(dev);
230 tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL);
234 tdata->dev = dev;
237 tzd = devm_thermal_of_zone_register(dev, index, tdata,
242 dev_info(dev, "temp%d_input not attached to any thermal zone\n",
244 devm_kfree(dev, tdata);
248 err = devm_add_action(dev, hwmon_thermal_remove_sensor, &tdata->node);
258 static int hwmon_thermal_register_sensors(struct device *dev)
260 struct hwmon_device *hwdev = to_hwmon_device(dev);
263 void *drvdata = dev_get_drvdata(dev);
283 err = hwmon_thermal_add_sensor(dev, j);
292 static void hwmon_thermal_notify(struct device *dev, int index)
294 struct hwmon_device *hwdev = to_hwmon_device(dev);
335 static int hwmon_match_device(struct device *dev, const void *data)
337 return dev->class == &hwmon_class;
340 static ssize_t pec_show(struct device *dev, struct device_attribute *dummy,
343 struct i2c_client *client = to_i2c_client(dev);
348 static ssize_t pec_store(struct device *dev, struct device_attribute *devattr,
351 struct i2c_client *client = to_i2c_client(dev);
361 hdev = device_find_child(dev, NULL, hwmon_match_device);
393 static void hwmon_remove_pec(void *dev)
395 device_remove_file(dev, &dev_attr_pec);
409 err = device_create_file(&client->dev, &dev_attr_pec);
413 return devm_add_action_or_reset(hdev, hwmon_remove_pec, &client->dev);
425 static ssize_t hwmon_attr_show(struct device *dev,
432 ret = hattr->ops->read(dev, hattr->type, hattr->attr, hattr->index,
443 static ssize_t hwmon_attr_show_string(struct device *dev,
452 ret = hattr->ops->read_string(dev, hattr->type, hattr->attr,
463 static ssize_t hwmon_attr_store(struct device *dev,
475 ret = hattr->ops->write(dev, hattr->type, hattr->attr, hattr->index,
756 int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
778 sysfs_notify(&dev->kobj, NULL, sattr);
779 kobject_uevent_env(&dev->kobj, KOBJ_CHANGE, envp);
782 hwmon_thermal_notify(dev, channel);
799 struct attribute **attrs,
831 attrs[aindex++] = a;
841 struct attribute **attrs;
849 attrs = kcalloc(nattrs + 1, sizeof(*attrs), GFP_KERNEL);
850 if (!attrs)
854 ret = hwmon_genattrs(drvdata, &attrs[aindex], chip->ops,
857 hwmon_free_attrs(attrs);
863 return attrs;
867 __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
874 struct device *tdev = dev;
875 int i, err, id;
879 dev_warn(dev,
883 id = ida_alloc(&hwmon_ida, GFP_KERNEL);
884 if (id < 0)
885 return ERR_PTR(id);
893 hdev = &hwdev->dev;
896 struct attribute **attrs;
909 attrs = __hwmon_create_attrs(drvdata, chip);
910 if (IS_ERR(attrs)) {
911 err = PTR_ERR(attrs);
915 hwdev->group.attrs = attrs;
929 if (dev && device_property_present(dev, "label")) {
930 err = device_property_read_string(dev, "label", &label);
943 hdev->parent = dev;
949 dev_set_name(hdev, HWMON_ID_FORMAT, id);
987 ida_free(&hwmon_ida, id);
993 * @dev: the parent device
1004 hwmon_device_register_with_groups(struct device *dev, const char *name,
1011 return __hwmon_device_register(dev, name, drvdata, NULL, groups);
1017 * @dev: the parent device (mandatory)
1030 hwmon_device_register_with_info(struct device *dev, const char *name,
1035 if (!dev || !name || !chip)
1041 return __hwmon_device_register(dev, name, drvdata, chip, extra_groups);
1047 * @dev: the parent device
1060 hwmon_device_register_for_thermal(struct device *dev, const char *name,
1063 if (!name || !dev)
1066 return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
1072 * @dev: the device to register
1079 struct device *hwmon_device_register(struct device *dev)
1081 dev_warn(dev,
1084 return __hwmon_device_register(dev, NULL, NULL, NULL, NULL);
1091 * @dev: the class device to destroy
1093 void hwmon_device_unregister(struct device *dev)
1095 int id;
1097 if (likely(sscanf(dev_name(dev), HWMON_ID_FORMAT, &id) == 1)) {
1098 device_unregister(dev);
1099 ida_free(&hwmon_ida, id);
1101 dev_dbg(dev->parent,
1106 static void devm_hwmon_release(struct device *dev, void *res)
1115 * @dev: the parent device
1124 devm_hwmon_device_register_with_groups(struct device *dev, const char *name,
1130 if (!dev)
1137 hwdev = hwmon_device_register_with_groups(dev, name, drvdata, groups);
1142 devres_add(dev, ptr);
1153 * @dev: the parent device
1163 devm_hwmon_device_register_with_info(struct device *dev, const char *name,
1170 if (!dev)
1174 name = devm_hwmon_sanitize_name(dev, dev_name(dev));
1183 hwdev = hwmon_device_register_with_info(dev, name, drvdata, chip,
1189 devres_add(dev, ptr);
1199 static char *__hwmon_sanitize_name(struct device *dev, const char *old_name)
1203 if (dev)
1204 name = devm_kstrdup(dev, old_name, GFP_KERNEL);
1235 * @dev: device to allocate memory for
1243 char *devm_hwmon_sanitize_name(struct device *dev, const char *name)
1245 if (!dev)
1248 return __hwmon_sanitize_name(dev, name);
1268 dev_info(&sb->dev,