diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2x00leds.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2x00leds.c | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2x00leds.c b/drivers/net/wireless/rt2x00/rt2x00leds.c index b362a1cf3f8d..68f4e0fc35b9 100644 --- a/drivers/net/wireless/rt2x00/rt2x00leds.c +++ b/drivers/net/wireless/rt2x00/rt2x00leds.c | |||
@@ -72,49 +72,33 @@ void rt2x00leds_led_quality(struct rt2x00_dev *rt2x00dev, int rssi) | |||
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
75 | void rt2x00led_led_activity(struct rt2x00_dev *rt2x00dev, bool enabled) | 75 | static void rt2x00led_led_simple(struct rt2x00_led *led, bool enabled) |
76 | { | 76 | { |
77 | struct rt2x00_led *led = &rt2x00dev->led_qual; | 77 | unsigned int brightness = enabled ? LED_FULL : LED_OFF; |
78 | unsigned int brightness; | ||
79 | 78 | ||
80 | if ((led->type != LED_TYPE_ACTIVITY) || !(led->flags & LED_REGISTERED)) | 79 | if (!(led->flags & LED_REGISTERED)) |
81 | return; | 80 | return; |
82 | 81 | ||
83 | brightness = enabled ? LED_FULL : LED_OFF; | 82 | led->led_dev.brightness_set(&led->led_dev, brightness); |
84 | if (brightness != led->led_dev.brightness) { | 83 | led->led_dev.brightness = brightness; |
85 | led->led_dev.brightness_set(&led->led_dev, brightness); | ||
86 | led->led_dev.brightness = brightness; | ||
87 | } | ||
88 | } | 84 | } |
89 | 85 | ||
90 | void rt2x00leds_led_assoc(struct rt2x00_dev *rt2x00dev, bool enabled) | 86 | void rt2x00led_led_activity(struct rt2x00_dev *rt2x00dev, bool enabled) |
91 | { | 87 | { |
92 | struct rt2x00_led *led = &rt2x00dev->led_assoc; | 88 | if (rt2x00dev->led_qual.type == LED_TYPE_ACTIVITY) |
93 | unsigned int brightness; | 89 | rt2x00led_led_simple(&rt2x00dev->led_qual, enabled); |
94 | 90 | } | |
95 | if ((led->type != LED_TYPE_ASSOC) || !(led->flags & LED_REGISTERED)) | ||
96 | return; | ||
97 | 91 | ||
98 | brightness = enabled ? LED_FULL : LED_OFF; | 92 | void rt2x00leds_led_assoc(struct rt2x00_dev *rt2x00dev, bool enabled) |
99 | if (brightness != led->led_dev.brightness) { | 93 | { |
100 | led->led_dev.brightness_set(&led->led_dev, brightness); | 94 | if (rt2x00dev->led_assoc.type == LED_TYPE_ASSOC) |
101 | led->led_dev.brightness = brightness; | 95 | rt2x00led_led_simple(&rt2x00dev->led_assoc, enabled); |
102 | } | ||
103 | } | 96 | } |
104 | 97 | ||
105 | void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled) | 98 | void rt2x00leds_led_radio(struct rt2x00_dev *rt2x00dev, bool enabled) |
106 | { | 99 | { |
107 | struct rt2x00_led *led = &rt2x00dev->led_radio; | 100 | if (rt2x00dev->led_radio.type == LED_TYPE_ASSOC) |
108 | unsigned int brightness; | 101 | rt2x00led_led_simple(&rt2x00dev->led_radio, enabled); |
109 | |||
110 | if ((led->type != LED_TYPE_RADIO) || !(led->flags & LED_REGISTERED)) | ||
111 | return; | ||
112 | |||
113 | brightness = enabled ? LED_FULL : LED_OFF; | ||
114 | if (brightness != led->led_dev.brightness) { | ||
115 | led->led_dev.brightness_set(&led->led_dev, brightness); | ||
116 | led->led_dev.brightness = brightness; | ||
117 | } | ||
118 | } | 102 | } |
119 | 103 | ||
120 | static int rt2x00leds_register_led(struct rt2x00_dev *rt2x00dev, | 104 | static int rt2x00leds_register_led(struct rt2x00_dev *rt2x00dev, |
@@ -125,6 +109,7 @@ static int rt2x00leds_register_led(struct rt2x00_dev *rt2x00dev, | |||
125 | int retval; | 109 | int retval; |
126 | 110 | ||
127 | led->led_dev.name = name; | 111 | led->led_dev.name = name; |
112 | led->led_dev.brightness = LED_OFF; | ||
128 | 113 | ||
129 | retval = led_classdev_register(device, &led->led_dev); | 114 | retval = led_classdev_register(device, &led->led_dev); |
130 | if (retval) { | 115 | if (retval) { |
@@ -199,7 +184,16 @@ exit_fail: | |||
199 | static void rt2x00leds_unregister_led(struct rt2x00_led *led) | 184 | static void rt2x00leds_unregister_led(struct rt2x00_led *led) |
200 | { | 185 | { |
201 | led_classdev_unregister(&led->led_dev); | 186 | led_classdev_unregister(&led->led_dev); |
202 | led->led_dev.brightness_set(&led->led_dev, LED_OFF); | 187 | |
188 | /* | ||
189 | * This might look weird, but when we are unregistering while | ||
190 | * suspended the led is already off, and since we haven't | ||
191 | * fully resumed yet, access to the device might not be | ||
192 | * possible yet. | ||
193 | */ | ||
194 | if (!(led->led_dev.flags & LED_SUSPENDED)) | ||
195 | led->led_dev.brightness_set(&led->led_dev, LED_OFF); | ||
196 | |||
203 | led->flags &= ~LED_REGISTERED; | 197 | led->flags &= ~LED_REGISTERED; |
204 | } | 198 | } |
205 | 199 | ||
@@ -213,22 +207,40 @@ void rt2x00leds_unregister(struct rt2x00_dev *rt2x00dev) | |||
213 | rt2x00leds_unregister_led(&rt2x00dev->led_radio); | 207 | rt2x00leds_unregister_led(&rt2x00dev->led_radio); |
214 | } | 208 | } |
215 | 209 | ||
210 | static inline void rt2x00leds_suspend_led(struct rt2x00_led *led) | ||
211 | { | ||
212 | led_classdev_suspend(&led->led_dev); | ||
213 | |||
214 | /* This shouldn't be needed, but just to be safe */ | ||
215 | led->led_dev.brightness_set(&led->led_dev, LED_OFF); | ||
216 | led->led_dev.brightness = LED_OFF; | ||
217 | } | ||
218 | |||
216 | void rt2x00leds_suspend(struct rt2x00_dev *rt2x00dev) | 219 | void rt2x00leds_suspend(struct rt2x00_dev *rt2x00dev) |
217 | { | 220 | { |
218 | if (rt2x00dev->led_qual.flags & LED_REGISTERED) | 221 | if (rt2x00dev->led_qual.flags & LED_REGISTERED) |
219 | led_classdev_suspend(&rt2x00dev->led_qual.led_dev); | 222 | rt2x00leds_suspend_led(&rt2x00dev->led_qual); |
220 | if (rt2x00dev->led_assoc.flags & LED_REGISTERED) | 223 | if (rt2x00dev->led_assoc.flags & LED_REGISTERED) |
221 | led_classdev_suspend(&rt2x00dev->led_assoc.led_dev); | 224 | rt2x00leds_suspend_led(&rt2x00dev->led_assoc); |
222 | if (rt2x00dev->led_radio.flags & LED_REGISTERED) | 225 | if (rt2x00dev->led_radio.flags & LED_REGISTERED) |
223 | led_classdev_suspend(&rt2x00dev->led_radio.led_dev); | 226 | rt2x00leds_suspend_led(&rt2x00dev->led_radio); |
227 | } | ||
228 | |||
229 | static inline void rt2x00leds_resume_led(struct rt2x00_led *led) | ||
230 | { | ||
231 | led_classdev_resume(&led->led_dev); | ||
232 | |||
233 | /* Device might have enabled the LEDS during resume */ | ||
234 | led->led_dev.brightness_set(&led->led_dev, LED_OFF); | ||
235 | led->led_dev.brightness = LED_OFF; | ||
224 | } | 236 | } |
225 | 237 | ||
226 | void rt2x00leds_resume(struct rt2x00_dev *rt2x00dev) | 238 | void rt2x00leds_resume(struct rt2x00_dev *rt2x00dev) |
227 | { | 239 | { |
228 | if (rt2x00dev->led_radio.flags & LED_REGISTERED) | 240 | if (rt2x00dev->led_radio.flags & LED_REGISTERED) |
229 | led_classdev_resume(&rt2x00dev->led_radio.led_dev); | 241 | rt2x00leds_resume_led(&rt2x00dev->led_radio); |
230 | if (rt2x00dev->led_assoc.flags & LED_REGISTERED) | 242 | if (rt2x00dev->led_assoc.flags & LED_REGISTERED) |
231 | led_classdev_resume(&rt2x00dev->led_assoc.led_dev); | 243 | rt2x00leds_resume_led(&rt2x00dev->led_assoc); |
232 | if (rt2x00dev->led_qual.flags & LED_REGISTERED) | 244 | if (rt2x00dev->led_qual.flags & LED_REGISTERED) |
233 | led_classdev_resume(&rt2x00dev->led_qual.led_dev); | 245 | rt2x00leds_resume_led(&rt2x00dev->led_qual); |
234 | } | 246 | } |