netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 14/32] rt2x00: Allocate eeprom memory
@ 2006-04-27 22:03 Ivo van Doorn
  0 siblings, 0 replies; only message in thread
From: Ivo van Doorn @ 2006-04-27 22:03 UTC (permalink / raw)
  To: netdev; +Cc: rt2x00-devel

[-- Attachment #1: Type: text/plain, Size: 5873 bytes --]

From: Ivo van Doorn <IvDoorn@gmail.com>

Make the EEPROM array in rt2x00_pci and rt2x00_usb a pointer,
and allocate the memory seperately. This is needed for make
the structures more generic for all rt2x00 pci or usb modules.

Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>

diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:45:08.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:47:22.000000000 +0200
@@ -1831,7 +1831,6 @@ rt2400pci_init_eeprom(struct rt2x00_pci 
 	u32			reg;
 	u16			value;
 	u16			eeprom;
-	int			counter;
 
 	/*
 	 * 1 - Detect EEPROM width.
@@ -1886,8 +1885,12 @@ rt2400pci_init_eeprom(struct rt2x00_pci 
 	/*
 	 * 7 - Read BBP data from EEPROM and store in private structure.
 	 */
+	rt2x00pci->eeprom = kzalloc(EEPROM_BBP_SIZE * sizeof(u16), GFP_KERNEL);
+	if (!rt2x00pci->eeprom) 
+		return -ENOMEM;
+
 	rt2x00_eeprom_multiread(rt2x00pci, EEPROM_BBP_START,
-		&rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
+		rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
 
 	return 0;
 }
@@ -2197,6 +2200,8 @@ rt2400pci_uninitialize(struct net_device
 	del_timer_sync(&rt2x00pci->poll_timer);
 #endif /* CONFIG_RT2400PCI_BUTTON */
 
+	kfree(rt2x00pci->eeprom);
+
 	if (likely(rt2x00pci->csr_addr)) {
 		iounmap(rt2x00pci->csr_addr);
 		rt2x00pci->csr_addr = NULL;
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.h
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2400pci.h	2006-04-27 21:45:08.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.h	2006-04-27 21:47:22.000000000 +0200
@@ -945,7 +945,7 @@ struct rt2x00_pci{
 	/*
 	 * EEPROM BBP data.
 	 */
-	u16					eeprom[EEPROM_BBP_SIZE];
+	u16					*eeprom;
 
 	/*
 	 * Low level statistics which will have
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:45:08.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:47:22.000000000 +0200
@@ -1939,7 +1939,6 @@ rt2500pci_init_eeprom(struct rt2x00_pci 
 	u32			reg;
 	u16			value;
 	u16			eeprom;
-	int			counter;
 
 	/*
 	 * 1 - Detect EEPROM width.
@@ -1998,8 +1997,12 @@ rt2500pci_init_eeprom(struct rt2x00_pci 
 	/*
 	 * 7 - Read BBP data from EEPROM and store in private structure.
 	 */
+	rt2x00pci->eeprom = kzalloc(EEPROM_BBP_SIZE * sizeof(u16), GFP_KERNEL);
+	if (!rt2x00pci->eeprom)
+		return -ENOMEM;
+
 	rt2x00_eeprom_multiread(rt2x00pci, EEPROM_BBP_START,
-		&rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
+		rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
 
 	return 0;
 }
@@ -2495,6 +2498,8 @@ rt2500pci_uninitialize(struct net_device
 	del_timer_sync(&rt2x00pci->poll_timer);
 #endif /* CONFIG_RT2500PCI_BUTTON */
 
+	kfree(rt2x00pci->eeprom);
+
 	if (likely(rt2x00pci->csr_addr)) {
 		iounmap(rt2x00pci->csr_addr);
 		rt2x00pci->csr_addr = NULL;
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.h
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500pci.h	2006-04-27 21:43:27.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.h	2006-04-27 21:47:22.000000000 +0200
@@ -1215,7 +1215,7 @@ struct rt2x00_pci{
 	/*
 	 * EEPROM BBP data.
 	 */
-	u16					eeprom[EEPROM_BBP_SIZE];
+	u16					*eeprom;
 
 	/*
 	 * Low level statistics which will have
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:45:08.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:47:22.000000000 +0200
@@ -1657,9 +1657,12 @@ rt2500usb_init_eeprom(struct rt2x00_usb 
 	/*
 	 * 5 - Read BBP data from EEPROM and store in private structure.
 	 */
-	memset(&rt2x00usb->eeprom, 0x00, sizeof(rt2x00usb->eeprom));
+	rt2x00usb->eeprom = kzalloc(EEPROM_BBP_SIZE * sizeof(u16), GFP_KERNEL);
+	if (!rt2x00usb->eeprom) 
+		return -ENOMEM;
+
 	rt2x00_eeprom_multiread(rt2x00usb, EEPROM_BBP_START,
-		&rt2x00usb->eeprom[0], EEPROM_BBP_SIZE);
+		rt2x00usb->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
 
 	return 0;
 }
@@ -2116,6 +2119,8 @@ rt2500usb_uninitialize(struct net_device
 {
 	struct rt2x00_usb	*rt2x00usb = ieee80211_dev_hw_data(net_dev);
 
+	kfree(rt2x00usb->eeprom);
+
 	if (rt2x00usb->scan) {
 		rt2x00usb->scan->cancelled = 1;
 		complete_all(&rt2x00usb->scan->completion);
@@ -2129,7 +2134,7 @@ rt2500usb_uninitialize(struct net_device
 
 		kfree(rt2x00usb->hw.modes);
 		rt2x00usb->hw.modes = NULL;
-	}
+}
 
 /*
  * USB driver handlers.
diff -uprN wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.h wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.h
--- wireless-dev-rt2x00/drivers/net/wireless/d80211/rt2x00/rt2500usb.h	2006-04-27 21:43:27.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.h	2006-04-27 21:47:22.000000000 +0200
@@ -727,7 +727,7 @@ struct rt2x00_usb{
 	/*
 	 * EEPROM BBP data.
 	 */
-	u16					eeprom[EEPROM_BBP_SIZE];
+	u16					*eeprom;
 
 	/*
 	 * Low level statistics which will have

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-04-27 22:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-27 22:03 [PATCH 14/32] rt2x00: Allocate eeprom memory Ivo van Doorn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).