Permalink
Browse files

Initial support for access point association and radio enabled LEDs i…

…n libertas.

Signed-off-by: Matt Isaacs <izzy@buglabs.net>
  • Loading branch information...
1 parent 907e7a9 commit 1195c410ef42bac17fbbf6911cad060812c62f8c Matt Isaacs committed Feb 15, 2011
@@ -1,5 +1,5 @@
libertas-objs := main.o wext.o rx.o tx.o cmd.o cmdresp.o scan.o 11d.o \
- debugfs.o persistcfg.o ethtool.o assoc.o
+ debugfs.o persistcfg.o ethtool.o assoc.o led.o
usb8xxx-objs += if_usb.o
libertas_cs-objs += if_cs.o
@@ -11,6 +11,7 @@
#include "host.h"
#include "scan.h"
#include "cmd.h"
+#include "led.h"
static const u8 bssid_any[ETH_ALEN] __attribute__ ((aligned (2))) =
{ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
@@ -225,7 +226,7 @@ static int lbs_assoc_post(struct lbs_private *priv,
/* Send a Media Connected event, according to the Spec */
priv->connect_status = LBS_CONNECTED;
-
+ lbs_led_assoc(priv, 1);
/* Update current SSID and BSSID */
memcpy(&priv->curbssparams.ssid, &bss->ssid, IW_ESSID_MAX_SIZE);
priv->curbssparams.ssid_len = bss->ssid_len;
@@ -14,6 +14,7 @@
#include "assoc.h"
#include "wext.h"
#include "cmd.h"
+#include "led.h"
static struct cmd_ctrl_node *lbs_get_cmd_ctrl_node(struct lbs_private *priv);
@@ -1332,7 +1333,7 @@ int lbs_set_radio(struct lbs_private *priv, u8 preamble, u8 radio_on)
radio_on ? "ON" : "OFF", preamble);
priv->radio_on = radio_on;
-
+ lbs_led_radio(priv);
ret = lbs_cmd_with_response(priv, CMD_802_11_RADIO_CONTROL, &cmd);
out:
@@ -14,6 +14,7 @@
#include "dev.h"
#include "assoc.h"
#include "wext.h"
+#include "led.h"
/**
* @brief This function handles disconnect event. it
@@ -61,7 +62,7 @@ void lbs_mac_event_disconnected(struct lbs_private *priv)
priv->nextSNRNF = 0;
priv->numSNRNF = 0;
priv->connect_status = LBS_DISCONNECTED;
-
+ lbs_led_assoc(priv, 0);
/* Clear out associated SSID and BSSID since connection is
* no longer valid.
*/
@@ -287,6 +287,10 @@ struct lbs_private {
u8 wpa_ie[MAX_WPA_IE_LEN];
u8 wpa_ie_len;
+ struct led_trigger *assoc_led;
+ char assoc_led_name[32];
+ struct led_trigger *radio_led;
+ char radio_led_name[32];
/** Requested Signal Strength*/
u16 SNR[MAX_TYPE_B][MAX_TYPE_AVG];
u16 NF[MAX_TYPE_B][MAX_TYPE_AVG];
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2011, Matt Isaacs <izzy@buglabs.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.
+ */
+
+#include <linux/if.h>
+#include <linux/slab.h>
+#include <linux/list.h>
+#include <linux/spinlock.h>
+#include <linux/leds.h>
+#include <net/cfg80211.h>
+#include "dev.h"
+
+void lbs_led_assoc(struct lbs_private *priv, bool associated)
+{
+ if (unlikely(!priv->assoc_led))
+ return;
+ if (associated)
+ led_trigger_event(priv->assoc_led, LED_FULL);
+ else
+ led_trigger_event(priv->assoc_led, LED_OFF);
+}
+
+void lbs_led_radio(struct lbs_private *priv)
+{
+ if (unlikely(!priv->radio_led))
+ return;
+ if (priv->radio_on)
+ led_trigger_event(priv->radio_led, LED_FULL);
+ else
+ led_trigger_event(priv->radio_led, LED_OFF);
+}
+
+void lbs_led_init(struct lbs_private *priv)
+{
+ priv->assoc_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (priv->assoc_led) {
+ snprintf(priv->assoc_led_name, sizeof(priv->assoc_led_name),
+ "%sassoc", priv->dev->name);
+ priv->assoc_led->name = priv->assoc_led_name;
+ if (led_trigger_register(priv->assoc_led)) {
+ kfree(priv->assoc_led);
+ priv->assoc_led = NULL;
+ }
+
+ }
+ priv->radio_led = kzalloc(sizeof(struct led_trigger), GFP_KERNEL);
+ if (priv->radio_led) {
+ snprintf(priv->radio_led_name, sizeof(priv->radio_led_name),
+ "%sradio", priv->dev->name);
+ priv->radio_led->name = priv->radio_led_name;
+ if (led_trigger_register(priv->radio_led)) {
+ kfree(priv->radio_led);
+ priv->radio_led = NULL;
+ }
+
+ }
+}
+
+void lbs_led_exit(struct lbs_private *priv)
+{
+ if (priv->assoc_led) {
+ led_trigger_unregister(priv->assoc_led);
+ kfree(priv->assoc_led);
+ }
+ if (priv->radio_led) {
+ led_trigger_unregister(priv->radio_led);
+ kfree(priv->radio_led);
+ }
+
+}
+
+
@@ -0,0 +1,5 @@
+extern void lbs_led_assoc(struct lbs_private *priv, bool associated);
+extern void lbs_led_radio(struct lbs_private *priv);
+extern void lbs_led_init(struct lbs_private *priv);
+extern void lbs_led_exit(struct lbs_private *priv);
+
@@ -23,6 +23,7 @@
#include "scan.h"
#include "assoc.h"
#include "cmd.h"
+#include "led.h"
#define DRIVER_RELEASE_VERSION "323.p0"
const char lbs_driver_version[] = "COMM-USB8388-" DRIVER_RELEASE_VERSION
@@ -1356,6 +1357,7 @@ int lbs_start_card(struct lbs_private *priv)
}
lbs_debugfs_init_one(priv, dev);
+ lbs_led_init(priv);
lbs_pr_info("%s: Marvell WLAN 802.11 adapter\n", dev->name);

0 comments on commit 1195c41

Please sign in to comment.