aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHenrique de Moraes Holschuh <hmh@hmh.eng.br>2006-11-25 13:35:09 -0500
committerLen Brown <len.brown@intel.com>2006-12-07 01:38:45 -0500
commitfb87a811a4c232e2af8d746dc75330cbe5b0780c (patch)
tree9a755895c17bcb17fea382c09edb10ce847c5160 /drivers
parent2df910b4c3edcce9a0c12394db6f5f4a6e69c712 (diff)
ACPI: ibm-acpi: backlight device cleanup
This patch cleans up the recently added backlight device support by Holger Macht <hmacht@suse.de> to fit well with the rest of the code, using the ibms struct as the other "subdrivers" in ibm-acpi. Signed-off-by: Henrique de Moraes Holschuh <hmh@hmh.eng.br>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/ibm_acpi.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/drivers/acpi/ibm_acpi.c b/drivers/acpi/ibm_acpi.c
index fbb4970ce16a..36e2667d8652 100644
--- a/drivers/acpi/ibm_acpi.c
+++ b/drivers/acpi/ibm_acpi.c
@@ -397,7 +397,7 @@ struct ibm_struct {
397 397
398static struct proc_dir_entry *proc_dir = NULL; 398static struct proc_dir_entry *proc_dir = NULL;
399 399
400static struct backlight_device *ibm_backlight_device; 400static struct backlight_device *ibm_backlight_device = NULL;
401 401
402#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off") 402#define onoff(status,bit) ((status) & (1 << (bit)) ? "on" : "off")
403#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled") 403#define enabled(status,bit) ((status) & (1 << (bit)) ? "enabled" : "disabled")
@@ -1639,6 +1639,7 @@ static int brightness_get(struct backlight_device *bd)
1639 return -EIO; 1639 return -EIO;
1640 1640
1641 level &= 0x7; 1641 level &= 0x7;
1642
1642 return level; 1643 return level;
1643} 1644}
1644 1645
@@ -1713,6 +1714,33 @@ static int brightness_update_status(struct backlight_device *bd)
1713 return brightness_set(bd->props->brightness); 1714 return brightness_set(bd->props->brightness);
1714} 1715}
1715 1716
1717static struct backlight_properties ibm_backlight_data = {
1718 .owner = THIS_MODULE,
1719 .get_brightness = brightness_get,
1720 .update_status = brightness_update_status,
1721 .max_brightness = 7,
1722};
1723
1724static int brightness_init(void)
1725{
1726 ibm_backlight_device = backlight_device_register("ibm", NULL,
1727 &ibm_backlight_data);
1728 if (IS_ERR(ibm_backlight_device)) {
1729 printk(IBM_ERR "Could not register backlight device\n");
1730 return PTR_ERR(ibm_backlight_device);
1731 }
1732
1733 return 0;
1734}
1735
1736static void brightness_exit(void)
1737{
1738 if (ibm_backlight_device) {
1739 backlight_device_unregister(ibm_backlight_device);
1740 ibm_backlight_device = NULL;
1741 }
1742}
1743
1716static int volume_offset = 0x30; 1744static int volume_offset = 0x30;
1717 1745
1718static int volume_read(char *p) 1746static int volume_read(char *p)
@@ -2377,6 +2405,8 @@ static struct ibm_struct ibms[] = {
2377 .name = "brightness", 2405 .name = "brightness",
2378 .read = brightness_read, 2406 .read = brightness_read,
2379 .write = brightness_write, 2407 .write = brightness_write,
2408 .init = brightness_init,
2409 .exit = brightness_exit,
2380 }, 2410 },
2381 { 2411 {
2382 .name = "volume", 2412 .name = "volume",
@@ -2642,20 +2672,10 @@ IBM_PARAM(brightness);
2642IBM_PARAM(volume); 2672IBM_PARAM(volume);
2643IBM_PARAM(fan); 2673IBM_PARAM(fan);
2644 2674
2645static struct backlight_properties ibm_backlight_data = {
2646 .owner = THIS_MODULE,
2647 .get_brightness = brightness_get,
2648 .update_status = brightness_update_status,
2649 .max_brightness = 7,
2650};
2651
2652static void acpi_ibm_exit(void) 2675static void acpi_ibm_exit(void)
2653{ 2676{
2654 int i; 2677 int i;
2655 2678
2656 if (ibm_backlight_device)
2657 backlight_device_unregister(ibm_backlight_device);
2658
2659 for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--) 2679 for (i = ARRAY_SIZE(ibms) - 1; i >= 0; i--)
2660 ibm_exit(&ibms[i]); 2680 ibm_exit(&ibms[i]);
2661 2681
@@ -2758,14 +2778,6 @@ static int __init acpi_ibm_init(void)
2758 } 2778 }
2759 } 2779 }
2760 2780
2761 ibm_backlight_device = backlight_device_register("ibm", NULL,
2762 &ibm_backlight_data);
2763 if (IS_ERR(ibm_backlight_device)) {
2764 printk(IBM_ERR "Could not register ibm backlight device\n");
2765 ibm_backlight_device = NULL;
2766 acpi_ibm_exit();
2767 }
2768
2769 return 0; 2781 return 0;
2770} 2782}
2771 2783