diff options
author | Mattia Dongili <malattia@linux.it> | 2007-02-07 14:01:56 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-02-13 03:07:13 -0500 |
commit | d78865cdb096781382074943c1b7781696b178a6 (patch) | |
tree | 3e6fee1fe76f941679bd249a27970ec446f0ddb4 /drivers/misc/sony-laptop.c | |
parent | 287ddfd522097257dadf37deb21969ad4dbc8148 (diff) |
sony-laptop: Group functions and structures to better draw subsytems usage
Signed-off-by: Mattia Dongili <malattia@linux.it>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/misc/sony-laptop.c')
-rw-r--r-- | drivers/misc/sony-laptop.c | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/drivers/misc/sony-laptop.c b/drivers/misc/sony-laptop.c index 1d14969fe6e7..4a69ce7cc6be 100644 --- a/drivers/misc/sony-laptop.c +++ b/drivers/misc/sony-laptop.c | |||
@@ -54,16 +54,6 @@ module_param(debug, int, 0); | |||
54 | MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " | 54 | MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " |
55 | "the development of this driver"); | 55 | "the development of this driver"); |
56 | 56 | ||
57 | static int sony_backlight_update_status(struct backlight_device *bd); | ||
58 | static int sony_backlight_get_brightness(struct backlight_device *bd); | ||
59 | static struct backlight_device *sony_backlight_device; | ||
60 | static struct backlight_properties sony_backlight_properties = { | ||
61 | .owner = THIS_MODULE, | ||
62 | .update_status = sony_backlight_update_status, | ||
63 | .get_brightness = sony_backlight_get_brightness, | ||
64 | .max_brightness = SONY_MAX_BRIGHTNESS - 1, | ||
65 | }; | ||
66 | |||
67 | static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *); | 57 | static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *); |
68 | static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t); | 58 | static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t); |
69 | 59 | ||
@@ -137,6 +127,9 @@ static struct sony_acpi_value sony_acpi_values[] = { | |||
137 | static acpi_handle sony_acpi_handle; | 127 | static acpi_handle sony_acpi_handle; |
138 | static struct acpi_device *sony_acpi_acpi_device = NULL; | 128 | static struct acpi_device *sony_acpi_acpi_device = NULL; |
139 | 129 | ||
130 | /* | ||
131 | * acpi_evaluate_object wrappers | ||
132 | */ | ||
140 | static int acpi_callgetfunc(acpi_handle handle, char *name, int *result) | 133 | static int acpi_callgetfunc(acpi_handle handle, char *name, int *result) |
141 | { | 134 | { |
142 | struct acpi_buffer output; | 135 | struct acpi_buffer output; |
@@ -335,25 +328,37 @@ static void sony_snc_pf_remove(void) | |||
335 | platform_driver_unregister(&sncpf_driver); | 328 | platform_driver_unregister(&sncpf_driver); |
336 | } | 329 | } |
337 | 330 | ||
338 | static int sony_acpi_resume(struct acpi_device *device) | 331 | /* |
332 | * Backlight device | ||
333 | */ | ||
334 | static int sony_backlight_update_status(struct backlight_device *bd) | ||
339 | { | 335 | { |
340 | struct sony_acpi_value *item; | 336 | return acpi_callsetfunc(sony_acpi_handle, "SBRT", |
337 | bd->props->brightness + 1, | ||
338 | NULL); | ||
339 | } | ||
341 | 340 | ||
342 | for (item = sony_acpi_values; item->name; item++) { | 341 | static int sony_backlight_get_brightness(struct backlight_device *bd) |
343 | int ret; | 342 | { |
343 | int value; | ||
344 | 344 | ||
345 | if (!item->valid) | 345 | if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value)) |
346 | continue; | 346 | return 0; |
347 | ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset, | 347 | /* brightness levels are 1-based, while backlight ones are 0-based */ |
348 | item->value, NULL); | 348 | return value - 1; |
349 | if (ret < 0) { | ||
350 | printk("%s: %d\n", __FUNCTION__, ret); | ||
351 | break; | ||
352 | } | ||
353 | } | ||
354 | return 0; | ||
355 | } | 349 | } |
356 | 350 | ||
351 | static struct backlight_device *sony_backlight_device; | ||
352 | static struct backlight_properties sony_backlight_properties = { | ||
353 | .owner = THIS_MODULE, | ||
354 | .update_status = sony_backlight_update_status, | ||
355 | .get_brightness = sony_backlight_get_brightness, | ||
356 | .max_brightness = SONY_MAX_BRIGHTNESS - 1, | ||
357 | }; | ||
358 | |||
359 | /* | ||
360 | * ACPI callbacks | ||
361 | */ | ||
357 | static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) | 362 | static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) |
358 | { | 363 | { |
359 | if (debug) | 364 | if (debug) |
@@ -376,6 +381,28 @@ static acpi_status sony_walk_callback(acpi_handle handle, u32 level, | |||
376 | return AE_OK; | 381 | return AE_OK; |
377 | } | 382 | } |
378 | 383 | ||
384 | /* | ||
385 | * ACPI device | ||
386 | */ | ||
387 | static int sony_acpi_resume(struct acpi_device *device) | ||
388 | { | ||
389 | struct sony_acpi_value *item; | ||
390 | |||
391 | for (item = sony_acpi_values; item->name; item++) { | ||
392 | int ret; | ||
393 | |||
394 | if (!item->valid) | ||
395 | continue; | ||
396 | ret = acpi_callsetfunc(sony_acpi_handle, *item->acpiset, | ||
397 | item->value, NULL); | ||
398 | if (ret < 0) { | ||
399 | printk("%s: %d\n", __FUNCTION__, ret); | ||
400 | break; | ||
401 | } | ||
402 | } | ||
403 | return 0; | ||
404 | } | ||
405 | |||
379 | static int sony_acpi_add(struct acpi_device *device) | 406 | static int sony_acpi_add(struct acpi_device *device) |
380 | { | 407 | { |
381 | acpi_status status; | 408 | acpi_status status; |
@@ -461,23 +488,6 @@ static int sony_acpi_remove(struct acpi_device *device, int type) | |||
461 | return 0; | 488 | return 0; |
462 | } | 489 | } |
463 | 490 | ||
464 | static int sony_backlight_update_status(struct backlight_device *bd) | ||
465 | { | ||
466 | return acpi_callsetfunc(sony_acpi_handle, "SBRT", | ||
467 | bd->props->brightness + 1, | ||
468 | NULL); | ||
469 | } | ||
470 | |||
471 | static int sony_backlight_get_brightness(struct backlight_device *bd) | ||
472 | { | ||
473 | int value; | ||
474 | |||
475 | if (acpi_callgetfunc(sony_acpi_handle, "GBRT", &value)) | ||
476 | return 0; | ||
477 | /* brightness levels are 1-based, while backlight ones are 0-based */ | ||
478 | return value - 1; | ||
479 | } | ||
480 | |||
481 | static struct acpi_driver sony_acpi_driver = { | 491 | static struct acpi_driver sony_acpi_driver = { |
482 | .name = ACPI_SNC_DRIVER_NAME, | 492 | .name = ACPI_SNC_DRIVER_NAME, |
483 | .class = ACPI_SNC_CLASS, | 493 | .class = ACPI_SNC_CLASS, |