diff options
author | Felix Fietkau <nbd@openwrt.org> | 2006-12-30 18:47:07 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2006-12-30 18:47:07 +0000 |
commit | c8fea8d38011ede78e3f86d774886e32272973bb (patch) | |
tree | fa3a1e6de2794a8fd5c5cc443bb87311a3a006d8 /package/d80211/src/ieee80211_led.c | |
parent | f9d5bdd6f35c1d796123f085077aba94bab70fa2 (diff) | |
download | mtk-20170518-c8fea8d38011ede78e3f86d774886e32272973bb.zip mtk-20170518-c8fea8d38011ede78e3f86d774886e32272973bb.tar.gz mtk-20170518-c8fea8d38011ede78e3f86d774886e32272973bb.tar.bz2 |
add d80211 from a recent wireless-dev checkout
SVN-Revision: 5939
Diffstat (limited to 'package/d80211/src/ieee80211_led.c')
-rw-r--r-- | package/d80211/src/ieee80211_led.c | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/package/d80211/src/ieee80211_led.c b/package/d80211/src/ieee80211_led.c new file mode 100644 index 0000000..34c5de4 --- /dev/null +++ b/package/d80211/src/ieee80211_led.c @@ -0,0 +1,91 @@ +/* + * Copyright 2006, Johannes Berg <johannes@sipsolutions.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* just for IFNAMSIZ */ +#include <linux/if.h> +#include "ieee80211_led.h" + +void ieee80211_led_rx(struct ieee80211_local *local) +{ + if (unlikely(!local->rx_led)) + return; + if (local->rx_led_counter++ % 2 == 0) + led_trigger_event(local->rx_led, LED_OFF); + else + led_trigger_event(local->rx_led, LED_FULL); +} + +/* q is 1 if a packet was enqueued, 0 if it has been transmitted */ +void ieee80211_led_tx(struct ieee80211_local *local, int q) +{ + if (unlikely(!local->tx_led)) + return; + /* not sure how this is supposed to work ... */ + local->tx_led_counter += 2*q-1; + if (local->tx_led_counter % 2 == 0) + led_trigger_event(local->tx_led, LED_OFF); + else + led_trigger_event(local->tx_led, LED_FULL); +} + +void ieee80211_led_init(struct ieee80211_local *local) +{ + local->rx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); + if (!local->rx_led) + return; + snprintf(local->rx_led_name, sizeof(local->rx_led_name), + "wiphy%drx", local->hw.index); + local->rx_led->name = local->rx_led_name; + if (led_trigger_register(local->rx_led)) { + kfree(local->rx_led); + local->rx_led = NULL; + } + + local->tx_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL); + if (!local->tx_led) + return; + snprintf(local->tx_led_name, sizeof(local->tx_led_name), + "wiphy%dtx", local->hw.index); + local->tx_led->name = local->tx_led_name; + if (led_trigger_register(local->tx_led)) { + kfree(local->tx_led); + local->tx_led = NULL; + } +} + +void ieee80211_led_exit(struct ieee80211_local *local) +{ + if (local->tx_led) { + led_trigger_unregister(local->tx_led); + kfree(local->tx_led); + } + if (local->rx_led) { + led_trigger_unregister(local->rx_led); + kfree(local->rx_led); + } +} + +char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw) +{ + struct ieee80211_local *local = hw_to_local(hw); + + if (local->tx_led) + return local->tx_led_name; + return NULL; +} +EXPORT_SYMBOL(__ieee80211_get_tx_led_name); + +char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw) +{ + struct ieee80211_local *local = hw_to_local(hw); + + if (local->rx_led) + return local->rx_led_name; + return NULL; +} +EXPORT_SYMBOL(__ieee80211_get_rx_led_name); |