more cosmetic fixes for ar7
[openwrt.git] / target / linux / ar7-2.6 / files / drivers / leds / leds-ar7.c
1 /*
2 * linux/drivers/leds/leds-ar7.c
3 *
4 * Copyright (C) 2007 OpenWrt.org
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21
22 #include <linux/kernel.h>
23 #include <linux/init.h>
24 #include <linux/platform_device.h>
25 #include <linux/leds.h>
26 #include <linux/err.h>
27 #include <asm/io.h>
28 #include <gpio.h>
29
30 #define DRVNAME "ar7-leds"
31 #define LONGNAME "TI AR7 LEDs driver"
32
33 MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>");
34 MODULE_DESCRIPTION(LONGNAME);
35 MODULE_LICENSE("GPL");
36
37 static void ar7_status_led_set(struct led_classdev *pled,
38 enum led_brightness value)
39 {
40 gpio_set_value(AR7_GPIO_BIT_STATUS_LED, value ? 0 : 1);
41 }
42
43 static struct led_classdev ar7_status_led = {
44 .name = "ar7:status",
45 .brightness_set = ar7_status_led_set,
46 };
47
48 #ifdef CONFIG_PM
49 static int ar7_leds_suspend(struct platform_device *dev,
50 pm_message_t state)
51 {
52 led_classdev_suspend(&ar7_status_led);
53 return 0;
54 }
55
56 static int ar7_leds_resume(struct platform_device *dev)
57 {
58 led_classdev_resume(&ar7_status_led);
59 return 0;
60 }
61 #else /* CONFIG_PM */
62 #define ar7_leds_suspend NULL
63 #define ar7_leds_resume NULL
64 #endif /* CONFIG_PM */
65
66 static int ar7_leds_probe(struct platform_device *pdev)
67 {
68 int rc;
69
70 rc = led_classdev_register(&pdev->dev, &ar7_status_led);
71 if (rc < 0 )
72 goto out;
73
74 ar7_gpio_enable(AR7_GPIO_BIT_STATUS_LED);
75 gpio_direction_output(AR7_GPIO_BIT_STATUS_LED);
76
77 out:
78 return rc;
79 }
80
81 static int ar7_leds_remove(struct platform_device *pdev)
82 {
83 led_classdev_unregister(&ar7_status_led);
84
85 return 0;
86 }
87
88 static struct platform_device *ar7_leds_device;
89
90 static struct platform_driver ar7_leds_driver = {
91 .probe = ar7_leds_probe,
92 .remove = ar7_leds_remove,
93 .suspend = ar7_leds_suspend,
94 .resume = ar7_leds_resume,
95 .driver = {
96 .name = DRVNAME,
97 },
98 };
99
100 static int __init ar7_leds_init(void)
101 {
102 int rc;
103
104 ar7_leds_device = platform_device_alloc(DRVNAME, -1);
105 if (!ar7_leds_device)
106 return -ENOMEM;
107
108 rc = platform_device_add(ar7_leds_device);
109 if (rc < 0)
110 goto out_put;
111
112 rc = platform_driver_register(&ar7_leds_driver);
113 if (rc < 0)
114 goto out_put;
115
116 goto out;
117
118 out_put:
119 platform_device_put(ar7_leds_device);
120 out:
121 return rc;
122 }
123
124 static void __exit ar7_leds_exit(void)
125 {
126 platform_driver_unregister(&ar7_leds_driver);
127 platform_device_unregister(ar7_leds_device);
128 }
129
130 module_init(ar7_leds_init);
131 module_exit(ar7_leds_exit);
This page took 0.04681 seconds and 5 git commands to generate.