Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mac80211: use oneshot blink API for LED triggers

Change mac80211 LED trigger code to use the generic
led_trigger_blink_oneshot() API for transmit and receive activity
indication.

This gives a better feedback to the user, as with the new API each
activity event results in a visible blink, while a constant traffic
results in a continuous blink at constant rate.

Signed-off-by: Fabio Baltieri <fabio.baltieri@gmail.com>
[fix LED disabled build error]
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

authored by

Fabio Baltieri and committed by
Johannes Berg
e47f2509 c82b5a74

+10 -17
-1
net/mac80211/ieee80211_i.h
··· 1094 1094 u32 dot11TransmittedFrameCount; 1095 1095 1096 1096 #ifdef CONFIG_MAC80211_LEDS 1097 - int tx_led_counter, rx_led_counter; 1098 1097 struct led_trigger *tx_led, *rx_led, *assoc_led, *radio_led; 1099 1098 struct tpt_led_trigger *tpt_led_trigger; 1100 1099 char tx_led_name[32], rx_led_name[32],
+7 -12
net/mac80211/led.c
··· 12 12 #include <linux/export.h> 13 13 #include "led.h" 14 14 15 + #define MAC80211_BLINK_DELAY 50 /* ms */ 16 + 15 17 void ieee80211_led_rx(struct ieee80211_local *local) 16 18 { 19 + unsigned long led_delay = MAC80211_BLINK_DELAY; 17 20 if (unlikely(!local->rx_led)) 18 21 return; 19 - if (local->rx_led_counter++ % 2 == 0) 20 - led_trigger_event(local->rx_led, LED_OFF); 21 - else 22 - led_trigger_event(local->rx_led, LED_FULL); 22 + led_trigger_blink_oneshot(local->rx_led, &led_delay, &led_delay, 0); 23 23 } 24 24 25 - /* q is 1 if a packet was enqueued, 0 if it has been transmitted */ 26 - void ieee80211_led_tx(struct ieee80211_local *local, int q) 25 + void ieee80211_led_tx(struct ieee80211_local *local) 27 26 { 27 + unsigned long led_delay = MAC80211_BLINK_DELAY; 28 28 if (unlikely(!local->tx_led)) 29 29 return; 30 - /* not sure how this is supposed to work ... */ 31 - local->tx_led_counter += 2*q-1; 32 - if (local->tx_led_counter % 2 == 0) 33 - led_trigger_event(local->tx_led, LED_OFF); 34 - else 35 - led_trigger_event(local->tx_led, LED_FULL); 30 + led_trigger_blink_oneshot(local->tx_led, &led_delay, &led_delay, 0); 36 31 } 37 32 38 33 void ieee80211_led_assoc(struct ieee80211_local *local, bool associated)
+2 -2
net/mac80211/led.h
··· 13 13 14 14 #ifdef CONFIG_MAC80211_LEDS 15 15 void ieee80211_led_rx(struct ieee80211_local *local); 16 - void ieee80211_led_tx(struct ieee80211_local *local, int q); 16 + void ieee80211_led_tx(struct ieee80211_local *local); 17 17 void ieee80211_led_assoc(struct ieee80211_local *local, 18 18 bool associated); 19 19 void ieee80211_led_radio(struct ieee80211_local *local, ··· 27 27 static inline void ieee80211_led_rx(struct ieee80211_local *local) 28 28 { 29 29 } 30 - static inline void ieee80211_led_tx(struct ieee80211_local *local, int q) 30 + static inline void ieee80211_led_tx(struct ieee80211_local *local) 31 31 { 32 32 } 33 33 static inline void ieee80211_led_assoc(struct ieee80211_local *local,
+1 -1
net/mac80211/status.c
··· 564 564 565 565 rcu_read_unlock(); 566 566 567 - ieee80211_led_tx(local, 0); 567 + ieee80211_led_tx(local); 568 568 569 569 /* SNMP counters 570 570 * Fragments are passed to low-level drivers as separate skbs, so these
-1
net/mac80211/tx.c
··· 1300 1300 txpending); 1301 1301 1302 1302 ieee80211_tpt_led_trig_tx(local, fc, led_len); 1303 - ieee80211_led_tx(local, 1); 1304 1303 1305 1304 WARN_ON_ONCE(!skb_queue_empty(skbs)); 1306 1305