netdev.vger.kernel.org archive mirror
 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 4/32] rt2x00: Add eeprom_multiread function
Date: Fri, 28 Apr 2006 00:02:53 +0200	[thread overview]
Message-ID: <200604280002.54192.IvDoorn@gmail.com> (raw)

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

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

Add the eeprom_multiread function and clean up the code
a bit by using it as well. ;)

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:37:02.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2400pci.c	2006-04-27 21:38:23.000000000 +0200
@@ -351,6 +351,17 @@ rt2x00_eeprom_read(
 	rt2x00_eeprom_pulse_low(rt2x00pci, &flags);
 }
 
+static void
+rt2x00_eeprom_multiread(
+	const struct rt2x00_pci *rt2x00pci,
+	const u8 word, u16 *data, const u16 length)
+{
+	int			counter;
+
+	for (counter = 0; counter < (length / sizeof(u16)); counter++)
+		rt2x00_eeprom_read(rt2x00pci, word + counter, data++);
+}
+
 /*
  * Configuration handlers.
  */
@@ -1824,9 +1835,8 @@ rt2400pci_init_eeprom(struct rt2x00_pci 
 	/*
 	 * 7 - Read BBP data from EEPROM and store in private structure.
 	 */
-	for (counter = 0; counter < EEPROM_BBP_SIZE; counter++)
-		rt2x00_eeprom_read(rt2x00pci, EEPROM_BBP_START + counter,
-			&rt2x00pci->eeprom[counter]);
+	rt2x00_eeprom_multiread(rt2x00pci, EEPROM_BBP_START,
+		&rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
 
 	return 0;
 }
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:37:02.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500pci.c	2006-04-27 21:38:23.000000000 +0200
@@ -351,6 +351,17 @@ rt2x00_eeprom_read(
 	rt2x00_eeprom_pulse_low(rt2x00pci, &flags);
 }
 
+static void
+rt2x00_eeprom_multiread(
+	const struct rt2x00_pci *rt2x00pci,
+	const u8 word, u16 *data, const u16 length)
+{
+	int			counter;
+
+	for (counter = 0; counter < (length / sizeof(u16)); counter++)
+		rt2x00_eeprom_read(rt2x00pci, word + counter, data++);
+}
+
 /*
  * Configuration handlers.
  */
@@ -1886,9 +1897,8 @@ rt2500pci_init_eeprom(struct rt2x00_pci 
 	/*
 	 * 7 - Read BBP data from EEPROM and store in private structure.
 	 */
-	for (counter = 0; counter < EEPROM_BBP_SIZE; counter++)
-		rt2x00_eeprom_read(rt2x00pci, EEPROM_BBP_START + counter,
-			&rt2x00pci->eeprom[counter]);
+	rt2x00_eeprom_multiread(rt2x00pci, EEPROM_BBP_START,
+		&rt2x00pci->eeprom, EEPROM_BBP_SIZE * sizeof(u16));
 
 	return 0;
 }
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:36:17.000000000 +0200
+++ wireless-dev-rt2x00-patch/drivers/net/wireless/d80211/rt2x00/rt2500usb.c	2006-04-27 21:38:23.000000000 +0200
@@ -228,11 +228,21 @@ rf_write:
 static inline void
 rt2x00_eeprom_read(
 	const struct rt2x00_usb *rt2x00usb,
-	const u16 offset, u16 *value, const u16 length)
+	const u16 word, u16 *data)
 {
 	rt2x00_vendor_request(
 		rt2x00usb, USB_EEPROM_READ, USB_VENDOR_REQUEST_IN,
-		offset, 0x00, value, length);
+		word, 0x00, data, 2);
+}
+
+static void
+rt2x00_eeprom_multiread(
+	const struct rt2x00_usb *rt2x00usb,
+	const u8 word, u16 *data, const u16 length)
+{
+	rt2x00_vendor_request(
+		rt2x00usb, USB_EEPROM_READ, USB_VENDOR_REQUEST_IN,
+		word, 0x00, data, length);
 }
 
 /*
@@ -1552,7 +1562,7 @@ rt2500usb_init_eeprom(struct rt2x00_usb 
 	/*
 	 * 1 - Read EEPROM word for configuration.
 	 */
-	rt2x00_eeprom_read(rt2x00usb, EEPROM_ANTENNA, &eeprom, 2);
+	rt2x00_eeprom_read(rt2x00usb, EEPROM_ANTENNA, &eeprom);
 
 	/*
 	 * 2 - Identify RF chipset.
@@ -1579,7 +1589,7 @@ rt2500usb_init_eeprom(struct rt2x00_usb 
 	 * 5 - Read BBP data from EEPROM and store in private structure.
 	 */
 	memset(&rt2x00usb->eeprom, 0x00, sizeof(rt2x00usb->eeprom));
-	rt2x00_eeprom_read(rt2x00usb, EEPROM_BBP_START,
+	rt2x00_eeprom_multiread(rt2x00usb, EEPROM_BBP_START,
 		&rt2x00usb->eeprom[0], EEPROM_BBP_SIZE);
 
 	return 0;
@@ -1595,7 +1605,7 @@ rt2500usb_init_mac(struct rt2x00_usb *rt
 	/*
 	 * Read MAC address from EEPROM.
 	 */
-	rt2x00_eeprom_read(rt2x00usb, EEPROM_MAC_ADDR, &reg[0], 6);
+	rt2x00_eeprom_multiread(rt2x00usb, EEPROM_MAC_ADDR, &reg[0], 6);
 
 	net_dev->dev_addr[0] = rt2x00_get_field16(reg[0], MAC_CSR2_BYTE0);
 	net_dev->dev_addr[1] = rt2x00_get_field16(reg[0], MAC_CSR2_BYTE1);
@@ -1733,7 +1743,7 @@ rt2500usb_init_hw_channels(struct rt2x00
 		 */
 	for (counter = 0; counter < EEPROM_TXPOWER_SIZE; counter++) {
 		rt2x00_eeprom_read(rt2x00usb,
-			EEPROM_TXPOWER_START + counter, &eeprom, 2);
+			EEPROM_TXPOWER_START + counter, &eeprom);
 
 		channels[(counter * 2)].power_level =
 			rt2x00_get_field16(eeprom, EEPROM_TXPOWER_1);

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

                 reply	other threads:[~2006-04-27 22:01 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=200604280002.54192.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 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).