aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/misc/sony-laptop.c
diff options
context:
space:
mode:
authorMattia Dongili <malattia@linux.it>2007-02-07 14:01:56 -0500
committerLen Brown <len.brown@intel.com>2007-02-13 03:07:13 -0500
commitd78865cdb096781382074943c1b7781696b178a6 (patch)
tree3e6fee1fe76f941679bd249a27970ec446f0ddb4 /drivers/misc/sony-laptop.c
parent287ddfd522097257dadf37deb21969ad4dbc8148 (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.c92
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);
54MODULE_PARM_DESC(debug, "set this to 1 (and RTFM) if you want to help " 54MODULE_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
57static int sony_backlight_update_status(struct backlight_device *bd);
58static int sony_backlight_get_brightness(struct backlight_device *bd);
59static struct backlight_device *sony_backlight_device;
60static 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
67static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *); 57static ssize_t sony_acpi_show(struct device *, struct device_attribute *, char *);
68static ssize_t sony_acpi_store(struct device *, struct device_attribute *, const char *, size_t); 58static 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[] = {
137static acpi_handle sony_acpi_handle; 127static acpi_handle sony_acpi_handle;
138static struct acpi_device *sony_acpi_acpi_device = NULL; 128static struct acpi_device *sony_acpi_acpi_device = NULL;
139 129
130/*
131 * acpi_evaluate_object wrappers
132 */
140static int acpi_callgetfunc(acpi_handle handle, char *name, int *result) 133static 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
338static int sony_acpi_resume(struct acpi_device *device) 331/*
332 * Backlight device
333 */
334static 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++) { 341static 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
351static struct backlight_device *sony_backlight_device;
352static 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 */
357static void sony_acpi_notify(acpi_handle handle, u32 event, void *data) 362static 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 */
387static 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
379static int sony_acpi_add(struct acpi_device *device) 406static 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
464static 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
471static 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
481static struct acpi_driver sony_acpi_driver = { 491static 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,