aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/thermal/thermal_sys.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c
index 71802caec2c3..11237bc2aa9c 100644
--- a/drivers/thermal/thermal_sys.c
+++ b/drivers/thermal/thermal_sys.c
@@ -310,22 +310,6 @@ static struct device_attribute trip_point_attrs[] = {
310 __ATTR(trip_point_11_temp, 0444, trip_point_temp_show, NULL), 310 __ATTR(trip_point_11_temp, 0444, trip_point_temp_show, NULL),
311}; 311};
312 312
313#define TRIP_POINT_ATTR_ADD(_dev, _index, result) \
314do { \
315 result = device_create_file(_dev, \
316 &trip_point_attrs[_index * 2]); \
317 if (result) \
318 break; \
319 result = device_create_file(_dev, \
320 &trip_point_attrs[_index * 2 + 1]); \
321} while (0)
322
323#define TRIP_POINT_ATTR_REMOVE(_dev, _index) \
324do { \
325 device_remove_file(_dev, &trip_point_attrs[_index * 2]); \
326 device_remove_file(_dev, &trip_point_attrs[_index * 2 + 1]); \
327} while (0)
328
329/* sys I/F for cooling device */ 313/* sys I/F for cooling device */
330#define to_cooling_device(_dev) \ 314#define to_cooling_device(_dev) \
331 container_of(_dev, struct thermal_cooling_device, device) 315 container_of(_dev, struct thermal_cooling_device, device)
@@ -1196,7 +1180,12 @@ struct thermal_zone_device *thermal_zone_device_register(char *type,
1196 } 1180 }
1197 1181
1198 for (count = 0; count < trips; count++) { 1182 for (count = 0; count < trips; count++) {
1199 TRIP_POINT_ATTR_ADD(&tz->device, count, result); 1183 result = device_create_file(&tz->device,
1184 &trip_point_attrs[count * 2]);
1185 if (result)
1186 break;
1187 result = device_create_file(&tz->device,
1188 &trip_point_attrs[count * 2 + 1]);
1200 if (result) 1189 if (result)
1201 goto unregister; 1190 goto unregister;
1202 tz->ops->get_trip_type(tz, count, &trip_type); 1191 tz->ops->get_trip_type(tz, count, &trip_type);
@@ -1276,9 +1265,12 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1276 if (tz->ops->get_mode) 1265 if (tz->ops->get_mode)
1277 device_remove_file(&tz->device, &dev_attr_mode); 1266 device_remove_file(&tz->device, &dev_attr_mode);
1278 1267
1279 for (count = 0; count < tz->trips; count++) 1268 for (count = 0; count < tz->trips; count++) {
1280 TRIP_POINT_ATTR_REMOVE(&tz->device, count); 1269 device_remove_file(&tz->device,
1281 1270 &trip_point_attrs[count * 2]);
1271 device_remove_file(&tz->device,
1272 &trip_point_attrs[count * 2 + 1]);
1273 }
1282 thermal_remove_hwmon_sysfs(tz); 1274 thermal_remove_hwmon_sysfs(tz);
1283 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id); 1275 release_idr(&thermal_tz_idr, &thermal_idr_lock, tz->id);
1284 idr_destroy(&tz->idr); 1276 idr_destroy(&tz->idr);