Skip to contentSkip to conversation

rt2x00: Cleanup allocation/initialization

PATCH New Ivo van Doorn 1 participant 1 message Jul 25, 2007 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 3/11 rt2x00: Cleanup allocation/initialization

Quoted 1 line

From 6d5aaddbc146959eaaef7ada1760ca7fb6cd9a7d Mon Sep 17 00:00:00 2001

From: Ivo van Doorn <[email protected]>
Date: Sat, 21 Jul 2007 14:36:47 +0200
Subject: [PATCH 03/11] rt2x00: Cleanup allocation/initialization

Allocation and initialization was not very transparent, this patch will make it more transparent by making the following changes:

- Each module allocate and cleans up its own mess
- eeprom array is allocated and freed by rt2x00pci/usb
- Function names concerning ring & entries allocation should be changes to better reflect the actual work they do.

---
 drivers/net/wireless/mac80211/rt2x00/rt2400pci.c |   25 +-
 drivers/net/wireless/mac80211/rt2x00/rt2500pci.c |   25 +-
 drivers/net/wireless/mac80211/rt2x00/rt2500usb.c |   25 +-
 drivers/net/wireless/mac80211/rt2x00/rt2x00.h    |    1 +
 drivers/net/wireless/mac80211/rt2x00/rt2x00dev.c |  518 +++++++++++-----------
 drivers/net/wireless/mac80211/rt2x00/rt2x00pci.c |   58 ++-
 drivers/net/wireless/mac80211/rt2x00/rt2x00usb.c |   66 +++-
 drivers/net/wireless/mac80211/rt2x00/rt61pci.c   |   25 +-
 drivers/net/wireless/mac80211/rt2x00/rt73usb.c   |   25 +-
 9 files changed, 403 insertions(+), 365 deletions(-)
drivers/net/wireless/mac80211/rt2x00/rt2400pci.c +9 -16
index df2221b..a6c7602 100644
@@ -1311,21 +1311,13 @@ static irqreturn_t rt2400pci_interrupt(int irq, void *dev_instance)
 /*
  * Device initialization functions.
  */
-static int rt2400pci_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2400pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	struct eeprom_93cx6 eeprom;
 	u32 reg;
 	u16 word;
 	u8 *mac;
 
-	/*
-	 * Allocate the eeprom memory, check the eeprom width
-	 * and copy the entire eeprom into this allocated memory.
-	 */
-	rt2x00dev->eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL);
-	if (!rt2x00dev->eeprom)
-		return -ENOMEM;
-
 	rt2x00pci_register_read(rt2x00dev, CSR21, &reg);
 
 	eeprom.data = rt2x00dev;
@@ -1482,7 +1474,7 @@ static int rt2400pci_init_hw(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Allocate eeprom data.
 	 */
-	retval = rt2400pci_alloc_eeprom(rt2x00dev);
+	retval = rt2400pci_validate_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
@@ -1644,13 +1636,14 @@ static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = {
 };
 
 static const struct rt2x00_ops rt2400pci_ops = {
-	.name	= DRV_NAME,
-	.rxd_size = RXD_DESC_SIZE,
-	.txd_size = TXD_DESC_SIZE,
-	.lib	= &rt2400pci_rt2x00_ops,
-	.hw	= &rt2400pci_mac80211_ops,
+	.name		= DRV_NAME,
+	.rxd_size	= RXD_DESC_SIZE,
+	.txd_size	= TXD_DESC_SIZE,
+	.eeprom_size	= EEPROM_SIZE,
+	.lib		= &rt2400pci_rt2x00_ops,
+	.hw		= &rt2400pci_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
-	.debugfs = &rt2400pci_rt2x00debug,
+	.debugfs	= &rt2400pci_rt2x00debug,
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 };
 
drivers/net/wireless/mac80211/rt2x00/rt2500pci.c +9 -16
index 34c2e9f..088c717 100644
@@ -1458,21 +1458,13 @@ static irqreturn_t rt2500pci_interrupt(int irq, void *dev_instance)
 /*
  * Device initialization functions.
  */
-static int rt2500pci_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	struct eeprom_93cx6 eeprom;
 	u32 reg;
 	u16 word;
 	u8 *mac;
 
-	/*
-	 * Allocate the eeprom memory, check the eeprom width
-	 * and copy the entire eeprom into this allocated memory.
-	 */
-	rt2x00dev->eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL);
-	if (!rt2x00dev->eeprom)
-		return -ENOMEM;
-
 	rt2x00pci_register_read(rt2x00dev, CSR21, &reg);
 
 	eeprom.data = rt2x00dev;
