diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-09-12 19:15:44 -0400 |
---|---|---|
committer | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-12-04 08:31:33 -0500 |
commit | 81bd4e1cebed5efb85bd94a15342ee4d6965a416 (patch) | |
tree | 8812dcdb72f93967c34f6f7015abc2b20308f5d8 /drivers | |
parent | dc1ccc48159d63eca5089e507c82c7d22ef60839 (diff) |
thermal: allow registering without .get_temp
This patch changes the thermal core driver to allow
registration of thermal zones without the .get_temp callback.
The idea behind this change is to allow lazy registration
of sensor callbacks.
The thermal zone will be disabled whenever the ops
does not contain a .get_temp callback. The sysfs interface
will be returning -EINVAL on any temperature read operation.
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: linux-pm@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/thermal/thermal_core.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index f1d511a9475b..0e43dc208fc6 100644 --- a/drivers/thermal/thermal_core.c +++ b/drivers/thermal/thermal_core.c | |||
@@ -403,7 +403,7 @@ int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp) | |||
403 | enum thermal_trip_type type; | 403 | enum thermal_trip_type type; |
404 | #endif | 404 | #endif |
405 | 405 | ||
406 | if (!tz || IS_ERR(tz)) | 406 | if (!tz || IS_ERR(tz) || !tz->ops->get_temp) |
407 | goto exit; | 407 | goto exit; |
408 | 408 | ||
409 | mutex_lock(&tz->lock); | 409 | mutex_lock(&tz->lock); |
@@ -456,6 +456,9 @@ void thermal_zone_device_update(struct thermal_zone_device *tz) | |||
456 | { | 456 | { |
457 | int count; | 457 | int count; |
458 | 458 | ||
459 | if (!tz->ops->get_temp) | ||
460 | return; | ||
461 | |||
459 | update_temperature(tz); | 462 | update_temperature(tz); |
460 | 463 | ||
461 | for (count = 0; count < tz->trips; count++) | 464 | for (count = 0; count < tz->trips; count++) |
@@ -1386,7 +1389,7 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, | |||
1386 | if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) | 1389 | if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) |
1387 | return ERR_PTR(-EINVAL); | 1390 | return ERR_PTR(-EINVAL); |
1388 | 1391 | ||
1389 | if (!ops || !ops->get_temp) | 1392 | if (!ops) |
1390 | return ERR_PTR(-EINVAL); | 1393 | return ERR_PTR(-EINVAL); |
1391 | 1394 | ||
1392 | if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) | 1395 | if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) |
@@ -1490,6 +1493,9 @@ struct thermal_zone_device *thermal_zone_device_register(const char *type, | |||
1490 | 1493 | ||
1491 | INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); | 1494 | INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); |
1492 | 1495 | ||
1496 | if (!tz->ops->get_temp) | ||
1497 | thermal_zone_device_set_polling(tz, 0); | ||
1498 | |||
1493 | thermal_zone_device_update(tz); | 1499 | thermal_zone_device_update(tz); |
1494 | 1500 | ||
1495 | if (!result) | 1501 | if (!result) |