diff options
author | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-01-10 12:15:32 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2010-02-15 16:39:12 -0500 |
commit | 373b32abf9b33616ad94283461bb2ab49e8371d5 (patch) | |
tree | f503bb29f47bbb019578141e399ee178c9a94728 /arch | |
parent | 7921fc4a25800f4210bca96c05dea67a6b736d32 (diff) |
ARM: move LED support code out of arch/arm/kernel/time.c
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/kernel/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/kernel/leds.c | 115 | ||||
-rw-r--r-- | arch/arm/kernel/time.c | 104 |
3 files changed, 116 insertions, 104 deletions
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index dd00f747e2ad..eb0284cd8661 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile | |||
@@ -17,6 +17,7 @@ obj-y := compat.o elf.o entry-armv.o entry-common.o irq.o \ | |||
17 | process.o ptrace.o return_address.o setup.o signal.o \ | 17 | process.o ptrace.o return_address.o setup.o signal.o \ |
18 | sys_arm.o stacktrace.o time.o traps.o | 18 | sys_arm.o stacktrace.o time.o traps.o |
19 | 19 | ||
20 | obj-$(CONFIG_LEDS) += leds.o | ||
20 | obj-$(CONFIG_OC_ETM) += etm.o | 21 | obj-$(CONFIG_OC_ETM) += etm.o |
21 | 22 | ||
22 | obj-$(CONFIG_ISA_DMA_API) += dma.o | 23 | obj-$(CONFIG_ISA_DMA_API) += dma.o |
diff --git a/arch/arm/kernel/leds.c b/arch/arm/kernel/leds.c new file mode 100644 index 000000000000..31a316c1777b --- /dev/null +++ b/arch/arm/kernel/leds.c | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * LED support code, ripped out of arch/arm/kernel/time.c | ||
3 | * | ||
4 | * Copyright (C) 1994-2001 Russell King | ||
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 version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/sysdev.h> | ||
13 | |||
14 | #include <asm/leds.h> | ||
15 | |||
16 | static void dummy_leds_event(led_event_t evt) | ||
17 | { | ||
18 | } | ||
19 | |||
20 | void (*leds_event)(led_event_t) = dummy_leds_event; | ||
21 | |||
22 | struct leds_evt_name { | ||
23 | const char name[8]; | ||
24 | int on; | ||
25 | int off; | ||
26 | }; | ||
27 | |||
28 | static const struct leds_evt_name evt_names[] = { | ||
29 | { "amber", led_amber_on, led_amber_off }, | ||
30 | { "blue", led_blue_on, led_blue_off }, | ||
31 | { "green", led_green_on, led_green_off }, | ||
32 | { "red", led_red_on, led_red_off }, | ||
33 | }; | ||
34 | |||
35 | static ssize_t leds_store(struct sys_device *dev, | ||
36 | struct sysdev_attribute *attr, | ||
37 | const char *buf, size_t size) | ||
38 | { | ||
39 | int ret = -EINVAL, len = strcspn(buf, " "); | ||
40 | |||
41 | if (len > 0 && buf[len] == '\0') | ||
42 | len--; | ||
43 | |||
44 | if (strncmp(buf, "claim", len) == 0) { | ||
45 | leds_event(led_claim); | ||
46 | ret = size; | ||
47 | } else if (strncmp(buf, "release", len) == 0) { | ||
48 | leds_event(led_release); | ||
49 | ret = size; | ||
50 | } else { | ||
51 | int i; | ||
52 | |||
53 | for (i = 0; i < ARRAY_SIZE(evt_names); i++) { | ||
54 | if (strlen(evt_names[i].name) != len || | ||
55 | strncmp(buf, evt_names[i].name, len) != 0) | ||
56 | continue; | ||
57 | if (strncmp(buf+len, " on", 3) == 0) { | ||
58 | leds_event(evt_names[i].on); | ||
59 | ret = size; | ||
60 | } else if (strncmp(buf+len, " off", 4) == 0) { | ||
61 | leds_event(evt_names[i].off); | ||
62 | ret = size; | ||
63 | } | ||
64 | break; | ||
65 | } | ||
66 | } | ||
67 | return ret; | ||
68 | } | ||
69 | |||
70 | static SYSDEV_ATTR(event, 0200, NULL, leds_store); | ||
71 | |||
72 | static int leds_suspend(struct sys_device *dev, pm_message_t state) | ||
73 | { | ||
74 | leds_event(led_stop); | ||
75 | return 0; | ||
76 | } | ||
77 | |||
78 | static int leds_resume(struct sys_device *dev) | ||
79 | { | ||
80 | leds_event(led_start); | ||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | static int leds_shutdown(struct sys_device *dev) | ||
85 | { | ||
86 | leds_event(led_halted); | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static struct sysdev_class leds_sysclass = { | ||
91 | .name = "leds", | ||
92 | .shutdown = leds_shutdown, | ||
93 | .suspend = leds_suspend, | ||
94 | .resume = leds_resume, | ||
95 | }; | ||
96 | |||
97 | static struct sys_device leds_device = { | ||
98 | .id = 0, | ||
99 | .cls = &leds_sysclass, | ||
100 | }; | ||
101 | |||
102 | static int __init leds_init(void) | ||
103 | { | ||
104 | int ret; | ||
105 | ret = sysdev_class_register(&leds_sysclass); | ||
106 | if (ret == 0) | ||
107 | ret = sysdev_register(&leds_device); | ||
108 | if (ret == 0) | ||
109 | ret = sysdev_create_file(&leds_device, &attr_event); | ||
110 | return ret; | ||
111 | } | ||
112 | |||
113 | device_initcall(leds_init); | ||
114 | |||
115 | EXPORT_SYMBOL(leds_event); | ||
diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c index e26f966d117b..28753805d2d1 100644 --- a/arch/arm/kernel/time.c +++ b/arch/arm/kernel/time.c | |||
@@ -79,110 +79,6 @@ static unsigned long dummy_gettimeoffset(void) | |||
79 | } | 79 | } |
80 | #endif | 80 | #endif |
81 | 81 | ||
82 | #ifdef CONFIG_LEDS | ||
83 | |||
84 | static void dummy_leds_event(led_event_t evt) | ||
85 | { | ||
86 | } | ||
87 | |||
88 | void (*leds_event)(led_event_t) = dummy_leds_event; | ||
89 | |||
90 | struct leds_evt_name { | ||
91 | const char name[8]; | ||
92 | int on; | ||
93 | int off; | ||
94 | }; | ||
95 | |||
96 | static const struct leds_evt_name evt_names[] = { | ||
97 | { "amber", led_amber_on, led_amber_off }, | ||
98 | { "blue", led_blue_on, led_blue_off }, | ||
99 | { "green", led_green_on, led_green_off }, | ||
100 | { "red", led_red_on, led_red_off }, | ||
101 | }; | ||
102 | |||
103 | static ssize_t leds_store(struct sys_device *dev, | ||
104 | struct sysdev_attribute *attr, | ||
105 | const char *buf, size_t size) | ||
106 | { | ||
107 | int ret = -EINVAL, len = strcspn(buf, " "); | ||
108 | |||
109 | if (len > 0 && buf[len] == '\0') | ||
110 | len--; | ||
111 | |||
112 | if (strncmp(buf, "claim", len) == 0) { | ||
113 | leds_event(led_claim); | ||
114 | ret = size; | ||
115 | } else if (strncmp(buf, "release", len) == 0) { | ||
116 | leds_event(led_release); | ||
117 | ret = size; | ||
118 | } else { | ||
119 | int i; | ||
120 | |||
121 | for (i = 0; i < ARRAY_SIZE(evt_names); i++) { | ||
122 | if (strlen(evt_names[i].name) != len || | ||
123 | strncmp(buf, evt_names[i].name, len) != 0) | ||
124 | continue; | ||
125 | if (strncmp(buf+len, " on", 3) == 0) { | ||
126 | leds_event(evt_names[i].on); | ||
127 | ret = size; | ||
128 | } else if (strncmp(buf+len, " off", 4) == 0) { | ||
129 | leds_event(evt_names[i].off); | ||
130 | ret = size; | ||
131 | } | ||
132 | break; | ||
133 | } | ||
134 | } | ||
135 | return ret; | ||
136 | } | ||
137 | |||
138 | static SYSDEV_ATTR(event, 0200, NULL, leds_store); | ||
139 | |||
140 | static int leds_suspend(struct sys_device *dev, pm_message_t state) | ||
141 | { | ||
142 | leds_event(led_stop); | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | static int leds_resume(struct sys_device *dev) | ||
147 | { | ||
148 | leds_event(led_start); | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static int leds_shutdown(struct sys_device *dev) | ||
153 | { | ||
154 | leds_event(led_halted); | ||
155 | return 0; | ||
156 | } | ||
157 | |||
158 | static struct sysdev_class leds_sysclass = { | ||
159 | .name = "leds", | ||
160 | .shutdown = leds_shutdown, | ||
161 | .suspend = leds_suspend, | ||
162 | .resume = leds_resume, | ||
163 | }; | ||
164 | |||
165 | static struct sys_device leds_device = { | ||
166 | .id = 0, | ||
167 | .cls = &leds_sysclass, | ||
168 | }; | ||
169 | |||
170 | static int __init leds_init(void) | ||
171 | { | ||
172 | int ret; | ||
173 | ret = sysdev_class_register(&leds_sysclass); | ||
174 | if (ret == 0) | ||
175 | ret = sysdev_register(&leds_device); | ||
176 | if (ret == 0) | ||
177 | ret = sysdev_create_file(&leds_device, &attr_event); | ||
178 | return ret; | ||
179 | } | ||
180 | |||
181 | device_initcall(leds_init); | ||
182 | |||
183 | EXPORT_SYMBOL(leds_event); | ||
184 | #endif | ||
185 | |||
186 | #ifdef CONFIG_LEDS_TIMER | 82 | #ifdef CONFIG_LEDS_TIMER |
187 | static inline void do_leds(void) | 83 | static inline void do_leds(void) |
188 | { | 84 | { |