@@ -1727,7 +1719,7 @@ static int rt2500pci_init_hw(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Allocate eeprom data.
 	 */
-	retval = rt2500pci_alloc_eeprom(rt2x00dev);
+	retval = rt2500pci_validate_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
@@ -1865,13 +1857,14 @@ static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = {
 };
 
 static const struct rt2x00_ops rt2500pci_ops = {
-	.name	= DRV_NAME,
-	.rxd_size = RXD_DESC_SIZE,
-	.txd_size = TXD_DESC_SIZE,
-	.lib	= &rt2500pci_rt2x00_ops,
-	.hw	= &rt2500pci_mac80211_ops,
+	.name		= DRV_NAME,
+	.rxd_size	= RXD_DESC_SIZE,
+	.txd_size	= TXD_DESC_SIZE,
+	.eeprom_size	= EEPROM_SIZE,
+	.lib		= &rt2500pci_rt2x00_ops,
+	.hw		= &rt2500pci_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
-	.debugfs = &rt2500pci_rt2x00debug,
+	.debugfs	= &rt2500pci_rt2x00debug,
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 };
 
drivers/net/wireless/mac80211/rt2x00/rt2500usb.c +9 -16
index 0d31c6c..8967155 100644
@@ -1135,19 +1135,11 @@ static int rt2500usb_fill_rxdone(struct data_entry *entry,
 /*
  * Device initialization functions.
  */
-static int rt2500usb_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt2500usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 
-	/*
-	 * Allocate the eeprom memory, check the eeprom width
-	 * and copy the entire eeprom into this allocated memory.
-	 */
-	rt2x00dev->eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL);
-	if (!rt2x00dev->eeprom)
-		return -ENOMEM;
-
 	rt2x00usb_vendor_request(
 		rt2x00dev, USB_EEPROM_READ, USB_VENDOR_REQUEST_IN,
 		EEPROM_BASE, 0x00, rt2x00dev->eeprom, EEPROM_SIZE,
@@ -1436,7 +1428,7 @@ static int rt2500usb_init_hw(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Allocate eeprom data.
 	 */
-	retval = rt2500usb_alloc_eeprom(rt2x00dev);
+	retval = rt2500usb_validate_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
@@ -1521,13 +1513,14 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
 };
 
 static const struct rt2x00_ops rt2500usb_ops = {
-	.name	= DRV_NAME,
-	.rxd_size = RXD_DESC_SIZE,
-	.txd_size = TXD_DESC_SIZE,
-	.lib	= &rt2500usb_rt2x00_ops,
-	.hw	= &rt2500usb_mac80211_ops,
+	.name		= DRV_NAME,
+	.rxd_size	= RXD_DESC_SIZE,
+	.txd_size	= TXD_DESC_SIZE,
+	.eeprom_size	= EEPROM_SIZE,
+	.lib		= &rt2500usb_rt2x00_ops,
+	.hw		= &rt2500usb_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
-	.debugfs = &rt2500usb_rt2x00debug,
+	.debugfs	= &rt2500usb_rt2x00debug,
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 };
 
drivers/net/wireless/mac80211/rt2x00/rt2x00.h +1 -0
index e6f84ac..bc4557d 100644
@@ -720,6 +720,7 @@ struct rt2x00_ops {
 	const char *name;
 	const unsigned int rxd_size;
 	const unsigned int txd_size;
+	const unsigned int eeprom_size;
 	const struct rt2x00lib_ops *lib;
 	const struct ieee80211_ops *hw;
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
drivers/net/wireless/mac80211/rt2x00/rt2x00dev.c +259 -259

602 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt2x00pci.c +47 -11

123 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt2x00usb.c +51 -15

129 lines not on this page · raw message

drivers/net/wireless/mac80211/rt2x00/rt61pci.c +9 -16
index 7ef847d..c935a43 100644
@@ -1905,7 +1905,7 @@ static irqreturn_t rt61pci_interrupt(int irq, void *dev_instance)
 /*
  * Device initialization functions.
  */
-static int rt61pci_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	struct eeprom_93cx6 eeprom;
 	u32 reg;
@@ -1913,14 +1913,6 @@ static int rt61pci_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
 	u8 *mac;
 	char value;
 
-	/*
-	 * Allocate the eeprom memory, check the eeprom width
-	 * and copy the entire eeprom into this allocated memory.
-	 */
-	rt2x00dev->eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL);
-	if (!rt2x00dev->eeprom)
-		return -ENOMEM;
-
 	rt2x00pci_register_read(rt2x00dev, E2PROM_CSR, &reg);
 
 	eeprom.data = rt2x00dev;
@@ -2230,7 +2222,7 @@ static int rt61pci_init_hw(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Allocate eeprom data.
 	 */
-	retval = rt61pci_alloc_eeprom(rt2x00dev);
+	retval = rt61pci_validate_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
@@ -2360,13 +2352,14 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
 };
 
 static const struct rt2x00_ops rt61pci_ops = {
-	.name	= DRV_NAME,
-	.rxd_size = RXD_DESC_SIZE,
-	.txd_size = TXD_DESC_SIZE,
-	.lib	= &rt61pci_rt2x00_ops,
-	.hw	= &rt61pci_mac80211_ops,
+	.name		= DRV_NAME,
+	.rxd_size	= RXD_DESC_SIZE,
+	.txd_size	= TXD_DESC_SIZE,
+	.eeprom_size	= EEPROM_SIZE,
+	.lib		= &rt61pci_rt2x00_ops,
+	.hw		= &rt61pci_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
-	.debugfs = &rt61pci_rt2x00debug,
+	.debugfs	= &rt61pci_rt2x00debug,
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 };
 
drivers/net/wireless/mac80211/rt2x00/rt73usb.c +9 -16
index 533067f..664cd38 100644
@@ -1390,20 +1390,12 @@ static int rt73usb_fill_rxdone(struct data_entry *entry,
 /*
  * Device initialization functions.
  */
-static int rt73usb_alloc_eeprom(struct rt2x00_dev *rt2x00dev)
+static int rt73usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	u16 word;
 	u8 *mac;
 	char value;
 
-	/*
-	 * Allocate the eeprom memory, check the eeprom width
-	 * and copy the entire eeprom into this allocated memory.
-	 */
-	rt2x00dev->eeprom = kzalloc(EEPROM_SIZE, GFP_KERNEL);
-	if (!rt2x00dev->eeprom)
-		return -ENOMEM;
-
 	rt2x00usb_vendor_request(
 		rt2x00dev, USB_EEPROM_READ, USB_VENDOR_REQUEST_IN,
 		EEPROM_BASE, 0x00, rt2x00dev->eeprom, EEPROM_SIZE,
@@ -1685,7 +1677,7 @@ static int rt73usb_init_hw(struct rt2x00_dev *rt2x00dev)
 	/*
 	 * Allocate eeprom data.
 	 */
-	retval = rt73usb_alloc_eeprom(rt2x00dev);
+	retval = rt73usb_validate_eeprom(rt2x00dev);
 	if (retval)
 		return retval;
 
@@ -1811,13 +1803,14 @@ static const struct rt2x00lib_ops rt73usb_rt2x00_ops = {
 };
 
 static const struct rt2x00_ops rt73usb_ops = {
-	.name	= DRV_NAME,
-	.rxd_size = RXD_DESC_SIZE,
-	.txd_size = TXD_DESC_SIZE,
-	.lib	= &rt73usb_rt2x00_ops,
-	.hw	= &rt73usb_mac80211_ops,
+	.name		= DRV_NAME,
+	.rxd_size	= RXD_DESC_SIZE,
+	.txd_size	= TXD_DESC_SIZE,
+	.eeprom_size	= EEPROM_SIZE,
+	.lib		= &rt73usb_rt2x00_ops,
+	.hw		= &rt73usb_mac80211_ops,
 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
-	.debugfs = &rt73usb_rt2x00debug,
+	.debugfs	= &rt73usb_rt2x00debug,
 #endif /* CONFIG_RT2X00_LIB_DEBUGFS */
 };
 
Signature · 1 line
1.5.2.2