ARM: move LED support code out of arch/arm/kernel/time.c
authorRussell King <rmk+kernel@arm.linux.org.uk>
Sun, 10 Jan 2010 17:15:32 +0000 (17:15 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Mon, 15 Feb 2010 21:39:12 +0000 (21:39 +0000)
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
arch/arm/kernel/Makefile
arch/arm/kernel/leds.c [new file with mode: 0644]
arch/arm/kernel/time.c

index dd00f747e2ad00aeb844dd6b8c8373dd34b2a853..eb0284cd8661cc0b07459b1feeda9ca7cb95aab7 100644 (file)
@@ -17,6 +17,7 @@ obj-y         := compat.o elf.o entry-armv.o entry-common.o irq.o \
                   process.o ptrace.o return_address.o setup.o signal.o \
                   sys_arm.o stacktrace.o time.o traps.o
 
+obj-$(CONFIG_LEDS)             += leds.o
 obj-$(CONFIG_OC_ETM)           += etm.o
 
 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 (file)
index 0000000..31a316c
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * LED support code, ripped out of arch/arm/kernel/time.c
+ *
+ *  Copyright (C) 1994-2001 Russell King
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/sysdev.h>
+
+#include <asm/leds.h>
+
+static void dummy_leds_event(led_event_t evt)
+{
+}
+
+void (*leds_event)(led_event_t) = dummy_leds_event;
+
+struct leds_evt_name {
+       const char      name[8];
+       int             on;
+       int             off;
+};
+
+static const struct leds_evt_name evt_names[] = {
+       { "amber", led_amber_on, led_amber_off },
+       { "blue",  led_blue_on,  led_blue_off  },
+       { "green", led_green_on, led_green_off },
+       { "red",   led_red_on,   led_red_off   },
+};
+
+static ssize_t leds_store(struct sys_device *dev,
+                       struct sysdev_attribute *attr,
+                       const char *buf, size_t size)
+{
+       int ret = -EINVAL, len = strcspn(buf, " ");
+
+       if (len > 0 && buf[len] == '\0')
+               len--;
+
+       if (strncmp(buf, "claim", len) == 0) {
+               leds_event(led_claim);
+               ret = size;
+       } else if (strncmp(buf, "release", len) == 0) {
+               leds_event(led_release);
+               ret = size;
+       } else {
+               int i;
+
+               for (i = 0; i < ARRAY_SIZE(evt_names); i++) {
+                       if (strlen(evt_names[i].name) != len ||
+                           strncmp(buf, evt_names[i].name, len) != 0)
+                               continue;
+                       if (strncmp(buf+len, " on", 3) == 0) {
+                               leds_event(evt_names[i].on);
+                               ret = size;
+                       } else if (strncmp(buf+len, " off", 4) == 0) {
+                               leds_event(evt_names[i].off);
+                               ret = size;
+                       }
+                       break;
+               }
+       }
+       return ret;
+}
+
+static SYSDEV_ATTR(event, 0200, NULL, leds_store);
+
+static int leds_suspend(struct sys_device *dev, pm_message_t state)
+{
+       leds_event(led_stop);
+       return 0;
+}
+
+static int leds_resume(struct sys_device *dev)
+{
+       leds_event(led_start);
+       return 0;
+}
+
+static int leds_shutdown(struct sys_device *dev)
+{
+       leds_event(led_halted);
+       return 0;
+}
+
+static struct sysdev_class leds_sysclass = {
+       .name           = "leds",
+       .shutdown       = leds_shutdown,
+       .suspend        = leds_suspend,
+       .resume         = leds_resume,
+};
+
+static struct sys_device leds_device = {
+       .id             = 0,
+       .cls            = &leds_sysclass,
+};
+
+static int __init leds_init(void)
+{
+       int ret;
+       ret = sysdev_class_register(&leds_sysclass);
+       if (ret == 0)
+               ret = sysdev_register(&leds_device);
+       if (ret == 0)
+               ret = sysdev_create_file(&leds_device, &attr_event);
+       return ret;
+}
+
+device_initcall(leds_init);
+
+EXPORT_SYMBOL(leds_event);
index e26f966d117bd0f6a4d1fbff650b7620fddd5a65..28753805d2d16f7cffa9fd25b4164011432b014b 100644 (file)
@@ -79,110 +79,6 @@ static unsigned long dummy_gettimeoffset(void)
 }
 #endif
 
-#ifdef CONFIG_LEDS
-
-static void dummy_leds_event(led_event_t evt)
-{
-}
-
-void (*leds_event)(led_event_t) = dummy_leds_event;
-
-struct leds_evt_name {
-       const char      name[8];
-       int             on;
-       int             off;
-};
-
-static const struct leds_evt_name evt_names[] = {
-       { "amber", led_amber_on, led_amber_off },
-       { "blue",  led_blue_on,  led_blue_off  },
-       { "green", led_green_on, led_green_off },
-       { "red",   led_red_on,   led_red_off   },
-};
-
-static ssize_t leds_store(struct sys_device *dev,
-                       struct sysdev_attribute *attr,
-                       const char *buf, size_t size)
-{
-       int ret = -EINVAL, len = strcspn(buf, " ");
-
-       if (len > 0 && buf[len] == '\0')
-               len--;
-
-       if (strncmp(buf, "claim", len) == 0) {
-               leds_event(led_claim);
-               ret = size;
-       } else if (strncmp(buf, "release", len) == 0) {
-               leds_event(led_release);
-               ret = size;
-       } else {
-               int i;
-
-               for (i = 0; i < ARRAY_SIZE(evt_names); i++) {
-                       if (strlen(evt_names[i].name) != len ||
-                           strncmp(buf, evt_names[i].name, len) != 0)
-                               continue;
-                       if (strncmp(buf+len, " on", 3) == 0) {
-                               leds_event(evt_names[i].on);
-                               ret = size;
-                       } else if (strncmp(buf+len, " off", 4) == 0) {
-                               leds_event(evt_names[i].off);
-                               ret = size;
-                       }
-                       break;
-               }
-       }
-       return ret;
-}
-
-static SYSDEV_ATTR(event, 0200, NULL, leds_store);
-
-static int leds_suspend(struct sys_device *dev, pm_message_t state)
-{
-       leds_event(led_stop);
-       return 0;
-}
-
-static int leds_resume(struct sys_device *dev)
-{
-       leds_event(led_start);
-       return 0;
-}
-
-static int leds_shutdown(struct sys_device *dev)
-{
-       leds_event(led_halted);
-       return 0;
-}
-
-static struct sysdev_class leds_sysclass = {
-       .name           = "leds",
-       .shutdown       = leds_shutdown,
-       .suspend        = leds_suspend,
-       .resume         = leds_resume,
-};
-
-static struct sys_device leds_device = {
-       .id             = 0,
-       .cls            = &leds_sysclass,
-};
-
-static int __init leds_init(void)
-{
-       int ret;
-       ret = sysdev_class_register(&leds_sysclass);
-       if (ret == 0)
-               ret = sysdev_register(&leds_device);
-       if (ret == 0)
-               ret = sysdev_create_file(&leds_device, &attr_event);
-       return ret;
-}
-
-device_initcall(leds_init);
-
-EXPORT_SYMBOL(leds_event);
-#endif
-
 #ifdef CONFIG_LEDS_TIMER
 static inline void do_leds(void)
 {