thermal: use integers rather than strings for thermal values
The thermal API currently uses strings to pass values to userspace. This makes it difficult to use from within the kernel. Change the interface to use integers and fix up the consumers. Signed-off-by: Matthew Garrett <mjg@redhat.com> Acked-by: Zhang Rui <rui.zhang@intel.com> Acked-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Len Brown <len.brown@intel.com>
此提交包含在:
@@ -358,32 +358,36 @@ static struct output_properties acpi_output_properties = {
|
||||
|
||||
|
||||
/* thermal cooling device callbacks */
|
||||
static int video_get_max_state(struct thermal_cooling_device *cdev, char *buf)
|
||||
static int video_get_max_state(struct thermal_cooling_device *cdev, unsigned
|
||||
long *state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_video_device *video = acpi_driver_data(device);
|
||||
|
||||
return sprintf(buf, "%d\n", video->brightness->count - 3);
|
||||
*state = video->brightness->count - 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int video_get_cur_state(struct thermal_cooling_device *cdev, char *buf)
|
||||
static int video_get_cur_state(struct thermal_cooling_device *cdev, unsigned
|
||||
long *state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_video_device *video = acpi_driver_data(device);
|
||||
unsigned long long level;
|
||||
int state;
|
||||
int offset;
|
||||
|
||||
acpi_video_device_lcd_get_level_current(video, &level);
|
||||
for (state = 2; state < video->brightness->count; state++)
|
||||
if (level == video->brightness->levels[state])
|
||||
return sprintf(buf, "%d\n",
|
||||
video->brightness->count - state - 1);
|
||||
for (offset = 2; offset < video->brightness->count; offset++)
|
||||
if (level == video->brightness->levels[offset]) {
|
||||
*state = video->brightness->count - offset - 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int
|
||||
video_set_cur_state(struct thermal_cooling_device *cdev, unsigned int state)
|
||||
video_set_cur_state(struct thermal_cooling_device *cdev, unsigned long state)
|
||||
{
|
||||
struct acpi_device *device = cdev->devdata;
|
||||
struct acpi_video_device *video = acpi_driver_data(device);
|
||||
|
新增問題並參考
封鎖使用者