0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #include <linux/slab.h>
0014 #include <linux/thermal.h>
0015
0016 #include "thermal_core.h"
0017
0018 static int user_space_bind(struct thermal_zone_device *tz)
0019 {
0020 pr_info_once("Consider using thermal netlink events interface\n");
0021
0022 return 0;
0023 }
0024
0025
0026
0027
0028
0029
0030
0031
0032 static int notify_user_space(struct thermal_zone_device *tz, int trip)
0033 {
0034 char *thermal_prop[5];
0035 int i;
0036
0037 mutex_lock(&tz->lock);
0038 thermal_prop[0] = kasprintf(GFP_KERNEL, "NAME=%s", tz->type);
0039 thermal_prop[1] = kasprintf(GFP_KERNEL, "TEMP=%d", tz->temperature);
0040 thermal_prop[2] = kasprintf(GFP_KERNEL, "TRIP=%d", trip);
0041 thermal_prop[3] = kasprintf(GFP_KERNEL, "EVENT=%d", tz->notify_event);
0042 thermal_prop[4] = NULL;
0043 kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, thermal_prop);
0044 for (i = 0; i < 4; ++i)
0045 kfree(thermal_prop[i]);
0046 mutex_unlock(&tz->lock);
0047 return 0;
0048 }
0049
0050 static struct thermal_governor thermal_gov_user_space = {
0051 .name = "user_space",
0052 .throttle = notify_user_space,
0053 .bind_to_tz = user_space_bind,
0054 };
0055 THERMAL_GOVERNOR_DECLARE(thermal_gov_user_space);