Document usage of multiple-instances of devpts
[linux-2.6/mini2440.git] / drivers / leds / leds-cobalt-qube.c
blob059aa2924b1cb21ba9fa36c7c3f4b441989e18b1
1 /*
2 * Copyright 2006 - Florian Fainelli <florian@openwrt.org>
4 * Control the Cobalt Qube/RaQ front LED
5 */
6 #include <linux/init.h>
7 #include <linux/io.h>
8 #include <linux/ioport.h>
9 #include <linux/leds.h>
10 #include <linux/module.h>
11 #include <linux/platform_device.h>
12 #include <linux/types.h>
14 #define LED_FRONT_LEFT 0x01
15 #define LED_FRONT_RIGHT 0x02
17 static void __iomem *led_port;
18 static u8 led_value;
20 static void qube_front_led_set(struct led_classdev *led_cdev,
21 enum led_brightness brightness)
23 if (brightness)
24 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
25 else
26 led_value = ~(LED_FRONT_LEFT | LED_FRONT_RIGHT);
27 writeb(led_value, led_port);
30 static struct led_classdev qube_front_led = {
31 .name = "qube-front",
32 .brightness = LED_FULL,
33 .brightness_set = qube_front_led_set,
34 .default_trigger = "ide-disk",
37 static int __devinit cobalt_qube_led_probe(struct platform_device *pdev)
39 struct resource *res;
40 int retval;
42 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
43 if (!res)
44 return -EBUSY;
46 led_port = ioremap(res->start, res->end - res->start + 1);
47 if (!led_port)
48 return -ENOMEM;
50 led_value = LED_FRONT_LEFT | LED_FRONT_RIGHT;
51 writeb(led_value, led_port);
53 retval = led_classdev_register(&pdev->dev, &qube_front_led);
54 if (retval)
55 goto err_iounmap;
57 return 0;
59 err_iounmap:
60 iounmap(led_port);
61 led_port = NULL;
63 return retval;
66 static int __devexit cobalt_qube_led_remove(struct platform_device *pdev)
68 led_classdev_unregister(&qube_front_led);
70 if (led_port) {
71 iounmap(led_port);
72 led_port = NULL;
75 return 0;
78 /* work with hotplug and coldplug */
79 MODULE_ALIAS("platform:cobalt-qube-leds");
81 static struct platform_driver cobalt_qube_led_driver = {
82 .probe = cobalt_qube_led_probe,
83 .remove = __devexit_p(cobalt_qube_led_remove),
84 .driver = {
85 .name = "cobalt-qube-leds",
86 .owner = THIS_MODULE,
90 static int __init cobalt_qube_led_init(void)
92 return platform_driver_register(&cobalt_qube_led_driver);
95 static void __exit cobalt_qube_led_exit(void)
97 platform_driver_unregister(&cobalt_qube_led_driver);
100 module_init(cobalt_qube_led_init);
101 module_exit(cobalt_qube_led_exit);
103 MODULE_LICENSE("GPL");
104 MODULE_DESCRIPTION("Front LED support for Cobalt Server");
105 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");