vsprintf: split out '%p' handling logic
[pandora-kernel.git] / drivers / leds / leds-cm-x270.c
1 /*
2  * drivers/leds/leds-cm-x270.c
3  *
4  * Copyright 2007 CompuLab Ltd.
5  * Author: Mike Rapoport <mike@compulab.co.il>
6  *
7  * Based on leds-corgi.c
8  * Author: Richard Purdie <rpurdie@openedhand.com>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  *
14  */
15
16 #include <linux/kernel.h>
17 #include <linux/init.h>
18 #include <linux/platform_device.h>
19 #include <linux/leds.h>
20
21 #include <asm/arch/hardware.h>
22 #include <asm/arch/pxa-regs.h>
23
24 #define GPIO_RED_LED                    (93)
25 #define GPIO_GREEN_LED                  (94)
26
27 static void cmx270_red_set(struct led_classdev *led_cdev,
28                            enum led_brightness value)
29 {
30         if (value)
31                 GPCR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED);
32         else
33                 GPSR(GPIO_RED_LED) = GPIO_bit(GPIO_RED_LED);
34 }
35
36 static void cmx270_green_set(struct led_classdev *led_cdev,
37                              enum led_brightness value)
38 {
39         if (value)
40                 GPCR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED);
41         else
42                 GPSR(GPIO_GREEN_LED) = GPIO_bit(GPIO_GREEN_LED);
43 }
44
45 static struct led_classdev cmx270_red_led = {
46         .name                   = "cm-x270:red",
47         .default_trigger        = "nand-disk",
48         .brightness_set         = cmx270_red_set,
49 };
50
51 static struct led_classdev cmx270_green_led = {
52         .name                   = "cm-x270:green",
53         .default_trigger        = "heartbeat",
54         .brightness_set         = cmx270_green_set,
55 };
56
57 #ifdef CONFIG_PM
58 static int cmx270led_suspend(struct platform_device *dev, pm_message_t state)
59 {
60         led_classdev_suspend(&cmx270_red_led);
61         led_classdev_suspend(&cmx270_green_led);
62         return 0;
63 }
64
65 static int cmx270led_resume(struct platform_device *dev)
66 {
67         led_classdev_resume(&cmx270_red_led);
68         led_classdev_resume(&cmx270_green_led);
69         return 0;
70 }
71 #endif
72
73 static int cmx270led_probe(struct platform_device *pdev)
74 {
75         int ret;
76
77         ret = led_classdev_register(&pdev->dev, &cmx270_red_led);
78         if (ret < 0)
79                 return ret;
80
81         ret = led_classdev_register(&pdev->dev, &cmx270_green_led);
82         if (ret < 0)
83                 led_classdev_unregister(&cmx270_red_led);
84
85         return ret;
86 }
87
88 static int cmx270led_remove(struct platform_device *pdev)
89 {
90         led_classdev_unregister(&cmx270_red_led);
91         led_classdev_unregister(&cmx270_green_led);
92         return 0;
93 }
94
95 static struct platform_driver cmx270led_driver = {
96         .probe          = cmx270led_probe,
97         .remove         = cmx270led_remove,
98 #ifdef CONFIG_PM
99         .suspend        = cmx270led_suspend,
100         .resume         = cmx270led_resume,
101 #endif
102         .driver         = {
103                 .name           = "cm-x270-led",
104                 .owner          = THIS_MODULE,
105         },
106 };
107
108 static int __init cmx270led_init(void)
109 {
110         return platform_driver_register(&cmx270led_driver);
111 }
112
113 static void __exit cmx270led_exit(void)
114 {
115         platform_driver_unregister(&cmx270led_driver);
116 }
117
118 module_init(cmx270led_init);
119 module_exit(cmx270led_exit);
120
121 MODULE_AUTHOR("Mike Rapoport <mike@compulab.co.il>");
122 MODULE_DESCRIPTION("CM-x270 LED driver");
123 MODULE_LICENSE("GPL");
124 MODULE_ALIAS("platform:cm-x270-led");