diff options
author | Vasanthakumar Thiagarajan <vasanth@atheros.com> | 2009-01-29 07:22:19 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-02-09 15:03:40 -0500 |
commit | f2bffa7ea012befc2230331f97bf9b002c0b62bb (patch) | |
tree | 5f29b3ef4a32ee974ee9aa0ce70f77697d910b53 /drivers/net/wireless/ath9k/main.c | |
parent | c0415b547d37e8065ad4adf289d11db2f3b16dfd (diff) |
ath9k: Fix LED blink pattern
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/main.c')
-rw-r--r-- | drivers/net/wireless/ath9k/main.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c index 91f7a7b69a30..e98f2d79af68 100644 --- a/drivers/net/wireless/ath9k/main.c +++ b/drivers/net/wireless/ath9k/main.c | |||
@@ -935,6 +935,32 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc, | |||
935 | /* LED functions */ | 935 | /* LED functions */ |
936 | /********************************/ | 936 | /********************************/ |
937 | 937 | ||
938 | static void ath_led_blink_work(struct work_struct *work) | ||
939 | { | ||
940 | struct ath_softc *sc = container_of(work, struct ath_softc, | ||
941 | ath_led_blink_work.work); | ||
942 | |||
943 | if (!(sc->sc_flags & SC_OP_LED_ASSOCIATED)) | ||
944 | return; | ||
945 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, | ||
946 | (sc->sc_flags & SC_OP_LED_ON) ? 1 : 0); | ||
947 | |||
948 | queue_delayed_work(sc->hw->workqueue, &sc->ath_led_blink_work, | ||
949 | (sc->sc_flags & SC_OP_LED_ON) ? | ||
950 | msecs_to_jiffies(sc->led_off_duration) : | ||
951 | msecs_to_jiffies(sc->led_on_duration)); | ||
952 | |||
953 | sc->led_on_duration = | ||
954 | max((ATH_LED_ON_DURATION_IDLE - sc->led_on_cnt), 25); | ||
955 | sc->led_off_duration = | ||
956 | max((ATH_LED_OFF_DURATION_IDLE - sc->led_off_cnt), 10); | ||
957 | sc->led_on_cnt = sc->led_off_cnt = 0; | ||
958 | if (sc->sc_flags & SC_OP_LED_ON) | ||
959 | sc->sc_flags &= ~SC_OP_LED_ON; | ||
960 | else | ||
961 | sc->sc_flags |= SC_OP_LED_ON; | ||
962 | } | ||
963 | |||
938 | static void ath_led_brightness(struct led_classdev *led_cdev, | 964 | static void ath_led_brightness(struct led_classdev *led_cdev, |
939 | enum led_brightness brightness) | 965 | enum led_brightness brightness) |
940 | { | 966 | { |
@@ -944,16 +970,27 @@ static void ath_led_brightness(struct led_classdev *led_cdev, | |||
944 | switch (brightness) { | 970 | switch (brightness) { |
945 | case LED_OFF: | 971 | case LED_OFF: |
946 | if (led->led_type == ATH_LED_ASSOC || | 972 | if (led->led_type == ATH_LED_ASSOC || |
947 | led->led_type == ATH_LED_RADIO) | 973 | led->led_type == ATH_LED_RADIO) { |
974 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, | ||
975 | (led->led_type == ATH_LED_RADIO)); | ||
948 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; | 976 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; |
949 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, | 977 | if (led->led_type == ATH_LED_RADIO) |
950 | (led->led_type == ATH_LED_RADIO) ? 1 : | 978 | sc->sc_flags &= ~SC_OP_LED_ON; |
951 | !!(sc->sc_flags & SC_OP_LED_ASSOCIATED)); | 979 | } else { |
980 | sc->led_off_cnt++; | ||
981 | } | ||
952 | break; | 982 | break; |
953 | case LED_FULL: | 983 | case LED_FULL: |
954 | if (led->led_type == ATH_LED_ASSOC) | 984 | if (led->led_type == ATH_LED_ASSOC) { |
955 | sc->sc_flags |= SC_OP_LED_ASSOCIATED; | 985 | sc->sc_flags |= SC_OP_LED_ASSOCIATED; |
956 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0); | 986 | queue_delayed_work(sc->hw->workqueue, |
987 | &sc->ath_led_blink_work, 0); | ||
988 | } else if (led->led_type == ATH_LED_RADIO) { | ||
989 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 0); | ||
990 | sc->sc_flags |= SC_OP_LED_ON; | ||
991 | } else { | ||
992 | sc->led_on_cnt++; | ||
993 | } | ||
957 | break; | 994 | break; |
958 | default: | 995 | default: |
959 | break; | 996 | break; |
@@ -989,6 +1026,7 @@ static void ath_unregister_led(struct ath_led *led) | |||
989 | 1026 | ||
990 | static void ath_deinit_leds(struct ath_softc *sc) | 1027 | static void ath_deinit_leds(struct ath_softc *sc) |
991 | { | 1028 | { |
1029 | cancel_delayed_work_sync(&sc->ath_led_blink_work); | ||
992 | ath_unregister_led(&sc->assoc_led); | 1030 | ath_unregister_led(&sc->assoc_led); |
993 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; | 1031 | sc->sc_flags &= ~SC_OP_LED_ASSOCIATED; |
994 | ath_unregister_led(&sc->tx_led); | 1032 | ath_unregister_led(&sc->tx_led); |
@@ -1008,6 +1046,8 @@ static void ath_init_leds(struct ath_softc *sc) | |||
1008 | /* LED off, active low */ | 1046 | /* LED off, active low */ |
1009 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); | 1047 | ath9k_hw_set_gpio(sc->sc_ah, ATH_LED_PIN, 1); |
1010 | 1048 | ||
1049 | INIT_DELAYED_WORK(&sc->ath_led_blink_work, ath_led_blink_work); | ||
1050 | |||
1011 | trigger = ieee80211_get_radio_led_name(sc->hw); | 1051 | trigger = ieee80211_get_radio_led_name(sc->hw); |
1012 | snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), | 1052 | snprintf(sc->radio_led.name, sizeof(sc->radio_led.name), |
1013 | "ath9k-%s:radio", wiphy_name(sc->hw->wiphy)); | 1053 | "ath9k-%s:radio", wiphy_name(sc->hw->wiphy)); |