Loading drivers/thermal/thermal_core.c +27 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <linux/idr.h> #include <linux/thermal.h> #include <linux/reboot.h> #include <linux/kthread.h> #include <net/netlink.h> #include <net/genetlink.h> Loading Loading @@ -290,6 +291,22 @@ static void sensor_update_work(struct work_struct *work) mutex_unlock(&sensor->lock); } static __ref int sensor_sysfs_notify(void *data) { int ret = 0; struct sensor_info *sensor = (struct sensor_info *)data; while (!kthread_should_stop()) { while (wait_for_completion_interruptible( &sensor->sysfs_notify_complete) != 0) ; INIT_COMPLETION(sensor->sysfs_notify_complete); sysfs_notify(&sensor->tz->device.kobj, NULL, THERMAL_UEVENT_DATA); } return ret; } /* Should not be called in an interrupt context. * Do NOT call sensor_set_trip from this function */ Loading Loading @@ -319,8 +336,7 @@ int thermal_sensor_trip(struct thermal_zone_device *tz, (pos->temp <= temp))) { if ((pos == &tz->tz_threshold[0]) || (pos == &tz->tz_threshold[1])) sysfs_notify(&tz->device.kobj, NULL, THERMAL_UEVENT_DATA); complete(&tz->sensor.sysfs_notify_complete); pos->active = 0; pos->notify(trip, temp, pos->data); } Loading Loading @@ -494,6 +510,14 @@ int sensor_init(struct thermal_zone_device *tz) tz->tz_threshold[1].trip = THERMAL_TRIP_CONFIGURABLE_LOW; list_add(&sensor->sensor_list, &sensor_info_list); INIT_WORK(&sensor->work, sensor_update_work); init_completion(&sensor->sysfs_notify_complete); sensor->sysfs_notify_thread = kthread_run(sensor_sysfs_notify, &tz->sensor, "therm_core:notify%d", tz->id); if (IS_ERR(sensor->sysfs_notify_thread)) pr_err("Failed to create notify thread %d", tz->id); return 0; } Loading Loading @@ -2227,6 +2251,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) thermal_remove_hwmon_sysfs(tz); flush_work(&tz->sensor.work); kthread_stop(tz->sensor.sysfs_notify_thread); mutex_lock(&thermal_list_lock); list_del(&tz->sensor.sensor_list); mutex_unlock(&thermal_list_lock); Loading include/linux/thermal.h +2 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ struct sensor_info { struct list_head threshold_list; struct mutex lock; struct work_struct work; struct task_struct *sysfs_notify_thread; struct completion sysfs_notify_complete; }; struct thermal_zone_device { Loading Loading
drivers/thermal/thermal_core.c +27 −2 Original line number Diff line number Diff line Loading @@ -34,6 +34,7 @@ #include <linux/idr.h> #include <linux/thermal.h> #include <linux/reboot.h> #include <linux/kthread.h> #include <net/netlink.h> #include <net/genetlink.h> Loading Loading @@ -290,6 +291,22 @@ static void sensor_update_work(struct work_struct *work) mutex_unlock(&sensor->lock); } static __ref int sensor_sysfs_notify(void *data) { int ret = 0; struct sensor_info *sensor = (struct sensor_info *)data; while (!kthread_should_stop()) { while (wait_for_completion_interruptible( &sensor->sysfs_notify_complete) != 0) ; INIT_COMPLETION(sensor->sysfs_notify_complete); sysfs_notify(&sensor->tz->device.kobj, NULL, THERMAL_UEVENT_DATA); } return ret; } /* Should not be called in an interrupt context. * Do NOT call sensor_set_trip from this function */ Loading Loading @@ -319,8 +336,7 @@ int thermal_sensor_trip(struct thermal_zone_device *tz, (pos->temp <= temp))) { if ((pos == &tz->tz_threshold[0]) || (pos == &tz->tz_threshold[1])) sysfs_notify(&tz->device.kobj, NULL, THERMAL_UEVENT_DATA); complete(&tz->sensor.sysfs_notify_complete); pos->active = 0; pos->notify(trip, temp, pos->data); } Loading Loading @@ -494,6 +510,14 @@ int sensor_init(struct thermal_zone_device *tz) tz->tz_threshold[1].trip = THERMAL_TRIP_CONFIGURABLE_LOW; list_add(&sensor->sensor_list, &sensor_info_list); INIT_WORK(&sensor->work, sensor_update_work); init_completion(&sensor->sysfs_notify_complete); sensor->sysfs_notify_thread = kthread_run(sensor_sysfs_notify, &tz->sensor, "therm_core:notify%d", tz->id); if (IS_ERR(sensor->sysfs_notify_thread)) pr_err("Failed to create notify thread %d", tz->id); return 0; } Loading Loading @@ -2227,6 +2251,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) thermal_remove_hwmon_sysfs(tz); flush_work(&tz->sensor.work); kthread_stop(tz->sensor.sysfs_notify_thread); mutex_lock(&thermal_list_lock); list_del(&tz->sensor.sensor_list); mutex_unlock(&thermal_list_lock); Loading
include/linux/thermal.h +2 −0 Original line number Diff line number Diff line Loading @@ -186,6 +186,8 @@ struct sensor_info { struct list_head threshold_list; struct mutex lock; struct work_struct work; struct task_struct *sysfs_notify_thread; struct completion sysfs_notify_complete; }; struct thermal_zone_device { Loading