Skip to contentSkip to conversation

staging: et131x: Remove redundant commented out code

PATCH New Mark Einon 1 participant 4 messages Aug 2, 2011 Staging

lore
Share & tools
lore

Mark Einon

author
#0 lore raw

PATCH 1/4 staging: et131x: Remove redundant commented out code

Removed commented out calls that no longer exist in the net_device struct.

---
 drivers/staging/et131x/et131x_netdev.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/staging/et131x/et131x_netdev.c +1 -2
index da60be7..93ef9d5 100644
@@ -669,8 +669,7 @@ struct net_device *et131x_device_alloc(void)
 	/* Setup the function registration table (and other data) for a
 	 * net_device
 	 */
-	/* netdev->init               = &et131x_init; */
-	/* netdev->set_config = &et131x_config; */
+
 	netdev->watchdog_timeo = ET131X_TX_TIMEOUT;
 	netdev->netdev_ops = &et131x_netdev_ops;
 
Signature · 1 line
1.7.4.4
author
#1 lore raw

PATCH 2/4 staging: et131x: Rename et131x_config_global_regs > et131x_configure_global_regs

Typo in header file. Also renaming a few adapter references to fit in with the rest of the file.

---
 drivers/staging/et131x/et131x.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/et131x/et131x.h +2 -2
index 9523a8b..91fafc0 100644
@@ -49,10 +49,10 @@
  */
 
 /* et131x_eeprom.c */
-int et131x_init_eeprom(struct et131x_adapter *etdev);
+int et131x_init_eeprom(struct et131x_adapter *adapter);
 
 /* et131x_initpci.c */
-void et131x_config_global_regs(struct et131x_adapter *pAdapter);
+void et131x_configure_global_regs(struct et131x_adapter *adapter);
 void et131x_enable_interrupts(struct et131x_adapter *adapter);
 void et131x_disable_interrupts(struct et131x_adapter *adapter);
 void et131x_align_allocated_memory(struct et131x_adapter *adapter,
Signature · 1 line
1.7.4.4
author
#2 lore raw

PATCH 3/4 staging: et131x: Rename var name 'etdev' to 'adapter' throughout module

In reply to Mark Einon

Used regex (from vim) :%s/\<etdev\>/adapter/g

Changed because:
* 'etdev' is easily confused as a misspelling of 'netdev'
* 'adapter' is more widely used for this struct type in net drivers. This change made comparing code with other drivers much easier.

---
 drivers/staging/et131x/et1310_eeprom.c  |   32 ++--
 drivers/staging/et131x/et1310_mac.c     |  206 ++++++++--------
 drivers/staging/et131x/et1310_phy.c     |  390 +++++++++++++++---------------
 drivers/staging/et131x/et1310_pm.c      |   44 ++--
 drivers/staging/et131x/et1310_rx.c      |  174 +++++++-------
 drivers/staging/et131x/et1310_tx.c      |  254 ++++++++++----------
 drivers/staging/et131x/et131x_initpci.c |  136 ++++++------
 drivers/staging/et131x/et131x_isr.c     |   46 ++--
 drivers/staging/et131x/et131x_netdev.c  |   26 +-
 9 files changed, 654 insertions(+), 654 deletions(-)
drivers/staging/et131x/et1310_eeprom.c +16 -16
index 2375840..e810254 100644
@@ -150,15 +150,15 @@ static int eeprom_wait_ready(struct pci_dev *pdev, u32 *status)
 
 /**
  * eeprom_write - Write a byte to the ET1310's EEPROM
- * @etdev: pointer to our private adapter structure
+ * @adapter: pointer to our private adapter structure
  * @addr: the address to write
  * @data: the value to write
  *
  * Returns 1 for a successful write.
  */
-static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data)
+static int eeprom_write(struct et131x_adapter *adapter, u32 addr, u8 data)
 {
-	struct pci_dev *pdev = etdev->pdev;
+	struct pci_dev *pdev = adapter->pdev;
 	int index = 0;
 	int retries;
 	int err = 0;
@@ -222,7 +222,7 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data)
 		 * 1, this is so we do a blind write for load bug.
 		 */
 		if ((status & LBCIF_STATUS_GENERAL_ERROR)
-			&& etdev->pdev->revision == 0)
+			&& adapter->pdev->revision == 0)
 			break;
 
 		/*
@@ -280,7 +280,7 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data)
 
 /**
  * eeprom_read - Read a byte from the ET1310's EEPROM
- * @etdev: pointer to our private adapter structure
+ * @adapter: pointer to our private adapter structure
  * @addr: the address from which to read
  * @pdata: a pointer to a byte in which to store the value of the read
  * @eeprom_id: the ID of the EEPROM
@@ -288,9 +288,9 @@ static int eeprom_write(struct et131x_adapter *etdev, u32 addr, u8 data)
  *
  * Returns 1 for a successful read
  */
