All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, jeff@garzik.org, gospo@redhat.com,
	Alexander Duyck <alexander.h.duyck@intel.com>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next PATCH 06/26] igb: make dev_spec a union and remove dynamic allocation
Date: Sat, 07 Feb 2009 01:16:45 -0800	[thread overview]
Message-ID: <20090207091645.15697.48924.stgit@lost.foo-projects.org> (raw)
In-Reply-To: <20090207091504.15697.26667.stgit@lost.foo-projects.org>

From: Alexander Duyck <alexander.h.duyck@intel.com>

This patch makes dev_spec a union and simplifies it so that it does not
require dynamic allocation and freeing in the driver.

Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---

 drivers/net/igb/e1000_82575.c |   34 +++++-----------------------------
 drivers/net/igb/e1000_hw.h    |    9 +++++++--
 drivers/net/igb/e1000_mac.c   |   13 -------------
 drivers/net/igb/e1000_mac.h   |    1 -
 drivers/net/igb/igb_main.c    |    2 --
 5 files changed, 12 insertions(+), 47 deletions(-)

diff --git a/drivers/net/igb/e1000_82575.c b/drivers/net/igb/e1000_82575.c
index f5e4cad..ed9e8c0 100644
--- a/drivers/net/igb/e1000_82575.c
+++ b/drivers/net/igb/e1000_82575.c
@@ -62,17 +62,12 @@ static bool igb_sgmii_active_82575(struct e1000_hw *);
 static s32  igb_reset_init_script_82575(struct e1000_hw *);
 static s32  igb_read_mac_addr_82575(struct e1000_hw *);
 
-
-struct e1000_dev_spec_82575 {
-	bool sgmii_active;
-};
-
 static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 {
 	struct e1000_phy_info *phy = &hw->phy;
 	struct e1000_nvm_info *nvm = &hw->nvm;
 	struct e1000_mac_info *mac = &hw->mac;
-	struct e1000_dev_spec_82575 *dev_spec;
+	struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575;
 	u32 eecd;
 	s32 ret_val;
 	u16 size;
@@ -94,17 +89,6 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)
 		break;
 	}
 
