
#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- /dev/null
+++ linux/drivers/leds/arm_event.c
@@ -0,0 +1,170 @@
+/*
+ * linux/drivers/leds/arm_event.c
+ *
+ *   Copyright (C) 2004 John Lenz <lenz@cs.wisc.edu>
+ *
+ * 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.
+ *
+ * This provides legacy support for the leds_event interface used by the arm port.
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/leds.h>
+
+#include <asm/leds.h>
+
+struct arm_event_led {
+	led_event_t on;
+	led_event_t off;
+	int registered;
+	struct led_properties props;
+};
+
+static void arm_event_light(struct device *dev, struct leds_properties *props)
+{
+	struct arm_event_led *led = container_of(props, struct arm_event_led, props);
+
+	if (props->light_state) {
+		leds_event(led->on);
+	} else {
+		leds_event(led->off);
+	}
+}
+
+static int arm_event_probe(struct device *dev)
+{
+	int i, ret;
+
+	leds_event(led_start);
+
+	/* register the leds */
+	for (i = 0; i < ARRAY_SIZE(arm_event_leds_list); i++) {
+		ret = leds_register(&arm_event_device, &arm_event_leds_list[i].props);
+		if (ret) {
+			printk(KERN_WARNING "Unable to register legacy arm led\n");
+			arm_event_leds_list[i].registered = 0;
+		} else {
+			arm_event_leds_list[i].registered = 1;
+		}
+	}
+
+	return 0;
+}
+
+static int arm_event_remove(struct device *dev)
+{
+	leds_event(led_halted);
+
+	for (i = 0; i < ARRAY_SIZE(arm_event_leds_list); i++) {
+		if (arm_event_leds_list[i].registered) {
+			leds_unreigster(&arm_event_leds_list[i].props);
+		}
+	}
+
+	return 0;
+}
+
+static int arm_event_suspend(struct device *dev, u32 state)
+{
+	leds_event(led_stop);
+	return 0;
+}
+
+static int arm_event_resume(struct device *dev)
+{
+	leds_event(led_start);
+	return 0;
+}
+
+static struct arm_event_led arm_event_leds_list[] = {
+	{
+		.on		= led_green_on,
+		.off		= led_green_off,
+		.registered	= 0,
+		.props = {
+			.owner		= THIS_MODULE,
+			.color		= "green",
+			.light_state	= 0,
+			.function	= leds_user,
+			.light		= arm_event_light,
+		},
+	},
+	{
+		.on		= led_amber_on,
+		.off		= led_amber_off,
+		.registered	= 0,
+		.props = {
+			.owner		= THIS_MODULE,
+			.color		= "amber",
+			.light_state	= 0,
+			.function	= leds_user,
+			.light		= arm_event_light,
+		},
+	},
+	{
+		.on		= led_red_on,
+		.off		= led_red_off,
+		.registered	= 0,
+		.props = {
+			.owner		= THIS_MODULE,
+			.color		= "red",
+			.light_state	= 0,
+			.function	= leds_user,
+			.light		= arm_event_light,
+		},
+	},
+	{
+		.on		= led_blue_on,
+		.off		= led_blue_off,
+		.registered	= 0,
+		.props = {
+			.owner		= THIS_MODULE,
+			.color		= "blue",
+			.light_state	= 0,
+			.function	= leds_user,
+			.light		= arm_event_light,
+		},
+	},
+};
+
+static struct platform_device arm_event_device = {
+	.name		= "leds-arm-legacy",
+	.id		= 0,
+	.num_resources	= 0,
+	.resource	= NULL,
+};
+
+static struct device_driver arm_event_driver = {
+	.name		= "leds-arm-legacy",
+	.bus		= &platform_bus_type,
+	.probe		= arm_event_probe,
+	.remove		= arm_event_remove,
+	.suspend	= arm_event_suspend,
+	.resume		= arm_event_resume,
+};
+
+static int __init arm_event_init(void)
+{
+	/* register the platform device and driver */
+	platform_device_register(&arm_event_device);
+	driver_register(&arm_event_driver);
+
+	return 0;
+}
+module_init(arm_event_init);
+
+static void __exit arm_event_exit(void)
+{
+	platform_device_unregister(&arm_event_device);
+	driver_unregister(&arm_event_driver);
+}
+module_exit(arm_event_exit);
+
+MODULE_AUTHOR("John Lenz <lenz@cs.wisc.edu>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Legacy leds_event interface for arm");
--- linux/drivers/leds/Kconfig~leds_arm
+++ linux/drivers/leds/Kconfig
@@ -15,4 +15,11 @@
 	  This option enables support for the LEDs on Sharp Locomo.
 
 
+config LEDS_ARM
+	bool "Legacy ARM support"
+	depends on CLASS_LEDS
+	help
+	  This option enables support for the old leds_event interface used by
+	  the arm port.  This driver can not be compiled as a module.
+
 endmenu
--- linux/drivers/leds/Makefile~leds_arm
+++ linux/drivers/leds/Makefile
@@ -4,3 +4,4 @@
 
 # drivers
 obj-$(CONFIG_LEDS_LOCOMO)		+= locomo.o
+obj-$(CONFIG_LEDS_ARM)			+= arm_event.o
--- linux/arch/arm/Kconfig~leds_arm
+++ linux/arch/arm/Kconfig
@@ -662,6 +662,8 @@
 
 source "drivers/media/Kconfig"
 
+source "drivers/leds/Kconfig"
+
 source "fs/Kconfig"
 
 source "arch/arm/oprofile/Kconfig"

