All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ivo van Doorn <ivdoorn@gmail.com>
To: netdev@vger.kernel.org
Cc: rt2x00-devel@lfcorreia.dyndns.org
Subject: [PATCH 14/32] rt2x00: Allocate eeprom memory
Date: Fri, 28 Apr 2006 00:03:05 +0200	[thread overview]
Message-ID: <200604280003.06338.IvDoorn@gmail.com> (raw)

[-- 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 --]

                 reply	other threads:[~2006-04-27 22:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200604280003.06338.IvDoorn@gmail.com \
    --to=ivdoorn@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=rt2x00-devel@lfcorreia.dyndns.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.