-	/* MAC initialization */
-	hw->dev_spec_size = sizeof(struct e1000_dev_spec_82575);
-
-	/* Device-specific structure allocation */
-	hw->dev_spec = kzalloc(hw->dev_spec_size, GFP_KERNEL);
-
-	if (!hw->dev_spec)
-		return -ENOMEM;
-
-	dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
-
 	/* Set media type */
 	/*
 	 * The 82575 uses bits 22:23 for link mode. The mode can be changed
@@ -1234,20 +1218,12 @@ out:
  **/
 static bool igb_sgmii_active_82575(struct e1000_hw *hw)
 {
-	struct e1000_dev_spec_82575 *dev_spec;
-	bool ret_val;
+	struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575;
 
-	if (hw->mac.type != e1000_82575) {
-		ret_val = false;
-		goto out;
-	}
-
-	dev_spec = (struct e1000_dev_spec_82575 *)hw->dev_spec;
+	if (hw->mac.type != e1000_82575 && hw->mac.type != e1000_82576)
+		return false;
 
-	ret_val = dev_spec->sgmii_active;
-
-out:
-	return ret_val;
+	return dev_spec->sgmii_active;
 }
 
 /**
diff --git a/drivers/net/igb/e1000_hw.h b/drivers/net/igb/e1000_hw.h
index 99504a6..06f72ae 100644
--- a/drivers/net/igb/e1000_hw.h
+++ b/drivers/net/igb/e1000_hw.h
@@ -565,9 +565,12 @@ struct e1000_fc_info {
 	enum e1000_fc_type original_type;
 };
 
+struct e1000_dev_spec_82575 {
+	bool sgmii_active;
+};
+
 struct e1000_hw {
 	void *back;
-	void *dev_spec;
 
 	u8 __iomem *hw_addr;
 	u8 __iomem *flash_address;
@@ -580,7 +583,9 @@ struct e1000_hw {
 	struct e1000_bus_info  bus;
 	struct e1000_host_mng_dhcp_cookie mng_cookie;
 
-	u32 dev_spec_size;
+	union {
+		struct e1000_dev_spec_82575	_82575;
+	} dev_spec;
 
 	u16 device_id;
 	u16 subsystem_vendor_id;
diff --git a/drivers/net/igb/e1000_mac.c b/drivers/net/igb/e1000_mac.c
index 97f0049..16fa083 100644
--- a/drivers/net/igb/e1000_mac.c
+++ b/drivers/net/igb/e1000_mac.c
@@ -37,19 +37,6 @@
 static s32 igb_set_default_fc(struct e1000_hw *hw);
 static s32 igb_set_fc_watermarks(struct e1000_hw *hw);
 
-/**
- *  igb_remove_device - Free device specific structure
- *  @hw: pointer to the HW structure
- *
- *  If a device specific structure was allocated, this function will
- *  free it.
- **/
-void igb_remove_device(struct e1000_hw *hw)
-{
-	/* Freeing the dev_spec member of e1000_hw structure */
-	kfree(hw->dev_spec);
-}
-
 static s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value)
 {
 	struct igb_adapter *adapter = hw->back;
diff --git a/drivers/net/igb/e1000_mac.h b/drivers/net/igb/e1000_mac.h
index cbee6af..4ef40d5 100644
--- a/drivers/net/igb/e1000_mac.h
+++ b/drivers/net/igb/e1000_mac.h
@@ -63,7 +63,6 @@ void igb_mta_set(struct e1000_hw *hw, u32 hash_value);
 void igb_put_hw_semaphore(struct e1000_hw *hw);
 void igb_rar_set(struct e1000_hw *hw, u8 *addr, u32 index);
 s32  igb_check_alt_mac_addr(struct e1000_hw *hw);
-void igb_remove_device(struct e1000_hw *hw);
 void igb_reset_adaptive(struct e1000_hw *hw);
 void igb_update_adaptive(struct e1000_hw *hw);
 void igb_write_vfta(struct e1000_hw *hw, u32 offset, u32 value);
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index b59088e..cb3ac34 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -1329,7 +1329,6 @@ err_eeprom:
 	if (hw->flash_address)
 		iounmap(hw->flash_address);
 
-	igb_remove_device(hw);
 	igb_free_queues(adapter);
 err_sw_init:
 err_hw_init:
@@ -1389,7 +1388,6 @@ static void __devexit igb_remove(struct pci_dev *pdev)
 	if (!igb_check_reset_block(&adapter->hw))
 		igb_reset_phy(&adapter->hw);
 
-	igb_remove_device(&adapter->hw);
 	igb_reset_interrupt_capability(adapter);
 
 	igb_free_queues(adapter);


  parent reply	other threads:[~2009-02-07  9:17 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-07  9:15 [net-next PATCH 01/26] igb: optomize/refactor receive path Jeff Kirsher
2009-02-07  9:15 ` [net-next PATCH 02/26] igb: move setting of buffsz out of repeated path in alloc_rx_buffers Jeff Kirsher
2009-02-07  9:15 ` [net-next PATCH 03/26] igb: move initialization of number of queues into set_interrupt_capability Jeff Kirsher
2009-02-07  9:16 ` [net-next PATCH 04/26] igb: remove check for needing an io port Jeff Kirsher
2009-02-07  9:16 ` [net-next PATCH 05/26] igb: add link check function Jeff Kirsher
2009-02-07  9:16 ` Jeff Kirsher [this message]
2009-02-07  9:17 ` [net-next PATCH 07/26] igb: read address from RAH/RAL instead of from EEPROM Jeff Kirsher
2009-02-07  9:17 ` [net-next PATCH 08/26] igb: rename phy ops Jeff Kirsher
2009-02-07  9:17 ` [net-next PATCH 09/26] igb: rename nvm ops Jeff Kirsher
2009-02-07  9:18 ` [net-next PATCH 10/26] igb: remove unused rx_hdr_split statistic Jeff Kirsher
2009-02-07  9:18 ` [net-next PATCH 11/26] igb: update feature flags supported in ethtool Jeff Kirsher
2009-02-07  9:18 ` [net-next PATCH 12/26] igb: update testing done by ethtool Jeff Kirsher
2009-02-07  9:19 ` [net-next PATCH 13/26] igb: add counter for dma out of sync errors Jeff Kirsher
2009-02-07  9:19 ` [net-next PATCH 14/26] igb: cleanup igb_netpoll to be more friendly with napi & GRO Jeff Kirsher
2009-02-07  9:19 ` [net-next PATCH 15/26] igb: remove redundant timer updates and cleanup watchdog_task Jeff Kirsher
2009-02-07  9:20 ` [net-next PATCH 16/26] igb: rename igb_update_mc_addr_list_82575 to not include the 82575 Jeff Kirsher
2009-02-07  9:20 ` [net-next PATCH 17/26] igb: remove unnecessary adapter->hw calls when just hw-> will do Jeff Kirsher
2009-02-07  9:20 ` [net-next PATCH 18/26] igb: don't read eicr when responding to legacy interrupts Jeff Kirsher
2009-02-07  9:21 ` [net-next PATCH 19/26] igb: move get_hw_control within igb_resume Jeff Kirsher
2009-02-07  9:21 ` [net-next PATCH 20/26] igb: change pba size determination from if to switch statement Jeff Kirsher
2009-02-07  9:21 ` [net-next PATCH 21/26] igb: remove disable_av variable from mac_info struct Jeff Kirsher
2009-02-07  9:22 ` [net-next PATCH 22/26] igb: remove redundant count set and err_hw_init Jeff Kirsher
2009-02-07  9:22 ` [net-next PATCH 23/26] igb: update stats before doing reset in igb_down Jeff Kirsher
2009-02-07  9:22 ` [net-next PATCH 24/26] igb: fix two minor items found during code review Jeff Kirsher
2009-02-07  9:23 ` [net-next PATCH 25/26] igb: update version number and copyright dates Jeff Kirsher
2009-02-07  9:23 ` [net-next PATCH 26/26] igb: remove dead code in transmit routine Jeff Kirsher
2009-02-07 10:46 ` [net-next PATCH 01/26] igb: optomize/refactor receive path David Miller

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=20090207091645.15697.48924.stgit@lost.foo-projects.org \
    --to=jeffrey.t.kirsher@intel.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=jeff@garzik.org \
    --cc=netdev@vger.kernel.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.