net: eepro100: Remove EEPRO100_SROM_WRITE
PATCH 1/30 net: eepro100: Remove EEPRO100_SROM_WRITE
This code is never enabled, last board that used it was ELPPC which was removed some 5 years ago, so just remove this code altogether.
--- README | 2 - drivers/net/eepro100.c | 87 ------------------------------------ scripts/config_whitelist.txt | 1 - 3 files changed, 90 deletions(-)
README +0 -2
@@ -891,8 +891,6 @@ The following options need to be configured: CONFIG_EEPRO100 Support for Intel 82557/82559/82559ER chips. - Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM - write routine for first time initialisation. CONFIG_TULIP Support for Digital 2114x chips.
drivers/net/eepro100.c +0 -87
93 lines not on this page · raw message
scripts/config_whitelist.txt +0 -1
@@ -401,7 +401,6 @@ CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 CONFIG_EEPRO100 -CONFIG_EEPRO100_SROM_WRITE CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET
Signature · 1 line
2.25.1
PATCH 2/30 net: eepro100: Clean up comments
Clean the comments up to they trigger fewer checkpatch warnings, no functional change.
--- drivers/net/eepro100.c | 100 +++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 64 deletions(-)
drivers/net/eepro100.c +36 -64
@@ -15,8 +15,7 @@#undef DEBUG -/* Ethernet chip registers. -*/ +/* Ethernet chip registers. */ #define SCBStatus 0/* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */ #define SCBCmd 2/* Rx/Command Unit Command *Word* */
@@ -30,8 +29,7 @@#define SCBGenControl 28/* 82559 General Control Register */ #define SCBGenStatus 29/* 82559 General Status register */ -/* 82559 SCB status word defnitions -*/ +/* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000/* CU finished command (transmit) */ #define SCB_STATUS_FR 0x4000/* frame received */ #define SCB_STATUS_CNA 0x2000/* CU left active state */
@@ -45,8 +43,7 @@#define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA)#define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR) -/* System control block commands -*/ +/* System control block commands */ /* CU Commands */ #define CU_NOP 0x0000#define CU_START 0x0010
@@ -81,16 +78,14 @@#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2))#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) -/* 82559 Port interface commands. -*/ +/* 82559 Port interface commands. */ #define I82559_RESET 0x00000000/* Software reset */ #define I82559_SELFTEST 0x00000001/* 82559 Selftest command */ #define I82559_SELECTIVE_RESET 0x00000002#define I82559_DUMP 0x00000003#define I82559_DUMP_WAKEUP 0x00000007 -/* 82559 Eeprom interface. -*/ +/* 82559 Eeprom interface. */ #define EE_SHIFT_CLK 0x01/* EEPROM shift clock. */ #define EE_CS 0x02/* EEPROM chip select. */ #define EE_DATA_WRITE 0x04/* EEPROM chip data in. */
@@ -101,15 +96,13 @@#define EE_CMD_BITS 3#define EE_DATA_BITS 16 -/* The EEPROM commands include the alway-set leading bit. -*/ +/* The EEPROM commands include the alway-set leading bit. */ #define EE_EWENB_CMD (4 << addr_len)#define EE_WRITE_CMD (5 << addr_len)#define EE_READ_CMD (6 << addr_len)#define EE_ERASE_CMD (7 << addr_len) -/* Receive frame descriptors. -*/ +/* Receive frame descriptors. */ struct RxFD {volatile u16 status;volatile u16 control;
@@ -143,8 +136,7 @@ struct RxFD {#define RFD_RX_IA_MATCH 0x0002/* individual address does not match */ #define RFD_RX_TCO 0x0001/* TCO indication */ -/* Transmit frame descriptors -*/ +/* Transmit frame descriptors */ struct TxFD {/* Transmit frame descriptor set. */ volatile u16 status;volatile u16 command;
@@ -152,9 +144,9 @@ struct TxFD { /* Transmit frame descriptor set. */volatile u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ volatile s32 count; -volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ +volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ volatile s32 tx_buf_size0;/* Length of Tx frame. */ -volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ +volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ volatile s32 tx_buf_size1;/* Length of Tx frame. */ };
@@ -168,12 +160,11 @@ struct TxFD { /* Transmit frame descriptor set. */#define TxCB_COUNT_MASK 0x3fff#define TxCB_COUNT_EOF 0x8000 -/* The Speedo3 Rx and Tx frame/buffer descriptors. -*/ +/* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */ volatile u16 status;volatile u16 command; -volatile u32 link;/* struct descriptor * */ +volatile u32 link;/* struct descriptor * */ unsigned char params[0 ]; };
@@ -187,15 +178,14 @@ struct descriptor { /* A generic descriptor. */#define CONFIG_SYS_STATUS_C 0x8000#define CONFIG_SYS_STATUS_OK 0x2000 -/* Misc. -*/ +/* Misc. */ #define NUM_RX_DESC PKTBUFSRX -#define NUM_TX_DESC 1/* Number of TX descriptors */ +#define NUM_TX_DESC 1/* Number of TX descriptors */ #define TOUT_LOOP 1000000 -static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ +static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ +static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ static int rx_next;/* RX descriptor ring pointer */ static int tx_next;/* TX descriptor ring pointer */ static int tx_threshold;
@@ -293,7 +283,8 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,return 0 ; } -/* Check if given phyaddr is valid, i.e. there is a PHY connected. +/* +* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ static struct eth_device* verify_phyaddr (const char *devname,
@@ -363,8 +354,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif -/* Wait for the chip get the command. -*/ +/* Wait for the chip get the command. */ static int wait_for_eepro100 (struct eth_device *dev) {int i;
@@ -394,8 +384,7 @@ int eepro100_initialize (bd_t * bis)int idx =0 ;while (1 ) { -/* Find PCI device -*/ +/* Find PCI device */ if ((devno =pci_find_devices (supported, idx++)) <0 ) {break ; }
@@ -412,8 +401,7 @@ int eepro100_initialize (bd_t * bis)PCI_COMMAND , PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); -/* Check if I/O accesses and Bus Mastering are enabled. -*/ +/* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword (devno,PCI_COMMAND , &status);if (!(status &PCI_COMMAND_MEMORY )) {printf ("Error: Can not enable MEM access.\n" );
@@ -459,8 +447,7 @@ int eepro100_initialize (bd_t * bis) card_number++; -/* Set the latency timer for value. -*/ +/* Set the latency timer for value. */ pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 );udelay (10 *1000 );
@@ -478,8 +465,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)int tx_cur;struct descriptor *ias_cmd, *cfg_cmd; -/* Reset the ethernet controller -*/ +/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 );
@@ -500,13 +486,11 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)OUTL (dev,0 , SCBPointer);OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); -/* Initialize Rx and Tx rings. -*/ +/* Initialize Rx and Tx rings. */ init_rx_ring (dev);purge_tx_ring (dev); -/* Tell the adapter where the RX ring is located. -*/ +/* Tell the adapter where the RX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); goto Done;
@@ -550,8 +534,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) goto Done; } -/* Send the Individual Address Setup frame -*/ +/* Send the Individual Address Setup frame */ tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC );
@@ -562,8 +545,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)memcpy (ias_cmd->params, dev->enetaddr,6 ); -/* Tell the adapter where the TX ring is located. -*/ +/* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); goto Done;
@@ -626,8 +608,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto Done; } -/* Send the packet. -*/ +/* Send the packet. */ OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd);
@@ -666,21 +647,16 @@ static int eepro100_recv (struct eth_device *dev)break ; } -/* Valid frame status. -*/ +/* Valid frame status. */ if ((status &RFD_STATUS_OK )) { -/* A valid frame received. -*/ +/* A valid frame received. */ length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; -/* Pass the packet up to the protocol -* layers. -*/ +/* Pass the packet up to the protocol layers. */ net_process_received_packet ((u8 *)rx_ring[rx_next].data, length); }else { -/* There was an error. -*/ +/* There was an error. */ printf ("RX error status = 0x%08X\n" , status); }
@@ -691,8 +667,7 @@ static int eepro100_recv (struct eth_device *dev) rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; rx_ring[rx_prev].control =0 ; -/* Update entry information. -*/ +/* Update entry information. */ rx_next = (rx_next +1 ) %NUM_RX_DESC ; }
@@ -700,8 +675,7 @@ static int eepro100_recv (struct eth_device *dev)printf ("%s: Receiver is not ready, restart it !\n" , dev->name); -/* Reinitialize Rx ring. -*/ +/* Reinitialize Rx ring. */ init_rx_ring (dev);if (!wait_for_eepro100 (dev)) {
@@ -719,8 +693,7 @@ static int eepro100_recv (struct eth_device *dev)static void eepro100_halt (struct eth_device *dev) { -/* Reset the ethernet controller -*/ +/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 );
@@ -745,8 +718,7 @@ static void eepro100_halt (struct eth_device *dev)return ; } -/* SROM Read. -*/ +/* SROM Read. */ static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ;
Signature · 1 line
2.25.1
PATCH 2/30 net: eepro100: Clean up comments
Quoted 310 lines · Marek Vasut
Clean the comments up to they trigger fewer checkpatch warnings, no functional change.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 100 +++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 64 deletions(-)drivers/net/eepro100.c +36
-65@@ -15,8 +15,7 @@#undef DEBUG -/* Ethernet chip registers. -*/ +/* Ethernet chip registers. */ #define SCBStatus 0/* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */ #define SCBCmd 2/* Rx/Command Unit Command *Word* */ @@ -30,8 +29,7 @@#define SCBGenControl 28/* 82559 General Control Register */ #define SCBGenStatus 29/* 82559 General Status register */ -/* 82559 SCB status word defnitions -*/ +/* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000/* CU finished command (transmit) */ #define SCB_STATUS_FR 0x4000/* frame received */ #define SCB_STATUS_CNA 0x2000/* CU left active state */ @@ -45,8 +43,7 @@#define SCB_INTACK_TX (SCB_STATUS_CX | SCB_STATUS_CNA)#define SCB_INTACK_RX (SCB_STATUS_FR | SCB_STATUS_RNR) -/* System control block commands -*/ +/* System control block commands */ /* CU Commands */ #define CU_NOP 0x0000#define CU_START 0x0010@@ -81,16 +78,14 @@#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2))#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) -/* 82559 Port interface commands. -*/ +/* 82559 Port interface commands. */ #define I82559_RESET 0x00000000/* Software reset */ #define I82559_SELFTEST 0x00000001/* 82559 Selftest command */ #define I82559_SELECTIVE_RESET 0x00000002#define I82559_DUMP 0x00000003#define I82559_DUMP_WAKEUP 0x00000007 -/* 82559 Eeprom interface. -*/ +/* 82559 Eeprom interface. */ #define EE_SHIFT_CLK 0x01/* EEPROM shift clock. */ #define EE_CS 0x02/* EEPROM chip select. */ #define EE_DATA_WRITE 0x04/* EEPROM chip data in. */ @@ -101,15 +96,13 @@#define EE_CMD_BITS 3#define EE_DATA_BITS 16 -/* The EEPROM commands include the alway-set leading bit. -*/ +/* The EEPROM commands include the alway-set leading bit. */ #define EE_EWENB_CMD (4 << addr_len)#define EE_WRITE_CMD (5 << addr_len)#define EE_READ_CMD (6 << addr_len)#define EE_ERASE_CMD (7 << addr_len) -/* Receive frame descriptors. -*/ +/* Receive frame descriptors. */ struct RxFD {volatile u16 status;volatile u16 control;@@ -143,8 +136,7 @@ struct RxFD {#define RFD_RX_IA_MATCH 0x0002/* individual address does not match */ #define RFD_RX_TCO 0x0001/* TCO indication */ -/* Transmit frame descriptors -*/ +/* Transmit frame descriptors */ struct TxFD {/* Transmit frame descriptor set. */ volatile u16 status;volatile u16 command;@@ -152,9 +144,9 @@ struct TxFD { /* Transmit frame descriptor set. */volatile u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ volatile s32 count; -volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ +volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ volatile s32 tx_buf_size0;/* Length of Tx frame. */ -volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ +volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ volatile s32 tx_buf_size1;/* Length of Tx frame. */ };@@ -168,12 +160,11 @@ struct TxFD { /* Transmit frame descriptor set. */#define TxCB_COUNT_MASK 0x3fff#define TxCB_COUNT_EOF 0x8000 -/* The Speedo3 Rx and Tx frame/buffer descriptors. -*/ +/* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */ volatile u16 status;volatile u16 command; -volatile u32 link;/* struct descriptor * */ +volatile u32 link;/* struct descriptor * */ unsigned char params[0 ]; };@@ -187,15 +178,14 @@ struct descriptor { /* A generic descriptor. */#define CONFIG_SYS_STATUS_C 0x8000#define CONFIG_SYS_STATUS_OK 0x2000 -/* Misc. -*/ +/* Misc. */ #define NUM_RX_DESC PKTBUFSRX -#define NUM_TX_DESC 1/* Number of TX descriptors */ +#define NUM_TX_DESC 1/* Number of TX descriptors */ #define TOUT_LOOP 1000000 -static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ +static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ +static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ static int rx_next;/* RX descriptor ring pointer */ static int tx_next;/* TX descriptor ring pointer */ static int tx_threshold;@@ -293,7 +283,8 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,return 0 ; } -/* Check if given phyaddr is valid, i.e. there is a PHY connected. +/* +* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ static struct eth_device* verify_phyaddr (const char *devname,@@ -363,8 +354,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif -/* Wait for the chip get the command. -*/ +/* Wait for the chip get the command. */ static int wait_for_eepro100 (struct eth_device *dev) {int i;@@ -394,8 +384,7 @@ int eepro100_initialize (bd_t * bis)int idx =0 ;while (1 ) { -/* Find PCI device -*/ +/* Find PCI device */ if ((devno =pci_find_devices (supported, idx++)) <0 ) {break ; }@@ -412,8 +401,7 @@ int eepro100_initialize (bd_t * bis)PCI_COMMAND , PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); -/* Check if I/O accesses and Bus Mastering are enabled. -*/ +/* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword (devno,PCI_COMMAND , &status);if (!(status &PCI_COMMAND_MEMORY )) {printf ("Error: Can not enable MEM access.\n" );@@ -459,8 +447,7 @@ int eepro100_initialize (bd_t * bis) card_number++; -/* Set the latency timer for value. -*/ +/* Set the latency timer for value. */ pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 );udelay (10 *1000 );@@ -478,8 +465,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)int tx_cur;struct descriptor *ias_cmd, *cfg_cmd; -/* Reset the ethernet controller -*/ +/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 );@@ -500,13 +486,11 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)OUTL (dev,0 , SCBPointer);OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); -/* Initialize Rx and Tx rings. -*/ +/* Initialize Rx and Tx rings. */ init_rx_ring (dev);purge_tx_ring (dev); -/* Tell the adapter where the RX ring is located. -*/ +/* Tell the adapter where the RX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); goto Done;@@ -550,8 +534,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) goto Done; } -/* Send the Individual Address Setup frame -*/ +/* Send the Individual Address Setup frame */ tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC );@@ -562,8 +545,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis)memcpy (ias_cmd->params, dev->enetaddr,6 ); -/* Tell the adapter where the TX ring is located. -*/ +/* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); goto Done;@@ -626,8 +608,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto Done; } -/* Send the packet. -*/ +/* Send the packet. */ OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd);@@ -666,21 +647,16 @@ static int eepro100_recv (struct eth_device *dev)break ; } -/* Valid frame status. -*/ +/* Valid frame status. */ if ((status &RFD_STATUS_OK )) { -/* A valid frame received. -*/ +/* A valid frame received. */ length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; -/* Pass the packet up to the protocol -* layers. -*/ +/* Pass the packet up to the protocol layers. */ net_process_received_packet ((u8 *)rx_ring[rx_next].data, length); }else { -/* There was an error. -*/ +/* There was an error. */ printf ("RX error status = 0x%08X\n" , status); }@@ -691,8 +667,7 @@ static int eepro100_recv (struct eth_device *dev) rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; rx_ring[rx_prev].control =0 ; -/* Update entry information. -*/ +/* Update entry information. */ rx_next = (rx_next +1 ) %NUM_RX_DESC ; }@@ -700,8 +675,7 @@ static int eepro100_recv (struct eth_device *dev)printf ("%s: Receiver is not ready, restart it !\n" , dev->name); -/* Reinitialize Rx ring. -*/ +/* Reinitialize Rx ring. */ init_rx_ring (dev);if (!wait_for_eepro100 (dev)) {@@ -719,8 +693,7 @@ static int eepro100_recv (struct eth_device *dev)static void eepro100_halt (struct eth_device *dev) { -/* Reset the ethernet controller -*/ +/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 );@@ -745,8 +718,7 @@ static void eepro100_halt (struct eth_device *dev)return ; } -/* SROM Read. -*/ +/* SROM Read. */ static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ; --
Quoted 2 lines
2.25.1
PATCH 3/30 net: eepro100: Use plain debug()
In reply to Marek VasutConvert all the ifdef DEBUG to plain debug(), no functional change.
--- drivers/net/eepro100.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/eepro100.c +4 -11
@@ -13,8 +13,6 @@#include <miiphy.h> #include <linux/delay.h> -#undef DEBUG -/* Ethernet chip registers. */ #define SCBStatus 0/* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */
@@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis)pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ; -#ifdef DEBUG -printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , - iobase); -#endif +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , + iobase); pci_write_config_dword (devno, PCI_COMMAND,
@@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)if (sum !=0xBABA ) {memset (dev->enetaddr,0 ,ETH_ALEN ); -#ifdef DEBUG -printf ("%s: Invalid EEPROM checksum %#4.4x, " -"check settings before activating this device!\n" , - dev->name, sum); -#endif +debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , + dev->name, sum); } }
Signature · 1 line
2.25.1
PATCH 3/30 net: eepro100: Use plain debug()
Quoted 48 lines · Marek Vasut
Convert all the ifdef DEBUG to plain
debug(), no functional change.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)drivers/net/eepro100.c +4
-12@@ -13,8 +13,6 @@#include <miiphy.h> #include <linux/delay.h> -#undef DEBUG -/* Ethernet chip registers. */ #define SCBStatus 0/* Rx/Command Unit Status *Word* */ #define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */ @@ -392,10 +390,8 @@ int eepro100_initialize (bd_t * bis)pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ; -#ifdef DEBUG -printf ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , - iobase); -#endif +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , + iobase); pci_write_config_dword (devno, PCI_COMMAND,@@ -810,10 +806,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis)if (sum !=0xBABA ) {memset (dev->enetaddr,0 ,ETH_ALEN ); -#ifdef DEBUG -printf ("%s: Invalid EEPROM checksum %#4.4x, " -"check settings before activating this device!\n" , - dev->name, sum); -#endif +debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , + dev->name, sum); } } --
Quoted 2 lines
2.25.1
PATCH 4/30 net: eepro100: Fix spacing
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types SPACING -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 278 ++++++++++++++++++++--------------------- 1 file changed, 139 insertions(+), 139 deletions(-)
drivers/net/eepro100.c +139 -139
@@ -68,13 +68,13 @@#define CU_STATUS_MASK 0x00C0#define RU_STATUS_MASK 0x003C -#define RU_STATUS_IDLE (0<<2) -#define RU_STATUS_SUS (1<<2) -#define RU_STATUS_NORES (2<<2) -#define RU_STATUS_READY (4<<2) -#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) +#define RU_STATUS_IDLE (0 << 2) +#define RU_STATUS_SUS (1 << 2) +#define RU_STATUS_NORES (2 << 2) +#define RU_STATUS_READY (4 << 2) +#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2))/* 82559 Port interface commands. */ #define I82559_RESET 0x00000000/* Software reset */
@@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); +static void init_rx_ring (struct eth_device *dev); +static void purge_tx_ring (struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev,bd_t * bis); +static void read_hw_addr (struct eth_device *dev,bd_t * bis); -static int eepro100_init (struct eth_device *dev,bd_t * bis); +static int eepro100_init (struct eth_device *dev,bd_t * bis);static int eepro100_send (struct eth_device *dev,void *packet,int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); +static int eepro100_recv (struct eth_device *dev); +static void eepro100_halt (struct eth_device *dev);#if defined(CONFIG_E500 )#define bus_to_phys (a) (a)
@@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev);#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a)#endif -static inline int INW (struct eth_device *dev,u_long addr) +static inline int INW (struct eth_device *dev,u_long addr) {return le16_to_cpu (*(volatile u16 *)(addr + (u_long )dev->iobase)); } -static inline void OUTW (struct eth_device *dev,int command,u_long addr) +static inline void OUTW (struct eth_device *dev,int command,u_long addr) { *(volatile u16 *)((addr + (u_long )dev->iobase)) =cpu_to_le16 (command); } -static inline void OUTL (struct eth_device *dev,int command,u_long addr) +static inline void OUTL (struct eth_device *dev,int command,u_long addr) { *(volatile u32 *)((addr + (u_long )dev->iobase)) =cpu_to_le32 (command); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static inline int INL (struct eth_device *dev,u_long addr) +static inline int INL (struct eth_device *dev,u_long addr) {return le32_to_cpu (*(volatile u32 *)(addr + (u_long )dev->iobase)); } -static int get_phyreg (struct eth_device *dev,unsigned char addr, +static int get_phyreg (struct eth_device *dev,unsigned char addr,unsigned char reg,unsigned short *value) {int cmd;
@@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned char addr,/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd, SCBCtrlMDI); +OUTL (dev, cmd, SCBCtrlMDI);do {udelay (1000 ); - cmd =INL (dev, SCBCtrlMDI); + cmd =INL (dev, SCBCtrlMDI); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )return -1 ; - *value = (unsigned short ) (cmd &0xffff ); + *value = (unsigned short )(cmd &0xffff );return 0 ; } -static int set_phyreg (struct eth_device *dev,unsigned char addr, +static int set_phyreg (struct eth_device *dev,unsigned char addr,unsigned char reg,unsigned short value) {int cmd;
@@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value, SCBCtrlMDI); +OUTL (dev, cmd | value, SCBCtrlMDI); -while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout)) +while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )
@@ -285,7 +285,7 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, +static struct eth_device *verify_phyaddr (const char *devname,unsigned char addr) {struct eth_device *dev;
@@ -353,11 +353,11 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif /* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static int wait_for_eepro100 (struct eth_device *dev) {int i; -for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP ) {return 0 ; }
@@ -373,7 +373,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize (bd_t * bis) +int eepro100_initialize (bd_t * bis) {pci_dev_t devno;int card_number =0 ;
@@ -383,50 +383,50 @@ int eepro100_initialize (bd_t * bis)while (1 ) {/* Find PCI device */ -if ((devno =pci_find_devices (supported, idx++)) <0 ) { +if ((devno =pci_find_devices (supported, idx++)) <0 ) {break ; } -pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); +pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ;debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); -pci_write_config_dword (devno, +pci_write_config_dword (devno,PCI_COMMAND ,PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */ -pci_read_config_dword (devno,PCI_COMMAND , &status); +pci_read_config_dword (devno,PCI_COMMAND , &status);if (!(status &PCI_COMMAND_MEMORY )) { -printf ("Error: Can not enable MEM access.\n" ); +printf ("Error: Can not enable MEM access.\n" );continue ; }if (!(status &PCI_COMMAND_MASTER )) { -printf ("Error: Can not enable Bus Mastering.\n" ); +printf ("Error: Can not enable Bus Mastering.\n" );continue ; } - dev = (struct eth_device *)malloc (sizeof *dev); + dev = (struct eth_device *)malloc (sizeof *dev);if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ; }memset (dev,0 ,sizeof (*dev)); -sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *) devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); +sprintf (dev->name,"i82559#%d" , card_number); + dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ + dev->iobase =bus_to_phys (iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; dev->recv = eepro100_recv; -eth_register (dev); +eth_register (dev); -#if defined (CONFIG_MII ) || defined(CONFIG_CMD_MII ) +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )/* register mii command access routines */ int retval;struct mii_dev *mdiodev =mdio_alloc ();
@@ -444,89 +444,89 @@ int eepro100_initialize (bd_t * bis) card_number++;/* Set the latency timer for value. */ -pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); +pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 );udelay (10 *1000 ); -read_hw_addr (dev, bis); +read_hw_addr (dev, bis); }return card_number; } -static int eepro100_init (struct eth_device *dev,bd_t * bis) +static int eepro100_init (struct eth_device *dev,bd_t * bis) {int i, status =-1 ;int tx_cur;struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET , SCBPort);udelay (20 ); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd);/* Initialize Rx and Tx rings. */ -init_rx_ring (dev); -purge_tx_ring (dev); +init_rx_ring (dev); +purge_tx_ring (dev);/* Tell the adapter where the RX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); +OUTW (dev,SCB_M |RUC_START , SCBCmd);/* Send the Configure frame */ tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - cfg_cmd = (struct descriptor *) &tx_ring[tx_cur]; + cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE )); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (cfg_cmd->params, i82558_config_cmd, -sizeof (i82558_config_cmd)); +memcpy (cfg_cmd->params, i82558_config_cmd, +sizeof (i82558_config_cmd)); -if (!wait_for_eepro100 (dev)) { -printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd);for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
@@ -534,34 +534,34 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - ias_cmd = (struct descriptor *) &tx_ring[tx_cur]; + ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS )); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (ias_cmd->params, dev->enetaddr,6 ); +memcpy (ias_cmd->params, dev->enetaddr,6 );/* Tell the adapter where the TX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); +for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
@@ -577,48 +577,48 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)int tx_cur;if (length <=0 ) { -printf ("%s: bad packet size: %d\n" , dev->name, length); +printf ("%s: bad packet size: %d\n" , dev->name, length); goto Done; } tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 ( TxCB_CMD_TRANSMIT | + tx_ring[tx_cur].command =cpu_to_le16 (TxCB_CMD_TRANSMIT | TxCB_CMD_SF | TxCB_CMD_S | - TxCB_CMD_EL ); + TxCB_CMD_EL); tx_ring[tx_cur].status =0 ; tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link = -cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); +cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); tx_ring[tx_cur].tx_desc_addr = -cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_cur].tx_buf_addr0)); +cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_cur].tx_buf_addr0)); tx_ring[tx_cur].tx_buf_addr0 = -cpu_to_le32 (phys_to_bus ((u_long ) packet)); +cpu_to_le32 (phys_to_bus ((u_long )packet)); tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); -if (!wait_for_eepro100 (dev)) { -printf ("%s: Tx error ethernet controller not ready.\n" , +if (!wait_for_eepro100 (dev)) { +printf ("%s: Tx error ethernet controller not ready.\n" , dev->name); goto Done; }/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); +for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
@@ -628,16 +628,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)return status; } -static int eepro100_recv (struct eth_device *dev) +static int eepro100_recv (struct eth_device *dev) {u16 status, stat;int rx_prev, length =0 ; - stat =INW (dev, SCBStatus); -OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus); + stat =INW (dev, SCBStatus); +OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus);for (;;) { - status =le16_to_cpu (rx_ring[rx_next].status); + status =le16_to_cpu (rx_ring[rx_next].status);if (!(status &RFD_STATUS_C )) {break ;
@@ -646,14 +646,14 @@ static int eepro100_recv (struct eth_device *dev)/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {/* A valid frame received. */ - length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; + length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ;/* Pass the packet up to the protocol layers. */ net_process_received_packet ((u8 *)rx_ring[rx_next].data, length); }else {/* There was an error. */ -printf ("RX error status = 0x%08X\n" , status); +printf ("RX error status = 0x%08X\n" , status); } rx_ring[rx_next].control =cpu_to_le16 (RFD_CONTROL_S );
@@ -669,87 +669,87 @@ static int eepro100_recv (struct eth_device *dev)if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name); +printf ("%s: Receiver is not ready, restart it !\n" , dev->name);/* Reinitialize Rx ring. */ -init_rx_ring (dev); +init_rx_ring (dev); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not restart ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not restart ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); +OUTW (dev,SCB_M |RUC_START , SCBCmd); } Done:return length; } -static void eepro100_halt (struct eth_device *dev) +static void eepro100_halt (struct eth_device *dev) {/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET , SCBPort);udelay (20 ); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); Done:return ; }/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ;int read_cmd = location |EE_READ_CMD ;int i; -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB , SCBeeprom);/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); +OUTW (dev,EE_ENB | dataval, SCBeeprom);udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom);udelay (1 ); } -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB , SCBeeprom);for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom);udelay (1 ); retval = (retval <<1 ) | - ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB , SCBeeprom); + ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB , SCBeeprom);udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom);return retval; } -static void init_rx_ring (struct eth_device *dev) +static void init_rx_ring (struct eth_device *dev) {int i;
@@ -759,7 +759,7 @@ static void init_rx_ring (struct eth_device *dev) (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link =cpu_to_le32 (phys_to_bus - ((u32) & rx_ring[(i +1 ) %NUM_RX_DESC ])); + ((u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); }
@@ -767,7 +767,7 @@ static void init_rx_ring (struct eth_device *dev) rx_next =0 ; } -static void purge_tx_ring (struct eth_device *dev) +static void purge_tx_ring (struct eth_device *dev) {int i;
@@ -788,14 +788,14 @@ static void purge_tx_ring (struct eth_device *dev) } } -static void read_hw_addr (struct eth_device *dev,bd_t * bis) +static void read_hw_addr (struct eth_device *dev,bd_t * bis) {u16 sum =0 ;int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; +int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ;for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); +u16 value =read_eeprom (dev, i, addr_len); sum += value;if (i <3 ) {
@@ -805,7 +805,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) }if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); +memset (dev->enetaddr,0 ,ETH_ALEN );debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , dev->name, sum); }
Signature · 1 line
2.25.1
PATCH 4/30 net: eepro100: Fix spacing
Quoted 658 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--types SPACING -f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 278 ++++++++++++++++++++--------------------- 1 file changed, 139 insertions(+), 139 deletions(-)drivers/net/eepro100.c +139
-140@@ -68,13 +68,13 @@#define CU_STATUS_MASK 0x00C0#define RU_STATUS_MASK 0x003C -#define RU_STATUS_IDLE (0<<2) -#define RU_STATUS_SUS (1<<2) -#define RU_STATUS_NORES (2<<2) -#define RU_STATUS_READY (4<<2) -#define RU_STATUS_NO_RBDS_SUS ((1<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_NORES ((2<<2)|(8<<2)) -#define RU_STATUS_NO_RBDS_READY ((4<<2)|(8<<2)) +#define RU_STATUS_IDLE (0 << 2) +#define RU_STATUS_SUS (1 << 2) +#define RU_STATUS_NORES (2 << 2) +#define RU_STATUS_READY (4 << 2) +#define RU_STATUS_NO_RBDS_SUS ((1 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_NORES ((2 << 2) | (8 << 2)) +#define RU_STATUS_NO_RBDS_READY ((4 << 2) | (8 << 2))/* 82559 Port interface commands. */ #define I82559_RESET 0x00000000/* Software reset */ @@ -200,15 +200,15 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); +static void init_rx_ring (struct eth_device *dev); +static void purge_tx_ring (struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev,bd_t * bis); +static void read_hw_addr (struct eth_device *dev,bd_t * bis); -static int eepro100_init (struct eth_device *dev,bd_t * bis); +static int eepro100_init (struct eth_device *dev,bd_t * bis);static int eepro100_send (struct eth_device *dev,void *packet,int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); +static int eepro100_recv (struct eth_device *dev); +static void eepro100_halt (struct eth_device *dev);#if defined(CONFIG_E500 )#define bus_to_phys (a) (a)@@ -218,28 +218,28 @@ static void eepro100_halt (struct eth_device *dev);#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a)#endif -static inline int INW (struct eth_device *dev,u_long addr) +static inline int INW (struct eth_device *dev,u_long addr) {return le16_to_cpu (*(volatile u16 *)(addr + (u_long )dev->iobase)); } -static inline void OUTW (struct eth_device *dev,int command,u_long addr) +static inline void OUTW (struct eth_device *dev,int command,u_long addr) { *(volatile u16 *)((addr + (u_long )dev->iobase)) =cpu_to_le16 (command); } -static inline void OUTL (struct eth_device *dev,int command,u_long addr) +static inline void OUTL (struct eth_device *dev,int command,u_long addr) { *(volatile u32 *)((addr + (u_long )dev->iobase)) =cpu_to_le32 (command); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static inline int INL (struct eth_device *dev,u_long addr) +static inline int INL (struct eth_device *dev,u_long addr) {return le32_to_cpu (*(volatile u32 *)(addr + (u_long )dev->iobase)); } -static int get_phyreg (struct eth_device *dev,unsigned char addr, +static int get_phyreg (struct eth_device *dev,unsigned char addr,unsigned char reg,unsigned short *value) {int cmd;@@ -247,22 +247,22 @@ static int get_phyreg (struct eth_device *dev, unsigned char addr,/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd, SCBCtrlMDI); +OUTL (dev, cmd, SCBCtrlMDI);do {udelay (1000 ); - cmd =INL (dev, SCBCtrlMDI); + cmd =INL (dev, SCBCtrlMDI); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )return -1 ; - *value = (unsigned short ) (cmd &0xffff ); + *value = (unsigned short )(cmd &0xffff );return 0 ; } -static int set_phyreg (struct eth_device *dev,unsigned char addr, +static int set_phyreg (struct eth_device *dev,unsigned char addr,unsigned char reg,unsigned short value) {int cmd;@@ -270,9 +270,9 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value, SCBCtrlMDI); +OUTL (dev, cmd | value, SCBCtrlMDI); -while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout)) +while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )@@ -285,7 +285,7 @@ static int set_phyreg (struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, +static struct eth_device *verify_phyaddr (const char *devname,unsigned char addr) {struct eth_device *dev;@@ -353,11 +353,11 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif /* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static int wait_for_eepro100 (struct eth_device *dev) {int i; -for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP ) {return 0 ; }@@ -373,7 +373,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize (bd_t * bis) +int eepro100_initialize (bd_t * bis) {pci_dev_t devno;int card_number =0 ;@@ -383,50 +383,50 @@ int eepro100_initialize (bd_t * bis)while (1 ) {/* Find PCI device */ -if ((devno =pci_find_devices (supported, idx++)) <0 ) { +if ((devno =pci_find_devices (supported, idx++)) <0 ) {break ; } -pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); +pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ;debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); -pci_write_config_dword (devno, +pci_write_config_dword (devno,PCI_COMMAND ,PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */ -pci_read_config_dword (devno,PCI_COMMAND , &status); +pci_read_config_dword (devno,PCI_COMMAND , &status);if (!(status &PCI_COMMAND_MEMORY )) { -printf ("Error: Can not enable MEM access.\n" ); +printf ("Error: Can not enable MEM access.\n" );continue ; }if (!(status &PCI_COMMAND_MASTER )) { -printf ("Error: Can not enable Bus Mastering.\n" ); +printf ("Error: Can not enable Bus Mastering.\n" );continue ; } - dev = (struct eth_device *)malloc (sizeof *dev); + dev = (struct eth_device *)malloc (sizeof *dev);if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ; }memset (dev,0 ,sizeof (*dev)); -sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *) devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); +sprintf (dev->name,"i82559#%d" , card_number); + dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ + dev->iobase =bus_to_phys (iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; dev->recv = eepro100_recv; -eth_register (dev); +eth_register (dev); -#if defined (CONFIG_MII ) || defined(CONFIG_CMD_MII ) +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )/* register mii command access routines */ int retval;struct mii_dev *mdiodev =mdio_alloc ();@@ -444,89 +444,89 @@ int eepro100_initialize (bd_t * bis) card_number++;/* Set the latency timer for value. */ -pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); +pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 );udelay (10 *1000 ); -read_hw_addr (dev, bis); +read_hw_addr (dev, bis); }return card_number; } -static int eepro100_init (struct eth_device *dev,bd_t * bis) +static int eepro100_init (struct eth_device *dev,bd_t * bis) {int i, status =-1 ;int tx_cur;struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET , SCBPort);udelay (20 ); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd);/* Initialize Rx and Tx rings. */ -init_rx_ring (dev); -purge_tx_ring (dev); +init_rx_ring (dev); +purge_tx_ring (dev);/* Tell the adapter where the RX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); +OUTW (dev,SCB_M |RUC_START , SCBCmd);/* Send the Configure frame */ tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - cfg_cmd = (struct descriptor *) &tx_ring[tx_cur]; + cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE )); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (cfg_cmd->params, i82558_config_cmd, -sizeof (i82558_config_cmd)); +memcpy (cfg_cmd->params, i82558_config_cmd, +sizeof (i82558_config_cmd)); -if (!wait_for_eepro100 (dev)) { -printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd);for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }@@ -534,34 +534,34 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - ias_cmd = (struct descriptor *) &tx_ring[tx_cur]; + ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS )); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (ias_cmd->params, dev->enetaddr,6 ); +memcpy (ias_cmd->params, dev->enetaddr,6 );/* Tell the adapter where the TX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); +for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }@@ -577,48 +577,48 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)int tx_cur;if (length <=0 ) { -printf ("%s: bad packet size: %d\n" , dev->name, length); +printf ("%s: bad packet size: %d\n" , dev->name, length); goto Done; } tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 ( TxCB_CMD_TRANSMIT | + tx_ring[tx_cur].command =cpu_to_le16 (TxCB_CMD_TRANSMIT | TxCB_CMD_SF | TxCB_CMD_S | - TxCB_CMD_EL ); + TxCB_CMD_EL); tx_ring[tx_cur].status =0 ; tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link = -cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_next])); +cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); tx_ring[tx_cur].tx_desc_addr = -cpu_to_le32 (phys_to_bus ((u32) & tx_ring[tx_cur].tx_buf_addr0)); +cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_cur].tx_buf_addr0)); tx_ring[tx_cur].tx_buf_addr0 = -cpu_to_le32 (phys_to_bus ((u_long ) packet)); +cpu_to_le32 (phys_to_bus ((u_long )packet)); tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); -if (!wait_for_eepro100 (dev)) { -printf ("%s: Tx error ethernet controller not ready.\n" , +if (!wait_for_eepro100 (dev)) { +printf ("%s: Tx error ethernet controller not ready.\n" , dev->name); goto Done; }/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32) & tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); +OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); +for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done; } } -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }@@ -628,16 +628,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)return status; } -static int eepro100_recv (struct eth_device *dev) +static int eepro100_recv (struct eth_device *dev) {u16 status, stat;int rx_prev, length =0 ; - stat =INW (dev, SCBStatus); -OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus); + stat =INW (dev, SCBStatus); +OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus);for (;;) { - status =le16_to_cpu (rx_ring[rx_next].status); + status =le16_to_cpu (rx_ring[rx_next].status);if (!(status &RFD_STATUS_C )) {break ;@@ -646,14 +646,14 @@ static int eepro100_recv (struct eth_device *dev)/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {/* A valid frame received. */ - length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; + length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ;/* Pass the packet up to the protocol layers. */ net_process_received_packet ((u8 *)rx_ring[rx_next].data, length); }else {/* There was an error. */ -printf ("RX error status = 0x%08X\n" , status); +printf ("RX error status = 0x%08X\n" , status); } rx_ring[rx_next].control =cpu_to_le16 (RFD_CONTROL_S );@@ -669,87 +669,87 @@ static int eepro100_recv (struct eth_device *dev)if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name); +printf ("%s: Receiver is not ready, restart it !\n" , dev->name);/* Reinitialize Rx ring. */ -init_rx_ring (dev); +init_rx_ring (dev); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not restart ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not restart ethernet controller.\n" ); goto Done; } -OUTL (dev,phys_to_bus ((u32) & rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); +OUTW (dev,SCB_M |RUC_START , SCBCmd); } Done:return length; } -static void eepro100_halt (struct eth_device *dev) +static void eepro100_halt (struct eth_device *dev) {/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET , SCBPort);udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET , SCBPort);udelay (20 ); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); +if (!wait_for_eepro100 (dev)) { +printf ("Error: Can not reset ethernet controller.\n" ); goto Done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 , SCBPointer); +OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); Done:return ; }/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ;int read_cmd = location |EE_READ_CMD ;int i; -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB , SCBeeprom);/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); +OUTW (dev,EE_ENB | dataval, SCBeeprom);udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom);udelay (1 ); } -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB , SCBeeprom);for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom);udelay (1 ); retval = (retval <<1 ) | - ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB , SCBeeprom); + ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB , SCBeeprom);udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom);return retval; } -static void init_rx_ring (struct eth_device *dev) +static void init_rx_ring (struct eth_device *dev) {int i;@@ -759,7 +759,7 @@ static void init_rx_ring (struct eth_device *dev) (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link =cpu_to_le32 (phys_to_bus - ((u32) & rx_ring[(i +1 ) %NUM_RX_DESC ])); + ((u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); }@@ -767,7 +767,7 @@ static void init_rx_ring (struct eth_device *dev) rx_next =0 ; } -static void purge_tx_ring (struct eth_device *dev) +static void purge_tx_ring (struct eth_device *dev) {int i;@@ -788,14 +788,14 @@ static void purge_tx_ring (struct eth_device *dev) } } -static void read_hw_addr (struct eth_device *dev,bd_t * bis) +static void read_hw_addr (struct eth_device *dev,bd_t * bis) {u16 sum =0 ;int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; +int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ;for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); +u16 value =read_eeprom (dev, i, addr_len); sum += value;if (i <3 ) {@@ -805,7 +805,7 @@ static void read_hw_addr (struct eth_device *dev, bd_t * bis) }if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); +memset (dev->enetaddr,0 ,ETH_ALEN );debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , dev->name, sum); } --
Quoted 2 lines
2.25.1
PATCH 5/30 net: eepro100: Fix braces
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types BRACES -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
drivers/net/eepro100.c +4 -7
@@ -358,9 +358,8 @@ static int wait_for_eepro100(struct eth_device *dev)int i;for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { -if (i >=TOUT_LOOP ) { +if (i >=TOUT_LOOP )return 0 ; - } }return 1 ;
@@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis)while (1 ) {/* Find PCI device */ -if ((devno =pci_find_devices (supported, idx++)) <0 ) { + devno =pci_find_devices (supported, idx++); +if (devno <0 )break ; - }pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ;
@@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev)for (;;) { status =le16_to_cpu (rx_ring[rx_next].status); -if (!(status &RFD_STATUS_C )) { +if (!(status &RFD_STATUS_C ))break ; - }/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {
@@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev) }if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name);/* Reinitialize Rx ring. */
Signature · 1 line
2.25.1
PATCH 5/30 net: eepro100: Fix braces
Quoted 57 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--types BRACES -f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)drivers/net/eepro100.c +4
-8@@ -358,9 +358,8 @@ static int wait_for_eepro100(struct eth_device *dev)int i;for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { -if (i >=TOUT_LOOP ) { +if (i >=TOUT_LOOP )return 0 ; - } }return 1 ;@@ -383,9 +382,9 @@ int eepro100_initialize(bd_t * bis)while (1 ) {/* Find PCI device */ -if ((devno =pci_find_devices (supported, idx++)) <0 ) { + devno =pci_find_devices (supported, idx++); +if (devno <0 )break ; - }pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); iobase &= ~0xf ;@@ -639,9 +638,8 @@ static int eepro100_recv(struct eth_device *dev)for (;;) { status =le16_to_cpu (rx_ring[rx_next].status); -if (!(status &RFD_STATUS_C )) { +if (!(status &RFD_STATUS_C ))break ; - }/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {@@ -668,7 +666,6 @@ static int eepro100_recv(struct eth_device *dev) }if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name);/* Reinitialize Rx ring. */ --
Quoted 2 lines
2.25.1
PATCH 6/30 net: eepro100: Fix parenthesis alignment
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types PARENTHESIS_ALIGNMENT -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/net/eepro100.c +10 -10
@@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr) }static int get_phyreg (struct eth_device *dev,unsigned char addr, -unsigned char reg,unsigned short *value) +unsigned char reg,unsigned short *value) {int cmd;int timeout =50 ;
@@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, }static int set_phyreg (struct eth_device *dev,unsigned char addr, -unsigned char reg,unsigned short value) +unsigned char reg,unsigned short value) {int cmd;int timeout =50 ;
@@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Do this by checking model value field from ID2 register. */ static struct eth_device *verify_phyaddr (const char *devname, -unsigned char addr) +unsigned char addr) {struct eth_device *dev;unsigned short value;
@@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis) iobase);pci_write_config_dword (devno, -PCI_COMMAND , +PCI_COMMAND ,PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */
@@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (cfg_cmd->params, i82558_config_cmd, -sizeof (i82558_config_cmd)); +sizeof (i82558_config_cmd));if (!wait_for_eepro100 (dev)) {printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" );
@@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis)if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
@@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , - dev->name); + dev->name); goto Done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
@@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!wait_for_eepro100 (dev)) {printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); + dev->name); goto Done; }
@@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }
Signature · 1 line
2.25.1
PATCH 6/30 net: eepro100: Fix parenthesis alignment
Quoted 104 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--typesPARENTHESIS_ALIGNMENT-f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)drivers/net/eepro100.c +10
-11@@ -240,7 +240,7 @@ static inline int INL(struct eth_device *dev, u_long addr) }static int get_phyreg (struct eth_device *dev,unsigned char addr, -unsigned char reg,unsigned short *value) +unsigned char reg,unsigned short *value) {int cmd;int timeout =50 ;@@ -263,7 +263,7 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr, }static int set_phyreg (struct eth_device *dev,unsigned char addr, -unsigned char reg,unsigned short value) +unsigned char reg,unsigned short value) {int cmd;int timeout =50 ;@@ -286,7 +286,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Do this by checking model value field from ID2 register. */ static struct eth_device *verify_phyaddr (const char *devname, -unsigned char addr) +unsigned char addr) {struct eth_device *dev;unsigned short value;@@ -393,7 +393,7 @@ int eepro100_initialize(bd_t * bis) iobase);pci_write_config_dword (devno, -PCI_COMMAND , +PCI_COMMAND ,PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */ @@ -504,7 +504,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (cfg_cmd->params, i82558_config_cmd, -sizeof (i82558_config_cmd)); +sizeof (i82558_config_cmd));if (!wait_for_eepro100 (dev)) {printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" );@@ -525,7 +525,7 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis)if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }@@ -553,14 +553,14 @@ static int eepro100_init(struct eth_device *dev, bd_t * bis) i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , - dev->name); + dev->name); goto Done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; }@@ -599,7 +599,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!wait_for_eepro100 (dev)) {printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); + dev->name); goto Done; }@@ -617,7 +617,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); +le16_to_cpu (tx_ring[tx_cur].status)); goto Done; } --
Quoted 2 lines
2.25.1
PATCH 7/30 net: eepro100: Fix pointer location
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types POINTER_LOCATION -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/eepro100.c +6 -6
@@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = {static void init_rx_ring (struct eth_device *dev);static void purge_tx_ring (struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev,bd_t * bis); +static void read_hw_addr (struct eth_device *dev,bd_t *bis); -static int eepro100_init (struct eth_device *dev,bd_t * bis); +static int eepro100_init (struct eth_device *dev,bd_t *bis);static int eepro100_send (struct eth_device *dev,void *packet,int length);static int eepro100_recv (struct eth_device *dev);static void eepro100_halt (struct eth_device *dev);
@@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, +static struct eth_device *verify_phyaddr (const char *devname,unsigned char addr) {struct eth_device *dev;
@@ -372,7 +372,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize (bd_t * bis) +int eepro100_initialize (bd_t *bis) {pci_dev_t devno;int card_number =0 ;
@@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis) } -static int eepro100_init (struct eth_device *dev,bd_t * bis) +static int eepro100_init (struct eth_device *dev,bd_t *bis) {int i, status =-1 ;int tx_cur;
@@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev) } } -static void read_hw_addr (struct eth_device *dev,bd_t * bis) +static void read_hw_addr (struct eth_device *dev,bd_t *bis) {u16 sum =0 ;int i, j;
Signature · 1 line
2.25.1
PATCH 7/30 net: eepro100: Fix pointer location
Quoted 63 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--typesPOINTER_LOCATION-f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)drivers/net/eepro100.c +6
-7@@ -203,9 +203,9 @@ static const char i82558_config_cmd[] = {static void init_rx_ring (struct eth_device *dev);static void purge_tx_ring (struct eth_device *dev); -static void read_hw_addr (struct eth_device *dev,bd_t * bis); +static void read_hw_addr (struct eth_device *dev,bd_t *bis); -static int eepro100_init (struct eth_device *dev,bd_t * bis); +static int eepro100_init (struct eth_device *dev,bd_t *bis);static int eepro100_send (struct eth_device *dev,void *packet,int length);static int eepro100_recv (struct eth_device *dev);static void eepro100_halt (struct eth_device *dev);@@ -285,7 +285,7 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, +static struct eth_device *verify_phyaddr (const char *devname,unsigned char addr) {struct eth_device *dev;@@ -372,7 +372,7 @@ static struct pci_device_id supported[] = { {} }; -int eepro100_initialize (bd_t * bis) +int eepro100_initialize (bd_t *bis) {pci_dev_t devno;int card_number =0 ;@@ -454,7 +454,7 @@ int eepro100_initialize(bd_t * bis) } -static int eepro100_init (struct eth_device *dev,bd_t * bis) +static int eepro100_init (struct eth_device *dev,bd_t *bis) {int i, status =-1 ;int tx_cur;@@ -785,7 +785,7 @@ static void purge_tx_ring(struct eth_device *dev) } } -static void read_hw_addr (struct eth_device *dev,bd_t * bis) +static void read_hw_addr (struct eth_device *dev,bd_t *bis) {u16 sum =0 ;int i, j; --
Quoted 2 lines
2.25.1
PATCH 8/30 net: eepro100: Fix indented label
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/eepro100.c +4 -4
@@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) status =0 ; - Done: +Done:return status; }
@@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) status = length; - Done: +Done:return status; }
@@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev)OUTW (dev,SCB_M |RUC_START , SCBCmd); } - Done: +Done:return length; }
@@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev)OUTL (dev,0 , SCBPointer);OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); - Done: +Done:return ; }
Signature · 1 line
2.25.1
PATCH 8/30 net: eepro100: Fix indented label
Quoted 51 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--typesINDENTED_LABEL-f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/eepro100.c +4
-5@@ -566,7 +566,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) status =0 ; - Done: +Done:return status; }@@ -623,7 +623,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) status = length; - Done: +Done:return status; }@@ -680,7 +680,7 @@ static int eepro100_recv(struct eth_device *dev)OUTW (dev,SCB_M |RUC_START , SCBCmd); } - Done: +Done:return length; }@@ -707,7 +707,7 @@ static void eepro100_halt(struct eth_device *dev)OUTL (dev,0 , SCBPointer);OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); - Done: +Done:return ; } --
Quoted 2 lines
2.25.1
PATCH 9/30 net: eepro100: Fix remaining checkpatch issues
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl -f --fix --fix-inplace drivers/net/eepro100.c
This fixes all the remaining errors except a couple of comments which are longer than 80 characters, all the volatile misuse and all the camelcase, that needs a separate patch.
--- drivers/net/eepro100.c | 45 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
drivers/net/eepro100.c +24 -21
@@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char *devname,unsigned char model; dev =eth_get_dev_by_name (devname); -if (dev ==NULL ) { +if (!dev) {printf ("%s: no such device\n" , devname);return NULL ; }
@@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,struct eth_device *dev; dev =verify_phyaddr (bus->name, addr); -if (dev ==NULL ) +if (!dev)return -1 ;if (get_phyreg (dev, addr, reg, &value) !=0 ) {
@@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,struct eth_device *dev; dev =verify_phyaddr (bus->name, addr); -if (dev ==NULL ) +if (!dev)return -1 ;if (set_phyreg (dev, addr, reg, value) !=0 ) {
@@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis)debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); -pci_write_config_dword (devno, -PCI_COMMAND , -PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); +pci_write_config_dword (devno,PCI_COMMAND , +PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword (devno,PCI_COMMAND , &status);
@@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev = (struct eth_device *)malloc (sizeof *dev); + dev = (struct eth_device *)malloc (sizeof (*dev));if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ;
@@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis)/* register mii command access routines */ int retval;struct mii_dev *mdiodev =mdio_alloc (); +if (!mdiodev)return -ENOMEM ;strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN );
@@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis)return card_number; } -static int eepro100_init (struct eth_device *dev,bd_t *bis) {int i, status =-1 ;
@@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next +1 ) %NUM_TX_DESC ); cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; - cfg_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE )); + cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND | +CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (cfg_cmd->params, i82558_config_cmd,sizeof (i82558_config_cmd));
@@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next +1 ) %NUM_TX_DESC ); ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; - ias_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS )); + ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND | +CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (ias_cmd->params, dev->enetaddr,6 );
@@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { +for (i =0 ; + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name);
@@ -607,8 +609,9 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { +for (i =0 ; + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done;
@@ -752,13 +755,13 @@ static void init_rx_ring(struct eth_device *dev)for (i =0 ; i <NUM_RX_DESC ; i++) { rx_ring[i].status =0 ; - rx_ring[i].control = - (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; + rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? +cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus - ((u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); +cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; - rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); + rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } rx_next =0 ;
Signature · 1 line
2.25.1
PATCH 9/30 net: eepro100: Fix remaining checkpatch issues
Quoted 152 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl-f --fix --fix-inplacedrivers/net/eepro100.cThis fixes all the remaining errors except a couple of comments which are longer than 80 characters, all the volatile misuse and all the camelcase, that needs a separate patch.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 45 ++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 21 deletions(-)drivers/net/eepro100.c +24
-22@@ -293,7 +293,7 @@ static struct eth_device *verify_phyaddr(const char *devname,unsigned char model; dev =eth_get_dev_by_name (devname); -if (dev ==NULL ) { +if (!dev) {printf ("%s: no such device\n" , devname);return NULL ; }@@ -322,7 +322,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,struct eth_device *dev; dev =verify_phyaddr (bus->name, addr); -if (dev ==NULL ) +if (!dev)return -1 ;if (get_phyreg (dev, addr, reg, &value) !=0 ) {@@ -339,7 +339,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,struct eth_device *dev; dev =verify_phyaddr (bus->name, addr); -if (dev ==NULL ) +if (!dev)return -1 ;if (set_phyreg (dev, addr, reg, value) !=0 ) {@@ -392,9 +392,8 @@ int eepro100_initialize(bd_t *bis)debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); -pci_write_config_dword (devno, -PCI_COMMAND , -PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); +pci_write_config_dword (devno,PCI_COMMAND , +PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER );/* Check if I/O accesses and Bus Mastering are enabled. */ pci_read_config_dword (devno,PCI_COMMAND , &status);@@ -408,7 +407,7 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev = (struct eth_device *)malloc (sizeof *dev); + dev = (struct eth_device *)malloc (sizeof (*dev));if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ;@@ -429,6 +428,7 @@ int eepro100_initialize(bd_t *bis)/* register mii command access routines */ int retval;struct mii_dev *mdiodev =mdio_alloc (); +if (!mdiodev)return -ENOMEM ;strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN );@@ -453,7 +453,6 @@ int eepro100_initialize(bd_t *bis)return card_number; } -static int eepro100_init (struct eth_device *dev,bd_t *bis) {int i, status =-1 ;@@ -499,9 +498,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next +1 ) %NUM_TX_DESC ); cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; - cfg_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE )); + cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND | +CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (cfg_cmd->params, i82558_config_cmd,sizeof (i82558_config_cmd));@@ -534,9 +534,10 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_next = ((tx_next +1 ) %NUM_TX_DESC ); ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; - ias_cmd->command =cpu_to_le16 ((CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS )); + ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND | +CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next]));memcpy (ias_cmd->params, dev->enetaddr,6 );@@ -549,8 +550,9 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { +for (i =0 ; + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name);@@ -607,8 +609,9 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer);OUTW (dev,SCB_M |CU_START , SCBCmd); -for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { +for (i =0 ; + !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); + i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); goto Done;@@ -752,13 +755,13 @@ static void init_rx_ring(struct eth_device *dev)for (i =0 ; i <NUM_RX_DESC ; i++) { rx_ring[i].status =0 ; - rx_ring[i].control = - (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; + rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? +cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus - ((u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); +cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; - rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); + rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } rx_next =0 ; --
Quoted 2 lines
2.25.1
PATCH 10/30 net: eepro100: Fix camelcase
In reply to Marek VasutThis is automated cleanup via checkpatch, no functional change. ./scripts/checkpatch.pl --show-types -f drivers/net/eepro100.c ./scripts/checkpatch.pl --types INDENTED_LABEL -f --fix --fix-inplace drivers/net/eepro100.c
--- drivers/net/eepro100.c | 172 ++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 87 deletions(-)
drivers/net/eepro100.c +85 -87
@@ -14,18 +14,18 @@#include <linux/delay.h> /* Ethernet chip registers. */ -#define SCBStatus 0/* Rx/Command Unit Status *Word* */ -#define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */ -#define SCBCmd 2/* Rx/Command Unit Command *Word* */ -#define SCBIntrCtlByte 3/* Rx/Command Unit Intr.Control Byte */ -#define SCBPointer 4/* General purpose pointer. */ -#define SCBPort 8/* Misc. commands and operands. */ -#define SCBflash 12/* Flash memory control. */ -#define SCBeeprom 14/* EEPROM memory control. */ -#define SCBCtrlMDI 16/* MDI interface control. */ -#define SCBEarlyRx 20/* Early receive byte count. */ -#define SCBGenControl 28/* 82559 General Control Register */ -#define SCBGenStatus 29/* 82559 General Status register */ +#define SCB_STATUS 0/* Rx/Command Unit Status *Word* */ +#define SCB_INT_ACK_BYTE 1/* Rx/Command Unit STAT/ACK byte */ +#define SCB_CMD 2/* Rx/Command Unit Command *Word* */ +#define SCB_INTR_CTL_BYTE 3/* Rx/Command Unit Intr.Control Byte */ +#define SCB_POINTER 4/* General purpose pointer. */ +#define SCB_PORT 8/* Misc. commands and operands. */ +#define SCB_FLASH 12/* Flash memory control. */ +#define SCB_EEPROM 14/* EEPROM memory control. */ +#define SCB_CTRL_MDI 16/* MDI interface control. */ +#define SCB_EARLY_RX 20/* Early receive byte count. */ +#define SCB_GEN_CONTROL 28/* 82559 General Control Register */ +#define SCB_GEN_STATUS 29/* 82559 General Status register */ /* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000/* CU finished command (transmit) */
@@ -101,10 +101,10 @@#define EE_ERASE_CMD (7 << addr_len)/* Receive frame descriptors. */ -struct RxFD { +struct eepro100_rxfd {volatile u16 status;volatile u16 control; -volatile u32 link;/* struct RxFD * */ +volatile u32 link;/* struct eepro100_rxfd * */ volatile u32 rx_buf_addr;/* void * */ volatile u32 count;
@@ -135,7 +135,7 @@ struct RxFD {#define RFD_RX_TCO 0x0001/* TCO indication */ /* Transmit frame descriptors */ -struct TxFD {/* Transmit frame descriptor set. */ +struct eepro100_txfd {/* Transmit frame descriptor set. */ volatile u16 status;volatile u16 command;volatile u32 link;/* void * */
@@ -148,15 +148,15 @@ struct TxFD { /* Transmit frame descriptor set. */volatile s32 tx_buf_size1;/* Length of Tx frame. */ }; -#define TxCB_CMD_TRANSMIT 0x0004/* transmit command */ -#define TxCB_CMD_SF 0x0008/* 0=simplified, 1=flexible mode */ -#define TxCB_CMD_NC 0x0010/* 0=CRC insert by controller */ -#define TxCB_CMD_I 0x2000/* generate interrupt on completion */ -#define TxCB_CMD_S 0x4000/* suspend on completion */ -#define TxCB_CMD_EL 0x8000/* last command block in CBL */ +#define TXCB_CMD_TRANSMIT 0x0004/* transmit command */ +#define TXCB_CMD_SF 0x0008/* 0=simplified, 1=flexible mode */ +#define TXCB_CMD_NC 0x0010/* 0=CRC insert by controller */ +#define TXCB_CMD_I 0x2000/* generate interrupt on completion */ +#define TXCB_CMD_S 0x4000/* suspend on completion */ +#define TXCB_CMD_EL 0x8000/* last command block in CBL */ -#define TxCB_COUNT_MASK 0x3fff -#define TxCB_COUNT_EOF 0x8000 +#define TXCB_COUNT_MASK 0x3fff +#define TXCB_COUNT_EOF 0x8000/* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */
@@ -182,8 +182,8 @@ struct descriptor { /* A generic descriptor. */#define TOUT_LOOP 1000000 -static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ +static struct eepro100_rxfd rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ +static struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ static int rx_next;/* RX descriptor ring pointer */ static int tx_next;/* TX descriptor ring pointer */ static int tx_threshold;
@@ -247,11 +247,11 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd, SCBCtrlMDI); +OUTL (dev, cmd,SCB_CTRL_MDI );do {udelay (1000 ); - cmd =INL (dev, SCBCtrlMDI); + cmd =INL (dev,SCB_CTRL_MDI ); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )
@@ -270,9 +270,9 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value, SCBCtrlMDI); +OUTL (dev, cmd | value,SCB_CTRL_MDI ); -while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout)) +while (!(INL (dev,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )
@@ -357,7 +357,7 @@ static int wait_for_eepro100(struct eth_device *dev) {int i; -for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP )return 0 ; }
@@ -460,25 +460,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET ,SCB_PORT );udelay (20 );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD );/* Initialize Rx and Tx rings. */ init_rx_ring (dev);
@@ -487,11 +487,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)/* Tell the adapter where the RX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (dev,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ tx_cur = tx_next;
@@ -508,25 +508,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)if (!wait_for_eepro100 (dev)) {printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD );for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; }/* Send the Individual Address Setup frame */
@@ -544,11 +544,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)/* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD ); for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);
@@ -556,19 +556,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; } status =0 ; -Done: +done:return status; }
@@ -579,16 +579,14 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (length <=0 ) {printf ("%s: bad packet size: %d\n" , dev->name, length); - goto Done; + goto done; } tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 (TxCB_CMD_TRANSMIT | - TxCB_CMD_SF | - TxCB_CMD_S | - TxCB_CMD_EL); + tx_ring[tx_cur].command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | +TXCB_CMD_S |TXCB_CMD_EL ); tx_ring[tx_cur].status =0 ; tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link =
@@ -602,31 +600,31 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!wait_for_eepro100 (dev)) {printf ("%s: Tx error ethernet controller not ready.\n" , dev->name); - goto Done; + goto done; }/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD );for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; } status = length; -Done: +done:return status; }
@@ -635,8 +633,8 @@ static int eepro100_recv(struct eth_device *dev)u16 status, stat;int rx_prev, length =0 ; - stat =INW (dev, SCBStatus); -OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus); + stat =INW (dev,SCB_STATUS ); +OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { status =le16_to_cpu (rx_ring[rx_next].status);
@@ -676,41 +674,41 @@ static int eepro100_recv(struct eth_device *dev)if (!wait_for_eepro100 (dev)) {printf ("Error: Can not restart ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); } -Done: +done:return length; }static void eepro100_halt (struct eth_device *dev) {/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET ,SCB_PORT );udelay (20 );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); -Done: +done:return ; }
@@ -721,31 +719,31 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)int read_cmd = location |EE_READ_CMD ;int i; -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (dev,EE_ENB ,SCB_EEPROM );/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); +OUTW (dev,EE_ENB | dataval,SCB_EEPROM );udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); } -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB ,SCB_EEPROM );for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); retval = (retval <<1 ) | - ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB , SCBeeprom); + ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB ,SCB_EEPROM );udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM );return retval; }
Signature · 1 line
2.25.1
PATCH 10/30 net: eepro100: Fix camelcase
Quoted 421 lines · Marek Vasut
This is automated cleanup via checkpatch, no functional change.
./scripts/checkpatch.pl--show-types -fdrivers/net/eepro100.c./scripts/checkpatch.pl--typesINDENTED_LABEL-f --fix --fix-inplacedrivers/net/eepro100.cSigned-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 172 ++++++++++++++++++++--------------------- 1 file changed, 85 insertions(+), 87 deletions(-)drivers/net/eepro100.c +85
-88@@ -14,18 +14,18 @@#include <linux/delay.h> /* Ethernet chip registers. */ -#define SCBStatus 0/* Rx/Command Unit Status *Word* */ -#define SCBIntAckByte 1/* Rx/Command Unit STAT/ACK byte */ -#define SCBCmd 2/* Rx/Command Unit Command *Word* */ -#define SCBIntrCtlByte 3/* Rx/Command Unit Intr.Control Byte */ -#define SCBPointer 4/* General purpose pointer. */ -#define SCBPort 8/* Misc. commands and operands. */ -#define SCBflash 12/* Flash memory control. */ -#define SCBeeprom 14/* EEPROM memory control. */ -#define SCBCtrlMDI 16/* MDI interface control. */ -#define SCBEarlyRx 20/* Early receive byte count. */ -#define SCBGenControl 28/* 82559 General Control Register */ -#define SCBGenStatus 29/* 82559 General Status register */ +#define SCB_STATUS 0/* Rx/Command Unit Status *Word* */ +#define SCB_INT_ACK_BYTE 1/* Rx/Command Unit STAT/ACK byte */ +#define SCB_CMD 2/* Rx/Command Unit Command *Word* */ +#define SCB_INTR_CTL_BYTE 3/* Rx/Command Unit Intr.Control Byte */ +#define SCB_POINTER 4/* General purpose pointer. */ +#define SCB_PORT 8/* Misc. commands and operands. */ +#define SCB_FLASH 12/* Flash memory control. */ +#define SCB_EEPROM 14/* EEPROM memory control. */ +#define SCB_CTRL_MDI 16/* MDI interface control. */ +#define SCB_EARLY_RX 20/* Early receive byte count. */ +#define SCB_GEN_CONTROL 28/* 82559 General Control Register */ +#define SCB_GEN_STATUS 29/* 82559 General Status register */ /* 82559 SCB status word defnitions */ #define SCB_STATUS_CX 0x8000/* CU finished command (transmit) */ @@ -101,10 +101,10 @@#define EE_ERASE_CMD (7 << addr_len)/* Receive frame descriptors. */ -struct RxFD { +struct eepro100_rxfd {volatile u16 status;volatile u16 control; -volatile u32 link;/* struct RxFD * */ +volatile u32 link;/* struct eepro100_rxfd * */ volatile u32 rx_buf_addr;/* void * */ volatile u32 count;@@ -135,7 +135,7 @@ struct RxFD {#define RFD_RX_TCO 0x0001/* TCO indication */ /* Transmit frame descriptors */ -struct TxFD {/* Transmit frame descriptor set. */ +struct eepro100_txfd {/* Transmit frame descriptor set. */ volatile u16 status;volatile u16 command;volatile u32 link;/* void * */ @@ -148,15 +148,15 @@ struct TxFD { /* Transmit frame descriptor set. */volatile s32 tx_buf_size1;/* Length of Tx frame. */ }; -#define TxCB_CMD_TRANSMIT 0x0004/* transmit command */ -#define TxCB_CMD_SF 0x0008/* 0=simplified, 1=flexible mode */ -#define TxCB_CMD_NC 0x0010/* 0=CRC insert by controller */ -#define TxCB_CMD_I 0x2000/* generate interrupt on completion */ -#define TxCB_CMD_S 0x4000/* suspend on completion */ -#define TxCB_CMD_EL 0x8000/* last command block in CBL */ +#define TXCB_CMD_TRANSMIT 0x0004/* transmit command */ +#define TXCB_CMD_SF 0x0008/* 0=simplified, 1=flexible mode */ +#define TXCB_CMD_NC 0x0010/* 0=CRC insert by controller */ +#define TXCB_CMD_I 0x2000/* generate interrupt on completion */ +#define TXCB_CMD_S 0x4000/* suspend on completion */ +#define TXCB_CMD_EL 0x8000/* last command block in CBL */ -#define TxCB_COUNT_MASK 0x3fff -#define TxCB_COUNT_EOF 0x8000 +#define TXCB_COUNT_MASK 0x3fff +#define TXCB_COUNT_EOF 0x8000/* The Speedo3 Rx and Tx frame/buffer descriptors. */ struct descriptor {/* A generic descriptor. */ @@ -182,8 +182,8 @@ struct descriptor { /* A generic descriptor. */#define TOUT_LOOP 1000000 -static struct RxFD rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct TxFD tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ +static struct eepro100_rxfd rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ +static struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ static int rx_next;/* RX descriptor ring pointer */ static int tx_next;/* TX descriptor ring pointer */ static int tx_threshold;@@ -247,11 +247,11 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd, SCBCtrlMDI); +OUTL (dev, cmd,SCB_CTRL_MDI );do {udelay (1000 ); - cmd =INL (dev, SCBCtrlMDI); + cmd =INL (dev,SCB_CTRL_MDI ); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )@@ -270,9 +270,9 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value, SCBCtrlMDI); +OUTL (dev, cmd | value,SCB_CTRL_MDI ); -while (!(INL (dev, SCBCtrlMDI) & (1 <<28 )) && (--timeout)) +while (!(INL (dev,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )@@ -357,7 +357,7 @@ static int wait_for_eepro100(struct eth_device *dev) {int i; -for (i =0 ;INW (dev, SCBCmd) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP )return 0 ; }@@ -460,25 +460,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET ,SCB_PORT );udelay (20 );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD );/* Initialize Rx and Tx rings. */ init_rx_ring (dev);@@ -487,11 +487,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)/* Tell the adapter where the RX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (dev,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ tx_cur = tx_next;@@ -508,25 +508,25 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)if (!wait_for_eepro100 (dev)) {printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD );for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; }/* Send the Individual Address Setup frame */ @@ -544,11 +544,11 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)/* Tell the adapter where the TX ring is located. */ if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD ); for (i = 0; !(le16_to_cpu(tx_ring[tx_cur].status) & CONFIG_SYS_STATUS_C);@@ -556,19 +556,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis)if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; } status =0 ; -Done: +done:return status; }@@ -579,16 +579,14 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (length <=0 ) {printf ("%s: bad packet size: %d\n" , dev->name, length); - goto Done; + goto done; } tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 (TxCB_CMD_TRANSMIT | - TxCB_CMD_SF | - TxCB_CMD_S | - TxCB_CMD_EL); + tx_ring[tx_cur].command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | +TXCB_CMD_S |TXCB_CMD_EL ); tx_ring[tx_cur].status =0 ; tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); tx_ring[tx_cur].link =@@ -602,31 +600,31 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)if (!wait_for_eepro100 (dev)) {printf ("%s: Tx error ethernet controller not ready.\n" , dev->name); - goto Done; + goto done; }/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]), SCBPointer); -OUTW (dev,SCB_M |CU_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD );for (i =0 ; !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); i++) {if (i >=TOUT_LOOP ) {printf ("%s: Tx error buffer not ready\n" , dev->name); - goto Done; + goto done; } }if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) {printf ("TX error status = 0x%08X\n" ,le16_to_cpu (tx_ring[tx_cur].status)); - goto Done; + goto done; } status = length; -Done: +done:return status; }@@ -635,8 +633,8 @@ static int eepro100_recv(struct eth_device *dev)u16 status, stat;int rx_prev, length =0 ; - stat =INW (dev, SCBStatus); -OUTW (dev, stat &SCB_STATUS_RNR , SCBStatus); + stat =INW (dev,SCB_STATUS ); +OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { status =le16_to_cpu (rx_ring[rx_next].status);@@ -676,41 +674,41 @@ static int eepro100_recv(struct eth_device *dev)if (!wait_for_eepro100 (dev)) {printf ("Error: Can not restart ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]), SCBPointer); -OUTW (dev,SCB_M |RUC_START , SCBCmd); +OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); } -Done: +done:return length; }static void eepro100_halt (struct eth_device *dev) {/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET , SCBPort); +OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET , SCBPort); +OUTL (dev,I82559_RESET ,SCB_PORT );udelay (20 );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |RUC_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD );if (!wait_for_eepro100 (dev)) {printf ("Error: Can not reset ethernet controller.\n" ); - goto Done; + goto done; } -OUTL (dev,0 , SCBPointer); -OUTW (dev,SCB_M |CU_ADDR_LOAD , SCBCmd); +OUTL (dev,0 ,SCB_POINTER ); +OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); -Done: +done:return ; }@@ -721,31 +719,31 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)int read_cmd = location |EE_READ_CMD ;int i; -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (dev,EE_ENB ,SCB_EEPROM );/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); +OUTW (dev,EE_ENB | dataval,SCB_EEPROM );udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); } -OUTW (dev,EE_ENB , SCBeeprom); +OUTW (dev,EE_ENB ,SCB_EEPROM );for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK , SCBeeprom); +OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); retval = (retval <<1 ) | - ((INW (dev, SCBeeprom) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB , SCBeeprom); + ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB ,SCB_EEPROM );udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM );return retval; } --
Quoted 2 lines
2.25.1
Sometime in the specs of the HW register are written camel case, I those cases I prefer to keep it aligned with the specs, but for variables that's a no no... :)
PATCH 11/30 net: eepro100: Use standard I/O accessors
In reply to Marek VasutThe current eepro100 driver accesses its memory mapped registers directly instead of using the standard I/O accessors. This can cause problems on some systems as the accesses can get out of order. So convert the direct volatile dereferences to use the normal in/out macros.
--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/eepro100.c +4 -4
@@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev);static inline int INW (struct eth_device *dev,u_long addr) { -return le16_to_cpu (*(volatile u16 *)(addr + (u_long )dev->iobase)); +return le16_to_cpu (readw (addr + (void *)dev->iobase)); }static inline void OUTW (struct eth_device *dev,int command,u_long addr) { - *(volatile u16 *)((addr + (u_long )dev->iobase)) =cpu_to_le16 (command); +writew (cpu_to_le16 (command), addr + (void *)dev->iobase); }static inline void OUTL (struct eth_device *dev,int command,u_long addr) { - *(volatile u32 *)((addr + (u_long )dev->iobase)) =cpu_to_le32 (command); +writel (cpu_to_le32 (command), addr + (void *)dev->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )static inline int INL (struct eth_device *dev,u_long addr) { -return le32_to_cpu (*(volatile u32 *)(addr + (u_long )dev->iobase)); +return le32_to_cpu (readl (addr + (void *)dev->iobase)); } static int get_phyreg(struct eth_device *dev, unsigned char addr,
Signature · 1 line
2.25.1
PATCH 11/30 net: eepro100: Use standard I/O accessors
Quoted 44 lines · Marek Vasut
The current eepro100 driver accesses its memory mapped registers directly instead of using the standard I/O accessors. This can cause problems on some systems as the accesses can get out of order. So convert the direct volatile dereferences to use the normal in/out macros.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/eepro100.c +4
-5@@ -220,23 +220,23 @@ static void eepro100_halt(struct eth_device *dev);static inline int INW (struct eth_device *dev,u_long addr) { -return le16_to_cpu (*(volatile u16 *)(addr + (u_long )dev->iobase)); +return le16_to_cpu (readw (addr + (void *)dev->iobase)); }static inline void OUTW (struct eth_device *dev,int command,u_long addr) { - *(volatile u16 *)((addr + (u_long )dev->iobase)) =cpu_to_le16 (command); +writew (cpu_to_le16 (command), addr + (void *)dev->iobase); }static inline void OUTL (struct eth_device *dev,int command,u_long addr) { - *(volatile u32 *)((addr + (u_long )dev->iobase)) =cpu_to_le32 (command); +writel (cpu_to_le32 (command), addr + (void *)dev->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII )static inline int INL (struct eth_device *dev,u_long addr) { -return le32_to_cpu (*(volatile u32 *)(addr + (u_long )dev->iobase)); +return le32_to_cpu (readl (addr + (void *)dev->iobase)); } static int get_phyreg(struct eth_device *dev, unsigned char addr, --
Quoted 2 lines
2.25.1
PATCH 12/30 net: eepro100: Replace purge_tx_ring() with memset()
In reply to Marek VasutThis function zeroes-out all the descriptors in the TX ring, use memset() instead.
--- drivers/net/eepro100.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
drivers/net/eepro100.c +1 -15
@@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev)static void purge_tx_ring (struct eth_device *dev) { -int i; - tx_next =0 ; tx_threshold =0x01208000 ; - -for (i =0 ; i <NUM_TX_DESC ; i++) { - tx_ring[i].status =0 ; - tx_ring[i].command =0 ; - tx_ring[i].link =0 ; - tx_ring[i].tx_desc_addr =0 ; - tx_ring[i].count =0 ; - - tx_ring[i].tx_buf_addr0 =0 ; - tx_ring[i].tx_buf_size0 =0 ; - tx_ring[i].tx_buf_addr1 =0 ; - tx_ring[i].tx_buf_size1 =0 ; - } +memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); }static void read_hw_addr (struct eth_device *dev,bd_t *bis)
Signature · 1 line
2.25.1
PATCH 12/30 net: eepro100: Replace purge_tx_ring() with memset()
Quoted 39 lines · Marek Vasut
This function zeroes-out all the descriptors in the TX ring, use
memset()instead.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)drivers/net/eepro100.c +1
-16@@ -767,23 +767,9 @@ static void init_rx_ring(struct eth_device *dev)static void purge_tx_ring (struct eth_device *dev) { -int i; - tx_next =0 ; tx_threshold =0x01208000 ; - -for (i =0 ; i <NUM_TX_DESC ; i++) { - tx_ring[i].status =0 ; - tx_ring[i].command =0 ; - tx_ring[i].link =0 ; - tx_ring[i].tx_desc_addr =0 ; - tx_ring[i].count =0 ; - - tx_ring[i].tx_buf_addr0 =0 ; - tx_ring[i].tx_buf_size0 =0 ; - tx_ring[i].tx_buf_addr1 =0 ; - tx_ring[i].tx_buf_size1 =0 ; - } +memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); }static void read_hw_addr (struct eth_device *dev,bd_t *bis) --
Quoted 2 lines
2.25.1
PATCH 13/30 net: eepro100: Factor out tx_ring command issuing
In reply to Marek VasutThis code is replicated in the driver thrice almost verbatim, factor it out into a separate function and clean it up. No functional change.
--- drivers/net/eepro100.c | 124 ++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 71 deletions(-)
drivers/net/eepro100.c +53 -71
@@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis)return card_number; } +static int eepro100_txcmd_send (struct eth_device *dev, +struct eepro100_txfd *desc) +{ +u16 rstat; +int i =0 ; + +if (!wait_for_eepro100 (dev)) +return -ETIMEDOUT ; + +OUTL (dev,phys_to_bus ((u32 )desc),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD ); + +while (true) { + rstat =le16_to_cpu (desc->status); +if (rstat &CONFIG_SYS_STATUS_C ) +break ; + +if (i++ >=TOUT_LOOP ) { +printf ("%s: Tx error buffer not ready\n" , dev->name); +return -EINVAL ; + } + } + + rstat =le16_to_cpu (desc->status); + +if (!(rstat &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , rstat); +return -EIO ; + } + +return 0 ; +} +static int eepro100_init (struct eth_device *dev,bd_t *bis) { -int i, status =-1 ; +struct eepro100_txfd *ias_cmd, *cfg_cmd; +int ret, status =-1 ;int tx_cur; -struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );
@@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; + cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (cfg_cmd->params, i82558_config_cmd, +memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd)); -if (!wait_for_eepro100 (dev)) { -printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); - goto done; - } - -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); - goto done; - } - } - -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, cfg_cmd); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); goto done; }
@@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; + ias_cmd = &tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (ias_cmd->params, dev->enetaddr,6 ); - -/* Tell the adapter where the TX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); - goto done; - } - -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , - dev->name); - goto done; - } - } +memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 ); -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, ias_cmd); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("Error: Can not reset ethernet controller.\n" ); goto done; }
@@ -574,7 +573,7 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { -int i, status =-1 ; +int ret, status =-1 ;int tx_cur;if (length <=0 ) {
@@ -597,28 +596,11 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)cpu_to_le32 (phys_to_bus ((u_long )packet)); tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); -if (!wait_for_eepro100 (dev)) { -printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); - goto done; - } - -/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); - goto done; - } - } - -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("%s: Tx error ethernet controller not ready.\n" , + dev->name); goto done; }
Signature · 1 line
2.25.1
PATCH 13/30 net: eepro100: Factor out tx_ring command issuing
Quoted 189 lines · Marek Vasut
This code is replicated in the driver thrice almost verbatim, factor it out into a separate function and clean it up. No functional change.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 124 ++++++++++++++++++----------------------- 1 file changed, 53 insertions(+), 71 deletions(-)drivers/net/eepro100.c +53
-72@@ -453,11 +453,44 @@ int eepro100_initialize(bd_t *bis)return card_number; } +static int eepro100_txcmd_send (struct eth_device *dev, +struct eepro100_txfd *desc) +{ +u16 rstat; +int i =0 ; + +if (!wait_for_eepro100 (dev)) +return -ETIMEDOUT ; + +OUTL (dev,phys_to_bus ((u32 )desc),SCB_POINTER ); +OUTW (dev,SCB_M |CU_START ,SCB_CMD ); + +while (true) { + rstat =le16_to_cpu (desc->status); +if (rstat &CONFIG_SYS_STATUS_C ) +break ; + +if (i++ >=TOUT_LOOP ) { +printf ("%s: Tx error buffer not ready\n" , dev->name); +return -EINVAL ; + } + } + + rstat =le16_to_cpu (desc->status); + +if (!(rstat &CONFIG_SYS_STATUS_OK )) { +printf ("TX error status = 0x%08X\n" , rstat); +return -EIO ; + } + +return 0 ; +} +static int eepro100_init (struct eth_device *dev,bd_t *bis) { -int i, status =-1 ; +struct eepro100_txfd *ias_cmd, *cfg_cmd; +int ret, status =-1 ;int tx_cur; -struct descriptor *ias_cmd, *cfg_cmd;/* Reset the ethernet controller */ OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT );@@ -497,35 +530,19 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - cfg_cmd = (struct descriptor *)&tx_ring[tx_cur]; + cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (cfg_cmd->params, i82558_config_cmd, +memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd)); -if (!wait_for_eepro100 (dev)) { -printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); - goto done; - } - -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); - goto done; - } - } - -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, cfg_cmd); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" ); goto done; }@@ -533,36 +550,18 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) tx_cur = tx_next; tx_next = ((tx_next +1 ) %NUM_TX_DESC ); - ias_cmd = (struct descriptor *)&tx_ring[tx_cur]; + ias_cmd = &tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); -memcpy (ias_cmd->params, dev->enetaddr,6 ); - -/* Tell the adapter where the TX ring is located. */ -if (!wait_for_eepro100 (dev)) { -printf ("Error: Can not reset ethernet controller.\n" ); - goto done; - } - -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , - dev->name); - goto done; - } - } +memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 ); -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, ias_cmd); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("Error: Can not reset ethernet controller.\n" ); goto done; }@@ -574,7 +573,7 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { -int i, status =-1 ; +int ret, status =-1 ;int tx_cur;if (length <=0 ) {@@ -597,28 +596,11 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length)cpu_to_le32 (phys_to_bus ((u_long )packet)); tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); -if (!wait_for_eepro100 (dev)) { -printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); - goto done; - } - -/* Send the packet. */ -OUTL (dev,phys_to_bus ((u32)&tx_ring[tx_cur]),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); - -for (i =0 ; - !(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_C ); - i++) { -if (i >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); - goto done; - } - } - -if (!(le16_to_cpu (tx_ring[tx_cur].status) &CONFIG_SYS_STATUS_OK )) { -printf ("TX error status = 0x%08X\n" , -le16_to_cpu (tx_ring[tx_cur].status)); + ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]); +if (ret) { +if (ret == -ETIMEDOUT ) +printf ("%s: Tx error ethernet controller not ready.\n" , + dev->name); goto done; } --
Quoted 2 lines
2.25.1
PATCH 14/30 net: eepro100: Add cache management
In reply to Marek VasutAdd cache invalidation and flushes wherever the DMA descriptors are written or read, otherwise this driver cannot work reliably on any systems where caches are enabled.
--- drivers/net/eepro100.c | 65 +++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-)
drivers/net/eepro100.c +45 -20
@@ -5,6 +5,7 @@*/ #include <common.h> +#include <cpu_func.h> #include <malloc.h> #include <net.h> #include <netdev.h>
@@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev,u16 rstat;int i =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); +if (!wait_for_eepro100 (dev))return -ETIMEDOUT ;
@@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev,OUTW (dev,SCB_M |CU_START ,SCB_CMD );while (true) { +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rstat =le16_to_cpu (desc->status);if (rstat &CONFIG_SYS_STATUS_C )break ;
@@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, } } +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rstat =le16_to_cpu (desc->status);if (!(rstat &CONFIG_SYS_STATUS_OK )) {
@@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) goto done; } +/* RX ring cache was already flushed in init_rx_ring() */ OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD );
@@ -573,6 +582,7 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { +struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;
@@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | -TXCB_CMD_S |TXCB_CMD_EL ); - tx_ring[tx_cur].status =0 ; - tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); - tx_ring[tx_cur].link = -cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); - tx_ring[tx_cur].tx_desc_addr = -cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_cur].tx_buf_addr0)); - tx_ring[tx_cur].tx_buf_addr0 = -cpu_to_le32 (phys_to_bus ((u_long )packet)); - tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); + desc = &tx_ring[tx_cur]; + desc->command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | +TXCB_CMD_S |TXCB_CMD_EL ); + desc->status =0 ; + desc->count =cpu_to_le32 (tx_threshold); + desc->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((u_long )packet)); + desc->tx_buf_size0 =cpu_to_le32 (length); ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]);if (ret) {
@@ -612,14 +620,18 @@ done:static int eepro100_recv (struct eth_device *dev) { -u16 status, stat; +struct eepro100_rxfd *desc;int rx_prev, length =0 ; +u16 status, stat; stat =INW (dev,SCB_STATUS );OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { - status =le16_to_cpu (rx_ring[rx_next].status); + desc = &rx_ring[rx_next]; +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); + status =le16_to_cpu (desc->status);if (!(status &RFD_STATUS_C ))break ;
@@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev)/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {/* A valid frame received. */ - length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; + length =le32_to_cpu (desc->count) &0x3fff ;/* Pass the packet up to the protocol layers. */ -net_process_received_packet ((u8 *)rx_ring[rx_next].data, - length); +net_process_received_packet ((u8 *)desc->data, length); }else {/* There was an error. */ printf ("RX error status = 0x%08X\n" , status); } - rx_ring[rx_next].control =cpu_to_le16 (RFD_CONTROL_S ); - rx_ring[rx_next].status =0 ; - rx_ring[rx_next].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); + desc->control =cpu_to_le16 (RFD_CONTROL_S ); + desc->status =0 ; + desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; - rx_ring[rx_prev].control =0 ; + desc = &rx_ring[rx_prev]; + desc->control =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc));/* Update entry information. */ rx_next = (rx_next +1 ) %NUM_RX_DESC ;
@@ -659,6 +675,7 @@ static int eepro100_recv(struct eth_device *dev) goto done; } +/* RX ring cache was already flushed in init_rx_ring() */ OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); }
@@ -744,6 +761,10 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } +flush_dcache_range ((unsigned long )rx_ring, + (unsigned long )rx_ring + + (sizeof (*rx_ring) *NUM_RX_DESC )); + rx_next =0 ; }
@@ -752,6 +773,10 @@ static void purge_tx_ring(struct eth_device *dev) tx_next =0 ; tx_threshold =0x01208000 ;memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); + +flush_dcache_range ((unsigned long )tx_ring, + (unsigned long )tx_ring + + (sizeof (*tx_ring) *NUM_TX_DESC )); }static void read_hw_addr (struct eth_device *dev,bd_t *bis)
Signature · 1 line
2.25.1
PATCH 14/30 net: eepro100: Add cache management
Quoted 179 lines · Marek Vasut
Add cache invalidation and flushes wherever the DMA descriptors are written or read, otherwise this driver cannot work reliably on any systems where caches are enabled.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 65 +++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-)drivers/net/eepro100.c +45
-21@@ -5,6 +5,7 @@*/ #include <common.h> +#include <cpu_func.h> #include <malloc.h> #include <net.h> #include <netdev.h> @@ -459,6 +460,9 @@ static int eepro100_txcmd_send(struct eth_device *dev,u16 rstat;int i =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); +if (!wait_for_eepro100 (dev))return -ETIMEDOUT ;@@ -466,6 +470,8 @@ static int eepro100_txcmd_send(struct eth_device *dev,OUTW (dev,SCB_M |CU_START ,SCB_CMD );while (true) { +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rstat =le16_to_cpu (desc->status);if (rstat &CONFIG_SYS_STATUS_C )break ;@@ -476,6 +482,8 @@ static int eepro100_txcmd_send(struct eth_device *dev, } } +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rstat =le16_to_cpu (desc->status);if (!(rstat &CONFIG_SYS_STATUS_OK )) {@@ -523,6 +531,7 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) goto done; } +/* RX ring cache was already flushed in init_rx_ring() */ OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD );@@ -573,6 +582,7 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { +struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;@@ -584,17 +594,15 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) tx_cur = tx_next; tx_next = (tx_next +1 ) %NUM_TX_DESC ; - tx_ring[tx_cur].command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | -TXCB_CMD_S |TXCB_CMD_EL ); - tx_ring[tx_cur].status =0 ; - tx_ring[tx_cur].count =cpu_to_le32 (tx_threshold); - tx_ring[tx_cur].link = -cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); - tx_ring[tx_cur].tx_desc_addr = -cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_cur].tx_buf_addr0)); - tx_ring[tx_cur].tx_buf_addr0 = -cpu_to_le32 (phys_to_bus ((u_long )packet)); - tx_ring[tx_cur].tx_buf_size0 =cpu_to_le32 (length); + desc = &tx_ring[tx_cur]; + desc->command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF | +TXCB_CMD_S |TXCB_CMD_EL ); + desc->status =0 ; + desc->count =cpu_to_le32 (tx_threshold); + desc->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((u_long )packet)); + desc->tx_buf_size0 =cpu_to_le32 (length); ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]);if (ret) {@@ -612,14 +620,18 @@ done:static int eepro100_recv (struct eth_device *dev) { -u16 status, stat; +struct eepro100_rxfd *desc;int rx_prev, length =0 ; +u16 status, stat; stat =INW (dev,SCB_STATUS );OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { - status =le16_to_cpu (rx_ring[rx_next].status); + desc = &rx_ring[rx_next]; +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); + status =le16_to_cpu (desc->status);if (!(status &RFD_STATUS_C ))break ;@@ -627,22 +639,26 @@ static int eepro100_recv(struct eth_device *dev)/* Valid frame status. */ if ((status &RFD_STATUS_OK )) {/* A valid frame received. */ - length =le32_to_cpu (rx_ring[rx_next].count) &0x3fff ; + length =le32_to_cpu (desc->count) &0x3fff ;/* Pass the packet up to the protocol layers. */ -net_process_received_packet ((u8 *)rx_ring[rx_next].data, - length); +net_process_received_packet ((u8 *)desc->data, length); }else {/* There was an error. */ printf ("RX error status = 0x%08X\n" , status); } - rx_ring[rx_next].control =cpu_to_le16 (RFD_CONTROL_S ); - rx_ring[rx_next].status =0 ; - rx_ring[rx_next].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); + desc->control =cpu_to_le16 (RFD_CONTROL_S ); + desc->status =0 ; + desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; - rx_ring[rx_prev].control =0 ; + desc = &rx_ring[rx_prev]; + desc->control =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc));/* Update entry information. */ rx_next = (rx_next +1 ) %NUM_RX_DESC ;@@ -659,6 +675,7 @@ static int eepro100_recv(struct eth_device *dev) goto done; } +/* RX ring cache was already flushed in init_rx_ring() */ OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); }@@ -744,6 +761,10 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } +flush_dcache_range ((unsigned long )rx_ring, + (unsigned long )rx_ring + + (sizeof (*rx_ring) *NUM_RX_DESC )); + rx_next =0 ; }@@ -752,6 +773,10 @@ static void purge_tx_ring(struct eth_device *dev) tx_next =0 ; tx_threshold =0x01208000 ;memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); + +flush_dcache_range ((unsigned long )tx_ring, + (unsigned long )tx_ring + + (sizeof (*tx_ring) *NUM_TX_DESC )); }static void read_hw_addr (struct eth_device *dev,bd_t *bis) --
Quoted 2 lines
2.25.1
PATCH 15/30 net: eepro100: Remove volatile misuse
In reply to Marek VasutRemove all the remaining use of the 'volatile' keyword, as this is no longer required. All the accesses which might have needed this use of 'volatile' have been repaired properly.
--- drivers/net/eepro100.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)
drivers/net/eepro100.c +21 -21
@@ -103,13 +103,13 @@/* Receive frame descriptors. */ struct eepro100_rxfd { -volatile u16 status; -volatile u16 control; -volatile u32 link;/* struct eepro100_rxfd * */ -volatile u32 rx_buf_addr;/* void * */ -volatile u32 count; +u16 status; +u16 control; +u32 link;/* struct eepro100_rxfd * */ +u32 rx_buf_addr;/* void * */ +u32 count; -volatile u8 data[PKTSIZE_ALIGN ]; +u8 data[PKTSIZE_ALIGN ]; };#define RFD_STATUS_C 0x8000/* completion of received frame */
@@ -136,17 +136,17 @@ struct eepro100_rxfd {#define RFD_RX_TCO 0x0001/* TCO indication */ /* Transmit frame descriptors */ -struct eepro100_txfd {/* Transmit frame descriptor set. */ -volatile u16 status; -volatile u16 command; -volatile u32 link;/* void * */ -volatile u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ -volatile s32 count; - -volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ -volatile s32 tx_buf_size0;/* Length of Tx frame. */ -volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ -volatile s32 tx_buf_size1;/* Length of Tx frame. */ +struct eepro100_txfd {/* Transmit frame descriptor set. */ +u16 status; +u16 command; +u32 link;/* void * */ +u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ +s32 count; + +u32 tx_buf_addr0;/* void *, frame to be transmitted. */ +s32 tx_buf_size0;/* Length of Tx frame. */ +u32 tx_buf_addr1;/* void *, frame to be transmitted. */ +s32 tx_buf_size1;/* Length of Tx frame. */ };#define TXCB_CMD_TRANSMIT 0x0004/* transmit command */
@@ -160,10 +160,10 @@ struct eepro100_txfd { /* Transmit frame descriptor set. */#define TXCB_COUNT_EOF 0x8000/* The Speedo3 Rx and Tx frame/buffer descriptors. */ -struct descriptor {/* A generic descriptor. */ -volatile u16 status; -volatile u16 command; -volatile u32 link;/* struct descriptor * */ +struct descriptor {/* A generic descriptor. */ +u16 status; +u16 command; +u32 link;/* struct descriptor * */ unsigned char params[0 ]; };
Signature · 1 line
2.25.1
PATCH 15/30 net: eepro100: Remove volatile misuse
Quoted 79 lines · Marek Vasut
Remove all the remaining use of the 'volatile' keyword, as this is no longer required. All the accesses which might have needed this use of 'volatile' have been repaired properly.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-)drivers/net/eepro100.c +21
-22@@ -103,13 +103,13 @@/* Receive frame descriptors. */ struct eepro100_rxfd { -volatile u16 status; -volatile u16 control; -volatile u32 link;/* struct eepro100_rxfd * */ -volatile u32 rx_buf_addr;/* void * */ -volatile u32 count; +u16 status; +u16 control; +u32 link;/* struct eepro100_rxfd * */ +u32 rx_buf_addr;/* void * */ +u32 count; -volatile u8 data[PKTSIZE_ALIGN ]; +u8 data[PKTSIZE_ALIGN ]; };#define RFD_STATUS_C 0x8000/* completion of received frame */ @@ -136,17 +136,17 @@ struct eepro100_rxfd {#define RFD_RX_TCO 0x0001/* TCO indication */ /* Transmit frame descriptors */ -struct eepro100_txfd {/* Transmit frame descriptor set. */ -volatile u16 status; -volatile u16 command; -volatile u32 link;/* void * */ -volatile u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ -volatile s32 count; - -volatile u32 tx_buf_addr0;/* void *, frame to be transmitted. */ -volatile s32 tx_buf_size0;/* Length of Tx frame. */ -volatile u32 tx_buf_addr1;/* void *, frame to be transmitted. */ -volatile s32 tx_buf_size1;/* Length of Tx frame. */ +struct eepro100_txfd {/* Transmit frame descriptor set. */ +u16 status; +u16 command; +u32 link;/* void * */ +u32 tx_desc_addr;/* Always points to the tx_buf_addr element. */ +s32 count; + +u32 tx_buf_addr0;/* void *, frame to be transmitted. */ +s32 tx_buf_size0;/* Length of Tx frame. */ +u32 tx_buf_addr1;/* void *, frame to be transmitted. */ +s32 tx_buf_size1;/* Length of Tx frame. */ };#define TXCB_CMD_TRANSMIT 0x0004/* transmit command */ @@ -160,10 +160,10 @@ struct eepro100_txfd { /* Transmit frame descriptor set. */#define TXCB_COUNT_EOF 0x8000/* The Speedo3 Rx and Tx frame/buffer descriptors. */ -struct descriptor {/* A generic descriptor. */ -volatile u16 status; -volatile u16 command; -volatile u32 link;/* struct descriptor * */ +struct descriptor {/* A generic descriptor. */ +u16 status; +u16 command; +u32 link;/* struct descriptor * */ unsigned char params[0 ]; }; --
Quoted 2 lines
2.25.1
PATCH 16/30 net: eepro100: Reorder functions in the driver
In reply to Marek VasutMove the functions around in the driver to prepare it for DM conversion. Drop forward declarations which are not necessary anymore. No functional change.
--- drivers/net/eepro100.c | 330 ++++++++++++++++++++--------------------- 1 file changed, 160 insertions(+), 170 deletions(-)
drivers/net/eepro100.c +160 -170
@@ -5,13 +5,13 @@*/ #include <common.h> +#include <asm/io.h> #include <cpu_func.h> #include <malloc.h> +#include <miiphy.h> #include <net.h> #include <netdev.h> -#include <asm/io.h> #include <pci.h> -#include <miiphy.h> #include <linux/delay.h> /* Ethernet chip registers. */
@@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); - -static void read_hw_addr (struct eth_device *dev,bd_t *bis); - -static int eepro100_init (struct eth_device *dev,bd_t *bis); -static int eepro100_send (struct eth_device *dev,void *packet,int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); -#if defined(CONFIG_E500 )#define bus_to_phys (a) (a)#define phys_to_bus (a) (a)
@@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif -/* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static void init_rx_ring (struct eth_device *dev) {int i; -for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { -if (i >=TOUT_LOOP ) -return 0 ; +for (i =0 ; i <NUM_RX_DESC ; i++) { + rx_ring[i].status =0 ; + rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? +cpu_to_le16 (RFD_CONTROL_S ) :0 ; + rx_ring[i].link = +cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +NUM_RX_DESC ])); + rx_ring[i].rx_buf_addr =0xffffffff ; + rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } -return 1 ; -} +flush_dcache_range ((unsigned long )rx_ring, + (unsigned long )rx_ring + + (sizeof (*rx_ring) *NUM_RX_DESC )); -static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, - {} -}; + rx_next =0 ; +} -int eepro100_initialize (bd_t *bis) +static void purge_tx_ring (struct eth_device *dev) { -pci_dev_t devno; -int card_number =0 ; -struct eth_device *dev; -u32 iobase, status; -int idx =0 ; - -while (1 ) { -/* Find PCI device */ - devno =pci_find_devices (supported, idx++); -if (devno <0 ) -break ; - -pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); - iobase &= ~0xf ; - -debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , - iobase); - -pci_write_config_dword (devno,PCI_COMMAND , -PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); - -/* Check if I/O accesses and Bus Mastering are enabled. */ -pci_read_config_dword (devno,PCI_COMMAND , &status); -if (!(status &PCI_COMMAND_MEMORY )) { -printf ("Error: Can not enable MEM access.\n" ); -continue ; - } - -if (!(status &PCI_COMMAND_MASTER )) { -printf ("Error: Can not enable Bus Mastering.\n" ); -continue ; - } - - dev = (struct eth_device *)malloc (sizeof (*dev)); -if (!dev) { -printf ("eepro100: Can not allocate memory\n" ); -break ; - } -memset (dev,0 ,sizeof (*dev)); - -sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); - dev->init = eepro100_init; - dev->halt = eepro100_halt; - dev->send = eepro100_send; - dev->recv = eepro100_recv; - -eth_register (dev); - -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -/* register mii command access routines */ -int retval; -struct mii_dev *mdiodev =mdio_alloc (); - -if (!mdiodev) -return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval =mdio_register (mdiodev); -if (retval <0 ) -return retval; -#endif - - card_number++; + tx_next =0 ; + tx_threshold =0x01208000 ; +memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); -/* Set the latency timer for value. */ -pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); +flush_dcache_range ((unsigned long )tx_ring, + (unsigned long )tx_ring + + (sizeof (*tx_ring) *NUM_TX_DESC )); +} -udelay (10 *1000 ); +/* Wait for the chip get the command. */ +static int wait_for_eepro100 (struct eth_device *dev) +{ +int i; -read_hw_addr (dev, bis); +for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +if (i >=TOUT_LOOP ) +return 0 ; } -return card_number; +return 1 ; } static int eepro100_txcmd_send(struct eth_device *dev,
@@ -494,6 +429,71 @@ static int eepro100_txcmd_send(struct eth_device *dev,return 0 ; } +/* SROM Read. */ +static int read_eeprom (struct eth_device *dev,int location,int addr_len) +{ +unsigned short retval =0 ; +int read_cmd = location |EE_READ_CMD ; +int i; + +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (dev,EE_ENB ,SCB_EEPROM ); + +/* Shift the read command bits out. */ +for (i =12 ; i >=0 ; i--) { +short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; + +OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); +udelay (1 ); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); +udelay (1 ); + } +OUTW (dev,EE_ENB ,SCB_EEPROM ); + +for (i =15 ; i >=0 ; i--) { +OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); +udelay (1 ); + retval = (retval <<1 ) | + ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB ,SCB_EEPROM ); +udelay (1 ); + } + +/* Terminate the EEPROM access. */ +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +return retval; +} + +static struct pci_device_id supported[] = { + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, + {} +}; + +static void read_hw_addr (struct eth_device *dev,bd_t *bis) +{ +u16 sum =0 ; +int i, j; +int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; + +for (j =0 , i =0 ; i <0x40 ; i++) { +u16 value =read_eeprom (dev, i, addr_len); + + sum += value; +if (i <3 ) { + dev->enetaddr[j++] = value; + dev->enetaddr[j++] = value >>8 ; + } + } + +if (sum !=0xBABA ) { +memset (dev->enetaddr,0 ,ETH_ALEN ); +debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , + dev->name, sum); + } +} +static int eepro100_init (struct eth_device *dev,bd_t *bis) {struct eepro100_txfd *ias_cmd, *cfg_cmd;
@@ -711,93 +711,83 @@ done:return ; } -/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +int eepro100_initialize (bd_t *bis) { -unsigned short retval =0 ; -int read_cmd = location |EE_READ_CMD ; -int i; +pci_dev_t devno; +int card_number =0 ; +struct eth_device *dev; +u32 iobase, status; +int idx =0 ; -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); +while (1 ) { +/* Find PCI device */ + devno =pci_find_devices (supported, idx++); +if (devno <0 ) +break ; -/* Shift the read command bits out. */ -for (i =12 ; i >=0 ; i--) { -short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; +pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); + iobase &= ~0xf ; -OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); -udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); -udelay (1 ); - } -OUTW (dev,EE_ENB ,SCB_EEPROM ); +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , + iobase); -for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); -udelay (1 ); - retval = (retval <<1 ) | - ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); -udelay (1 ); - } +pci_write_config_dword (devno,PCI_COMMAND , +PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); -/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -return retval; -} +/* Check if I/O accesses and Bus Mastering are enabled. */ +pci_read_config_dword (devno,PCI_COMMAND , &status); +if (!(status &PCI_COMMAND_MEMORY )) { +printf ("Error: Can not enable MEM access.\n" ); +continue ; + } -static void init_rx_ring (struct eth_device *dev) -{ -int i; +if (!(status &PCI_COMMAND_MASTER )) { +printf ("Error: Can not enable Bus Mastering.\n" ); +continue ; + } -for (i =0 ; i <NUM_RX_DESC ; i++) { - rx_ring[i].status =0 ; - rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? -cpu_to_le16 (RFD_CONTROL_S ) :0 ; - rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % -NUM_RX_DESC ])); - rx_ring[i].rx_buf_addr =0xffffffff ; - rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); - } + dev = (struct eth_device *)malloc (sizeof (*dev)); +if (!dev) { +printf ("eepro100: Can not allocate memory\n" ); +break ; + } +memset (dev,0 ,sizeof (*dev)); -flush_dcache_range ((unsigned long )rx_ring, - (unsigned long )rx_ring + - (sizeof (*rx_ring) *NUM_RX_DESC )); +sprintf (dev->name,"i82559#%d" , card_number); + dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ + dev->iobase =bus_to_phys (iobase); + dev->init = eepro100_init; + dev->halt = eepro100_halt; + dev->send = eepro100_send; + dev->recv = eepro100_recv; - rx_next =0 ; -} +eth_register (dev); -static void purge_tx_ring (struct eth_device *dev) -{ - tx_next =0 ; - tx_threshold =0x01208000 ; -memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) +/* register mii command access routines */ +int retval; +struct mii_dev *mdiodev =mdio_alloc (); -flush_dcache_range ((unsigned long )tx_ring, - (unsigned long )tx_ring + - (sizeof (*tx_ring) *NUM_TX_DESC )); -} +if (!mdiodev) +return -ENOMEM ; +strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; -static void read_hw_addr (struct eth_device *dev,bd_t *bis) -{ -u16 sum =0 ; -int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; + retval =mdio_register (mdiodev); +if (retval <0 ) +return retval; +#endif -for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); + card_number++; - sum += value; -if (i <3 ) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >>8 ; - } - } +/* Set the latency timer for value. */ +pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); -if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); -debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , - dev->name, sum); +udelay (10 *1000 ); + +read_hw_addr (dev, bis); } + +return card_number; }
Signature · 1 line
2.25.1
PATCH 16/30 net: eepro100: Reorder functions in the driver
Quoted 413 lines · Marek Vasut
Move the functions around in the driver to prepare it for DM conversion. Drop forward declarations which are not necessary anymore. No functional change.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 330 ++++++++++++++++++++--------------------- 1 file changed, 160 insertions(+), 170 deletions(-)drivers/net/eepro100.c +160
-171@@ -5,13 +5,13 @@*/ #include <common.h> +#include <asm/io.h> #include <cpu_func.h> #include <malloc.h> +#include <miiphy.h> #include <net.h> #include <netdev.h> -#include <asm/io.h> #include <pci.h> -#include <miiphy.h> #include <linux/delay.h> /* Ethernet chip registers. */ @@ -201,16 +201,6 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; -static void init_rx_ring (struct eth_device *dev); -static void purge_tx_ring (struct eth_device *dev); - -static void read_hw_addr (struct eth_device *dev,bd_t *bis); - -static int eepro100_init (struct eth_device *dev,bd_t *bis); -static int eepro100_send (struct eth_device *dev,void *packet,int length); -static int eepro100_recv (struct eth_device *dev); -static void eepro100_halt (struct eth_device *dev); -#if defined(CONFIG_E500 )#define bus_to_phys (a) (a)#define phys_to_bus (a) (a)@@ -353,105 +343,50 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,#endif -/* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static void init_rx_ring (struct eth_device *dev) {int i; -for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { -if (i >=TOUT_LOOP ) -return 0 ; +for (i =0 ; i <NUM_RX_DESC ; i++) { + rx_ring[i].status =0 ; + rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? +cpu_to_le16 (RFD_CONTROL_S ) :0 ; + rx_ring[i].link = +cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +NUM_RX_DESC ])); + rx_ring[i].rx_buf_addr =0xffffffff ; + rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); } -return 1 ; -} +flush_dcache_range ((unsigned long )rx_ring, + (unsigned long )rx_ring + + (sizeof (*rx_ring) *NUM_RX_DESC )); -static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, - {} -}; + rx_next =0 ; +} -int eepro100_initialize (bd_t *bis) +static void purge_tx_ring (struct eth_device *dev) { -pci_dev_t devno; -int card_number =0 ; -struct eth_device *dev; -u32 iobase, status; -int idx =0 ; - -while (1 ) { -/* Find PCI device */ - devno =pci_find_devices (supported, idx++); -if (devno <0 ) -break ; - -pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); - iobase &= ~0xf ; - -debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , - iobase); - -pci_write_config_dword (devno,PCI_COMMAND , -PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); - -/* Check if I/O accesses and Bus Mastering are enabled. */ -pci_read_config_dword (devno,PCI_COMMAND , &status); -if (!(status &PCI_COMMAND_MEMORY )) { -printf ("Error: Can not enable MEM access.\n" ); -continue ; - } - -if (!(status &PCI_COMMAND_MASTER )) { -printf ("Error: Can not enable Bus Mastering.\n" ); -continue ; - } - - dev = (struct eth_device *)malloc (sizeof (*dev)); -if (!dev) { -printf ("eepro100: Can not allocate memory\n" ); -break ; - } -memset (dev,0 ,sizeof (*dev)); - -sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); - dev->init = eepro100_init; - dev->halt = eepro100_halt; - dev->send = eepro100_send; - dev->recv = eepro100_recv; - -eth_register (dev); - -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -/* register mii command access routines */ -int retval; -struct mii_dev *mdiodev =mdio_alloc (); - -if (!mdiodev) -return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval =mdio_register (mdiodev); -if (retval <0 ) -return retval; -#endif - - card_number++; + tx_next =0 ; + tx_threshold =0x01208000 ; +memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); -/* Set the latency timer for value. */ -pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); +flush_dcache_range ((unsigned long )tx_ring, + (unsigned long )tx_ring + + (sizeof (*tx_ring) *NUM_TX_DESC )); +} -udelay (10 *1000 ); +/* Wait for the chip get the command. */ +static int wait_for_eepro100 (struct eth_device *dev) +{ +int i; -read_hw_addr (dev, bis); +for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +if (i >=TOUT_LOOP ) +return 0 ; } -return card_number; +return 1 ; } static int eepro100_txcmd_send(struct eth_device *dev,@@ -494,6 +429,71 @@ static int eepro100_txcmd_send(struct eth_device *dev,return 0 ; } +/* SROM Read. */ +static int read_eeprom (struct eth_device *dev,int location,int addr_len) +{ +unsigned short retval =0 ; +int read_cmd = location |EE_READ_CMD ; +int i; + +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (dev,EE_ENB ,SCB_EEPROM ); + +/* Shift the read command bits out. */ +for (i =12 ; i >=0 ; i--) { +short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; + +OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); +udelay (1 ); +OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); +udelay (1 ); + } +OUTW (dev,EE_ENB ,SCB_EEPROM ); + +for (i =15 ; i >=0 ; i--) { +OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); +udelay (1 ); + retval = (retval <<1 ) | + ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); +OUTW (dev,EE_ENB ,SCB_EEPROM ); +udelay (1 ); + } + +/* Terminate the EEPROM access. */ +OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +return retval; +} + +static struct pci_device_id supported[] = { + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, + {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, + {} +}; + +static void read_hw_addr (struct eth_device *dev,bd_t *bis) +{ +u16 sum =0 ; +int i, j; +int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; + +for (j =0 , i =0 ; i <0x40 ; i++) { +u16 value =read_eeprom (dev, i, addr_len); + + sum += value; +if (i <3 ) { + dev->enetaddr[j++] = value; + dev->enetaddr[j++] = value >>8 ; + } + } + +if (sum !=0xBABA ) { +memset (dev->enetaddr,0 ,ETH_ALEN ); +debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , + dev->name, sum); + } +} +static int eepro100_init (struct eth_device *dev,bd_t *bis) {struct eepro100_txfd *ias_cmd, *cfg_cmd;@@ -711,93 +711,83 @@ done:return ; } -/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +int eepro100_initialize (bd_t *bis) { -unsigned short retval =0 ; -int read_cmd = location |EE_READ_CMD ; -int i; +pci_dev_t devno; +int card_number =0 ; +struct eth_device *dev; +u32 iobase, status; +int idx =0 ; -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); +while (1 ) { +/* Find PCI device */ + devno =pci_find_devices (supported, idx++); +if (devno <0 ) +break ; -/* Shift the read command bits out. */ -for (i =12 ; i >=0 ; i--) { -short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; +pci_read_config_dword (devno,PCI_BASE_ADDRESS_0 , &iobase); + iobase &= ~0xf ; -OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); -udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); -udelay (1 ); - } -OUTW (dev,EE_ENB ,SCB_EEPROM ); +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , + iobase); -for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); -udelay (1 ); - retval = (retval <<1 ) | - ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); -udelay (1 ); - } +pci_write_config_dword (devno,PCI_COMMAND , +PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ); -/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -return retval; -} +/* Check if I/O accesses and Bus Mastering are enabled. */ +pci_read_config_dword (devno,PCI_COMMAND , &status); +if (!(status &PCI_COMMAND_MEMORY )) { +printf ("Error: Can not enable MEM access.\n" ); +continue ; + } -static void init_rx_ring (struct eth_device *dev) -{ -int i; +if (!(status &PCI_COMMAND_MASTER )) { +printf ("Error: Can not enable Bus Mastering.\n" ); +continue ; + } -for (i =0 ; i <NUM_RX_DESC ; i++) { - rx_ring[i].status =0 ; - rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ? -cpu_to_le16 (RFD_CONTROL_S ) :0 ; - rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % -NUM_RX_DESC ])); - rx_ring[i].rx_buf_addr =0xffffffff ; - rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); - } + dev = (struct eth_device *)malloc (sizeof (*dev)); +if (!dev) { +printf ("eepro100: Can not allocate memory\n" ); +break ; + } +memset (dev,0 ,sizeof (*dev)); -flush_dcache_range ((unsigned long )rx_ring, - (unsigned long )rx_ring + - (sizeof (*rx_ring) *NUM_RX_DESC )); +sprintf (dev->name,"i82559#%d" , card_number); + dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ + dev->iobase =bus_to_phys (iobase); + dev->init = eepro100_init; + dev->halt = eepro100_halt; + dev->send = eepro100_send; + dev->recv = eepro100_recv; - rx_next =0 ; -} +eth_register (dev); -static void purge_tx_ring (struct eth_device *dev) -{ - tx_next =0 ; - tx_threshold =0x01208000 ; -memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) +/* register mii command access routines */ +int retval; +struct mii_dev *mdiodev =mdio_alloc (); -flush_dcache_range ((unsigned long )tx_ring, - (unsigned long )tx_ring + - (sizeof (*tx_ring) *NUM_TX_DESC )); -} +if (!mdiodev) +return -ENOMEM ; +strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; -static void read_hw_addr (struct eth_device *dev,bd_t *bis) -{ -u16 sum =0 ; -int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; + retval =mdio_register (mdiodev); +if (retval <0 ) +return retval; +#endif -for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); + card_number++; - sum += value; -if (i <3 ) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >>8 ; - } - } +/* Set the latency timer for value. */ +pci_write_config_byte (devno,PCI_LATENCY_TIMER ,0x20 ); -if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); -debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , - dev->name, sum); +udelay (10 *1000 ); + +read_hw_addr (dev, bis); } + +return card_number; } --
Quoted 2 lines
2.25.1
PATCH 17/30 net: eepro100: Use PCI_DEVICE() to define PCI device compat list
In reply to Marek VasutUse this macro to fully fill the PCI device ID table. This is mandatory for the DM PCI support, which checks all the fields.
--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/eepro100.c +4 -4
@@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) }static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, - {} + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER ) }, + { } };static void read_hw_addr (struct eth_device *dev,bd_t *bis)
Signature · 1 line
2.25.1
PATCH 17/30 net: eepro100: Use PCI_DEVICE() to define PCI device compat list
Quoted 29 lines · Marek Vasut
Use this macro to fully fill the PCI device ID table. This is mandatory for the DM PCI support, which checks all the fields.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/eepro100.c +4
-5@@ -465,10 +465,10 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len) }static struct pci_device_id supported[] = { - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 }, - {PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER }, - {} + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 ) }, + {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559ER ) }, + { } };static void read_hw_addr (struct eth_device *dev,bd_t *bis) --
Quoted 2 lines
2.25.1
PATCH 18/30 net: eepro100: Switch from malloc()+memset() to calloc()
In reply to Marek VasutReplace malloc()+memset() combination with calloc(), no functional change.
--- drivers/net/eepro100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/eepro100.c +1 -2
@@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev = (struct eth_device *)malloc (sizeof (*dev)); + dev =calloc (1 ,sizeof (*dev));if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ; } -memset (dev,0 ,sizeof (*dev));sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */
Signature · 1 line
2.25.1
PATCH 18/30 net: eepro100: Switch from malloc()+memset() to calloc()
Quoted 27 lines · Marek Vasut
Replace malloc()+memset() combination with
calloc(), no functional change.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/eepro100.c +1
-3@@ -746,12 +746,11 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev = (struct eth_device *)malloc (sizeof (*dev)); + dev =calloc (1 ,sizeof (*dev));if (!dev) {printf ("eepro100: Can not allocate memory\n" );break ; } -memset (dev,0 ,sizeof (*dev));sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ --
Quoted 2 lines
2.25.1
PATCH 19/30 net: eepro100: Factor out MII registration
In reply to Marek VasutPull the MII registration code into a separate function. Moreover, properly free memory in case any of the registration or allocation functions fail, so this fixes an existing memleak.
--- drivers/net/eepro100.c | 56 +++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-)
drivers/net/eepro100.c +39 -17
@@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)return retval; } +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) +static int eepro100_initialize_mii (struct eth_device *dev) +{ +/* register mii command access routines */ +struct mii_dev *mdiodev; +int ret; + + mdiodev =mdio_alloc (); +if (!mdiodev) +return -ENOMEM ; + +strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; + + ret =mdio_register (mdiodev); +if (ret <0 ) { +mdio_free (mdiodev); +return ret; + } + +return 0 ; +} +#else +static int eepro100_initialize_mii (struct eth_device *dev) +{ +return 0 ; +} +#endif +static struct pci_device_id supported[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 ) }, {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 ) },
@@ -713,11 +743,12 @@ done:int eepro100_initialize (bd_t *bis) { -pci_dev_t devno; -int card_number =0 ;struct eth_device *dev; +int card_number =0 ;u32 iobase, status; +pci_dev_t devno;int idx =0 ; +int ret;while (1 ) {/* Find PCI device */
@@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis)eth_register (dev); -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -/* register mii command access routines */ -int retval; -struct mii_dev *mdiodev =mdio_alloc (); - -if (!mdiodev) -return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval =mdio_register (mdiodev); -if (retval <0 ) -return retval; -#endif + ret =eepro100_initialize_mii (dev); +if (ret) { +eth_unregister (dev); +free (dev); +return ret; + } card_number++;
Signature · 1 line
2.25.1
PATCH 19/30 net: eepro100: Factor out MII registration
Quoted 95 lines · Marek Vasut
Pull the MII registration code into a separate function. Moreover, properly free memory in case any of the registration or allocation functions fail, so this fixes an existing memleak.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 56 +++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 17 deletions(-)drivers/net/eepro100.c +39
-18@@ -464,6 +464,36 @@ static int read_eeprom(struct eth_device *dev, int location, int addr_len)return retval; } +#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) +static int eepro100_initialize_mii (struct eth_device *dev) +{ +/* register mii command access routines */ +struct mii_dev *mdiodev; +int ret; + + mdiodev =mdio_alloc (); +if (!mdiodev) +return -ENOMEM ; + +strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); + mdiodev->read = eepro100_miiphy_read; + mdiodev->write = eepro100_miiphy_write; + + ret =mdio_register (mdiodev); +if (ret <0 ) { +mdio_free (mdiodev); +return ret; + } + +return 0 ; +} +#else +static int eepro100_initialize_mii (struct eth_device *dev) +{ +return 0 ; +} +#endif +static struct pci_device_id supported[] = { {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82557 ) }, {PCI_DEVICE (PCI_VENDOR_ID_INTEL ,PCI_DEVICE_ID_INTEL_82559 ) },@@ -713,11 +743,12 @@ done:int eepro100_initialize (bd_t *bis) { -pci_dev_t devno; -int card_number =0 ;struct eth_device *dev; +int card_number =0 ;u32 iobase, status; +pci_dev_t devno;int idx =0 ; +int ret;while (1 ) {/* Find PCI device */ @@ -762,21 +793,12 @@ int eepro100_initialize(bd_t *bis)eth_register (dev); -#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -/* register mii command access routines */ -int retval; -struct mii_dev *mdiodev =mdio_alloc (); - -if (!mdiodev) -return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); - mdiodev->read = eepro100_miiphy_read; - mdiodev->write = eepro100_miiphy_write; - - retval =mdio_register (mdiodev); -if (retval <0 ) -return retval; -#endif + ret =eepro100_initialize_mii (dev); +if (ret) { +eth_unregister (dev); +free (dev); +return ret; + } card_number++; --
Quoted 2 lines
2.25.1
PATCH 20/30 net: eepro100: Fix EE_*_CMD macros
In reply to Marek VasutThose macros depended on specific variable names to be declared at their usage sites, fix this by adding an argument to those macros and also protect the argument with braces.
--- drivers/net/eepro100.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/eepro100.c +5 -5
@@ -96,10 +96,10 @@#define EE_DATA_BITS 16/* The EEPROM commands include the alway-set leading bit. */ -#define EE_EWENB_CMD (4 << addr_len) -#define EE_WRITE_CMD (5 << addr_len) -#define EE_READ_CMD (6 << addr_len) -#define EE_ERASE_CMD (7 << addr_len) +#define EE_EWENB_CMD (addr_len) (4 << (addr_len)) +#define EE_WRITE_CMD (addr_len) (5 << (addr_len)) +#define EE_READ_CMD (addr_len) (6 << (addr_len)) +#define EE_ERASE_CMD (addr_len) (7 << (addr_len))/* Receive frame descriptors. */ struct eepro100_rxfd {
@@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ; -int read_cmd = location |EE_READ_CMD ; +int read_cmd = location |EE_READ_CMD (addr_len);int i;OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM );
Signature · 1 line
2.25.1
PATCH 20/30 net: eepro100: Fix EE_*_CMD macros
Quoted 39 lines · Marek Vasut
Those macros depended on specific variable names to be declared at their usage sites, fix this by adding an argument to those macros and also protect the argument with braces.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/net/eepro100.c +5
-6@@ -96,10 +96,10 @@#define EE_DATA_BITS 16/* The EEPROM commands include the alway-set leading bit. */ -#define EE_EWENB_CMD (4 << addr_len) -#define EE_WRITE_CMD (5 << addr_len) -#define EE_READ_CMD (6 << addr_len) -#define EE_ERASE_CMD (7 << addr_len) +#define EE_EWENB_CMD (addr_len) (4 << (addr_len)) +#define EE_WRITE_CMD (addr_len) (5 << (addr_len)) +#define EE_READ_CMD (addr_len) (6 << (addr_len)) +#define EE_ERASE_CMD (addr_len) (7 << (addr_len))/* Receive frame descriptors. */ struct eepro100_rxfd {@@ -433,7 +433,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,static int read_eeprom (struct eth_device *dev,int location,int addr_len) {unsigned short retval =0 ; -int read_cmd = location |EE_READ_CMD ; +int read_cmd = location |EE_READ_CMD (addr_len);int i;OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); --
Quoted 2 lines
2.25.1
PATCH 21/30 net: eepro100: Drop inline keyword
In reply to Marek VasutDrop the inline keyword from the static functions, the compiler has a much better overview and can decide how to inline those functions much better.
--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/eepro100.c +4 -4
@@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = {#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a)#endif -static inline int INW (struct eth_device *dev,u_long addr) +static int INW (struct eth_device *dev,u_long addr) {return le16_to_cpu (readw (addr + (void *)dev->iobase)); } -static inline void OUTW (struct eth_device *dev,int command,u_long addr) +static void OUTW (struct eth_device *dev,int command,u_long addr) {writew (cpu_to_le16 (command), addr + (void *)dev->iobase); } -static inline void OUTL (struct eth_device *dev,int command,u_long addr) +static void OUTL (struct eth_device *dev,int command,u_long addr) {writel (cpu_to_le32 (command), addr + (void *)dev->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static inline int INL (struct eth_device *dev,u_long addr) +static int INL (struct eth_device *dev,u_long addr) {return le32_to_cpu (readl (addr + (void *)dev->iobase)); }
Signature · 1 line
2.25.1
PATCH 21/30 net: eepro100: Drop inline keyword
Quoted 43 lines · Marek Vasut
Drop the inline keyword from the static functions, the compiler has a much better overview and can decide how to inline those functions much better.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/net/eepro100.c +4
-5@@ -209,23 +209,23 @@ static const char i82558_config_cmd[] = {#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a)#endif -static inline int INW (struct eth_device *dev,u_long addr) +static int INW (struct eth_device *dev,u_long addr) {return le16_to_cpu (readw (addr + (void *)dev->iobase)); } -static inline void OUTW (struct eth_device *dev,int command,u_long addr) +static void OUTW (struct eth_device *dev,int command,u_long addr) {writew (cpu_to_le16 (command), addr + (void *)dev->iobase); } -static inline void OUTL (struct eth_device *dev,int command,u_long addr) +static void OUTL (struct eth_device *dev,int command,u_long addr) {writel (cpu_to_le32 (command), addr + (void *)dev->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static inline int INL (struct eth_device *dev,u_long addr) +static int INL (struct eth_device *dev,u_long addr) {return le32_to_cpu (readl (addr + (void *)dev->iobase)); } --
Quoted 2 lines
2.25.1
Actually, AFAIK even if inline is used the compiled is free to do whatever he wants,
this is only a suggestion, there's a GCC property named always_inline which forces the compiler to inline.
PATCH 22/30 net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus()
In reply to Marek VasutThis is a trick in preparation for adding DM support. By passing in the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling that dev, we can substitute dev with udevice when DM support lands and do minor adjustment to the macros to support both DM and non-DM operation. No functional change.
--- drivers/net/eepro100.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
drivers/net/eepro100.c +22 -14
@@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = { };#if defined(CONFIG_E500 ) -#define bus_to_phys (a) (a) -#define phys_to_bus (a) (a) +#define bus_to_phys (dev, a) (a) +#define phys_to_bus (dev, a) (a)#else -#define bus_to_phys (a) pci_mem_to_phys((pci_dev_t)dev->priv, a) -#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a) +#define bus_to_phys (dev, a) pci_mem_to_phys((dev), (a)) +#define phys_to_bus (dev, a) pci_phys_to_mem((dev), (a))#endif static int INW (struct eth_device *dev,u_long addr)
@@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 );
@@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,if (!wait_for_eepro100 (dev))return -ETIMEDOUT ; -OUTL (dev,phys_to_bus ((u32 )desc),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32 )desc),SCB_POINTER );OUTW (dev,SCB_M |CU_START ,SCB_CMD );while (true) {
@@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32)&rx_ring[rx_next]), +SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */
@@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd));
@@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 );
@@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status =0 ; desc->count =cpu_to_le32 (tx_threshold); - desc->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); - desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((u_long )packet)); + desc->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u_long )packet)); desc->tx_buf_size0 =cpu_to_le32 (length); ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]);
@@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, + (u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); }
@@ -785,7 +793,7 @@ int eepro100_initialize(bd_t *bis)sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); + dev->iobase =bus_to_phys (devno, iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send;
Signature · 1 line
2.25.1
PATCH 22/30 net: eepro100: Pass PCI BDF into bus_to_phys()/phys_to_bus()
Quoted 117 lines · Marek Vasut
This is a trick in preparation for adding DM support. By passing in the PCI BDF into the bus_to_phys()/phys_to_bus() macros and calling that dev, we can substitute dev with udevice when DM support lands and do minor adjustment to the macros to support both DM and non-DM operation. No functional change.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)drivers/net/eepro100.c +22
-15@@ -202,11 +202,11 @@ static const char i82558_config_cmd[] = { };#if defined(CONFIG_E500 ) -#define bus_to_phys (a) (a) -#define phys_to_bus (a) (a) +#define bus_to_phys (dev, a) (a) +#define phys_to_bus (dev, a) (a)#else -#define bus_to_phys (a) pci_mem_to_phys((pci_dev_t)dev->priv, a) -#define phys_to_bus (a) pci_phys_to_mem((pci_dev_t)dev->priv, a) +#define bus_to_phys (dev, a) pci_mem_to_phys((dev), (a)) +#define phys_to_bus (dev, a) pci_phys_to_mem((dev), (a))#endif static int INW (struct eth_device *dev,u_long addr)@@ -352,7 +352,8 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((u32)&rx_ring[(i +1 ) % +cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ; rx_ring[i].count =cpu_to_le32 (PKTSIZE_ALIGN <<16 );@@ -401,7 +402,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,if (!wait_for_eepro100 (dev))return -ETIMEDOUT ; -OUTL (dev,phys_to_bus ((u32 )desc),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32 )desc),SCB_POINTER );OUTW (dev,SCB_M |CU_START ,SCB_CMD );while (true) {@@ -562,7 +563,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32)&rx_ring[rx_next]), +SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ @@ -573,7 +575,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + cfg_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd));@@ -593,7 +596,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); + ias_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 );@@ -629,9 +633,12 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status =0 ; desc->count =cpu_to_le32 (tx_threshold); - desc->link =cpu_to_le32 (phys_to_bus ((u32)&tx_ring[tx_next])); - desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((u_long )packet)); + desc->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u32)&desc->tx_buf_addr0)); + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + (u_long )packet)); desc->tx_buf_size0 =cpu_to_le32 (length); ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]);@@ -706,7 +713,8 @@ static int eepro100_recv(struct eth_device *dev) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, + (u32)&rx_ring[rx_next]),SCB_POINTER );OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); }@@ -785,7 +793,7 @@ int eepro100_initialize(bd_t *bis)sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (iobase); + dev->iobase =bus_to_phys (devno, iobase); dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send; --
Quoted 2 lines
2.25.1
PATCH 23/30 net: eepro100: Introduce device private data
In reply to Marek Vasut--- drivers/net/eepro100.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/net/eepro100.c +9 -3
@@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; +struct eepro100_priv { +struct eth_device dev; +}; +#if defined(CONFIG_E500 )#define bus_to_phys (dev, a) (a)#define phys_to_bus (dev, a) (a)
@@ -751,6 +755,7 @@ done:int eepro100_initialize (bd_t *bis) { +struct eepro100_priv *priv;struct eth_device *dev;int card_number =0 ;u32 iobase, status;
@@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev =calloc (1 ,sizeof (*dev)); -if (!dev) { + priv =calloc (1 ,sizeof (*priv)); +if (!priv) {printf ("eepro100: Can not allocate memory\n" );break ; } + dev = &priv->dev;sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */
@@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis) ret =eepro100_initialize_mii (dev);if (ret) {eth_unregister (dev); -free (dev); +free (priv);return ret; }
Signature · 1 line
2.25.1
PATCH 23/30 net: eepro100: Introduce device private data
Quoted 54 lines · Marek Vasut
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)drivers/net/eepro100.c +9
-4@@ -201,6 +201,10 @@ static const char i82558_config_cmd[] = { 0x31, 0x05, }; +struct eepro100_priv { +struct eth_device dev; +}; +#if defined(CONFIG_E500 )#define bus_to_phys (dev, a) (a)#define phys_to_bus (dev, a) (a)@@ -751,6 +755,7 @@ done:int eepro100_initialize (bd_t *bis) { +struct eepro100_priv *priv;struct eth_device *dev;int card_number =0 ;u32 iobase, status;@@ -785,11 +790,12 @@ int eepro100_initialize(bd_t *bis)continue ; } - dev =calloc (1 ,sizeof (*dev)); -if (!dev) { + priv =calloc (1 ,sizeof (*priv)); +if (!priv) {printf ("eepro100: Can not allocate memory\n" );break ; } + dev = &priv->dev;sprintf (dev->name,"i82559#%d" , card_number); dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ @@ -804,7 +810,7 @@ int eepro100_initialize(bd_t *bis) ret =eepro100_initialize_mii (dev);if (ret) {eth_unregister (dev); -free (dev); +free (priv);return ret; } --
Quoted 2 lines
2.25.1
PATCH 24/30 net: eepro100: Pass device private data around
In reply to Marek VasutThis patch replaces the various uses of struct eth_device for accessing device private data with struct eepro100_priv, which is compatible both with DM and non-DM operation.
--- drivers/net/eepro100.c | 264 ++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 124 deletions(-)
drivers/net/eepro100.c +140 -124
@@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = {struct eepro100_priv {struct eth_device dev; +pci_dev_t devno; +char *name; +void __iomem *iobase; +u8 *enetaddr; };#if defined(CONFIG_E500 )
@@ -213,40 +217,40 @@ struct eepro100_priv {#define phys_to_bus (dev, a) pci_phys_to_mem((dev), (a))#endif -static int INW (struct eth_device *dev,u_long addr) +static int INW (struct eepro100_priv *priv,u_long addr) { -return le16_to_cpu (readw (addr + (void *)dev->iobase)); +return le16_to_cpu (readw (addr + priv->iobase)); } -static void OUTW (struct eth_device *dev,int command,u_long addr) +static void OUTW (struct eepro100_priv *priv,int command,u_long addr) { -writew (cpu_to_le16 (command), addr + (void *)dev->iobase); +writew (cpu_to_le16 (command), addr + priv->iobase); } -static void OUTL (struct eth_device *dev,int command,u_long addr) +static void OUTL (struct eepro100_priv *priv,int command,u_long addr) { -writel (cpu_to_le32 (command), addr + (void *)dev->iobase); +writel (cpu_to_le32 (command), addr + priv->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static int INL (struct eth_device *dev,u_long addr) +static int INL (struct eepro100_priv *priv,u_long addr) { -return le32_to_cpu (readl (addr + (void *)dev->iobase)); +return le32_to_cpu (readl (addr + priv->iobase)); } -static int get_phyreg (struct eth_device *dev,unsigned char addr, +static int get_phyreg (struct eepro100_priv *priv,unsigned char addr,unsigned char reg,unsigned short *value) { -int cmd;int timeout =50 ; +int cmd;/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd,SCB_CTRL_MDI ); +OUTL (priv, cmd,SCB_CTRL_MDI );do {udelay (1000 ); - cmd =INL (dev,SCB_CTRL_MDI ); + cmd =INL (priv,SCB_CTRL_MDI ); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )
@@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,return 0 ; } -static int set_phyreg (struct eth_device *dev,unsigned char addr, +static int set_phyreg (struct eepro100_priv *priv,unsigned char addr,unsigned char reg,unsigned short value) { -int cmd;int timeout =50 ; +int cmd;/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value,SCB_CTRL_MDI ); +OUTL (priv, cmd | value,SCB_CTRL_MDI ); -while (!(INL (dev,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout)) +while (!(INL (priv,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )
@@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, -unsigned char addr) +static int verify_phyaddr (struct eepro100_priv *priv,unsigned char addr) { -struct eth_device *dev; -unsigned short value; -unsigned char model; - - dev =eth_get_dev_by_name (devname); -if (!dev) { -printf ("%s: no such device\n" , devname); -return NULL ; - } +unsigned short value, model; +int ret;/* read id2 register */ -if (get_phyreg (dev, addr,MII_PHYSID2 , &value) !=0 ) { -printf ("%s: mii read timeout!\n" , devname); -return NULL ; + ret =get_phyreg (priv, addr,MII_PHYSID2 , &value); +if (ret) { +printf ("%s: mii read timeout!\n" , priv->name); +return ret; }/* get model */ - model = (unsigned char )((value >>4 ) &0x003f ); - -if (model ==0 ) { -printf ("%s: no PHY at address %d\n" , devname, addr); -return NULL ; + model = (value >>4 ) &0x003f ; +if (!model) { +printf ("%s: no PHY at address %d\n" , priv->name, addr); +return -EINVAL ; } -return dev; +return 0 ; }static int eepro100_miiphy_read (struct mii_dev *bus,int addr,int devad,int reg) { +struct eth_device *dev =eth_get_dev_by_name (bus->name); +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);unsigned short value =0 ; -struct eth_device *dev; +int ret; - dev =verify_phyaddr (bus->name, addr); -if (!dev) -return -1 ; + ret =verify_phyaddr (priv, addr); +if (ret) +return ret; -if (get_phyreg (dev, addr, reg, &value) !=0 ) { + ret =get_phyreg (priv, addr, reg, &value); +if (ret) {printf ("%s: mii read timeout!\n" , bus->name); -return -1 ; +return ret; }return value;
@@ -331,23 +331,26 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,static int eepro100_miiphy_write (struct mii_dev *bus,int addr,int devad,int reg,u16 value) { -struct eth_device *dev; +struct eth_device *dev =eth_get_dev_by_name (bus->name); +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +int ret; - dev =verify_phyaddr (bus->name, addr); -if (!dev) -return -1 ; + ret =verify_phyaddr (priv, addr); +if (ret) +return ret; -if (set_phyreg (dev, addr, reg, value) !=0 ) { + ret =set_phyreg (priv, addr, reg, value); +if (ret) {printf ("%s: mii write timeout!\n" , bus->name); -return -1 ; +return ret; }return 0 ; } -#endif -static void init_rx_ring (struct eth_device *dev) +static void init_rx_ring (struct eepro100_priv *priv) {int i;
@@ -356,7 +359,7 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, +cpu_to_le32 (phys_to_bus (priv->devno, (u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ;
@@ -370,7 +373,7 @@ static void init_rx_ring(struct eth_device *dev) rx_next =0 ; } -static void purge_tx_ring (struct eth_device *dev) +static void purge_tx_ring (struct eepro100_priv *priv) { tx_next =0 ; tx_threshold =0x01208000 ;
@@ -382,11 +385,11 @@ static void purge_tx_ring(struct eth_device *dev) }/* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static int wait_for_eepro100 (struct eepro100_priv *priv) {int i; -for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (priv,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP )return 0 ; }
@@ -394,7 +397,7 @@ static int wait_for_eepro100(struct eth_device *dev)return 1 ; } -static int eepro100_txcmd_send (struct eth_device *dev, +static int eepro100_txcmd_send (struct eepro100_priv *priv,struct eepro100_txfd *desc) {u16 rstat;
@@ -403,11 +406,11 @@ static int eepro100_txcmd_send(struct eth_device *dev,flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); -if (!wait_for_eepro100 (dev)) +if (!wait_for_eepro100 (priv))return -ETIMEDOUT ; -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32 )desc),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); +OUTL (priv,phys_to_bus (priv->devno, (u32 )desc),SCB_POINTER ); +OUTW (priv,SCB_M |CU_START ,SCB_CMD );while (true) { invalidate_dcache_range((unsigned long)desc,
@@ -417,7 +420,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,break ;if (i++ >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , priv->name);return -EINVAL ; } }
@@ -435,42 +438,42 @@ static int eepro100_txcmd_send(struct eth_device *dev, }/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +static int read_eeprom (struct eepro100_priv *priv,int location,int addr_len) {unsigned short retval =0 ;int read_cmd = location |EE_READ_CMD (addr_len);int i; -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); +OUTW (priv,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (priv,EE_ENB ,SCB_EEPROM );/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); +OUTW (priv,EE_ENB | dataval,SCB_EEPROM );udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); +OUTW (priv,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); } -OUTW (dev,EE_ENB ,SCB_EEPROM ); +OUTW (priv,EE_ENB ,SCB_EEPROM );for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); +OUTW (priv,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); retval = (retval <<1 ) | - ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); + !!(INW (priv,SCB_EEPROM ) &EE_DATA_READ ); +OUTW (priv,EE_ENB ,SCB_EEPROM );udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (priv,EE_ENB & ~EE_CS ,SCB_EEPROM );return retval; }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static int eepro100_initialize_mii (struct eth_device *dev) +static int eepro100_initialize_mii (struct eepro100_priv *priv) {/* register mii command access routines */ struct mii_dev *mdiodev;
@@ -480,7 +483,7 @@ static int eepro100_initialize_mii(struct eth_device *dev)if (!mdiodev)return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); +strncpy (mdiodev->name, priv->name,MDIO_NAME_LEN ); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write;
@@ -493,7 +496,7 @@ static int eepro100_initialize_mii(struct eth_device *dev) return 0; }#else -static int eepro100_initialize_mii (struct eth_device *dev) +static int eepro100_initialize_mii (struct eepro100_priv *priv) {return 0 ; }
@@ -506,70 +509,72 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr (struct eth_device *dev,bd_t *bis) +static void read_hw_addr (struct eepro100_priv *priv,bd_t *bis) {u16 sum =0 ;int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; +int addr_len =read_eeprom (priv,0 ,6 ) ==0xffff ?8 :6 ;for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); +u16 value =read_eeprom (priv, i, addr_len); sum += value;if (i <3 ) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >>8 ; + priv->enetaddr[j++] = value; + priv->enetaddr[j++] = value >>8 ; } }if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); +memset (priv->enetaddr,0 ,ETH_ALEN );debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , - dev->name, sum); + priv->name, sum); } }static int eepro100_init (struct eth_device *dev,bd_t *bis) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *ias_cmd, *cfg_cmd;int ret, status =-1 ;int tx_cur;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT ); +OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET ,SCB_PORT ); +OUTL (priv,I82559_RESET ,SCB_PORT );udelay (20 ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |CU_ADDR_LOAD ,SCB_CMD );/* Initialize Rx and Tx rings. */ -init_rx_ring (dev); -purge_tx_ring (dev); +init_rx_ring (priv); +purge_tx_ring (priv);/* Tell the adapter where the RX ring is located. */ -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32)&rx_ring[rx_next]), +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[rx_next]),SCB_POINTER ); -OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ tx_cur = tx_next;
@@ -579,13 +584,13 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + cfg_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd)); - ret =eepro100_txcmd_send (dev, cfg_cmd); + ret =eepro100_txcmd_send (priv, cfg_cmd);if (ret) {if (ret == -ETIMEDOUT )printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" );
@@ -600,12 +605,12 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + ias_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&tx_ring[tx_next])); -memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 ); +memcpy (((struct descriptor *)ias_cmd)->params, priv->enetaddr,6 ); - ret =eepro100_txcmd_send (dev, ias_cmd); + ret =eepro100_txcmd_send (priv, ias_cmd);if (ret) {if (ret == -ETIMEDOUT )printf ("Error: Can not reset ethernet controller.\n" );
@@ -620,12 +625,14 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;if (length <=0 ) { -printf ("%s: bad packet size: %d\n" , dev->name, length); +printf ("%s: bad packet size: %d\n" , priv->name, length); goto done; }
@@ -637,19 +644,19 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status =0 ; desc->count =cpu_to_le32 (tx_threshold); - desc->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, - (u32)&tx_ring[tx_next])); - desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + desc->link =cpu_to_le32 (phys_to_bus (priv->devno, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus (priv->devno, (u_long )packet)); desc->tx_buf_size0 =cpu_to_le32 (length); - ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]); + ret =eepro100_txcmd_send (priv, &tx_ring[tx_cur]);if (ret) {if (ret == -ETIMEDOUT )printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); + priv->name); goto done; }
@@ -661,12 +668,14 @@ done:static int eepro100_recv (struct eth_device *dev) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *desc;int rx_prev, length =0 ;u16 status, stat; - stat =INW (dev,SCB_STATUS ); -OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS ); + stat =INW (priv,SCB_STATUS ); +OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { desc = &rx_ring[rx_next];
@@ -706,20 +715,20 @@ static int eepro100_recv(struct eth_device *dev) }if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name); +printf ("%s: Receiver is not ready, restart it !\n" , priv->name);/* Reinitialize Rx ring. */ -init_rx_ring (dev); +init_rx_ring (priv); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not restart ethernet controller.\n" ); goto done; }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, - (u32)&rx_ring[rx_next]),SCB_POINTER ); -OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); +OUTL (priv,phys_to_bus (priv->devno, + (u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); } done:
@@ -728,26 +737,29 @@ done:static void eepro100_halt (struct eth_device *dev) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT ); +OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET ,SCB_PORT ); +OUTL (priv,I82559_RESET ,SCB_PORT );udelay (20 ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); done:return ;
@@ -798,8 +810,12 @@ int eepro100_initialize(bd_t *bis) dev = &priv->dev;sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (devno, iobase); + priv->name = dev->name; +/* this have to come before bus_to_phys() */ + priv->devno = devno; + priv->iobase = (void __iomem *)bus_to_phys (devno, iobase); + priv->enetaddr = dev->enetaddr; + dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send;
@@ -807,7 +823,7 @@ int eepro100_initialize(bd_t *bis)eth_register (dev); - ret =eepro100_initialize_mii (dev); + ret =eepro100_initialize_mii (priv);if (ret) {eth_unregister (dev);free (priv);
@@ -821,7 +837,7 @@ int eepro100_initialize(bd_t *bis)udelay (10 *1000 ); -read_hw_addr (dev, bis); +read_hw_addr (priv, bis); }return card_number;
Signature · 1 line
2.25.1
PATCH 24/30 net: eepro100: Pass device private data around
Quoted 627 lines · Marek Vasut
This patch replaces the various uses of struct
eth_devicefor accessing device private data with structeepro100_priv, which is compatible both with DM and non-DM operation.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 264 ++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 124 deletions(-)drivers/net/eepro100.c +140
-125@@ -203,6 +203,10 @@ static const char i82558_config_cmd[] = {struct eepro100_priv {struct eth_device dev; +pci_dev_t devno; +char *name; +void __iomem *iobase; +u8 *enetaddr; };#if defined(CONFIG_E500 )@@ -213,40 +217,40 @@ struct eepro100_priv {#define phys_to_bus (dev, a) pci_phys_to_mem((dev), (a))#endif -static int INW (struct eth_device *dev,u_long addr) +static int INW (struct eepro100_priv *priv,u_long addr) { -return le16_to_cpu (readw (addr + (void *)dev->iobase)); +return le16_to_cpu (readw (addr + priv->iobase)); } -static void OUTW (struct eth_device *dev,int command,u_long addr) +static void OUTW (struct eepro100_priv *priv,int command,u_long addr) { -writew (cpu_to_le16 (command), addr + (void *)dev->iobase); +writew (cpu_to_le16 (command), addr + priv->iobase); } -static void OUTL (struct eth_device *dev,int command,u_long addr) +static void OUTL (struct eepro100_priv *priv,int command,u_long addr) { -writel (cpu_to_le32 (command), addr + (void *)dev->iobase); +writel (cpu_to_le32 (command), addr + priv->iobase); }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static int INL (struct eth_device *dev,u_long addr) +static int INL (struct eepro100_priv *priv,u_long addr) { -return le32_to_cpu (readl (addr + (void *)dev->iobase)); +return le32_to_cpu (readl (addr + priv->iobase)); } -static int get_phyreg (struct eth_device *dev,unsigned char addr, +static int get_phyreg (struct eepro100_priv *priv,unsigned char addr,unsigned char reg,unsigned short *value) { -int cmd;int timeout =50 ; +int cmd;/* read requested data */ cmd = (2 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd,SCB_CTRL_MDI ); +OUTL (priv, cmd,SCB_CTRL_MDI );do {udelay (1000 ); - cmd =INL (dev,SCB_CTRL_MDI ); + cmd =INL (priv,SCB_CTRL_MDI ); }while (!(cmd & (1 <<28 )) && (--timeout));if (timeout ==0 )@@ -257,17 +261,17 @@ static int get_phyreg(struct eth_device *dev, unsigned char addr,return 0 ; } -static int set_phyreg (struct eth_device *dev,unsigned char addr, +static int set_phyreg (struct eepro100_priv *priv,unsigned char addr,unsigned char reg,unsigned short value) { -int cmd;int timeout =50 ; +int cmd;/* write requested data */ cmd = (1 <<26 ) | ((addr &0x1f ) <<21 ) | ((reg &0x1f ) <<16 ); -OUTL (dev, cmd | value,SCB_CTRL_MDI ); +OUTL (priv, cmd | value,SCB_CTRL_MDI ); -while (!(INL (dev,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout)) +while (!(INL (priv,SCB_CTRL_MDI ) & (1 <<28 )) && (--timeout))udelay (1000 );if (timeout ==0 )@@ -280,49 +284,45 @@ static int set_phyreg(struct eth_device *dev, unsigned char addr,* Check if given phyaddr is valid, i.e. there is a PHY connected. * Do this by checking model value field from ID2 register. */ -static struct eth_device *verify_phyaddr (const char *devname, -unsigned char addr) +static int verify_phyaddr (struct eepro100_priv *priv,unsigned char addr) { -struct eth_device *dev; -unsigned short value; -unsigned char model; - - dev =eth_get_dev_by_name (devname); -if (!dev) { -printf ("%s: no such device\n" , devname); -return NULL ; - } +unsigned short value, model; +int ret;/* read id2 register */ -if (get_phyreg (dev, addr,MII_PHYSID2 , &value) !=0 ) { -printf ("%s: mii read timeout!\n" , devname); -return NULL ; + ret =get_phyreg (priv, addr,MII_PHYSID2 , &value); +if (ret) { +printf ("%s: mii read timeout!\n" , priv->name); +return ret; }/* get model */ - model = (unsigned char )((value >>4 ) &0x003f ); - -if (model ==0 ) { -printf ("%s: no PHY at address %d\n" , devname, addr); -return NULL ; + model = (value >>4 ) &0x003f ; +if (!model) { +printf ("%s: no PHY at address %d\n" , priv->name, addr); +return -EINVAL ; } -return dev; +return 0 ; }static int eepro100_miiphy_read (struct mii_dev *bus,int addr,int devad,int reg) { +struct eth_device *dev =eth_get_dev_by_name (bus->name); +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);unsigned short value =0 ; -struct eth_device *dev; +int ret; - dev =verify_phyaddr (bus->name, addr); -if (!dev) -return -1 ; + ret =verify_phyaddr (priv, addr); +if (ret) +return ret; -if (get_phyreg (dev, addr, reg, &value) !=0 ) { + ret =get_phyreg (priv, addr, reg, &value); +if (ret) {printf ("%s: mii read timeout!\n" , bus->name); -return -1 ; +return ret; }return value;@@ -331,23 +331,26 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,static int eepro100_miiphy_write (struct mii_dev *bus,int addr,int devad,int reg,u16 value) { -struct eth_device *dev; +struct eth_device *dev =eth_get_dev_by_name (bus->name); +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +int ret; - dev =verify_phyaddr (bus->name, addr); -if (!dev) -return -1 ; + ret =verify_phyaddr (priv, addr); +if (ret) +return ret; -if (set_phyreg (dev, addr, reg, value) !=0 ) { + ret =set_phyreg (priv, addr, reg, value); +if (ret) {printf ("%s: mii write timeout!\n" , bus->name); -return -1 ; +return ret; }return 0 ; } -#endif -static void init_rx_ring (struct eth_device *dev) +static void init_rx_ring (struct eepro100_priv *priv) {int i;@@ -356,7 +359,7 @@ static void init_rx_ring(struct eth_device *dev) rx_ring[i].control = (i ==NUM_RX_DESC -1 ) ?cpu_to_le16 (RFD_CONTROL_S ) :0 ; rx_ring[i].link = -cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, +cpu_to_le32 (phys_to_bus (priv->devno, (u32)&rx_ring[(i +1 ) %NUM_RX_DESC ])); rx_ring[i].rx_buf_addr =0xffffffff ;@@ -370,7 +373,7 @@ static void init_rx_ring(struct eth_device *dev) rx_next =0 ; } -static void purge_tx_ring (struct eth_device *dev) +static void purge_tx_ring (struct eepro100_priv *priv) { tx_next =0 ; tx_threshold =0x01208000 ;@@ -382,11 +385,11 @@ static void purge_tx_ring(struct eth_device *dev) }/* Wait for the chip get the command. */ -static int wait_for_eepro100 (struct eth_device *dev) +static int wait_for_eepro100 (struct eepro100_priv *priv) {int i; -for (i =0 ;INW (dev,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) { +for (i =0 ;INW (priv,SCB_CMD ) & (CU_CMD_MASK |RU_CMD_MASK ); i++) {if (i >=TOUT_LOOP )return 0 ; }@@ -394,7 +397,7 @@ static int wait_for_eepro100(struct eth_device *dev)return 1 ; } -static int eepro100_txcmd_send (struct eth_device *dev, +static int eepro100_txcmd_send (struct eepro100_priv *priv,struct eepro100_txfd *desc) {u16 rstat;@@ -403,11 +406,11 @@ static int eepro100_txcmd_send(struct eth_device *dev,flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); -if (!wait_for_eepro100 (dev)) +if (!wait_for_eepro100 (priv))return -ETIMEDOUT ; -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32 )desc),SCB_POINTER ); -OUTW (dev,SCB_M |CU_START ,SCB_CMD ); +OUTL (priv,phys_to_bus (priv->devno, (u32 )desc),SCB_POINTER ); +OUTW (priv,SCB_M |CU_START ,SCB_CMD );while (true) { invalidate_dcache_range((unsigned long)desc,@@ -417,7 +420,7 @@ static int eepro100_txcmd_send(struct eth_device *dev,break ;if (i++ >=TOUT_LOOP ) { -printf ("%s: Tx error buffer not ready\n" , dev->name); +printf ("%s: Tx error buffer not ready\n" , priv->name);return -EINVAL ; } }@@ -435,42 +438,42 @@ static int eepro100_txcmd_send(struct eth_device *dev, }/* SROM Read. */ -static int read_eeprom (struct eth_device *dev,int location,int addr_len) +static int read_eeprom (struct eepro100_priv *priv,int location,int addr_len) {unsigned short retval =0 ;int read_cmd = location |EE_READ_CMD (addr_len);int i; -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); +OUTW (priv,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (priv,EE_ENB ,SCB_EEPROM );/* Shift the read command bits out. */ for (i =12 ; i >=0 ; i--) {short dataval = (read_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval,SCB_EEPROM ); +OUTW (priv,EE_ENB | dataval,SCB_EEPROM );udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM ); +OUTW (priv,EE_ENB | dataval |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); } -OUTW (dev,EE_ENB ,SCB_EEPROM ); +OUTW (priv,EE_ENB ,SCB_EEPROM );for (i =15 ; i >=0 ; i--) { -OUTW (dev,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM ); +OUTW (priv,EE_ENB |EE_SHIFT_CLK ,SCB_EEPROM );udelay (1 ); retval = (retval <<1 ) | - ((INW (dev,SCB_EEPROM ) &EE_DATA_READ ) ?1 :0 ); -OUTW (dev,EE_ENB ,SCB_EEPROM ); + !!(INW (priv,SCB_EEPROM ) &EE_DATA_READ ); +OUTW (priv,EE_ENB ,SCB_EEPROM );udelay (1 ); }/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS ,SCB_EEPROM ); +OUTW (priv,EE_ENB & ~EE_CS ,SCB_EEPROM );return retval; }#if defined(CONFIG_MII ) || defined(CONFIG_CMD_MII ) -static int eepro100_initialize_mii (struct eth_device *dev) +static int eepro100_initialize_mii (struct eepro100_priv *priv) {/* register mii command access routines */ struct mii_dev *mdiodev;@@ -480,7 +483,7 @@ static int eepro100_initialize_mii(struct eth_device *dev)if (!mdiodev)return -ENOMEM ; -strncpy (mdiodev->name, dev->name,MDIO_NAME_LEN ); +strncpy (mdiodev->name, priv->name,MDIO_NAME_LEN ); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write;@@ -493,7 +496,7 @@ static int eepro100_initialize_mii(struct eth_device *dev) return 0; }#else -static int eepro100_initialize_mii (struct eth_device *dev) +static int eepro100_initialize_mii (struct eepro100_priv *priv) {return 0 ; }@@ -506,70 +509,72 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr (struct eth_device *dev,bd_t *bis) +static void read_hw_addr (struct eepro100_priv *priv,bd_t *bis) {u16 sum =0 ;int i, j; -int addr_len =read_eeprom (dev,0 ,6 ) ==0xffff ?8 :6 ; +int addr_len =read_eeprom (priv,0 ,6 ) ==0xffff ?8 :6 ;for (j =0 , i =0 ; i <0x40 ; i++) { -u16 value =read_eeprom (dev, i, addr_len); +u16 value =read_eeprom (priv, i, addr_len); sum += value;if (i <3 ) { - dev->enetaddr[j++] = value; - dev->enetaddr[j++] = value >>8 ; + priv->enetaddr[j++] = value; + priv->enetaddr[j++] = value >>8 ; } }if (sum !=0xBABA ) { -memset (dev->enetaddr,0 ,ETH_ALEN ); +memset (priv->enetaddr,0 ,ETH_ALEN );debug ("%s: Invalid EEPROM checksum %#4.4x, check settings before activating this device!\n" , - dev->name, sum); + priv->name, sum); } }static int eepro100_init (struct eth_device *dev,bd_t *bis) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *ias_cmd, *cfg_cmd;int ret, status =-1 ;int tx_cur;/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT ); +OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET ,SCB_PORT ); +OUTL (priv,I82559_RESET ,SCB_PORT );udelay (20 ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |CU_ADDR_LOAD ,SCB_CMD );/* Initialize Rx and Tx rings. */ -init_rx_ring (dev); -purge_tx_ring (dev); +init_rx_ring (priv); +purge_tx_ring (priv);/* Tell the adapter where the RX ring is located. */ -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, (u32)&rx_ring[rx_next]), +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[rx_next]),SCB_POINTER ); -OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ tx_cur = tx_next;@@ -579,13 +584,13 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; - cfg_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + cfg_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&tx_ring[tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd)); - ret =eepro100_txcmd_send (dev, cfg_cmd); + ret =eepro100_txcmd_send (priv, cfg_cmd);if (ret) {if (ret == -ETIMEDOUT )printf ("Error---CONFIG_SYS_CMD_CONFIGURE: Can not reset ethernet controller.\n" );@@ -600,12 +605,12 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; - ias_cmd->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + ias_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&tx_ring[tx_next])); -memcpy (((struct descriptor *)ias_cmd)->params, dev->enetaddr,6 ); +memcpy (((struct descriptor *)ias_cmd)->params, priv->enetaddr,6 ); - ret =eepro100_txcmd_send (dev, ias_cmd); + ret =eepro100_txcmd_send (priv, ias_cmd);if (ret) {if (ret == -ETIMEDOUT )printf ("Error: Can not reset ethernet controller.\n" );@@ -620,12 +625,14 @@ done:static int eepro100_send (struct eth_device *dev,void *packet,int length) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;if (length <=0 ) { -printf ("%s: bad packet size: %d\n" , dev->name, length); +printf ("%s: bad packet size: %d\n" , priv->name, length); goto done; }@@ -637,19 +644,19 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) TXCB_CMD_S | TXCB_CMD_EL); desc->status =0 ; desc->count =cpu_to_le32 (tx_threshold); - desc->link =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, - (u32)&tx_ring[tx_next])); - desc->tx_desc_addr =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + desc->link =cpu_to_le32 (phys_to_bus (priv->devno, + (u32)&tx_ring[tx_next])); + desc->tx_desc_addr =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&desc->tx_buf_addr0)); - desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus ((pci_dev_t )dev->priv, + desc->tx_buf_addr0 =cpu_to_le32 (phys_to_bus (priv->devno, (u_long )packet)); desc->tx_buf_size0 =cpu_to_le32 (length); - ret =eepro100_txcmd_send (dev, &tx_ring[tx_cur]); + ret =eepro100_txcmd_send (priv, &tx_ring[tx_cur]);if (ret) {if (ret == -ETIMEDOUT )printf ("%s: Tx error ethernet controller not ready.\n" , - dev->name); + priv->name); goto done; }@@ -661,12 +668,14 @@ done:static int eepro100_recv (struct eth_device *dev) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *desc;int rx_prev, length =0 ;u16 status, stat; - stat =INW (dev,SCB_STATUS ); -OUTW (dev, stat &SCB_STATUS_RNR ,SCB_STATUS ); + stat =INW (priv,SCB_STATUS ); +OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { desc = &rx_ring[rx_next];@@ -706,20 +715,20 @@ static int eepro100_recv(struct eth_device *dev) }if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , dev->name); +printf ("%s: Receiver is not ready, restart it !\n" , priv->name);/* Reinitialize Rx ring. */ -init_rx_ring (dev); +init_rx_ring (priv); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not restart ethernet controller.\n" ); goto done; }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (dev,phys_to_bus ((pci_dev_t )dev->priv, - (u32)&rx_ring[rx_next]),SCB_POINTER ); -OUTW (dev,SCB_M |RUC_START ,SCB_CMD ); +OUTL (priv,phys_to_bus (priv->devno, + (u32)&rx_ring[rx_next]),SCB_POINTER ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); } done:@@ -728,26 +737,29 @@ done:static void eepro100_halt (struct eth_device *dev) { +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +/* Reset the ethernet controller */ -OUTL (dev,I82559_SELECTIVE_RESET ,SCB_PORT ); +OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 ); -OUTL (dev,I82559_RESET ,SCB_PORT ); +OUTL (priv,I82559_RESET ,SCB_PORT );udelay (20 ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |RUC_ADDR_LOAD ,SCB_CMD ); -if (!wait_for_eepro100 (dev)) { +if (!wait_for_eepro100 (priv)) {printf ("Error: Can not reset ethernet controller.\n" ); goto done; } -OUTL (dev,0 ,SCB_POINTER ); -OUTW (dev,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); +OUTL (priv,0 ,SCB_POINTER ); +OUTW (priv,SCB_M |CU_ADDR_LOAD ,SCB_CMD ); done:return ;@@ -798,8 +810,12 @@ int eepro100_initialize(bd_t *bis) dev = &priv->dev;sprintf (dev->name,"i82559#%d" , card_number); - dev->priv = (void *)devno;/* this have to come before bus_to_phys() */ - dev->iobase =bus_to_phys (devno, iobase); + priv->name = dev->name; +/* this have to come before bus_to_phys() */ + priv->devno = devno; + priv->iobase = (void __iomem *)bus_to_phys (devno, iobase); + priv->enetaddr = dev->enetaddr; + dev->init = eepro100_init; dev->halt = eepro100_halt; dev->send = eepro100_send;@@ -807,7 +823,7 @@ int eepro100_initialize(bd_t *bis)eth_register (dev); - ret =eepro100_initialize_mii (dev); + ret =eepro100_initialize_mii (priv);if (ret) {eth_unregister (dev);free (priv);@@ -821,7 +837,7 @@ int eepro100_initialize(bd_t *bis)udelay (10 *1000 ); -read_hw_addr (dev, bis); +read_hw_addr (priv, bis); }return card_number; --
Quoted 2 lines
2.25.1
PATCH 25/30 net: eepro100: Pass device private data into mdiobus
In reply to Marek VasutInstead of doing ethernet device lookup by name every time there is an MDIO access, pass the driver private data via mdiobus priv to the MDIO bus accessors.
--- drivers/net/eepro100.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/eepro100.c +3 -6
@@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)static int eepro100_miiphy_read (struct mii_dev *bus,int addr,int devad,int reg) { -struct eth_device *dev =eth_get_dev_by_name (bus->name); -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); +struct eepro100_priv *priv = bus->priv;unsigned short value =0 ;int ret;
@@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,static int eepro100_miiphy_write (struct mii_dev *bus,int addr,int devad,int reg,u16 value) { -struct eth_device *dev =eth_get_dev_by_name (bus->name); -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); +struct eepro100_priv *priv = bus->priv;int ret; ret =verify_phyaddr (priv, addr);
@@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv)strncpy (mdiodev->name, priv->name,MDIO_NAME_LEN ); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write; + mdiodev->priv = priv; ret =mdio_register (mdiodev);if (ret <0 ) {
Signature · 1 line
2.25.1
PATCH 25/30 net: eepro100: Pass device private data into mdiobus
Quoted 45 lines · Marek Vasut
Instead of doing ethernet device lookup by name every time there is an MDIO access, pass the driver private data via mdiobus priv to the MDIO bus accessors.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)drivers/net/eepro100.c +3
-7@@ -309,9 +309,7 @@ static int verify_phyaddr(struct eepro100_priv *priv, unsigned char addr)static int eepro100_miiphy_read (struct mii_dev *bus,int addr,int devad,int reg) { -struct eth_device *dev =eth_get_dev_by_name (bus->name); -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); +struct eepro100_priv *priv = bus->priv;unsigned short value =0 ;int ret;@@ -331,9 +329,7 @@ static int eepro100_miiphy_read(struct mii_dev *bus, int addr, int devad,static int eepro100_miiphy_write (struct mii_dev *bus,int addr,int devad,int reg,u16 value) { -struct eth_device *dev =eth_get_dev_by_name (bus->name); -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); +struct eepro100_priv *priv = bus->priv;int ret; ret =verify_phyaddr (priv, addr);@@ -486,6 +482,7 @@ static int eepro100_initialize_mii(struct eepro100_priv *priv)strncpy (mdiodev->name, priv->name,MDIO_NAME_LEN ); mdiodev->read = eepro100_miiphy_read; mdiodev->write = eepro100_miiphy_write; + mdiodev->priv = priv; ret =mdio_register (mdiodev);if (ret <0 ) { --
Quoted 2 lines
2.25.1
PATCH 26/30 net: eepro100: Add RX/TX rings into the private data
In reply to Marek VasutThe RX/TX DMA descriptor rings are per-device-instance private data, so move them into the private data.
--- drivers/net/eepro100.c | 59 +++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 24 deletions(-)
drivers/net/eepro100.c +35 -24
@@ -183,12 +183,6 @@ struct descriptor { /* A generic descriptor. */#define TOUT_LOOP 1000000 -static struct eepro100_rxfd rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ -static int rx_next;/* RX descriptor ring pointer */ -static int tx_next;/* TX descriptor ring pointer */ -static int tx_threshold; -/* * The parameters for a CmdConfigure operation. * There are so many options that it would be difficult to document
@@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = { };struct eepro100_priv { +/* RX descriptor ring */ +struct eepro100_rxfd rx_ring[NUM_RX_DESC ]; +/* TX descriptor ring */ +struct eepro100_txfd tx_ring[NUM_TX_DESC ]; +/* RX descriptor ring pointer */ +int rx_next; +/* TX descriptor ring pointer */ +int tx_next; +int tx_threshold;struct eth_device dev;pci_dev_t devno;char *name;
@@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,static void init_rx_ring (struct eepro100_priv *priv) { +struct eepro100_rxfd *rx_ring = priv->rx_ring;int i;for (i =0 ; i <NUM_RX_DESC ; i++) {
@@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv) (unsigned long )rx_ring + (sizeof(*rx_ring) * NUM_RX_DESC)); - rx_next =0 ; + priv->rx_next =0 ; }static void purge_tx_ring (struct eepro100_priv *priv) { - tx_next =0 ; - tx_threshold =0x01208000 ; +struct eepro100_txfd *tx_ring = priv->tx_ring; + + priv->tx_next =0 ; + priv->tx_threshold =0x01208000 ;memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); flush_dcache_range((unsigned long)tx_ring,
@@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_rxfd *rx_ring = priv->rx_ring; +struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *ias_cmd, *cfg_cmd;int ret, status =-1 ;int tx_cur;
@@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[rx_next]), +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[priv->rx_next]),SCB_POINTER );OUTW (priv,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ - tx_cur = tx_next; - tx_next = ((tx_next +1 ) %NUM_TX_DESC ); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next +1 ) %NUM_TX_DESC ); cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; cfg_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd));
@@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* Send the Individual Address Setup frame */ - tx_cur = tx_next; - tx_next = ((tx_next +1 ) %NUM_TX_DESC ); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next +1 ) %NUM_TX_DESC ); ias_cmd = &tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; ias_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next]));memcpy (((struct descriptor *)ias_cmd)->params, priv->enetaddr,6 );
@@ -624,6 +632,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;
@@ -633,16 +642,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto done; } - tx_cur = tx_next; - tx_next = (tx_next +1 ) %NUM_TX_DESC ; + tx_cur = priv->tx_next; + priv->tx_next = (priv->tx_next +1 ) %NUM_TX_DESC ; desc = &tx_ring[tx_cur]; desc->command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF |TXCB_CMD_S |TXCB_CMD_EL ); desc->status =0 ; - desc->count =cpu_to_le32 (tx_threshold); + desc->count =cpu_to_le32 (priv->tx_threshold); desc->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); desc->tx_desc_addr =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&desc->tx_buf_addr0)); desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno,
@@ -667,6 +676,7 @@ static int eepro100_recv(struct eth_device *dev) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_rxfd *desc;int rx_prev, length =0 ;u16 status, stat;
@@ -675,7 +685,7 @@ static int eepro100_recv(struct eth_device *dev)OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { - desc = &rx_ring[rx_next]; + desc = &rx_ring[priv->rx_next];invalidate_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); status =le16_to_cpu (desc->status);
@@ -701,14 +711,14 @@ static int eepro100_recv(struct eth_device *dev)flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); - rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; + rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; desc = &rx_ring[rx_prev]; desc->control =0 ;flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc));/* Update entry information. */ - rx_next = (rx_next +1 ) %NUM_RX_DESC ; + priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; }if (stat &SCB_STATUS_RNR ) {
@@ -724,7 +734,8 @@ static int eepro100_recv(struct eth_device *dev)/* RX ring cache was already flushed in init_rx_ring() */ OUTL (priv,phys_to_bus (priv->devno, - (u32)&rx_ring[rx_next]),SCB_POINTER ); + (u32)&rx_ring[priv->rx_next]), +SCB_POINTER );OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); }
Signature · 1 line
2.25.1
PATCH 26/30 net: eepro100: Add RX/TX rings into the private data
Quoted 196 lines · Marek Vasut
The RX/TX DMA descriptor rings are per-device-instance private data, so move them into the private data.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 59 +++++++++++++++++++++++++----------------- 1 file changed, 35 insertions(+), 24 deletions(-)drivers/net/eepro100.c +35
-25@@ -183,12 +183,6 @@ struct descriptor { /* A generic descriptor. */#define TOUT_LOOP 1000000 -static struct eepro100_rxfd rx_ring[NUM_RX_DESC ];/* RX descriptor ring */ -static struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* TX descriptor ring */ -static int rx_next;/* RX descriptor ring pointer */ -static int tx_next;/* TX descriptor ring pointer */ -static int tx_threshold; -/* * The parameters for a CmdConfigure operation. * There are so many options that it would be difficult to document @@ -202,6 +196,15 @@ static const char i82558_config_cmd[] = { };struct eepro100_priv { +/* RX descriptor ring */ +struct eepro100_rxfd rx_ring[NUM_RX_DESC ]; +/* TX descriptor ring */ +struct eepro100_txfd tx_ring[NUM_TX_DESC ]; +/* RX descriptor ring pointer */ +int rx_next; +/* TX descriptor ring pointer */ +int tx_next; +int tx_threshold;struct eth_device dev;pci_dev_t devno;char *name;@@ -348,6 +351,7 @@ static int eepro100_miiphy_write(struct mii_dev *bus, int addr, int devad,static void init_rx_ring (struct eepro100_priv *priv) { +struct eepro100_rxfd *rx_ring = priv->rx_ring;int i;for (i =0 ; i <NUM_RX_DESC ; i++) {@@ -366,13 +370,15 @@ static void init_rx_ring(struct eepro100_priv *priv) (unsigned long )rx_ring + (sizeof(*rx_ring) * NUM_RX_DESC)); - rx_next =0 ; + priv->rx_next =0 ; }static void purge_tx_ring (struct eepro100_priv *priv) { - tx_next =0 ; - tx_threshold =0x01208000 ; +struct eepro100_txfd *tx_ring = priv->tx_ring; + + priv->tx_next =0 ; + priv->tx_threshold =0x01208000 ;memset (tx_ring,0 ,sizeof (*tx_ring) *NUM_TX_DESC ); flush_dcache_range((unsigned long)tx_ring,@@ -533,6 +539,8 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_rxfd *rx_ring = priv->rx_ring; +struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *ias_cmd, *cfg_cmd;int ret, status =-1 ;int tx_cur;@@ -569,20 +577,20 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[rx_next]), +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[priv->rx_next]),SCB_POINTER );OUTW (priv,SCB_M |RUC_START ,SCB_CMD );/* Send the Configure frame */ - tx_cur = tx_next; - tx_next = ((tx_next +1 ) %NUM_TX_DESC ); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next +1 ) %NUM_TX_DESC ); cfg_cmd = &tx_ring[tx_cur]; cfg_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_CONFIGURE ); cfg_cmd->status =0 ; cfg_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next]));memcpy (((struct descriptor *)cfg_cmd)->params, i82558_config_cmd,sizeof (i82558_config_cmd));@@ -595,15 +603,15 @@ static int eepro100_init(struct eth_device *dev, bd_t *bis) }/* Send the Individual Address Setup frame */ - tx_cur = tx_next; - tx_next = ((tx_next +1 ) %NUM_TX_DESC ); + tx_cur = priv->tx_next; + priv->tx_next = ((priv->tx_next +1 ) %NUM_TX_DESC ); ias_cmd = &tx_ring[tx_cur]; ias_cmd->command =cpu_to_le16 (CONFIG_SYS_CMD_SUSPEND |CONFIG_SYS_CMD_IAS ); ias_cmd->status =0 ; ias_cmd->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next]));memcpy (((struct descriptor *)ias_cmd)->params, priv->enetaddr,6 );@@ -624,6 +632,7 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *desc;int ret, status =-1 ;int tx_cur;@@ -633,16 +642,16 @@ static int eepro100_send(struct eth_device *dev, void *packet, int length) goto done; } - tx_cur = tx_next; - tx_next = (tx_next +1 ) %NUM_TX_DESC ; + tx_cur = priv->tx_next; + priv->tx_next = (priv->tx_next +1 ) %NUM_TX_DESC ; desc = &tx_ring[tx_cur]; desc->command =cpu_to_le16 (TXCB_CMD_TRANSMIT |TXCB_CMD_SF |TXCB_CMD_S |TXCB_CMD_EL ); desc->status =0 ; - desc->count =cpu_to_le32 (tx_threshold); + desc->count =cpu_to_le32 (priv->tx_threshold); desc->link =cpu_to_le32 (phys_to_bus (priv->devno, - (u32)&tx_ring[tx_next])); + (u32)&tx_ring[priv->tx_next])); desc->tx_desc_addr =cpu_to_le32 (phys_to_bus (priv->devno, (u32)&desc->tx_buf_addr0)); desc->tx_buf_addr0 = cpu_to_le32(phys_to_bus(priv->devno,@@ -667,6 +676,7 @@ static int eepro100_recv(struct eth_device *dev) {struct eepro100_priv *priv = container_of(dev, struct eepro100_priv, dev); +struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_rxfd *desc;int rx_prev, length =0 ;u16 status, stat;@@ -675,7 +685,7 @@ static int eepro100_recv(struct eth_device *dev)OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS );for (;;) { - desc = &rx_ring[rx_next]; + desc = &rx_ring[priv->rx_next];invalidate_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); status =le16_to_cpu (desc->status);@@ -701,14 +711,14 @@ static int eepro100_recv(struct eth_device *dev)flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc)); - rx_prev = (rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; + rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; desc = &rx_ring[rx_prev]; desc->control =0 ;flush_dcache_range ((unsigned long )desc, (unsigned long )desc +sizeof (*desc));/* Update entry information. */ - rx_next = (rx_next +1 ) %NUM_RX_DESC ; + priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; }if (stat &SCB_STATUS_RNR ) {@@ -724,7 +734,8 @@ static int eepro100_recv(struct eth_device *dev)/* RX ring cache was already flushed in init_rx_ring() */ OUTL (priv,phys_to_bus (priv->devno, - (u32)&rx_ring[rx_next]),SCB_POINTER ); + (u32)&rx_ring[priv->rx_next]), +SCB_POINTER );OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); } --
Quoted 2 lines
2.25.1
PATCH 27/30 net: eepro100: Drop bd_t pointer from read_hw_addr()
In reply to Marek VasutThe pointer is unused, so drop it. Rename the function to start with the eepro100_ prefix.
--- drivers/net/eepro100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/eepro100.c +2 -2
@@ -512,7 +512,7 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr (struct eepro100_priv *priv,bd_t *bis) +static void eepro100_get_hwaddr (struct eepro100_priv *priv) {u16 sum =0 ;int i, j;
@@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis)udelay (10 *1000 ); -read_hw_addr (priv, bis); +eepro100_get_hwaddr (priv); }return card_number;
Signature · 1 line
2.25.1
PATCH 27/30 net: eepro100: Drop bd_t pointer from read_hw_addr()
Quoted 32 lines · Marek Vasut
The pointer is unused, so drop it. Rename the function to start with the
eepro100_prefix.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/net/eepro100.c +2
-3@@ -512,7 +512,7 @@ static struct pci_device_id supported[] = { { } }; -static void read_hw_addr (struct eepro100_priv *priv,bd_t *bis) +static void eepro100_get_hwaddr (struct eepro100_priv *priv) {u16 sum =0 ;int i, j;@@ -845,7 +845,7 @@ int eepro100_initialize(bd_t *bis)udelay (10 *1000 ); -read_hw_addr (priv, bis); +eepro100_get_hwaddr (priv); }return card_number; --
Quoted 2 lines
2.25.1
PATCH 28/30 net: eepro100: Split common parts of non-DM functions out
In reply to Marek VasutSplit the common code from the non-DM code, so it can be reused by the DM code later. As always, the recv() function had to be split into the actual receiving part and free_pkt part to fit with the DM.
--- drivers/net/eepro100.c | 162 +++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 62 deletions(-)
drivers/net/eepro100.c +100 -62
@@ -202,6 +202,7 @@ struct eepro100_priv {struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* RX descriptor ring pointer */ int rx_next; +u16 rx_stat;/* TX descriptor ring pointer */ int tx_next;int tx_threshold;
@@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv *priv) } } -static int eepro100_init (struct eth_device *dev,bd_t *bis) +static int eepro100_init_common (struct eepro100_priv *priv) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *ias_cmd, *cfg_cmd;
@@ -628,10 +627,9 @@ done:return status; } -static int eepro100_send (struct eth_device *dev,void *packet,int length) +static int eepro100_send_common (struct eepro100_priv *priv, +void *packet,int length) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *desc;int ret, status =-1 ;
@@ -672,82 +670,82 @@ done:return status; } -static int eepro100_recv (struct eth_device *dev) +static int eepro100_recv_common (struct eepro100_priv *priv,uchar **packetp) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_rxfd *desc; -int rx_prev, length =0 ; -u16 status, stat; +int length; +u16 status; - stat =INW (priv,SCB_STATUS ); -OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS ); + priv->rx_stat =INW (priv,SCB_STATUS ); +OUTW (priv, priv->rx_stat &SCB_STATUS_RNR ,SCB_STATUS ); -for (;;) { - desc = &rx_ring[priv->rx_next]; -invalidate_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); - status =le16_to_cpu (desc->status); + desc = &rx_ring[priv->rx_next]; +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); + status =le16_to_cpu (desc->status); + +if (!(status &RFD_STATUS_C )) +return 0 ; + +/* Valid frame status. */ +if (status &RFD_STATUS_OK ) { +/* A valid frame received. */ + length =le32_to_cpu (desc->count) &0x3fff ; +/* Pass the packet up to the protocol layers. */ + *packetp = desc->data; +return length; + } -if (!(status &RFD_STATUS_C )) -break ; +/* There was an error. */ +printf ("RX error status = 0x%08X\n" , status); +return -EINVAL ; +} -/* Valid frame status. */ -if ((status &RFD_STATUS_OK )) { -/* A valid frame received. */ - length =le32_to_cpu (desc->count) &0x3fff ; +static void eepro100_free_pkt_common (struct eepro100_priv *priv) +{ +struct eepro100_rxfd *rx_ring = priv->rx_ring; +struct eepro100_rxfd *desc; +int rx_prev; -/* Pass the packet up to the protocol layers. */ -net_process_received_packet ((u8 *)desc->data, length); - }else { -/* There was an error. */ -printf ("RX error status = 0x%08X\n" , status); - } + desc = &rx_ring[priv->rx_next]; - desc->control =cpu_to_le16 (RFD_CONTROL_S ); - desc->status =0 ; - desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); -flush_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); + desc->control =cpu_to_le16 (RFD_CONTROL_S ); + desc->status =0 ; + desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); - rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; - desc = &rx_ring[rx_prev]; - desc->control =0 ; -flush_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); + rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; + desc = &rx_ring[rx_prev]; + desc->control =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); -/* Update entry information. */ - priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; - } +/* Update entry information. */ + priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; -if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , priv->name); +if (!(priv->rx_stat &SCB_STATUS_RNR )) +return ; -/* Reinitialize Rx ring. */ -init_rx_ring (priv); +printf ("%s: Receiver is not ready, restart it !\n" , priv->name); -if (!wait_for_eepro100 (priv)) { -printf ("Error: Can not restart ethernet controller.\n" ); - goto done; - } +/* Reinitialize Rx ring. */ +init_rx_ring (priv); -/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (priv,phys_to_bus (priv->devno, - (u32)&rx_ring[priv->rx_next]), -SCB_POINTER ); -OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); +if (!wait_for_eepro100 (priv)) { +printf ("Error: Can not restart ethernet controller.\n" ); +return ; } -done: -return length; +/* RX ring cache was already flushed in init_rx_ring() */ +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[priv->rx_next]), +SCB_POINTER ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); } -static void eepro100_halt (struct eth_device *dev) +static void eepro100_halt_common (struct eepro100_priv *priv) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); -/* Reset the ethernet controller */ OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 );
@@ -773,6 +771,46 @@ done:return ; } +static int eepro100_init (struct eth_device *dev,bd_t *bis) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +return eepro100_init_common (priv); +} + +static void eepro100_halt (struct eth_device *dev) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +eepro100_halt_common (priv); +} + +static int eepro100_send (struct eth_device *dev,void *packet,int length) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +return eepro100_send_common (priv, packet, length); +} + +static int eepro100_recv (struct eth_device *dev) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +uchar *packet; +int ret; + + ret =eepro100_recv_common (priv, &packet); +if (ret >0 ) +net_process_received_packet (packet, ret); +if (ret) +eepro100_free_pkt_common (priv); + +return ret; +} +int eepro100_initialize (bd_t *bis) {struct eepro100_priv *priv;
Signature · 1 line
2.25.1
PATCH 28/30 net: eepro100: Split common parts of non-DM functions out
Quoted 235 lines · Marek Vasut
Split the common code from the non-DM code, so it can be reused by the DM code later. As always, the
recv()function had to be split into the actual receiving part andfree_pktpart to fit with the DM.Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 162 +++++++++++++++++++++++++---------------- 1 file changed, 100 insertions(+), 62 deletions(-)drivers/net/eepro100.c +100
-63@@ -202,6 +202,7 @@ struct eepro100_priv {struct eepro100_txfd tx_ring[NUM_TX_DESC ];/* RX descriptor ring pointer */ int rx_next; +u16 rx_stat;/* TX descriptor ring pointer */ int tx_next;int tx_threshold;@@ -535,10 +536,8 @@ static void eepro100_get_hwaddr(struct eepro100_priv *priv) } } -static int eepro100_init (struct eth_device *dev,bd_t *bis) +static int eepro100_init_common (struct eepro100_priv *priv) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *ias_cmd, *cfg_cmd;@@ -628,10 +627,9 @@ done:return status; } -static int eepro100_send (struct eth_device *dev,void *packet,int length) +static int eepro100_send_common (struct eepro100_priv *priv, +void *packet,int length) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_txfd *tx_ring = priv->tx_ring;struct eepro100_txfd *desc;int ret, status =-1 ;@@ -672,82 +670,82 @@ done:return status; } -static int eepro100_recv (struct eth_device *dev) +static int eepro100_recv_common (struct eepro100_priv *priv,uchar **packetp) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev);struct eepro100_rxfd *rx_ring = priv->rx_ring;struct eepro100_rxfd *desc; -int rx_prev, length =0 ; -u16 status, stat; +int length; +u16 status; - stat =INW (priv,SCB_STATUS ); -OUTW (priv, stat &SCB_STATUS_RNR ,SCB_STATUS ); + priv->rx_stat =INW (priv,SCB_STATUS ); +OUTW (priv, priv->rx_stat &SCB_STATUS_RNR ,SCB_STATUS ); -for (;;) { - desc = &rx_ring[priv->rx_next]; -invalidate_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); - status =le16_to_cpu (desc->status); + desc = &rx_ring[priv->rx_next]; +invalidate_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); + status =le16_to_cpu (desc->status); + +if (!(status &RFD_STATUS_C )) +return 0 ; + +/* Valid frame status. */ +if (status &RFD_STATUS_OK ) { +/* A valid frame received. */ + length =le32_to_cpu (desc->count) &0x3fff ; +/* Pass the packet up to the protocol layers. */ + *packetp = desc->data; +return length; + } -if (!(status &RFD_STATUS_C )) -break ; +/* There was an error. */ +printf ("RX error status = 0x%08X\n" , status); +return -EINVAL ; +} -/* Valid frame status. */ -if ((status &RFD_STATUS_OK )) { -/* A valid frame received. */ - length =le32_to_cpu (desc->count) &0x3fff ; +static void eepro100_free_pkt_common (struct eepro100_priv *priv) +{ +struct eepro100_rxfd *rx_ring = priv->rx_ring; +struct eepro100_rxfd *desc; +int rx_prev; -/* Pass the packet up to the protocol layers. */ -net_process_received_packet ((u8 *)desc->data, length); - }else { -/* There was an error. */ -printf ("RX error status = 0x%08X\n" , status); - } + desc = &rx_ring[priv->rx_next]; - desc->control =cpu_to_le16 (RFD_CONTROL_S ); - desc->status =0 ; - desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); -flush_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); + desc->control =cpu_to_le16 (RFD_CONTROL_S ); + desc->status =0 ; + desc->count =cpu_to_le32 (PKTSIZE_ALIGN <<16 ); +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); - rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; - desc = &rx_ring[rx_prev]; - desc->control =0 ; -flush_dcache_range ((unsigned long )desc, - (unsigned long )desc +sizeof (*desc)); + rx_prev = (priv->rx_next +NUM_RX_DESC -1 ) %NUM_RX_DESC ; + desc = &rx_ring[rx_prev]; + desc->control =0 ; +flush_dcache_range ((unsigned long )desc, + (unsigned long )desc +sizeof (*desc)); -/* Update entry information. */ - priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; - } +/* Update entry information. */ + priv->rx_next = (priv->rx_next +1 ) %NUM_RX_DESC ; -if (stat &SCB_STATUS_RNR ) { -printf ("%s: Receiver is not ready, restart it !\n" , priv->name); +if (!(priv->rx_stat &SCB_STATUS_RNR )) +return ; -/* Reinitialize Rx ring. */ -init_rx_ring (priv); +printf ("%s: Receiver is not ready, restart it !\n" , priv->name); -if (!wait_for_eepro100 (priv)) { -printf ("Error: Can not restart ethernet controller.\n" ); - goto done; - } +/* Reinitialize Rx ring. */ +init_rx_ring (priv); -/* RX ring cache was already flushed in init_rx_ring() */ -OUTL (priv,phys_to_bus (priv->devno, - (u32)&rx_ring[priv->rx_next]), -SCB_POINTER ); -OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); +if (!wait_for_eepro100 (priv)) { +printf ("Error: Can not restart ethernet controller.\n" ); +return ; } -done: -return length; +/* RX ring cache was already flushed in init_rx_ring() */ +OUTL (priv,phys_to_bus (priv->devno, (u32)&rx_ring[priv->rx_next]), +SCB_POINTER ); +OUTW (priv,SCB_M |RUC_START ,SCB_CMD ); } -static void eepro100_halt (struct eth_device *dev) +static void eepro100_halt_common (struct eepro100_priv *priv) { -struct eepro100_priv *priv = - container_of(dev, struct eepro100_priv, dev); -/* Reset the ethernet controller */ OUTL (priv,I82559_SELECTIVE_RESET ,SCB_PORT );udelay (20 );@@ -773,6 +771,46 @@ done:return ; } +static int eepro100_init (struct eth_device *dev,bd_t *bis) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +return eepro100_init_common (priv); +} + +static void eepro100_halt (struct eth_device *dev) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +eepro100_halt_common (priv); +} + +static int eepro100_send (struct eth_device *dev,void *packet,int length) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); + +return eepro100_send_common (priv, packet, length); +} + +static int eepro100_recv (struct eth_device *dev) +{ +struct eepro100_priv *priv = + container_of(dev, struct eepro100_priv, dev); +uchar *packet; +int ret; + + ret =eepro100_recv_common (priv, &packet); +if (ret >0 ) +net_process_received_packet (packet, ret); +if (ret) +eepro100_free_pkt_common (priv); + +return ret; +} +int eepro100_initialize (bd_t *bis) {struct eepro100_priv *priv; --
Quoted 2 lines
2.25.1
PATCH 29/30 net: eepro100: Add DM support
In reply to Marek VasutAdd support for driver model to the driver.
--- drivers/net/eepro100.c | 129 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-)
drivers/net/eepro100.c +128 -1
@@ -206,14 +206,21 @@ struct eepro100_priv {/* TX descriptor ring pointer */ int tx_next;int tx_threshold; +#ifdef CONFIG_DM_ETH +struct udevice *devno; +#else struct eth_device dev;pci_dev_t devno; +#endif char *name;void __iomem *iobase;u8 *enetaddr; }; -#if defined(CONFIG_E500 ) +#if defined(CONFIG_DM_ETH ) +#define bus_to_phys (dev, a) dm_pci_mem_to_phys((dev), (a)) +#define phys_to_bus (dev, a) dm_pci_phys_to_mem((dev), (a)) +#elif defined(CONFIG_E500 )#define bus_to_phys (dev, a) (a)#define phys_to_bus (dev, a) (a)#else
@@ -771,6 +778,7 @@ done:return ; } +#ifndef CONFIG_DM_ETH static int eepro100_init (struct eth_device *dev,bd_t *bis) { struct eepro100_priv *priv =
@@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis)return card_number; } + +#else /* DM_ETH */ +static int eepro100_start (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_platdata (dev); +struct eepro100_priv *priv =dev_get_priv (dev); + +memcpy (priv->enetaddr, plat->enetaddr,sizeof (plat->enetaddr)); + +return eepro100_init_common (priv); +} + +static void eepro100_stop (struct udevice *dev) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_halt_common (priv); +} + +static int eepro100_send (struct udevice *dev,void *packet,int length) +{ +struct eepro100_priv *priv =dev_get_priv (dev); +int ret; + + ret =eepro100_send_common (priv, packet, length); + +return ret ?0 : -ETIMEDOUT ; +} + +static int eepro100_recv (struct udevice *dev,int flags,uchar **packetp) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +return eepro100_recv_common (priv, packetp); +} + +static int eepro100_free_pkt (struct udevice *dev,uchar *packet,int length) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_free_pkt_common (priv); + +return 0 ; +} + +static int eepro100_read_rom_hwaddr (struct udevice *dev) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_get_hwaddr (priv); + +return 0 ; +} + +static int eepro100_bind (struct udevice *dev) +{ +static int card_number; +char name[16 ]; + +sprintf (name,"eepro100#%u" , card_number++); + +return device_set_name (dev, name); +} + +static int eepro100_probe (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_platdata (dev); +struct eepro100_priv *priv =dev_get_priv (dev); +u16 command, status; +u32 iobase; +int ret; + +dm_pci_read_config32 (dev,PCI_BASE_ADDRESS_0 , &iobase); + iobase &= ~0xf ; + +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); + + priv->devno = dev; + priv->enetaddr = plat->enetaddr; + priv->iobase = (void __iomem *)bus_to_phys (dev, iobase); + + command =PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ; +dm_pci_write_config16 (dev,PCI_COMMAND , command); +dm_pci_read_config16 (dev,PCI_COMMAND , &status); +if ((status & command) != command) { +printf ("eepro100: Couldn't enable IO access or Bus Mastering\n" ); +return -EINVAL ; + } + + ret =eepro100_initialize_mii (priv); +if (ret) +return ret; + +dm_pci_write_config8 (dev,PCI_LATENCY_TIMER ,0x20 ); + +return 0 ; +} + +static const struct eth_ops eepro100_ops = { + .start = eepro100_start, + .send = eepro100_send, + .recv = eepro100_recv, + .stop = eepro100_stop, + .free_pkt = eepro100_free_pkt, + .read_rom_hwaddr = eepro100_read_rom_hwaddr, +}; + +U_BOOT_DRIVER (eth_eepro100) = { + .name ="eth_eepro100" , + .id =UCLASS_ETH , + .bind = eepro100_bind, + .probe = eepro100_probe, + .ops = &eepro100_ops, + .priv_auto_alloc_size =sizeof (struct eepro100_priv ), + .platdata_auto_alloc_size =sizeof (struct eth_pdata ), +}; + +U_BOOT_PCI_DEVICE (eth_eepro100, supported); +#endif
Signature · 1 line
2.25.1
PATCH 29/30 net: eepro100: Add DM support
Quoted 167 lines · Marek Vasut
Add support for driver model to the driver.
Signed-off-by Marek Vasut <[email protected]>--- drivers/net/eepro100.c | 129 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-)drivers/net/eepro100.c +128
-2@@ -206,14 +206,21 @@ struct eepro100_priv {/* TX descriptor ring pointer */ int tx_next;int tx_threshold; +#ifdef CONFIG_DM_ETH +struct udevice *devno; +#else struct eth_device dev;pci_dev_t devno; +#endif char *name;void __iomem *iobase;u8 *enetaddr; }; -#if defined(CONFIG_E500 ) +#if defined(CONFIG_DM_ETH ) +#define bus_to_phys (dev, a) dm_pci_mem_to_phys((dev), (a)) +#define phys_to_bus (dev, a) dm_pci_phys_to_mem((dev), (a)) +#elif defined(CONFIG_E500 )#define bus_to_phys (dev, a) (a)#define phys_to_bus (dev, a) (a)#else @@ -771,6 +778,7 @@ done:return ; } +#ifndef CONFIG_DM_ETH static int eepro100_init (struct eth_device *dev,bd_t *bis) { struct eepro100_priv *priv =@@ -888,3 +896,122 @@ int eepro100_initialize(bd_t *bis)return card_number; } + +#else /* DM_ETH */ +static int eepro100_start (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_platdata (dev); +struct eepro100_priv *priv =dev_get_priv (dev); + +memcpy (priv->enetaddr, plat->enetaddr,sizeof (plat->enetaddr)); + +return eepro100_init_common (priv); +} + +static void eepro100_stop (struct udevice *dev) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_halt_common (priv); +} + +static int eepro100_send (struct udevice *dev,void *packet,int length) +{ +struct eepro100_priv *priv =dev_get_priv (dev); +int ret; + + ret =eepro100_send_common (priv, packet, length); + +return ret ?0 : -ETIMEDOUT ; +} + +static int eepro100_recv (struct udevice *dev,int flags,uchar **packetp) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +return eepro100_recv_common (priv, packetp); +} + +static int eepro100_free_pkt (struct udevice *dev,uchar *packet,int length) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_free_pkt_common (priv); + +return 0 ; +} + +static int eepro100_read_rom_hwaddr (struct udevice *dev) +{ +struct eepro100_priv *priv =dev_get_priv (dev); + +eepro100_get_hwaddr (priv); + +return 0 ; +} + +static int eepro100_bind (struct udevice *dev) +{ +static int card_number; +char name[16 ]; + +sprintf (name,"eepro100#%u" , card_number++); + +return device_set_name (dev, name); +} + +static int eepro100_probe (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_platdata (dev); +struct eepro100_priv *priv =dev_get_priv (dev); +u16 command, status; +u32 iobase; +int ret; + +dm_pci_read_config32 (dev,PCI_BASE_ADDRESS_0 , &iobase); + iobase &= ~0xf ; + +debug ("eepro100: Intel i82559 PCI EtherExpressPro @0x%x\n" , iobase); + + priv->devno = dev; + priv->enetaddr = plat->enetaddr; + priv->iobase = (void __iomem *)bus_to_phys (dev, iobase); + + command =PCI_COMMAND_MEMORY |PCI_COMMAND_MASTER ; +dm_pci_write_config16 (dev,PCI_COMMAND , command); +dm_pci_read_config16 (dev,PCI_COMMAND , &status); +if ((status & command) != command) { +printf ("eepro100: Couldn't enable IO access or Bus Mastering\n" ); +return -EINVAL ; + } + + ret =eepro100_initialize_mii (priv); +if (ret) +return ret; + +dm_pci_write_config8 (dev,PCI_LATENCY_TIMER ,0x20 ); + +return 0 ; +} + +static const struct eth_ops eepro100_ops = { + .start = eepro100_start, + .send = eepro100_send, + .recv = eepro100_recv, + .stop = eepro100_stop, + .free_pkt = eepro100_free_pkt, + .read_rom_hwaddr = eepro100_read_rom_hwaddr, +}; + +U_BOOT_DRIVER (eth_eepro100) = { + .name ="eth_eepro100" , + .id =UCLASS_ETH , + .bind = eepro100_bind, + .probe = eepro100_probe, + .ops = &eepro100_ops, + .priv_auto_alloc_size =sizeof (struct eepro100_priv ), + .platdata_auto_alloc_size =sizeof (struct eth_pdata ), +}; + +U_BOOT_PCI_DEVICE (eth_eepro100, supported); +#endif --
Quoted 2 lines
2.25.1
PATCH 30/30 net: eepro100: Add Kconfig entries
In reply to Marek VasutAdd Kconfig entries for the eepro100 driver and convert various boards.
--- README | 3 --- configs/MPC8315ERDB_defconfig | 1 + configs/TQM834x_defconfig | 1 + configs/integratorap_cm720t_defconfig | 1 + configs/integratorap_cm920t_defconfig | 1 + configs/integratorap_cm926ejs_defconfig | 1 + configs/integratorap_cm946es_defconfig | 1 + drivers/net/Kconfig | 6 ++++++ include/configs/MPC8315ERDB.h | 1 - include/configs/MPC8323ERDB.h | 1 - include/configs/MPC832XEMDS.h | 1 - include/configs/MPC8349EMDS.h | 1 - include/configs/MPC8349EMDS_SDRAM.h | 1 - include/configs/MPC837XEMDS.h | 1 - include/configs/MPC8536DS.h | 1 - include/configs/MPC8540ADS.h | 1 - include/configs/MPC8541CDS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8548CDS.h | 1 - include/configs/MPC8555CDS.h | 1 - include/configs/MPC8560ADS.h | 1 - include/configs/MPC8568MDS.h | 1 - include/configs/MPC8569MDS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - include/configs/TQM834x.h | 2 -- include/configs/caddy2.h | 1 - include/configs/integratorap.h | 1 - include/configs/sbc8349.h | 1 - include/configs/sbc8548.h | 1 - include/configs/sbc8641d.h | 1 - include/configs/vme8349.h | 1 - scripts/config_whitelist.txt | 1 - 33 files changed, 12 insertions(+), 29 deletions(-)
README +0 -3
@@ -889,9 +889,6 @@ The following options need to be configured: Allow generic access to the SPI bus on the Intel 8257x, for example with the "sspi" command. - CONFIG_EEPRO100 - Support for Intel 82557/82559/82559ER chips. - CONFIG_TULIP Support for Digital 2114x chips.
configs/MPC8315ERDB_defconfig +1 -0
@@ -147,6 +147,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y
configs/TQM834x_defconfig +1 -0
@@ -159,6 +159,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=y
configs/integratorap_cm720t_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y
configs/integratorap_cm920t_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y
configs/integratorap_cm926ejs_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y
configs/integratorap_cm946es_defconfig +1 -0
@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=y
drivers/net/Kconfig +6 -0
@@ -192,6 +192,12 @@ config CMD_E1000 used on devices with SPI support you can reprogram the EEPROM from U-Boot. +config EEPRO100 + bool "Intel PRO/100 82557/82559/82559ER Fast Ethernet support" + help + This driver supports Intel(R) PRO/100 82557/82559/82559ER fast + ethernet family of adapters. + config ETH_SANDBOX depends on DM_ETH && SANDBOX default y
include/configs/MPC8315ERDB.h +0 -1
@@ -239,7 +239,6 @@#define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCIE -#define CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */
include/configs/MPC8323ERDB.h +0 -1
@@ -172,7 +172,6 @@#define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCI_SKIP_HOST_BRIDGE -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */
include/configs/MPC832XEMDS.h +0 -1
@@ -196,7 +196,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */
include/configs/MPC8349EMDS.h +0 -1
@@ -220,7 +220,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/MPC8349EMDS_SDRAM.h +0 -1
@@ -275,7 +275,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/MPC837XEMDS.h +0 -1
@@ -238,7 +238,6 @@ extern int board_pci_host_broken(void);#define CONFIG_USB_EHCI_FSL #define CONFIG_EHCI_HCD_INIT_AFTER_RESET -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ #endif /* CONFIG_PCI */
include/configs/MPC8536DS.h +0 -1
@@ -466,7 +466,6 @@#define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP
include/configs/MPC8540ADS.h +0 -1
@@ -236,7 +236,6 @@#define CONFIG_SYS_PCI1_IO_SIZE 0x100000/* 1M */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/MPC8541CDS.h +0 -1
@@ -282,7 +282,6 @@ extern unsigned long get_clock_freq(void);#define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */
include/configs/MPC8544DS.h +0 -1
@@ -258,7 +258,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP
include/configs/MPC8548CDS.h +0 -1
@@ -380,7 +380,6 @@ extern unsigned long get_clock_freq(void);#endif #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_DM_PCI )
include/configs/MPC8555CDS.h +0 -1
@@ -280,7 +280,6 @@ extern unsigned long get_clock_freq(void);#define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */
include/configs/MPC8560ADS.h +0 -1
@@ -233,7 +233,6 @@#define CONFIG_SYS_PCI1_IO_SIZE 0x100000/* 1M */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/MPC8568MDS.h +0 -1
@@ -290,7 +290,6 @@ extern unsigned long get_clock_freq(void);#endif /* CONFIG_QE */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */
include/configs/MPC8569MDS.h +0 -1
@@ -396,7 +396,6 @@ extern unsigned long get_clock_freq(void);#endif /* CONFIG_QE */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */
include/configs/MPC8572DS.h +0 -1
@@ -443,7 +443,6 @@#define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP
include/configs/MPC8641HPCN.h +0 -1
@@ -334,7 +334,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100#undef CONFIG_TULIP/************************************************************
include/configs/TQM834x.h +0 -2
@@ -167,8 +167,6 @@#define CONFIG_SYS_PCI1_IO_PHYS CONFIG_SYS_PCI1_IO_BASE#define CONFIG_SYS_PCI1_IO_SIZE 0x1000000/* 16M */ -#undef CONFIG_EEPRO100 -#define CONFIG_EEPRO100 #undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/caddy2.h +0 -1
@@ -155,7 +155,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/integratorap.h +0 -1
@@ -38,7 +38,6 @@*/ #define CONFIG_TULIP -#define CONFIG_EEPRO100 #define CONFIG_SYS_RX_ETH_BUFFER 8/* use 8 rx buffer on eepro100 */ /*-----------------------------------------------------------------------
include/configs/sbc8349.h +0 -1
@@ -180,7 +180,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/sbc8548.h +0 -1
@@ -434,7 +434,6 @@#endif #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */
include/configs/sbc8641d.h +0 -1
@@ -276,7 +276,6 @@#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
include/configs/vme8349.h +0 -1
@@ -155,7 +155,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )
scripts/config_whitelist.txt +0 -1
@@ -400,7 +400,6 @@ CONFIG_EDB93XX_SDCS0 CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 -CONFIG_EEPRO100 CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET
Signature · 1 line
2.25.1
PATCH 30/30 net: eepro100: Add Kconfig entries
Quoted 445 lines · Marek Vasut
Add
Kconfigentries for the eepro100 driver and convert various boards.Signed-off-by Marek Vasut <[email protected]>--- README | 3 --- configs/MPC8315ERDB_defconfig | 1 + configs/TQM834x_defconfig | 1 + configs/integratorap_cm720t_defconfig | 1 + configs/integratorap_cm920t_defconfig | 1 + configs/integratorap_cm926ejs_defconfig | 1 + configs/integratorap_cm946es_defconfig | 1 + drivers/net/Kconfig | 6 ++++++ include/configs/MPC8315ERDB.h | 1 - include/configs/MPC8323ERDB.h | 1 - include/configs/MPC832XEMDS.h | 1 - include/configs/MPC8349EMDS.h | 1 - include/configs/MPC8349EMDS_SDRAM.h | 1 - include/configs/MPC837XEMDS.h | 1 - include/configs/MPC8536DS.h | 1 - include/configs/MPC8540ADS.h | 1 - include/configs/MPC8541CDS.h | 1 - include/configs/MPC8544DS.h | 1 - include/configs/MPC8548CDS.h | 1 - include/configs/MPC8555CDS.h | 1 - include/configs/MPC8560ADS.h | 1 - include/configs/MPC8568MDS.h | 1 - include/configs/MPC8569MDS.h | 1 - include/configs/MPC8572DS.h | 1 - include/configs/MPC8641HPCN.h | 1 - include/configs/TQM834x.h | 2 -- include/configs/caddy2.h | 1 - include/configs/integratorap.h | 1 - include/configs/sbc8349.h | 1 - include/configs/sbc8548.h | 1 - include/configs/sbc8641d.h | 1 - include/configs/vme8349.h | 1 - scripts/config_whitelist.txt | 1 - 33 files changed, 12 insertions(+), 29 deletions(-)README +0
-3@@ -889,9 +889,6 @@ The following options need to be configured: Allow generic access to the SPI bus on the Intel 8257x, for example with the "sspi" command. - CONFIG_EEPRO100 - Support for Intel 82557/82559/82559ER chips. - CONFIG_TULIP Support for Digital 2114x chips.configs/MPC8315ERDB_defconfig +1
-0@@ -147,6 +147,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=yconfigs/TQM834x_defconfig +1
-0@@ -159,6 +159,7 @@ CONFIG_PHY_NATSEMI=y CONFIG_PHY_REALTEK=y CONFIG_PHY_SMSC=y CONFIG_PHY_VITESSE=y +CONFIG_EEPRO100=y CONFIG_MII=y CONFIG_TSEC_ENET=y CONFIG_SYS_NS16550=yconfigs/integratorap_cm720t_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=yconfigs/integratorap_cm920t_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=yconfigs/integratorap_cm926ejs_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=yconfigs/integratorap_cm946es_defconfig +1
-0@@ -24,6 +24,7 @@ CONFIG_MTD_NOR_FLASH=y CONFIG_FLASH_CFI_DRIVER=y CONFIG_SYS_FLASH_PROTECTION=y CONFIG_SYS_FLASH_CFI=y +CONFIG_EEPRO100=y CONFIG_PCI=y CONFIG_BAUDRATE=38400 CONFIG_OF_LIBFDT=ydrivers/net/Kconfig +6
-0@@ -192,6 +192,12 @@ config CMD_E1000 used on devices with SPI support you can reprogram the EEPROM from U-Boot. +config EEPRO100 + bool "Intel PRO/100 82557/82559/82559ER Fast Ethernet support" + help + This driver supports Intel(R) PRO/100 82557/82559/82559ER fast + ethernet family of adapters. + config ETH_SANDBOX depends on DM_ETH && SANDBOX default yinclude/configs/MPC8315ERDB.h +0
-1@@ -239,7 +239,6 @@#define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCIE -#define CONFIG_EEPRO100 #undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ include/configs/MPC8323ERDB.h +0
-1@@ -172,7 +172,6 @@#define CONFIG_PCI_INDIRECT_BRIDGE #define CONFIG_PCI_SKIP_HOST_BRIDGE -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ include/configs/MPC832XEMDS.h +0
-1@@ -196,7 +196,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ include/configs/MPC8349EMDS.h +0
-1@@ -220,7 +220,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/MPC8349EMDS_SDRAM.h +0
-1@@ -275,7 +275,6 @@#define CONFIG_83XX_PCI_STREAMING -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/MPC837XEMDS.h +0
-1@@ -238,7 +238,6 @@ extern int board_pci_host_broken(void);#define CONFIG_USB_EHCI_FSL #define CONFIG_EHCI_HCD_INIT_AFTER_RESET -#undef CONFIG_EEPRO100#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ #define CONFIG_SYS_PCI_SUBSYS_VENDORID 0x1957/* Freescale */ #endif /* CONFIG_PCI */ include/configs/MPC8536DS.h +0
-1@@ -466,7 +466,6 @@#define CONFIG_SYS_ISA_IO_BASE_ADDRESS CONFIG_SYS_PCIE3_IO_VIRT#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP include/configs/MPC8540ADS.h +0
-1@@ -236,7 +236,6 @@#define CONFIG_SYS_PCI1_IO_SIZE 0x100000/* 1M */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/MPC8541CDS.h +0
-1@@ -282,7 +282,6 @@ extern unsigned long get_clock_freq(void);#define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ include/configs/MPC8544DS.h +0
-1@@ -258,7 +258,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP include/configs/MPC8548CDS.h +0
-1@@ -380,7 +380,6 @@ extern unsigned long get_clock_freq(void);#endif #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_DM_PCI )include/configs/MPC8555CDS.h +0
-1@@ -280,7 +280,6 @@ extern unsigned long get_clock_freq(void);#define CONFIG_MPC85XX_PCI2 -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ include/configs/MPC8560ADS.h +0
-1@@ -233,7 +233,6 @@#define CONFIG_SYS_PCI1_IO_SIZE 0x100000/* 1M */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/MPC8568MDS.h +0
-1@@ -290,7 +290,6 @@ extern unsigned long get_clock_freq(void);#endif /* CONFIG_QE */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ include/configs/MPC8569MDS.h +0
-1@@ -396,7 +396,6 @@ extern unsigned long get_clock_freq(void);#endif /* CONFIG_QE */ #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#undef CONFIG_PCI_SCAN_SHOW/* show pci devices on startup */ include/configs/MPC8572DS.h +0
-1@@ -443,7 +443,6 @@#define CONFIG_SYS_ISA_IO_BASE_ADDRESS VIDEO_IO_OFFSET#endif -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#ifndef CONFIG_PCI_PNP include/configs/MPC8641HPCN.h +0
-1@@ -334,7 +334,6 @@ extern unsigned long get_board_sys_clk(unsigned long dummy);#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100#undef CONFIG_TULIP/************************************************************ include/configs/TQM834x.h +0
-2@@ -167,8 +167,6 @@#define CONFIG_SYS_PCI1_IO_PHYS CONFIG_SYS_PCI1_IO_BASE#define CONFIG_SYS_PCI1_IO_SIZE 0x1000000/* 16M */ -#undef CONFIG_EEPRO100 -#define CONFIG_EEPRO100 #undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/caddy2.h +0
-1@@ -155,7 +155,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/integratorap.h +0
-1@@ -38,7 +38,6 @@*/ #define CONFIG_TULIP -#define CONFIG_EEPRO100 #define CONFIG_SYS_RX_ETH_BUFFER 8/* use 8 rx buffer on eepro100 */ /*----------------------------------------------------------------------- include/configs/sbc8349.h +0
-1@@ -180,7 +180,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/sbc8548.h +0
-1@@ -434,7 +434,6 @@#endif #if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ include/configs/sbc8641d.h +0
-1@@ -276,7 +276,6 @@#define CONFIG_PCI_SCAN_SHOW /* show pci devices on startup */ -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )include/configs/vme8349.h +0
-1@@ -155,7 +155,6 @@#if defined(CONFIG_PCI ) -#undef CONFIG_EEPRO100#undef CONFIG_TULIP#if !defined(CONFIG_PCI_PNP )scripts/config_whitelist.txt +0
-2@@ -400,7 +400,6 @@ CONFIG_EDB93XX_SDCS0 CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 -CONFIG_EEPRO100 CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET --
Quoted 2 lines
2.25.1
PATCH 1/30 net: eepro100: Remove EEPRO100_SROM_WRITE
In reply to Marek VasutQuoted 135 lines · Marek Vasut
This code is never enabled, last board that used it was ELPPC which was removed some 5 years ago, so just remove this code altogether.
Signed-off-by Marek Vasut <[email protected]>--- README | 2 - drivers/net/eepro100.c | 87 ------------------------------------ scripts/config_whitelist.txt | 1 - 3 files changed, 90 deletions(-)README +0
-2@@ -891,8 +891,6 @@ The following options need to be configured: CONFIG_EEPRO100 Support for Intel 82557/82559/82559ER chips. - Optional CONFIG_EEPRO100_SROM_WRITE enables EEPROM - write routine for first time initialisation. CONFIG_TULIP Support for Digital 2114x chips.drivers/net/eepro100.c +0
-87@@ -781,93 +781,6 @@ static int read_eeprom (struct eth_device *dev, int location, int addr_len)return retval; } -#ifdef CONFIG_EEPRO100_SROM_WRITE -int eepro100_write_eeprom (struct eth_device * dev,int location,int addr_len,unsigned short data) -{ -unsigned short dataval; -int enable_cmd =0x3f |EE_EWENB_CMD ; -int write_cmd = location |EE_WRITE_CMD ; -int i; -unsigned long datalong, tmplong; - -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB , SCBeeprom); - -/* Shift the enable command bits out. */ -for (i = (addr_len+EE_CMD_BITS -1 ); i >=0 ; i--) - { - dataval = (enable_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); -udelay (1 ); - } - -OUTW (dev,EE_ENB , SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB , SCBeeprom); - - -/* Shift the write command bits out. */ -for (i = (addr_len+EE_CMD_BITS -1 ); i >=0 ; i--) - { - dataval = (write_cmd & (1 << i)) ?EE_DATA_WRITE :0 ; -OUTW (dev,EE_ENB | dataval, SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); -udelay (1 ); - } - -/* Write the data */ - datalong= (unsigned long ) ((((data) &0x00ff ) <<8 ) | ( (data) >>8 )); - -for (i =0 ; i<EE_DATA_BITS ; i++) - { -/* Extract and move data bit to bit DI */ - dataval = ((datalong &0x8000 )>>13 ) ?EE_DATA_WRITE :0 ; - -OUTW (dev,EE_ENB | dataval, SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB | dataval |EE_SHIFT_CLK , SCBeeprom); -udelay (1 ); -OUTW (dev,EE_ENB | dataval, SCBeeprom); -udelay (1 ); - - datalong = datalong <<1 ;/* Adjust significant data bit*/ - } - -/* Finish up command (toggle CS) */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); -udelay (1 );/* delay for more than 250 ns */ -OUTW (dev,EE_ENB , SCBeeprom); - -/* Wait for programming ready (D0 = 1) */ - tmplong =10 ; -do - { - dataval =INW (dev, SCBeeprom); -if (dataval &EE_DATA_READ ) -break ; -udelay (10000 ); - } -while (-- tmplong); - -if (tmplong ==0 ) - { -printf ("Write i82559 eeprom timed out (100 ms waiting for data ready.\n" ); -return -1 ; - } - -/* Terminate the EEPROM access. */ -OUTW (dev,EE_ENB & ~EE_CS , SCBeeprom); - -return 0 ; -} -#endif -static void init_rx_ring (struct eth_device *dev) {int i;scripts/config_whitelist.txt +0
-2@@ -401,7 +401,6 @@ CONFIG_EDB93XX_SDCS1 CONFIG_EDB93XX_SDCS2 CONFIG_EDB93XX_SDCS3 CONFIG_EEPRO100 -CONFIG_EEPRO100_SROM_WRITE CONFIG_EFLASH_PROTSECTORS CONFIG_EHCI_DESC_BIG_ENDIAN CONFIG_EHCI_HCD_INIT_AFTER_RESET --
Quoted 2 lines
2.25.1