{"thread":{"id":"23715","subject":"[PATCH] [ath5k][leds] Ability to disable leds support. If leds support enabled do not force mac802.11 leds layer selection.","startedAt":"2010-04-07T18:58:29Z","lastAt":"2010-04-07T18:58:29Z","messageCount":1,"participants":["Dmytro Milinevskyy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"141032","messageId":"4be26029.13125e0a.66ce.ffffad95@mx.google.com","threadId":"23715","inReplyTo":null,"subject":"[PATCH] [ath5k][leds] Ability to disable leds support. If leds support enabled do not force mac802.11 leds layer selection.","fromName":"Dmytro Milinevskyy","fromEmail":"milinevskyy@gmail.com","sentAt":"2010-04-07T18:58:29Z","receivedAt":"2010-04-07T18:58:29Z","isPatch":true,"sender":{"key":"milinevskyy@gmail.com","avatar":null},"body":"Hello!\n\nHere is the patch to disable ath5k leds support on build stage.\nHowever if the leds support was enabled do not force selection of 802.11 leds layer.\n\n---\n drivers/net/wireless/ath/ath5k/Kconfig  |   10 +++++++---\n drivers/net/wireless/ath/ath5k/Makefile |    2 +-\n drivers/net/wireless/ath/ath5k/ath5k.h  |   11 ++++++-----\n drivers/net/wireless/ath/ath5k/attach.c |    2 ++\n drivers/net/wireless/ath/ath5k/base.c   |   18 ++++++++++++++++++\n drivers/net/wireless/ath/ath5k/base.h   |   12 ++++++++++++\n drivers/net/wireless/ath/ath5k/gpio.c   |    2 ++\n drivers/net/wireless/ath/ath5k/led.c    |    9 +++++++++\n 8 files changed, 57 insertions(+), 9 deletions(-)\n\ndiff --git a/drivers/net/wireless/ath/ath5k/Kconfig b/drivers/net/wireless/ath/ath5k/Kconfig\nindex eb83b7b..6b5677e 100644\n--- a/drivers/net/wireless/ath/ath5k/Kconfig\n+++ b/drivers/net/wireless/ath/ath5k/Kconfig\n@@ -1,9 +1,6 @@\n config ATH5K\n \ttristate \"Atheros 5xxx wireless cards support\"\n \tdepends on PCI && MAC80211\n-\tselect MAC80211_LEDS\n-\tselect LEDS_CLASS\n-\tselect NEW_LEDS\n \t---help---\n \t  This module adds support for wireless adapters based on\n \t  Atheros 5xxx chipset.\n@@ -18,6 +15,13 @@ config ATH5K\n \t  If you choose to build a module, it'll be called ath5k. Say M if\n \t  unsure.\n \n+\n+config ATH5K_LEDS\n+\ttristate \"Atheros 5xxx wireless cards LEDs support\"\n+\tdepends on ATH5K\n+\t---help---\n+\t  Atheros 5xxx LED support.\n+\n config ATH5K_DEBUG\n \tbool \"Atheros 5xxx debugging\"\n \tdepends on ATH5K\ndiff --git a/drivers/net/wireless/ath/ath5k/Makefile b/drivers/net/wireless/ath/ath5k/Makefile\nindex 090dc6d..fd36145 100644\n--- a/drivers/net/wireless/ath/ath5k/Makefile\n+++ b/drivers/net/wireless/ath/ath5k/Makefile\n@@ -10,7 +10,7 @@ ath5k-y\t\t\t\t+= phy.o\n ath5k-y\t\t\t\t+= reset.o\n ath5k-y\t\t\t\t+= attach.o\n ath5k-y\t\t\t\t+= base.o\n-ath5k-y\t\t\t\t+= led.o\n ath5k-y\t\t\t\t+= rfkill.o\n ath5k-$(CONFIG_ATH5K_DEBUG)\t+= debug.o\n+ath5k-$(CONFIG_ATH5K_LEDS) += led.o\n obj-$(CONFIG_ATH5K)\t\t+= ath5k.o\ndiff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h\nindex ac67f02..8285c07 100644\n--- a/drivers/net/wireless/ath/ath5k/ath5k.h\n+++ b/drivers/net/wireless/ath/ath5k/ath5k.h\n@@ -929,6 +929,7 @@ enum ath5k_power_mode {\n \tAR5K_PM_NETWORK_SLEEP,\n };\n \n+#ifdef CONFIG_ATH5K_LEDS\n /*\n  * These match net80211 definitions (not used in\n  * mac80211).\n@@ -939,11 +940,7 @@ enum ath5k_power_mode {\n #define AR5K_LED_AUTH\t2 /*IEEE80211_S_AUTH*/\n #define AR5K_LED_ASSOC\t3 /*IEEE80211_S_ASSOC*/\n #define AR5K_LED_RUN\t4 /*IEEE80211_S_RUN*/\n-\n-/* GPIO-controlled software LED */\n-#define AR5K_SOFTLED_PIN\t0\n-#define AR5K_SOFTLED_ON\t\t0\n-#define AR5K_SOFTLED_OFF\t1\n+#endif\n \n /*\n  * Chipset capabilities -see ath5k_hw_get_capability-\n@@ -1161,11 +1158,13 @@ struct ath5k_hw {\n extern int ath5k_hw_attach(struct ath5k_softc *sc);\n extern void ath5k_hw_detach(struct ath5k_hw *ah);\n \n+#ifdef CONFIG_ATH5K_LEDS\n /* LED functions */\n extern int ath5k_init_leds(struct ath5k_softc *sc);\n extern void ath5k_led_enable(struct ath5k_softc *sc);\n extern void ath5k_led_off(struct ath5k_softc *sc);\n extern void ath5k_unregister_leds(struct ath5k_softc *sc);\n+#endif\n \n /* Reset Functions */\n extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial);\n@@ -1259,7 +1258,9 @@ extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time);\n extern int ath5k_hw_init_desc_functions(struct ath5k_hw *ah);\n \n /* GPIO Functions */\n+#ifdef CONFIG_ATH5K_LEDS\n extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);\n+#endif\n extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);\n extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);\n extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);\ndiff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c\nindex dc0786c..c27f741 100644\n--- a/drivers/net/wireless/ath/ath5k/attach.c\n+++ b/drivers/net/wireless/ath/ath5k/attach.c\n@@ -334,8 +334,10 @@ int ath5k_hw_attach(struct ath5k_softc *sc)\n \n \tath5k_hw_init_nfcal_hist(ah);\n \n+#ifdef CONFIG_ATH5K_LEDS\n \t/* turn on HW LEDs */\n \tath5k_hw_set_ledstate(ah, AR5K_LED_INIT);\n+#endif\n \n \treturn 0;\n err_free:\ndiff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c\nindex 3abbe75..db8ca05 100644\n--- a/drivers/net/wireless/ath/ath5k/base.c\n+++ b/drivers/net/wireless/ath/ath5k/base.c\n@@ -709,18 +709,22 @@ ath5k_pci_remove(struct pci_dev *pdev)\n #ifdef CONFIG_PM\n static int ath5k_pci_suspend(struct device *dev)\n {\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ieee80211_hw *hw = pci_get_drvdata(to_pci_dev(dev));\n \tstruct ath5k_softc *sc = hw->priv;\n \n \tath5k_led_off(sc);\n+#endif\n \treturn 0;\n }\n \n static int ath5k_pci_resume(struct device *dev)\n {\n \tstruct pci_dev *pdev = to_pci_dev(dev);\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ieee80211_hw *hw = pci_get_drvdata(pdev);\n \tstruct ath5k_softc *sc = hw->priv;\n+#endif\n \n \t/*\n \t * Suspend/Resume resets the PCI configuration space, so we have to\n@@ -729,7 +733,9 @@ static int ath5k_pci_resume(struct device *dev)\n \t */\n \tpci_write_config_byte(pdev, 0x41, 0);\n \n+#ifdef CONFIG_ATH5K_LEDS\n \tath5k_led_enable(sc);\n+#endif\n \treturn 0;\n }\n #endif /* CONFIG_PM */\n@@ -859,7 +865,9 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw)\n \tif (!ath_is_world_regd(regulatory))\n \t\tregulatory_hint(hw->wiphy, regulatory->alpha2);\n \n+#ifdef CONFIG_ATH5K_LEDS\n \tath5k_init_leds(sc);\n+#endif\n \n \treturn 0;\n err_queues:\n@@ -894,7 +902,9 @@ ath5k_detach(struct pci_dev *pdev, struct ieee80211_hw *hw)\n \tath5k_desc_free(sc, pdev);\n \tath5k_txq_release(sc);\n \tath5k_hw_release_tx_queue(sc->ah, sc->bhalq);\n+#ifdef CONFIG_ATH5K_LEDS\n \tath5k_unregister_leds(sc);\n+#endif\n \n \t/*\n \t * NB: can't reclaim these until after ieee80211_ifdetach\n@@ -2470,7 +2480,9 @@ ath5k_stop_locked(struct ath5k_softc *sc)\n \tieee80211_stop_queues(sc->hw);\n \n \tif (!test_bit(ATH_STAT_INVALID, sc->status)) {\n+#ifdef CONFIG_ATH5K_LEDS\n \t\tath5k_led_off(sc);\n+#endif\n \t\tath5k_hw_set_imr(ah, 0);\n \t\tsynchronize_irq(sc->pdev->irq);\n \t}\n@@ -3246,8 +3258,10 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw,\n \t\tsc->assoc = bss_conf->assoc;\n \t\tif (sc->opmode == NL80211_IFTYPE_STATION)\n \t\t\tset_beacon_filter(hw, sc->assoc);\n+#ifdef CONFIG_ATH5K_LEDS\n \t\tath5k_hw_set_ledstate(sc->ah, sc->assoc ?\n \t\t\tAR5K_LED_ASSOC : AR5K_LED_INIT);\n+#endif\n \t\tif (bss_conf->assoc) {\n \t\t\tATH5K_DBG(sc, ATH5K_DEBUG_ANY,\n \t\t\t\t  \"Bss Info ASSOC %d, bssid: %pM\\n\",\n@@ -3277,16 +3291,20 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw,\n \n static void ath5k_sw_scan_start(struct ieee80211_hw *hw)\n {\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ath5k_softc *sc = hw->priv;\n \tif (!sc->assoc)\n \t\tath5k_hw_set_ledstate(sc->ah, AR5K_LED_SCAN);\n+#endif\n }\n \n static void ath5k_sw_scan_complete(struct ieee80211_hw *hw)\n {\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ath5k_softc *sc = hw->priv;\n \tath5k_hw_set_ledstate(sc->ah, sc->assoc ?\n \t\tAR5K_LED_ASSOC : AR5K_LED_INIT);\n+#endif\n }\n \n /**\ndiff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h\nindex 7e1a88a..19208a7 100644\n--- a/drivers/net/wireless/ath/ath5k/base.h\n+++ b/drivers/net/wireless/ath/ath5k/base.h\n@@ -85,15 +85,21 @@ struct ath5k_txq {\n \n #define ATH5K_LED_MAX_NAME_LEN 31\n \n+#ifdef CONFIG_ATH5K_LEDS\n /*\n  * State for LED triggers\n  */\n struct ath5k_led\n {\n+#ifdef CONFIG_LEDS_CLASS\n \tchar name[ATH5K_LED_MAX_NAME_LEN + 1];\t/* name of the LED in sysfs */\n+#endif\n \tstruct ath5k_softc *sc;\t\t\t/* driver state */\n+#ifdef CONFIG_LEDS_CLASS\n \tstruct led_classdev led_dev;\t\t/* led classdev */\n+#endif\n };\n+#endif\n \n /* Rfkill */\n struct ath5k_rfkill {\n@@ -154,8 +160,10 @@ struct ath5k_softc {\n \n \tu8\t\t\tbssidmask[ETH_ALEN];\n \n+#ifdef CONFIG_ATH5K_LEDS\n \tunsigned int\t\tled_pin,\t/* GPIO pin for driving LED */\n \t\t\t\tled_on;\t\t/* pin setting for LED on */\n+#endif\n \n \tstruct tasklet_struct\trestq;\t\t/* reset tasklet */\n \n@@ -164,7 +172,9 @@ struct ath5k_softc {\n \tspinlock_t\t\trxbuflock;\n \tu32\t\t\t*rxlink;\t/* link ptr in last RX desc */\n \tstruct tasklet_struct\trxtq;\t\t/* rx intr tasklet */\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ath5k_led\trx_led;\t\t/* rx led */\n+#endif\n \n \tstruct list_head\ttxbuf;\t\t/* transmit buffer */\n \tspinlock_t\t\ttxbuflock;\n@@ -172,7 +182,9 @@ struct ath5k_softc {\n \tstruct ath5k_txq\ttxqs[AR5K_NUM_TX_QUEUES];\t/* tx queues */\n \tstruct ath5k_txq\t*txq;\t\t/* main tx queue */\n \tstruct tasklet_struct\ttxtq;\t\t/* tx intr tasklet */\n+#ifdef CONFIG_ATH5K_LEDS\n \tstruct ath5k_led\ttx_led;\t\t/* tx led */\n+#endif\n \n \tstruct ath5k_rfkill\trf_kill;\n \ndiff --git a/drivers/net/wireless/ath/ath5k/gpio.c b/drivers/net/wireless/ath/ath5k/gpio.c\nindex 64a27e7..9e757b3 100644\n--- a/drivers/net/wireless/ath/ath5k/gpio.c\n+++ b/drivers/net/wireless/ath/ath5k/gpio.c\n@@ -25,6 +25,7 @@\n #include \"debug.h\"\n #include \"base.h\"\n \n+#ifdef CONFIG_ATH5K_LEDS\n /*\n  * Set led state\n  */\n@@ -76,6 +77,7 @@ void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state)\n \telse\n \t\tAR5K_REG_ENABLE_BITS(ah, AR5K_PCICFG, led_5210);\n }\n+#endif\n \n /*\n  * Set GPIO inputs\ndiff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c\nindex 67aa52e..df8e8d2 100644\n--- a/drivers/net/wireless/ath/ath5k/led.c\n+++ b/drivers/net/wireless/ath/ath5k/led.c\n@@ -121,6 +121,7 @@ ath5k_led_brightness_set(struct led_classdev *led_dev,\n \t\tath5k_led_on(led->sc);\n }\n \n+#ifdef CONFIG_LEDS_CLASS\n static int\n ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led,\n \t\t   const char *name, char *trigger)\n@@ -140,13 +141,16 @@ ath5k_register_led(struct ath5k_softc *sc, struct ath5k_led *led,\n \t}\n \treturn err;\n }\n+#endif\n \n static void\n ath5k_unregister_led(struct ath5k_led *led)\n {\n \tif (!led->sc)\n \t\treturn;\n+#ifdef CONFIG_LEDS_CLASS\n \tled_classdev_unregister(&led->led_dev);\n+#endif\n \tath5k_led_off(led->sc);\n \tled->sc = NULL;\n }\n@@ -177,6 +181,7 @@ int ath5k_init_leds(struct ath5k_softc *sc)\n \n \tath5k_led_enable(sc);\n \n+#ifdef CONFIG_LEDS_CLASS\n \tsnprintf(name, sizeof(name), \"ath5k-%s::rx\", wiphy_name(hw->wiphy));\n \tret = ath5k_register_led(sc, &sc->rx_led, name,\n \t\tieee80211_get_rx_led_name(hw));\n@@ -186,6 +191,10 @@ int ath5k_init_leds(struct ath5k_softc *sc)\n \tsnprintf(name, sizeof(name), \"ath5k-%s::tx\", wiphy_name(hw->wiphy));\n \tret = ath5k_register_led(sc, &sc->tx_led, name,\n \t\tieee80211_get_tx_led_name(hw));\n+#else\n+    sc->rx_led.sc = sc;\n+    sc->tx_led.sc = sc;\n+#endif\n out:\n \treturn ret;\n }\n-- \n1.7.1\n"}]}