svn commit: r228888 - head/sys/dev/ath
Adrian Chadd
adrian at FreeBSD.org
Mon Dec 26 05:46:23 UTC 2011
Author: adrian
Date: Mon Dec 26 05:46:22 2011
New Revision: 228888
URL: http://svn.freebsd.org/changeset/base/228888
Log:
Refactor out the software LED config code into a common function, called
ath_led_config().
The eventual aim is to have both software and hardware based LED
configuration done here.
Modified:
head/sys/dev/ath/if_ath.c
head/sys/dev/ath/if_ath_led.c
head/sys/dev/ath/if_ath_led.h
head/sys/dev/ath/if_ath_sysctl.c
Modified: head/sys/dev/ath/if_ath.c
==============================================================================
--- head/sys/dev/ath/if_ath.c Mon Dec 26 05:37:09 2011 (r228887)
+++ head/sys/dev/ath/if_ath.c Mon Dec 26 05:46:22 2011 (r228888)
@@ -490,11 +490,7 @@ ath_attach(u_int16_t devid, struct ath_s
* support with a sysctl.
*/
sc->sc_softled = (devid == AR5212_DEVID_IBM || devid == AR5211_DEVID);
- if (sc->sc_softled) {
- ath_hal_gpioCfgOutput(ah, sc->sc_ledpin,
- HAL_GPIO_MUX_MAC_NETWORK_LED);
- ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon);
- }
+ ath_led_config(sc);
ifp->if_softc = sc;
ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST;
@@ -1332,11 +1328,7 @@ ath_resume(struct ath_softc *sc)
} else
ieee80211_resume_all(ic);
}
- if (sc->sc_softled) {
- ath_hal_gpioCfgOutput(ah, sc->sc_ledpin,
- HAL_GPIO_MUX_MAC_NETWORK_LED);
- ath_hal_gpioset(ah, sc->sc_ledpin, !sc->sc_ledon);
- }
+ ath_led_config(sc);
/* XXX beacons ? */
}
Modified: head/sys/dev/ath/if_ath_led.c
==============================================================================
--- head/sys/dev/ath/if_ath_led.c Mon Dec 26 05:37:09 2011 (r228887)
+++ head/sys/dev/ath/if_ath_led.c Mon Dec 26 05:46:22 2011 (r228888)
@@ -110,6 +110,26 @@ __FBSDID("$FreeBSD$");
* XXX TODO: move the LED sysctls here.
*/
+
+/*
+ * Configure the hardware for software and/or LED blinking.
+ *
+ * This requires the configuration to be set beforehand.
+ */
+void
+ath_led_config(struct ath_softc *sc)
+{
+ /* Software LED blinking - GPIO controlled LED */
+ if (sc->sc_softled) {
+ ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
+ HAL_GPIO_MUX_MAC_NETWORK_LED);
+ ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin, !sc->sc_ledon);
+ return;
+ }
+
+ /* Hardware LED blinking - MAC controlled LED */
+}
+
static void
ath_led_done(void *arg)
{
Modified: head/sys/dev/ath/if_ath_led.h
==============================================================================
--- head/sys/dev/ath/if_ath_led.h Mon Dec 26 05:37:09 2011 (r228887)
+++ head/sys/dev/ath/if_ath_led.h Mon Dec 26 05:46:22 2011 (r228888)
@@ -32,5 +32,6 @@
#define __IF_ATH_LED_H__
extern void ath_led_event(struct ath_softc *sc, int rix);
+extern void ath_led_config(struct ath_softc *sc);
#endif
Modified: head/sys/dev/ath/if_ath_sysctl.c
==============================================================================
--- head/sys/dev/ath/if_ath_sysctl.c Mon Dec 26 05:37:09 2011 (r228887)
+++ head/sys/dev/ath/if_ath_sysctl.c Mon Dec 26 05:46:22 2011 (r228888)
@@ -90,6 +90,7 @@ __FBSDID("$FreeBSD$");
#include <dev/ath/ath_hal/ah_diagcodes.h>
#include <dev/ath/if_ath_debug.h>
+#include <dev/ath/if_ath_led.h>
#include <dev/ath/if_ath_misc.h>
#include <dev/ath/if_ath_tx.h>
#include <dev/ath/if_ath_sysctl.h>
@@ -151,10 +152,7 @@ ath_sysctl_softled(SYSCTL_HANDLER_ARGS)
if (softled != sc->sc_softled) {
if (softled) {
/* NB: handle any sc_ledpin change */
- ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
- HAL_GPIO_MUX_MAC_NETWORK_LED);
- ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
- !sc->sc_ledon);
+ ath_led_config(sc);
}
sc->sc_softled = softled;
}
@@ -174,10 +172,7 @@ ath_sysctl_ledpin(SYSCTL_HANDLER_ARGS)
if (ledpin != sc->sc_ledpin) {
sc->sc_ledpin = ledpin;
if (sc->sc_softled) {
- ath_hal_gpioCfgOutput(sc->sc_ah, sc->sc_ledpin,
- HAL_GPIO_MUX_MAC_NETWORK_LED);
- ath_hal_gpioset(sc->sc_ah, sc->sc_ledpin,
- !sc->sc_ledon);
+ ath_led_config(sc);
}
}
return 0;
More information about the svn-src-head
mailing list