-static int eeprom_read(struct et131x_adapter *etdev, u32 addr, u8 *pdata)
+static int eeprom_read(struct et131x_adapter *adapter, u32 addr, u8 *pdata)
 {
-	struct pci_dev *pdev = etdev->pdev;
+	struct pci_dev *pdev = adapter->pdev;
 	int err;
 	u32 status;
 
@@ -337,9 +337,9 @@ static int eeprom_read(struct et131x_adapter *etdev, u32 addr, u8 *pdata)
 	return (status & LBCIF_STATUS_ACK_ERROR) ? -EIO : 0;
 }
 
-int et131x_init_eeprom(struct et131x_adapter *etdev)
+int et131x_init_eeprom(struct et131x_adapter *adapter)
 {
-	struct pci_dev *pdev = etdev->pdev;
+	struct pci_dev *pdev = adapter->pdev;
 	u8 eestatus;
 
 	/* We first need to check the EEPROM Status code located at offset
@@ -374,7 +374,7 @@ int et131x_init_eeprom(struct et131x_adapter *etdev)
 			 * corruption seen with 1310 B Silicon
 			 */
 			for (i = 0; i < 3; i++)
-				if (eeprom_write(etdev, i, eedata[i]) < 0)
+				if (eeprom_write(adapter, i, eedata[i]) < 0)
 					write_failed = 1;
 		}
 		if (pdev->revision  != 0x01 || write_failed) {
@@ -387,21 +387,21 @@ int et131x_init_eeprom(struct et131x_adapter *etdev)
 			 * gather additional information that normally would
 			 * come from the eeprom, like MAC Address
 			 */
-			etdev->has_eeprom = 0;
+			adapter->has_eeprom = 0;
 			return -EIO;
 		}
 	}
-	etdev->has_eeprom = 1;
+	adapter->has_eeprom = 1;
 
 	/* Read the EEPROM for information regarding LED behavior. Refer to
 	 * ET1310_phy.c, et131x_xcvr_init(), for its use.
 	 */
-	eeprom_read(etdev, 0x70, &etdev->eeprom_data[0]);
-	eeprom_read(etdev, 0x71, &etdev->eeprom_data[1]);
+	eeprom_read(adapter, 0x70, &adapter->eeprom_data[0]);
+	eeprom_read(adapter, 0x71, &adapter->eeprom_data[1]);
 
-	if (etdev->eeprom_data[0] != 0xcd)
+	if (adapter->eeprom_data[0] != 0xcd)
 		/* Disable all optional features */
-		etdev->eeprom_data[1] = 0x00;
+		adapter->eeprom_data[1] = 0x00;
 
 	return 0;
 }
drivers/staging/et131x/et1310_mac.c +103 -103

431 lines not on this page · raw message

drivers/staging/et131x/et1310_phy.c +195 -195

847 lines not on this page · raw message

drivers/staging/et131x/et1310_pm.c +22 -22

104 lines not on this page · raw message

drivers/staging/et131x/et1310_rx.c +87 -87

437 lines not on this page · raw message

drivers/staging/et131x/et1310_tx.c +127 -127

573 lines not on this page · raw message

drivers/staging/et131x/et131x_initpci.c +68 -68

268 lines not on this page · raw message

drivers/staging/et131x/et131x_isr.c +23 -23

