aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/thermal/sysfs-api.txt2
-rw-r--r--drivers/thermal/thermal_core.c80
-rw-r--r--include/linux/thermal.h2
3 files changed, 59 insertions, 25 deletions
diff --git a/Documentation/thermal/sysfs-api.txt b/Documentation/thermal/sysfs-api.txt
index b2ffe98cf469..bb42266afc66 100644
--- a/Documentation/thermal/sysfs-api.txt
+++ b/Documentation/thermal/sysfs-api.txt
@@ -367,7 +367,7 @@ This function returns the thermal_instance corresponding to a given
367{thermal_zone, cooling_device, trip_point} combination. Returns NULL 367{thermal_zone, cooling_device, trip_point} combination. Returns NULL
368if such an instance does not exist. 368if such an instance does not exist.
369 369
3705.3:notify_thermal_framework: 3705.3:thermal_notify_framework:
371This function handles the trip events from sensor drivers. It starts 371This function handles the trip events from sensor drivers. It starts
372throttling the cooling devices according to the policy configured. 372throttling the cooling devices according to the policy configured.
373For CRITICAL and HOT trip points, this notifies the respective drivers, 373For CRITICAL and HOT trip points, this notifies the respective drivers,
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index c0779adb2459..f36cd44816d8 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -40,7 +40,7 @@
40 40
41MODULE_AUTHOR("Zhang Rui"); 41MODULE_AUTHOR("Zhang Rui");
42MODULE_DESCRIPTION("Generic thermal management sysfs support"); 42MODULE_DESCRIPTION("Generic thermal management sysfs support");
43MODULE_LICENSE("GPL"); 43MODULE_LICENSE("GPL v2");
44 44
45static DEFINE_IDR(thermal_tz_idr); 45static DEFINE_IDR(thermal_tz_idr);
46static DEFINE_IDR(thermal_cdev_idr); 46static DEFINE_IDR(thermal_cdev_idr);
@@ -446,7 +446,7 @@ void thermal_zone_device_update(struct thermal_zone_device *tz)
446 for (count = 0; count < tz->trips; count++) 446 for (count = 0; count < tz->trips; count++)
447 handle_thermal_trip(tz, count); 447 handle_thermal_trip(tz, count);
448} 448}
449EXPORT_SYMBOL(thermal_zone_device_update); 449EXPORT_SYMBOL_GPL(thermal_zone_device_update);
450 450
451static void thermal_zone_device_check(struct work_struct *work) 451static void thermal_zone_device_check(struct work_struct *work)
452{ 452{
@@ -1109,13 +1109,23 @@ thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
1109#endif 1109#endif
1110 1110
1111/** 1111/**
1112 * thermal_zone_bind_cooling_device - bind a cooling device to a thermal zone 1112 * thermal_zone_bind_cooling_device() - bind a cooling device to a thermal zone
1113 * @tz: thermal zone device 1113 * @tz: pointer to struct thermal_zone_device
1114 * @trip: indicates which trip point the cooling devices is 1114 * @trip: indicates which trip point the cooling devices is
1115 * associated with in this thermal zone. 1115 * associated with in this thermal zone.
1116 * @cdev: thermal cooling device 1116 * @cdev: pointer to struct thermal_cooling_device
1117 * @upper: the Maximum cooling state for this trip point.
1118 * THERMAL_NO_LIMIT means no upper limit,
1119 * and the cooling device can be in max_state.
1120 * @lower: the Minimum cooling state can be used for this trip point.
1121 * THERMAL_NO_LIMIT means no lower limit,
1122 * and the cooling device can be in cooling state 0.
1117 * 1123 *
1124 * This interface function bind a thermal cooling device to the certain trip
1125 * point of a thermal zone device.
1118 * This function is usually called in the thermal zone device .bind callback. 1126 * This function is usually called in the thermal zone device .bind callback.
1127 *
1128 * Return: 0 on success, the proper error value otherwise.
1119 */ 1129 */
1120int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz, 1130int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
1121 int trip, 1131 int trip,
@@ -1209,16 +1219,21 @@ free_mem:
1209 kfree(dev); 1219 kfree(dev);
1210 return result; 1220 return result;
1211} 1221}
1212EXPORT_SYMBOL(thermal_zone_bind_cooling_device); 1222EXPORT_SYMBOL_GPL(thermal_zone_bind_cooling_device);
1213 1223
1214/** 1224/**
1215 * thermal_zone_unbind_cooling_device - unbind a cooling device from a thermal zone 1225 * thermal_zone_unbind_cooling_device() - unbind a cooling device from a
1216 * @tz: thermal zone device 1226 * thermal zone.
1227 * @tz: pointer to a struct thermal_zone_device.
1217 * @trip: indicates which trip point the cooling devices is 1228 * @trip: indicates which trip point the cooling devices is
1218 * associated with in this thermal zone. 1229 * associated with in this thermal zone.
1219 * @cdev: thermal cooling device 1230 * @cdev: pointer to a struct thermal_cooling_device.
1220 * 1231 *
1232 * This interface function unbind a thermal cooling device from the certain
1233 * trip point of a thermal zone device.
1221 * This function is usually called in the thermal zone device .unbind callback. 1234 * This function is usually called in the thermal zone device .unbind callback.
1235 *
1236 * Return: 0 on success, the proper error value otherwise.
1222 */ 1237 */
1223int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz, 1238int thermal_zone_unbind_cooling_device(struct thermal_zone_device *tz,
1224 int trip, 1239 int trip,
@@ -1249,7 +1264,7 @@ unbind:
1249 kfree(pos); 1264 kfree(pos);
1250 return 0; 1265 return 0;
1251} 1266}
1252EXPORT_SYMBOL(thermal_zone_unbind_cooling_device); 1267EXPORT_SYMBOL_GPL(thermal_zone_unbind_cooling_device);
1253 1268
1254static void thermal_release(struct device *dev) 1269static void thermal_release(struct device *dev)
1255{ 1270{
@@ -1272,10 +1287,17 @@ static struct class thermal_class = {
1272}; 1287};
1273 1288
1274/** 1289/**
1275 * thermal_cooling_device_register - register a new thermal cooling device 1290 * thermal_cooling_device_register() - register a new thermal cooling device
1276 * @type: the thermal cooling device type. 1291 * @type: the thermal cooling device type.
1277 * @devdata: device private data. 1292 * @devdata: device private data.
1278 * @ops: standard thermal cooling devices callbacks. 1293 * @ops: standard thermal cooling devices callbacks.
1294 *
1295 * This interface function adds a new thermal cooling device (fan/processor/...)
1296 * to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
1297 * to all the thermal zone devices registered at the same time.
1298 *
1299 * Return: a pointer to the created struct thermal_cooling_device or an
1300 * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
1279 */ 1301 */
1280struct thermal_cooling_device * 1302struct thermal_cooling_device *
1281thermal_cooling_device_register(char *type, void *devdata, 1303thermal_cooling_device_register(char *type, void *devdata,
@@ -1301,7 +1323,7 @@ thermal_cooling_device_register(char *type, void *devdata,
1301 return ERR_PTR(result); 1323 return ERR_PTR(result);
1302 } 1324 }
1303 1325
1304 strcpy(cdev->type, type ? : ""); 1326 strlcpy(cdev->type, type ? : "", sizeof(cdev->type));
1305 mutex_init(&cdev->lock); 1327 mutex_init(&cdev->lock);
1306 INIT_LIST_HEAD(&cdev->thermal_instances); 1328 INIT_LIST_HEAD(&cdev->thermal_instances);
1307 cdev->ops = ops; 1329 cdev->ops = ops;
@@ -1346,7 +1368,7 @@ unregister:
1346 device_unregister(&cdev->device); 1368 device_unregister(&cdev->device);
1347 return ERR_PTR(result); 1369 return ERR_PTR(result);
1348} 1370}
1349EXPORT_SYMBOL(thermal_cooling_device_register); 1371EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
1350 1372
1351/** 1373/**
1352 * thermal_cooling_device_unregister - removes the registered thermal cooling device 1374 * thermal_cooling_device_unregister - removes the registered thermal cooling device
@@ -1406,7 +1428,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)
1406 device_unregister(&cdev->device); 1428 device_unregister(&cdev->device);
1407 return; 1429 return;
1408} 1430}
1409EXPORT_SYMBOL(thermal_cooling_device_unregister); 1431EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);
1410 1432
1411void thermal_cdev_update(struct thermal_cooling_device *cdev) 1433void thermal_cdev_update(struct thermal_cooling_device *cdev)
1412{ 1434{
@@ -1432,7 +1454,7 @@ void thermal_cdev_update(struct thermal_cooling_device *cdev)
1432EXPORT_SYMBOL(thermal_cdev_update); 1454EXPORT_SYMBOL(thermal_cdev_update);
1433 1455
1434/** 1456/**
1435 * notify_thermal_framework - Sensor drivers use this API to notify framework 1457 * thermal_notify_framework - Sensor drivers use this API to notify framework
1436 * @tz: thermal zone device 1458 * @tz: thermal zone device
1437 * @trip: indicates which trip point has been crossed 1459 * @trip: indicates which trip point has been crossed
1438 * 1460 *
@@ -1443,16 +1465,21 @@ EXPORT_SYMBOL(thermal_cdev_update);
1443 * The throttling policy is based on the configured platform data; if no 1465 * The throttling policy is based on the configured platform data; if no
1444 * platform data is provided, this uses the step_wise throttling policy. 1466 * platform data is provided, this uses the step_wise throttling policy.
1445 */ 1467 */
1446void notify_thermal_framework(struct thermal_zone_device *tz, int trip) 1468void thermal_notify_framework(struct thermal_zone_device *tz, int trip)
1447{ 1469{
1448 handle_thermal_trip(tz, trip); 1470 handle_thermal_trip(tz, trip);
1449} 1471}
1450EXPORT_SYMBOL(notify_thermal_framework); 1472EXPORT_SYMBOL_GPL(thermal_notify_framework);
1451 1473
1452/** 1474/**
1453 * create_trip_attrs - create attributes for trip points 1475 * create_trip_attrs() - create attributes for trip points
1454 * @tz: the thermal zone device 1476 * @tz: the thermal zone device
1455 * @mask: Writeable trip point bitmap. 1477 * @mask: Writeable trip point bitmap.
1478 *
1479 * helper function to instantiate sysfs entries for every trip
1480 * point and its properties of a struct thermal_zone_device.
1481 *
1482 * Return: 0 on success, the proper error value otherwise.
1456 */ 1483 */
1457static int create_trip_attrs(struct thermal_zone_device *tz, int mask) 1484static int create_trip_attrs(struct thermal_zone_device *tz, int mask)
1458{ 1485{
@@ -1553,7 +1580,7 @@ static void remove_trip_attrs(struct thermal_zone_device *tz)
1553} 1580}
1554 1581
1555/** 1582/**
1556 * thermal_zone_device_register - register a new thermal zone device 1583 * thermal_zone_device_register() - register a new thermal zone device
1557 * @type: the thermal zone device type 1584 * @type: the thermal zone device type
1558 * @trips: the number of trip points the thermal zone support 1585 * @trips: the number of trip points the thermal zone support
1559 * @mask: a bit string indicating the writeablility of trip points 1586 * @mask: a bit string indicating the writeablility of trip points
@@ -1566,8 +1593,15 @@ static void remove_trip_attrs(struct thermal_zone_device *tz)
1566 * whether trip points have been crossed (0 for interrupt 1593 * whether trip points have been crossed (0 for interrupt
1567 * driven systems) 1594 * driven systems)
1568 * 1595 *
1596 * This interface function adds a new thermal zone device (sensor) to
1597 * /sys/class/thermal folder as thermal_zone[0-*]. It tries to bind all the
1598 * thermal cooling devices registered at the same time.
1569 * thermal_zone_device_unregister() must be called when the device is no 1599 * thermal_zone_device_unregister() must be called when the device is no
1570 * longer needed. The passive cooling depends on the .get_trend() return value. 1600 * longer needed. The passive cooling depends on the .get_trend() return value.
1601 *
1602 * Return: a pointer to the created struct thermal_zone_device or an
1603 * in case of error, an ERR_PTR. Caller must check return value with
1604 * IS_ERR*() helpers.
1571 */ 1605 */
1572struct thermal_zone_device *thermal_zone_device_register(const char *type, 1606struct thermal_zone_device *thermal_zone_device_register(const char *type,
1573 int trips, int mask, void *devdata, 1607 int trips, int mask, void *devdata,
@@ -1606,7 +1640,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type,
1606 return ERR_PTR(result); 1640 return ERR_PTR(result);
1607 } 1641 }
1608 1642
1609 strcpy(tz->type, type ? : ""); 1643 strlcpy(tz->type, type ? : "", sizeof(tz->type));
1610 tz->ops = ops; 1644 tz->ops = ops;
1611 tz->tzp = tzp; 1645 tz->tzp = tzp;
1612 tz->device.class = &thermal_class; 1646 tz->device.class = &thermal_class;
@@ -1699,7 +1733,7 @@ unregister:
1699 device_unregister(&tz->device); 1733 device_unregister(&tz->device);
1700 return ERR_PTR(result); 1734 return ERR_PTR(result);
1701} 1735}
1702EXPORT_SYMBOL(thermal_zone_device_register); 1736EXPORT_SYMBOL_GPL(thermal_zone_device_register);
1703 1737
1704/** 1738/**
1705 * thermal_device_unregister - removes the registered thermal zone device 1739 * thermal_device_unregister - removes the registered thermal zone device
@@ -1766,7 +1800,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
1766 device_unregister(&tz->device); 1800 device_unregister(&tz->device);
1767 return; 1801 return;
1768} 1802}
1769EXPORT_SYMBOL(thermal_zone_device_unregister); 1803EXPORT_SYMBOL_GPL(thermal_zone_device_unregister);
1770 1804
1771/** 1805/**
1772 * thermal_zone_get_zone_by_name() - search for a zone and returns its ref 1806 * thermal_zone_get_zone_by_name() - search for a zone and returns its ref
@@ -1882,7 +1916,7 @@ int thermal_generate_netlink_event(struct thermal_zone_device *tz,
1882 1916
1883 return result; 1917 return result;
1884} 1918}
1885EXPORT_SYMBOL(thermal_generate_netlink_event); 1919EXPORT_SYMBOL_GPL(thermal_generate_netlink_event);
1886 1920
1887static int genetlink_init(void) 1921static int genetlink_init(void)
1888{ 1922{
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index ec2b886f9d96..d7272ab20ebc 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -246,7 +246,7 @@ int get_tz_trend(struct thermal_zone_device *, int);
246struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, 246struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,
247 struct thermal_cooling_device *, int); 247 struct thermal_cooling_device *, int);
248void thermal_cdev_update(struct thermal_cooling_device *); 248void thermal_cdev_update(struct thermal_cooling_device *);
249void notify_thermal_framework(struct thermal_zone_device *, int); 249void thermal_notify_framework(struct thermal_zone_device *, int);
250 250
251#ifdef CONFIG_NET 251#ifdef CONFIG_NET
252extern int thermal_generate_netlink_event(struct thermal_zone_device *tz, 252extern int thermal_generate_netlink_event(struct thermal_zone_device *tz,