Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+8 -2
+8 -2
drivers/thermal/thermal_core.c
··· 403 403 enum thermal_trip_type type; 404 404 #endif 405 405 406 - if (!tz || IS_ERR(tz)) 406 + if (!tz || IS_ERR(tz) || !tz->ops->get_temp) 407 407 goto exit; 408 408 409 409 mutex_lock(&tz->lock); ··· 455 455 void thermal_zone_device_update(struct thermal_zone_device *tz) 456 456 { 457 457 int count; 458 + 459 + if (!tz->ops->get_temp) 460 + return; 458 461 459 462 update_temperature(tz); 460 463 ··· 1389 1386 if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) 1390 1387 return ERR_PTR(-EINVAL); 1391 1388 1392 - if (!ops || !ops->get_temp) 1389 + if (!ops) 1393 1390 return ERR_PTR(-EINVAL); 1394 1391 1395 1392 if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp)) ··· 1492 1489 bind_tz(tz); 1493 1490 1494 1491 INIT_DELAYED_WORK(&(tz->poll_queue), thermal_zone_device_check); 1492 + 1493 + if (!tz->ops->get_temp) 1494 + thermal_zone_device_set_polling(tz, 0); 1495 1495 1496 1496 thermal_zone_device_update(tz); 1497 1497