ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / drivers / leds / leds-wrap.c
blob2982c86ac4cffb9e93da0a252b232a573c02ac22
1 /*
2 * LEDs driver for PCEngines WRAP
4 * Copyright (C) 2006 Kristian Kielhofner <kris@krisk.org>
6 * Based on leds-net48xx.c
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/kernel.h>
14 #include <linux/init.h>
15 #include <linux/platform_device.h>
16 #include <linux/leds.h>
17 #include <linux/err.h>
18 #include <asm/io.h>
19 #include <linux/scx200_gpio.h>
21 #define DRVNAME "wrap-led"
22 #define WRAP_POWER_LED_GPIO 2
23 #define WRAP_ERROR_LED_GPIO 3
24 #define WRAP_EXTRA_LED_GPIO 18
26 static struct platform_device *pdev;
28 static void wrap_power_led_set(struct led_classdev *led_cdev,
29 enum led_brightness value)
31 if (value)
32 scx200_gpio_set_low(WRAP_POWER_LED_GPIO);
33 else
34 scx200_gpio_set_high(WRAP_POWER_LED_GPIO);
37 static void wrap_error_led_set(struct led_classdev *led_cdev,
38 enum led_brightness value)
40 if (value)
41 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
42 else
43 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
46 static void wrap_extra_led_set(struct led_classdev *led_cdev,
47 enum led_brightness value)
49 if (value)
50 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
51 else
52 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
55 static struct led_classdev wrap_power_led = {
56 .name = "wrap::power",
57 .brightness_set = wrap_power_led_set,
58 .default_trigger = "default-on",
59 .flags = LED_CORE_SUSPENDRESUME,
62 static struct led_classdev wrap_error_led = {
63 .name = "wrap::error",
64 .brightness_set = wrap_error_led_set,
65 .flags = LED_CORE_SUSPENDRESUME,
68 static struct led_classdev wrap_extra_led = {
69 .name = "wrap::extra",
70 .brightness_set = wrap_extra_led_set,
71 .flags = LED_CORE_SUSPENDRESUME,
74 static int wrap_led_probe(struct platform_device *pdev)
76 int ret;
78 ret = led_classdev_register(&pdev->dev, &wrap_power_led);
79 if (ret < 0)
80 return ret;
82 ret = led_classdev_register(&pdev->dev, &wrap_error_led);
83 if (ret < 0)
84 goto err1;
86 ret = led_classdev_register(&pdev->dev, &wrap_extra_led);
87 if (ret < 0)
88 goto err2;
90 return ret;
92 err2:
93 led_classdev_unregister(&wrap_error_led);
94 err1:
95 led_classdev_unregister(&wrap_power_led);
97 return ret;
100 static int wrap_led_remove(struct platform_device *pdev)
102 led_classdev_unregister(&wrap_power_led);
103 led_classdev_unregister(&wrap_error_led);
104 led_classdev_unregister(&wrap_extra_led);
105 return 0;
108 static struct platform_driver wrap_led_driver = {
109 .probe = wrap_led_probe,
110 .remove = wrap_led_remove,
111 .driver = {
112 .name = DRVNAME,
113 .owner = THIS_MODULE,
117 static int __init wrap_led_init(void)
119 int ret;
121 if (!scx200_gpio_present()) {
122 ret = -ENODEV;
123 goto out;
126 ret = platform_driver_register(&wrap_led_driver);
127 if (ret < 0)
128 goto out;
130 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
131 if (IS_ERR(pdev)) {
132 ret = PTR_ERR(pdev);
133 platform_driver_unregister(&wrap_led_driver);
134 goto out;
137 out:
138 return ret;
141 static void __exit wrap_led_exit(void)
143 platform_device_unregister(pdev);
144 platform_driver_unregister(&wrap_led_driver);
147 module_init(wrap_led_init);
148 module_exit(wrap_led_exit);
150 MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
151 MODULE_DESCRIPTION("PCEngines WRAP LED driver");
152 MODULE_LICENSE("GPL");