132 lines not on this page · raw message

drivers/staging/et131x/et131x_netdev.c +13 -13
index 93ef9d5..37e1069 100644
@@ -212,19 +212,19 @@ int et131x_close(struct net_device *netdev)
 int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
 {
 	int status = 0;
-	struct et131x_adapter *etdev = netdev_priv(netdev);
+	struct et131x_adapter *adapter = netdev_priv(netdev);
 	struct mii_ioctl_data *data = if_mii(reqbuf);
 
 	switch (cmd) {
 	case SIOCGMIIPHY:
-		data->phy_id = etdev->stats.xcvr_addr;
+		data->phy_id = adapter->stats.xcvr_addr;
 		break;
 
 	case SIOCGMIIREG:
 		if (!capable(CAP_NET_ADMIN))
 			status = -EPERM;
 		else
-			status = et131x_mii_read(etdev,
+			status = et131x_mii_read(adapter,
 					data->reg_num, &data->val_out);
 		break;
 
@@ -232,7 +232,7 @@ int et131x_ioctl_mii(struct net_device *netdev, struct ifreq *reqbuf, int cmd)
 		if (!capable(CAP_NET_ADMIN))
 			status = -EPERM;
 		else
-			status = et131x_mii_write(etdev, data->reg_num,
+			status = et131x_mii_write(adapter, data->reg_num,
 					 data->val_in);
 		break;
 
@@ -445,35 +445,35 @@ int et131x_tx(struct sk_buff *skb, struct net_device *netdev)
  */
 void et131x_tx_timeout(struct net_device *netdev)
 {
-	struct et131x_adapter *etdev = netdev_priv(netdev);
+	struct et131x_adapter *adapter = netdev_priv(netdev);
 	struct tcb *tcb;
 	unsigned long flags;
 
 	/* Any nonrecoverable hardware error?
 	 * Checks adapter->flags for any failure in phy reading
 	 */
-	if (etdev->flags & fMP_ADAPTER_NON_RECOVER_ERROR)
+	if (adapter->flags & fMP_ADAPTER_NON_RECOVER_ERROR)
 		return;
 
 	/* Hardware failure? */
-	if (etdev->flags & fMP_ADAPTER_HARDWARE_ERROR) {
-		dev_err(&etdev->pdev->dev, "hardware error - reset\n");
+	if (adapter->flags & fMP_ADAPTER_HARDWARE_ERROR) {
+		dev_err(&adapter->pdev->dev, "hardware error - reset\n");
 		return;
 	}
 
 	/* Is send stuck? */
-	spin_lock_irqsave(&etdev->tcb_send_qlock, flags);
+	spin_lock_irqsave(&adapter->tcb_send_qlock, flags);
 
-	tcb = etdev->tx_ring.send_head;
+	tcb = adapter->tx_ring.send_head;
 
 	if (tcb != NULL) {
 		tcb->count++;
 
 		if (tcb->count > NIC_SEND_HANG_THRESHOLD) {
-			spin_unlock_irqrestore(&etdev->tcb_send_qlock,
+			spin_unlock_irqrestore(&adapter->tcb_send_qlock,
 					       flags);
 
-			dev_warn(&etdev->pdev->dev,
+			dev_warn(&adapter->pdev->dev,
 				"Send stuck - reset.  tcb->WrIndex %x, flags 0x%08x\n",
 				tcb->index,
 				tcb->flags);
@@ -485,7 +485,7 @@ void et131x_tx_timeout(struct net_device *netdev)
 		}
 	}
 
-	spin_unlock_irqrestore(&etdev->tcb_send_qlock, flags);
+	spin_unlock_irqrestore(&adapter->tcb_send_qlock, flags);
 }
 
 /**
Signature · 1 line
1.7.4.4
author
#3 lore raw

PATCH 4/4 staging: et131x: Fix link detection signalling

In reply to Mark Einon

Remove redundant code around netif_carrier_XXX calls, and associated adapter->media_state, which prevented the link from being reported as off. Tested on an ET-1310 device.

---
 drivers/staging/et131x/et1310_phy.c     |   26 +-------------------------
 drivers/staging/et131x/et131x_adapter.h |    6 ------
 drivers/staging/et131x/et131x_initpci.c |   23 +----------------------
 3 files changed, 2 insertions(+), 53 deletions(-)
drivers/staging/et131x/et1310_phy.c +1 -25
index 6eb9d5c..2c6898f 100644
@@ -737,16 +737,6 @@ void et131x_mii_check(struct et131x_adapter *adapter,
 	if (bmsr_ints & MI_BMSR_LINK_STATUS) {
 		if (bmsr & MI_BMSR_LINK_STATUS) {
 			adapter->boot_coma = 20;
-
-			/* Update our state variables and indicate the
-			 * connected state
-			 */
-			spin_lock_irqsave(&adapter->lock, flags);
-
-			adapter->media_state = NETIF_STATUS_MEDIA_CONNECT;
-
-			spin_unlock_irqrestore(&adapter->lock, flags);
-
 			netif_carrier_on(adapter->netdev);
 		} else {
 			dev_warn(&adapter->pdev->dev,
@@ -768,21 +758,7 @@ void et131x_mii_check(struct et131x_adapter *adapter,
 				et131x_mii_write(adapter, 0x12, register18);
 			}
 
-			/* For the first N seconds of life, we are in "link
-			 * detection" When we are in this state, we should
-			 * only report "connected". When the LinkDetection
-			 * Timer expires, we can report disconnected (handled
-			 * in the LinkDetectionDPC).
-			 */
-			if (adapter->media_state == NETIF_STATUS_MEDIA_DISCONNECT) {
-				spin_lock_irqsave(&adapter->lock, flags);
-				adapter->media_state =
-				    NETIF_STATUS_MEDIA_DISCONNECT;
-				spin_unlock_irqrestore(&adapter->lock,
-						       flags);
-
-				netif_carrier_off(adapter->netdev);
-			}
+			netif_carrier_off(adapter->netdev);
 
 			adapter->linkspeed = 0;
 			adapter->duplex_mode = 0;
drivers/staging/et131x/et131x_adapter.h +0 -6
index 5dfa153..762e07c 100644
@@ -196,12 +196,6 @@ struct et131x_adapter {
 	u8 ai_force_duplex;	/* duplex setting */
 	u16 ai_force_speed;	/* 'Speed', user over-ride of line speed */
 	u8 flowcontrol;		/* flow control validated by the far-end */
-	enum {
-		NETIF_STATUS_INVALID = 0,
-		NETIF_STATUS_MEDIA_CONNECT,
-		NETIF_STATUS_MEDIA_DISCONNECT,
-		NETIF_STATUS_MAX
-	} media_state;
 
 	/* Minimize init-time */
 	struct timer_list error_timer;
drivers/staging/et131x/et131x_initpci.c +1 -22
index 59637c6..072cfb5 100644
@@ -299,27 +299,6 @@ void et131x_error_timer_handler(unsigned long data)
 }
 
 /**
- * et131x_link_detection_handler
- *
- * Timer function for link up at driver load time
- */
-void et131x_link_detection_handler(unsigned long data)
-{
-	struct et131x_adapter *adapter = (struct et131x_adapter *) data;
-	unsigned long flags;
-
-	if (adapter->media_state == 0) {
-		spin_lock_irqsave(&adapter->lock, flags);
-
-		adapter->media_state = NETIF_STATUS_MEDIA_DISCONNECT;
-
-		spin_unlock_irqrestore(&adapter->lock, flags);
-
-		netif_carrier_off(adapter->netdev);
-	}
-}
-
-/**
  * et131x_configure_global_regs	-	configure JAGCore global regs
  * @adapter: pointer to our adapter structure
  *
@@ -718,7 +697,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,
 	adapter->error_timer.data = (unsigned long)adapter;
 
 	/* Initialize link state */
-	et131x_link_detection_handler((unsigned long)adapter);
+	netif_carrier_off(adapter->netdev);
 
 	/* Initialize variable for counting how long we do not have
 							link status */
Signature · 1 line
1.7.4.4