x86/speculation: Use Indirect Branch Prediction Barrier in context switch
[linux/fpc-iii.git] / drivers / leds / leds-wrap.c
blob473fb6b97ed4f5f5ca86710f9b0afbfbaefa6ff3
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 <linux/io.h>
19 #include <linux/scx200_gpio.h>
20 #include <linux/module.h>
22 #define DRVNAME "wrap-led"
23 #define WRAP_POWER_LED_GPIO 2
24 #define WRAP_ERROR_LED_GPIO 3
25 #define WRAP_EXTRA_LED_GPIO 18
27 static struct platform_device *pdev;
29 static void wrap_power_led_set(struct led_classdev *led_cdev,
30 enum led_brightness value)
32 if (value)
33 scx200_gpio_set_low(WRAP_POWER_LED_GPIO);
34 else
35 scx200_gpio_set_high(WRAP_POWER_LED_GPIO);
38 static void wrap_error_led_set(struct led_classdev *led_cdev,
39 enum led_brightness value)
41 if (value)
42 scx200_gpio_set_low(WRAP_ERROR_LED_GPIO);
43 else
44 scx200_gpio_set_high(WRAP_ERROR_LED_GPIO);
47 static void wrap_extra_led_set(struct led_classdev *led_cdev,
48 enum led_brightness value)
50 if (value)
51 scx200_gpio_set_low(WRAP_EXTRA_LED_GPIO);
52 else
53 scx200_gpio_set_high(WRAP_EXTRA_LED_GPIO);
56 static struct led_classdev wrap_power_led = {
57 .name = "wrap::power",
58 .brightness_set = wrap_power_led_set,
59 .default_trigger = "default-on",
60 .flags = LED_CORE_SUSPENDRESUME,
63 static struct led_classdev wrap_error_led = {
64 .name = "wrap::error",
65 .brightness_set = wrap_error_led_set,
66 .flags = LED_CORE_SUSPENDRESUME,
69 static struct led_classdev wrap_extra_led = {
70 .name = "wrap::extra",
71 .brightness_set = wrap_extra_led_set,
72 .flags = LED_CORE_SUSPENDRESUME,
75 static int wrap_led_probe(struct platform_device *pdev)
77 int ret;
79 ret = devm_led_classdev_register(&pdev->dev, &wrap_power_led);
80 if (ret < 0)
81 return ret;
83 ret = devm_led_classdev_register(&pdev->dev, &wrap_error_led);
84 if (ret < 0)
85 return ret;
87 return devm_led_classdev_register(&pdev->dev, &wrap_extra_led);
90 static struct platform_driver wrap_led_driver = {
91 .probe = wrap_led_probe,
92 .driver = {
93 .name = DRVNAME,
97 static int __init wrap_led_init(void)
99 int ret;
101 if (!scx200_gpio_present()) {
102 ret = -ENODEV;
103 goto out;
106 ret = platform_driver_register(&wrap_led_driver);
107 if (ret < 0)
108 goto out;
110 pdev = platform_device_register_simple(DRVNAME, -1, NULL, 0);
111 if (IS_ERR(pdev)) {
112 ret = PTR_ERR(pdev);
113 platform_driver_unregister(&wrap_led_driver);
114 goto out;
117 out:
118 return ret;
121 static void __exit wrap_led_exit(void)
123 platform_device_unregister(pdev);
124 platform_driver_unregister(&wrap_led_driver);
127 module_init(wrap_led_init);
128 module_exit(wrap_led_exit);
130 MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
131 MODULE_DESCRIPTION("PCEngines WRAP LED driver");
132 MODULE_LICENSE("GPL");