[NETFILTER]: nfnetlink: remove unnecessary packed attributes
[linux-2.6.22.y-op.git] / drivers / leds / leds-ams-delta.c
blobe9f06116c4d774085990ef2a3d14284340be3252
1 /*
2 * LEDs driver for Amstrad Delta (E3)
4 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
11 #include <linux/config.h>
12 #include <linux/kernel.h>
13 #include <linux/init.h>
14 #include <linux/platform_device.h>
15 #include <linux/leds.h>
16 #include <asm/arch/board-ams-delta.h>
19 * Our context
21 struct ams_delta_led {
22 struct led_classdev cdev;
23 u8 bitmask;
26 static void ams_delta_led_set(struct led_classdev *led_cdev,
27 enum led_brightness value)
29 struct ams_delta_led *led_dev =
30 container_of(led_cdev, struct ams_delta_led, cdev);
32 if (value)
33 ams_delta_latch1_write(led_dev->bitmask, led_dev->bitmask);
34 else
35 ams_delta_latch1_write(led_dev->bitmask, 0);
38 static struct ams_delta_led ams_delta_leds[] = {
40 .cdev = {
41 .name = "ams-delta:camera",
42 .brightness_set = ams_delta_led_set,
44 .bitmask = AMS_DELTA_LATCH1_LED_CAMERA,
47 .cdev = {
48 .name = "ams-delta:advert",
49 .brightness_set = ams_delta_led_set,
51 .bitmask = AMS_DELTA_LATCH1_LED_ADVERT,
54 .cdev = {
55 .name = "ams-delta:email",
56 .brightness_set = ams_delta_led_set,
58 .bitmask = AMS_DELTA_LATCH1_LED_EMAIL,
61 .cdev = {
62 .name = "ams-delta:handsfree",
63 .brightness_set = ams_delta_led_set,
65 .bitmask = AMS_DELTA_LATCH1_LED_HANDSFREE,
68 .cdev = {
69 .name = "ams-delta:voicemail",
70 .brightness_set = ams_delta_led_set,
72 .bitmask = AMS_DELTA_LATCH1_LED_VOICEMAIL,
75 .cdev = {
76 .name = "ams-delta:voice",
77 .brightness_set = ams_delta_led_set,
79 .bitmask = AMS_DELTA_LATCH1_LED_VOICE,
83 #ifdef CONFIG_PM
84 static int ams_delta_led_suspend(struct platform_device *dev,
85 pm_message_t state)
87 int i;
89 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
90 led_classdev_suspend(&ams_delta_leds[i].cdev);
92 return 0;
95 static int ams_delta_led_resume(struct platform_device *dev)
97 int i;
99 for (i = 0; i < ARRAY_SIZE(ams_delta_leds); i++)
100 led_classdev_resume(&ams_delta_leds[i].cdev);
102 return 0;
104 #else
105 #define ams_delta_led_suspend NULL
106 #define ams_delta_led_resume NULL
107 #endif
109 static int ams_delta_led_probe(struct platform_device *pdev)
111 int i;
112 int ret;
114 for (i = ret = 0; ret >= 0 && i < ARRAY_SIZE(ams_delta_leds); i++) {
115 ret = led_classdev_register(&pdev->dev,
116 &ams_delta_leds[i].cdev);
119 if (ret < 0 && i > 1) {
120 for (i = i - 2; i >= 0; i--)
121 led_classdev_unregister(&ams_delta_leds[i].cdev);
124 return ret;
127 static int ams_delta_led_remove(struct platform_device *pdev)
129 int i;
131 for (i = ARRAY_SIZE(ams_delta_leds) - 1; i >= 0; i--)
132 led_classdev_unregister(&ams_delta_leds[i].cdev);
134 return 0;
137 static struct platform_driver ams_delta_led_driver = {
138 .probe = ams_delta_led_probe,
139 .remove = ams_delta_led_remove,
140 .suspend = ams_delta_led_suspend,
141 .resume = ams_delta_led_resume,
142 .driver = {
143 .name = "ams-delta-led",
147 static int __init ams_delta_led_init(void)
149 return platform_driver_register(&ams_delta_led_driver);
152 static void __exit ams_delta_led_exit(void)
154 return platform_driver_unregister(&ams_delta_led_driver);
157 module_init(ams_delta_led_init);
158 module_exit(ams_delta_led_exit);
160 MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
161 MODULE_DESCRIPTION("Amstrad Delta LED driver");
162 MODULE_LICENSE("GPL");