From 804a5ec71bed4fcd31fac5470bbe3ea913c73315 Mon Sep 17 00:00:00 2001
From: hauke <hauke@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Sun, 25 Nov 2012 20:11:15 +0000
Subject: broadcom-wl: fix two problems when more then one wifi card is
 available.

* The device should get a unique name at the beginning and not wl%d.
* load the nvram just one time into the own buffer, also when there is
  more than one device.


git-svn-id: svn://svn.openwrt.org/openwrt/trunk@34381 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 .../patches/100-fix_nvram_two_devices.patch        | 32 ++++++++++++++++++++++
 .../patches/110-add_number_to_dev_name.patch       | 11 ++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 package/broadcom-wl/patches/100-fix_nvram_two_devices.patch
 create mode 100644 package/broadcom-wl/patches/110-add_number_to_dev_name.patch

diff --git a/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch b/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch
new file mode 100644
index 000000000..5650862f8
--- /dev/null
+++ b/package/broadcom-wl/patches/100-fix_nvram_two_devices.patch
@@ -0,0 +1,32 @@
+--- a/driver/nvram_stub.c
++++ b/driver/nvram_stub.c
+@@ -22,6 +22,7 @@ typedef struct _vars {
+ #define	VARS_T_OH	sizeof(vars_t)
+ 
+ static vars_t *vars = NULL;
++static int nvram_init_done = 0;
+ extern char *nvram_buf[];
+ 
+ int
+@@ -33,6 +34,10 @@ BCMATTACHFN(nvram_init)(void *si)
+ 	uint nvs, bufsz;
+ 	vars_t *new;
+ 
++	nvram_init_done++;
++	if (nvram_init_done != 1)
++		return 0;
++
+ 	osh = si_osh(sih);
+ 
+ 	nvs = R_REG(osh, &nvh->len) - sizeof(struct nvram_header);
+@@ -79,6 +84,10 @@ BCMATTACHFN(nvram_exit)(void *si)
+ 	vars_t *this, *next;
+ 	si_t *sih;
+ 
++	nvram_init_done--;
++	if (nvram_init_done != 0)
++		return 0;
++
+ 	sih = (si_t *)si;
+ 	this = vars;
+ 	while (this) {
diff --git a/package/broadcom-wl/patches/110-add_number_to_dev_name.patch b/package/broadcom-wl/patches/110-add_number_to_dev_name.patch
new file mode 100644
index 000000000..13ce72741
--- /dev/null
+++ b/package/broadcom-wl/patches/110-add_number_to_dev_name.patch
@@ -0,0 +1,11 @@
+--- a/driver/wl_linux.c
++++ b/driver/wl_linux.c
+@@ -1412,7 +1412,7 @@ wl_alloc_if(wl_info_t *wl, int iftype, u
+ 	dev = alloc_etherdev(sizeof(wl_if_t));
+ 	wlif = netdev_priv(dev);
+ 	bzero(wlif, sizeof(wl_if_t));
+-	strncpy(dev->name, name, IFNAMSIZ);
++	snprintf(dev->name, IFNAMSIZ, name, subunit);
+ 
+ 	wlif->type = iftype;
+ 	wlif->dev = dev;
-- 
cgit v1.2.3