Lines Matching +full:led +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 LED control
7 Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
9 Copyright (c) 2005-2007 Michael Buesch <m@bues.ch>
48 struct b43_led *led) in b43_led_update() argument
53 if (!led->wl) in b43_led_update()
56 radio_enabled = (dev->phy.radio_on && dev->radio_hw_enable); in b43_led_update()
58 /* The led->state read is racy, but we don't care. In case we raced in b43_led_update()
62 turn_on = atomic_read(&led->state) != LED_OFF; in b43_led_update()
65 if (turn_on == led->hw_state) in b43_led_update()
67 led->hw_state = turn_on; in b43_led_update()
70 b43_led_turn_on(dev, led->index, led->activelow); in b43_led_update()
72 b43_led_turn_off(dev, led->index, led->activelow); in b43_led_update()
81 mutex_lock(&wl->mutex); in b43_leds_work()
82 dev = wl->current_dev; in b43_leds_work()
86 b43_led_update(dev, &wl->leds.led_tx); in b43_leds_work()
87 b43_led_update(dev, &wl->leds.led_rx); in b43_leds_work()
88 b43_led_update(dev, &wl->leds.led_radio); in b43_leds_work()
89 b43_led_update(dev, &wl->leds.led_assoc); in b43_leds_work()
92 mutex_unlock(&wl->mutex); in b43_leds_work()
95 /* Callback from the LED subsystem. */
99 struct b43_led *led = container_of(led_dev, struct b43_led, led_dev); in b43_led_brightness_set() local
100 struct b43_wl *wl = led->wl; in b43_led_brightness_set()
102 if (likely(!wl->leds.stop)) { in b43_led_brightness_set()
103 atomic_set(&led->state, brightness); in b43_led_brightness_set()
104 ieee80211_queue_work(wl->hw, &wl->leds.work); in b43_led_brightness_set()
108 static int b43_register_led(struct b43_wldev *dev, struct b43_led *led, in b43_register_led() argument
114 if (led->wl) in b43_register_led()
115 return -EEXIST; in b43_register_led()
117 return -EINVAL; in b43_register_led()
118 led->wl = dev->wl; in b43_register_led()
119 led->index = led_index; in b43_register_led()
120 led->activelow = activelow; in b43_register_led()
121 strlcpy(led->name, name, sizeof(led->name)); in b43_register_led()
122 atomic_set(&led->state, 0); in b43_register_led()
124 led->led_dev.name = led->name; in b43_register_led()
125 led->led_dev.default_trigger = default_trigger; in b43_register_led()
126 led->led_dev.brightness_set = b43_led_brightness_set; in b43_register_led()
128 err = led_classdev_register(dev->dev->dev, &led->led_dev); in b43_register_led()
130 b43warn(dev->wl, "LEDs: Failed to register %s\n", name); in b43_register_led()
131 led->wl = NULL; in b43_register_led()
138 static void b43_unregister_led(struct b43_led *led) in b43_unregister_led() argument
140 if (!led->wl) in b43_unregister_led()
142 led_classdev_unregister(&led->led_dev); in b43_unregister_led()
143 led->wl = NULL; in b43_unregister_led()
151 struct ieee80211_hw *hw = dev->wl->hw; in b43_map_led()
154 /* Map the b43 specific LED behaviour value to the in b43_map_led()
155 * generic LED triggers. */ in b43_map_led()
165 "b43-%s::tx", wiphy_name(hw->wiphy)); in b43_map_led()
166 b43_register_led(dev, &dev->wl->leds.led_tx, name, in b43_map_led()
170 "b43-%s::rx", wiphy_name(hw->wiphy)); in b43_map_led()
171 b43_register_led(dev, &dev->wl->leds.led_rx, name, in b43_map_led()
180 "b43-%s::radio", wiphy_name(hw->wiphy)); in b43_map_led()
181 b43_register_led(dev, &dev->wl->leds.led_radio, name, in b43_map_led()
188 "b43-%s::assoc", wiphy_name(hw->wiphy)); in b43_map_led()
189 b43_register_led(dev, &dev->wl->leds.led_assoc, name, in b43_map_led()
194 b43warn(dev->wl, "LEDs: Unknown behaviour 0x%02X\n", in b43_map_led()
207 sprom[0] = dev->dev->bus_sprom->gpio0; in b43_led_get_sprominfo()
208 sprom[1] = dev->dev->bus_sprom->gpio1; in b43_led_get_sprominfo()
209 sprom[2] = dev->dev->bus_sprom->gpio2; in b43_led_get_sprominfo()
210 sprom[3] = dev->dev->bus_sprom->gpio3; in b43_led_get_sprominfo()
213 /* There is no LED information in the SPROM in b43_led_get_sprominfo()
214 * for this LED. Hardcode it here. */ in b43_led_get_sprominfo()
220 if (dev->dev->board_vendor == PCI_VENDOR_ID_COMPAQ) in b43_led_get_sprominfo()
225 if (dev->dev->board_vendor == PCI_VENDOR_ID_ASUSTEK) in b43_led_get_sprominfo()
240 /* keep LED disabled if no mapping is defined */ in b43_led_get_sprominfo()
251 struct b43_led *led; in b43_leds_init() local
256 /* Sync the RF-kill LED state (if we have one) with radio and switch states. */ in b43_leds_init()
257 led = &dev->wl->leds.led_radio; in b43_leds_init()
258 if (led->wl) { in b43_leds_init()
259 if (dev->phy.radio_on && b43_is_hw_radio_enabled(dev)) { in b43_leds_init()
260 b43_led_turn_on(dev, led->index, led->activelow); in b43_leds_init()
261 led->hw_state = true; in b43_leds_init()
262 atomic_set(&led->state, 1); in b43_leds_init()
264 b43_led_turn_off(dev, led->index, led->activelow); in b43_leds_init()
265 led->hw_state = false; in b43_leds_init()
266 atomic_set(&led->state, 0); in b43_leds_init()
271 led = &dev->wl->leds.led_tx; in b43_leds_init()
272 if (led->wl) { in b43_leds_init()
273 b43_led_turn_off(dev, led->index, led->activelow); in b43_leds_init()
274 led->hw_state = false; in b43_leds_init()
275 atomic_set(&led->state, 0); in b43_leds_init()
277 led = &dev->wl->leds.led_rx; in b43_leds_init()
278 if (led->wl) { in b43_leds_init()
279 b43_led_turn_off(dev, led->index, led->activelow); in b43_leds_init()
280 led->hw_state = false; in b43_leds_init()
281 atomic_set(&led->state, 0); in b43_leds_init()
283 led = &dev->wl->leds.led_assoc; in b43_leds_init()
284 if (led->wl) { in b43_leds_init()
285 b43_led_turn_off(dev, led->index, led->activelow); in b43_leds_init()
286 led->hw_state = false; in b43_leds_init()
287 atomic_set(&led->state, 0); in b43_leds_init()
290 /* Initialize other LED states. */ in b43_leds_init()
301 /* Leave others as-is. */ in b43_leds_init()
306 dev->wl->leds.stop = 0; in b43_leds_init()
311 struct b43_leds *leds = &dev->wl->leds; in b43_leds_exit()
313 b43_led_turn_off(dev, leds->led_tx.index, leds->led_tx.activelow); in b43_leds_exit()
314 b43_led_turn_off(dev, leds->led_rx.index, leds->led_rx.activelow); in b43_leds_exit()
315 b43_led_turn_off(dev, leds->led_assoc.index, leds->led_assoc.activelow); in b43_leds_exit()
316 b43_led_turn_off(dev, leds->led_radio.index, leds->led_radio.activelow); in b43_leds_exit()
321 struct b43_leds *leds = &dev->wl->leds; in b43_leds_stop()
323 leds->stop = 1; in b43_leds_stop()
324 cancel_work_sync(&leds->work); in b43_leds_stop()
333 INIT_WORK(&dev->wl->leds.work, b43_leds_work); in b43_leds_register()
335 /* Register the LEDs to the LED subsystem. */ in b43_leds_register()
344 struct b43_leds *leds = &wl->leds; in b43_leds_unregister()
346 b43_unregister_led(&leds->led_tx); in b43_leds_unregister()
347 b43_unregister_led(&leds->led_rx); in b43_leds_unregister()
348 b43_unregister_led(&leds->led_assoc); in b43_leds_unregister()
349 b43_unregister_led(&leds->led_radio); in b43_leds_unregister()