aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2015-02-20 21:10:08 -0500
committerEduardo Valentin <edubezval@gmail.com>2015-03-05 00:47:57 -0500
commit2dc10f8963e6a03a1a75deafe1d1984bafab08dd (patch)
tree36c23fa93ef3062dac39b2ebc76cd39ccc324cf6 /drivers/thermal
parentd5bce867778c8cb5ff655efe47fecb4b31f30406 (diff)
thermal: Make sysfs attributes of cooling devices default attributes
Default attributes are created when the device is registered. Attributes created after device registration can lead to race conditions, where user space (e.g. udev) sees the device but not the attributes. Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r--drivers/thermal/thermal_core.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 48491d1a81d6..174d3bcf8bd7 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -899,6 +899,22 @@ thermal_cooling_device_trip_point_show(struct device *dev,
899 return sprintf(buf, "%d\n", instance->trip); 899 return sprintf(buf, "%d\n", instance->trip);
900} 900}
901 901
902static struct attribute *cooling_device_attrs[] = {
903 &dev_attr_cdev_type.attr,
904 &dev_attr_max_state.attr,
905 &dev_attr_cur_state.attr,
906 NULL,
907};
908
909static const struct attribute_group cooling_device_attr_group = {
910 .attrs = cooling_device_attrs,
911};
912
913static const struct attribute_group *cooling_device_attr_groups[] = {
914 &cooling_device_attr_group,
915 NULL,
916};
917
902/* Device management */ 918/* Device management */
903 919
904/** 920/**
@@ -1130,6 +1146,7 @@ __thermal_cooling_device_register(struct device_node *np,
1130 cdev->ops = ops; 1146 cdev->ops = ops;
1131 cdev->updated = false; 1147 cdev->updated = false;
1132 cdev->device.class = &thermal_class; 1148 cdev->device.class = &thermal_class;
1149 cdev->device.groups = cooling_device_attr_groups;
1133 cdev->devdata = devdata; 1150 cdev->devdata = devdata;
1134 dev_set_name(&cdev->device, "cooling_device%d", cdev->id); 1151 dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
1135 result = device_register(&cdev->device); 1152 result = device_register(&cdev->device);
@@ -1139,21 +1156,6 @@ __thermal_cooling_device_register(struct device_node *np,
1139 return ERR_PTR(result); 1156 return ERR_PTR(result);
1140 } 1157 }
1141 1158
1142 /* sys I/F */
1143 if (type) {
1144 result = device_create_file(&cdev->device, &dev_attr_cdev_type);
1145 if (result)
1146 goto unregister;
1147 }
1148
1149 result = device_create_file(&cdev->device, &dev_attr_max_state);
1150 if (result)
1151 goto unregister;
1152
1153 result = device_create_file(&cdev->device, &dev_attr_cur_state);
1154 if (result)
1155 goto unregister;
1156
1157 /* Add 'this' new cdev to the global cdev list */ 1159 /* Add 'this' new cdev to the global cdev list */
1158 mutex_lock(&thermal_list_lock); 1160 mutex_lock(&thermal_list_lock);
1159 list_add(&cdev->node, &thermal_cdev_list); 1161 list_add(&cdev->node, &thermal_cdev_list);
@@ -1163,11 +1165,6 @@ __thermal_cooling_device_register(struct device_node *np,
1163 bind_cdev(cdev); 1165 bind_cdev(cdev);
1164 1166
1165 return cdev; 1167 return cdev;
1166
1167unregister:
1168 release_idr(&thermal_cdev_idr, &thermal_idr_lock, cdev->id);
1169 device_unregister(&cdev->device);
1170 return ERR_PTR(result);
1171} 1168}
1172 1169
1173/** 1170/**