Fix Ethernet init() return codes
Subsystems (2)
PATCH 1/1 Fix Ethernet init() return codes
Change return values of init() functions in all Ethernet drivers to conform to the following:
Quoted 1 line
=0: Success
<0: Failure
All drivers going forward should return 0 on success. Current drivers that return 1 on success were left as-is to minimize changes.
--- cpu/ixp/npe/npe.c | 8 ++++---- cpu/mpc8xx/fec.c | 6 +++--- drivers/net/dc2114x.c | 4 ++-- drivers/net/eepro100.c | 4 ++-- drivers/net/macb.c | 4 ++-- drivers/net/pcnet.c | 4 ++-- drivers/net/rtl8139.c | 4 ++-- drivers/net/rtl8169.c | 5 +++-- drivers/net/tsec.c | 2 +- drivers/net/tsi108_eth.c | 4 ++-- drivers/net/uli526x.c | 6 +++--- net/eth.c | 2 +- 12 files changed, 27 insertions(+), 26 deletions(-)
cpu/ixp/npe/npe.c +4 -4
@@ -408,25 +408,25 @@ static int npe_init(struct eth_device *dev, bd_t * bis)if (ixEthAccPortRxCallbackRegister (p_npe->eth_id, npe_rx_callback, (u32 )p_npe) !=IX_ETH_ACC_SUCCESS ) {printf ("can't register RX callback!\n" ); -return 0 ; +return -1 ; }if (ixEthAccPortTxDoneCallbackRegister (p_npe->eth_id, npe_tx_callback, (u32 )p_npe) !=IX_ETH_ACC_SUCCESS ) {printf ("can't register TX callback!\n" ); -return 0 ; +return -1 ; }npe_set_mac_address (dev);if (ixEthAccPortEnable (p_npe->eth_id) !=IX_ETH_ACC_SUCCESS ) {printf ("can't enable port!\n" ); -return 0 ; +return -1 ; } p_npe->active =1 ; -return 1 ; +return 0 ; }#if 0 /* test-only: probably have to deal with it when booting linux (for a clean state) */
cpu/mpc8xx/fec.c +3 -3
@@ -588,7 +588,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd) }if (i ==FEC_RESET_DELAY ) {printf ("FEC_RESET_DELAY timeout\n" ); -return 0 ; +return -1 ; }/* We use strictly polling mode only
@@ -708,7 +708,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd)if (efis->actual_phy_addr ==-1 ) {printf ("Unable to discover phy!\n" ); -return 0 ; +return -1 ; }#else efis->actual_phy_addr =-1 ;
@@ -751,7 +751,7 @@ static int fec_init (struct eth_device *dev, bd_t * bd) efis->initialized =1 ; -return 1 ; +return 0 ; }
drivers/net/dc2114x.c +2 -2
@@ -332,7 +332,7 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)if ((INL (dev,DE4X5_STS ) & (STS_TS |STS_RS )) !=0 ) {printf ("Error: Cannot reset ethernet controller.\n" ); -return 0 ; +return -1 ; }#ifdef CONFIG_TULIP_SELECT_MEDIA
@@ -382,7 +382,7 @@ static int dc21x4x_init(struct eth_device* dev, bd_t* bis)send_setup_frame (dev, bis); -return 1 ; +return 0 ; }static int dc21x4x_send (struct eth_device * dev,volatile void *packet,int length)
drivers/net/eepro100.c +2 -2
@@ -485,7 +485,7 @@ int eepro100_initialize (bd_t * bis)static int eepro100_init (struct eth_device *dev,bd_t * bis) { -int i, status =0 ; +int i, status =-1 ;int tx_cur;struct descriptor *ias_cmd, *cfg_cmd;
@@ -598,7 +598,7 @@ static int eepro100_init (struct eth_device *dev, bd_t * bis) goto Done; } - status =1 ; + status =0 ; Done:return status;
drivers/net/macb.c +2 -2
@@ -423,12 +423,12 @@ static int macb_init(struct eth_device *netdev, bd_t *bd)#endif if (!macb_phy_init (macb)) -return 0 ; +return -1 ;/* Enable TX and RX */ macb_writel (macb,NCR ,MACB_BIT (TE ) |MACB_BIT (RE )); -return 1 ; +return 0 ; }static void macb_halt (struct eth_device *netdev)
drivers/net/pcnet.c +2 -2
@@ -402,7 +402,7 @@ static int pcnet_init(struct eth_device* dev, bd_t *bis)if (i <=0 ) {printf ("%s: TIMEOUT: controller init failed\n" , dev->name);pcnet_reset (dev); -return 0 ; +return -1 ; }/*
@@ -410,7 +410,7 @@ static int pcnet_init(struct eth_device* dev, bd_t *bis)*/ pcnet_write_csr (dev,0 ,0x0002 ); -return 1 ; +return 0 ; }static int pcnet_send (struct eth_device * dev,volatile void *packet,int pkt_len)
drivers/net/rtl8139.c +2 -2
@@ -273,10 +273,10 @@ static int rtl8139_probe(struct eth_device *dev, bd_t *bis)if (inb (ioaddr + MediaStatus) & MSRLinkFail) {printf ("Cable not connected or other link failure\n" ); -return (0 ); +return -1 ; } -return 1 ; +return 0 ; }/* Serial EEPROM section. */
drivers/net/rtl8169.c +3 -2
@@ -620,7 +620,7 @@ static void rtl8169_init_ring(struct eth_device *dev)/************************************************************************** RESET - Finish setting up the ethernet interface ***************************************************************************/ -static void rtl_reset (struct eth_device *dev,bd_t *bis) +static int rtl_reset (struct eth_device *dev,bd_t *bis) {int i;u8 diff;
@@ -649,7 +649,7 @@ static void rtl_reset(struct eth_device *dev, bd_t *bis)if (tpc->TxDescArrays ==NULL || tpc->RxDescArrays ==NULL ) {puts ("Allocate RxDescArray or TxDescArray failed\n" ); -return ; +return -1 ; }rtl8169_init_ring (dev);
@@ -669,6 +669,7 @@ static void rtl_reset(struct eth_device *dev, bd_t *bis)#ifdef DEBUG_RTL8169 printf ("%s elapsed time : %d\n" , __FUNCTION__,currticks ()-stime);#endif +return 0 ; }/**************************************************************************
drivers/net/tsec.c +1 -1
@@ -232,7 +232,7 @@ int tsec_init(struct eth_device *dev, bd_t * bd)startup_tsec (dev);/* If there's no link, fail */ -return priv->link; +return (priv->link ?0 :-1 ); }
drivers/net/tsi108_eth.c +2 -2
@@ -792,7 +792,7 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis) (dev->enetaddr[0 ] <<16 );if (marvell_88e_phy_config (dev, &speed, &duplex) ==0 ) -return 0 ; +return -1 ; value = MAC_CONFIG_2_PREAMBLE_LENGTH(7) | MAC_CONFIG_2_PAD_CRC |
@@ -864,7 +864,7 @@ static int tsi108_eth_probe (struct eth_device *dev, bd_t * bis)/* enable TX queue */ reg_TX_CONTROL (base) =TX_CONTROL_GO |0x01 ; -return 1 ; +return 0 ; }/*
drivers/net/uli526x.c +3 -3
@@ -279,12 +279,12 @@ static int uli526x_init_one(struct eth_device *dev, bd_t *bis) db->desc_pool_ptr = (uchar *)&desc_pool_array[0 ]; db->desc_pool_dma_ptr = (dma_addr_t)&desc_pool_array[0 ];if (db->desc_pool_ptr ==NULL ) -return 0 ; +return -1 ; db->buf_pool_ptr = &buf_pool[0 ]; db->buf_pool_dma_ptr = (dma_addr_t)&buf_pool[0 ];if (db->buf_pool_ptr ==NULL ) -return 0 ; +return -1 ; db->first_tx_desc = (struct tx_desc *) db->desc_pool_ptr; db->first_tx_desc_dma = db->desc_pool_dma_ptr;
@@ -331,7 +331,7 @@ static int uli526x_init_one(struct eth_device *dev, bd_t *bis) db->cr6_data |=ULI526X_TXTH_256 ; db->cr0_data =CR0_DEFAULT ;uli526x_init (dev); -return 1 ; +return 0 ; }static void uli526x_disable (struct eth_device *dev)
net/eth.c +1 -1
@@ -430,7 +430,7 @@ int eth_init(bd_t *bis) do { debug ("Trying %s\n", eth_current->name); - if (!eth_current->init(eth_current,bis)) { + if (eth_current->init(eth_current,bis) >= 0) { eth_current->state = ETH_STATE_ACTIVE; return 0;
Signature · 1 line
1.5.2.5
PATCH 1/1 Fix Ethernet init() return codes
Quoted 10 lines · Ben Warren
Change return values of
init()functions in all Ethernet drivers to conform to the following:Quoted 1 line
=0: Success
<0: Failure
All drivers going forward should return 0 on success. Current drivers that return 1 on success were left as-is to minimize changes.
Signed-off-by Ben Warren <[email protected]>
Quoted 14 lines
--- cpu/ixp/npe/npe.c | 8 ++++---- cpu/mpc8xx/fec.c | 6 +++--- drivers/net/dc2114x.c | 4 ++-- drivers/net/eepro100.c | 4 ++-- drivers/net/macb.c | 4 ++-- drivers/net/pcnet.c | 4 ++-- drivers/net/rtl8139.c | 4 ++-- drivers/net/rtl8169.c | 5 +++-- drivers/net/tsec.c | 2 +- drivers/net/tsi108_eth.c | 4 ++-- drivers/net/uli526x.c | 6 +++--- net/eth.c | 2 +- 12 files changed, 27 insertions(+), 26 deletions(-)
You forgot drivers/qe/uec.c
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH 1/1 Fix Ethernet init() return codes
Quoted 37 lines
-----Original Message-----
From: u-boot-users-bounces at lists.sourceforge.net [mailto:u-boot-users-bounces at lists.sourceforge.net] On Behalf Of Tabi Timur
Sent: Tuesday, January 08, 2008 4:01 PM
To: Ben Warren
Cc: u-boot-users at lists.sourceforge.net
Subject: Re: [U-Boot-Users] [PATCH] Fix Ethernetinit()return codesQuoted 1 line · Ben Warren
Change return values of
init()functions in all Ethernetdrivers to conform
Quoted 6 lines
to the following:
Quoted 1 line
=0: Success
<0: Failure
All drivers going forward should return 0 on success.
Current drivers that
Quoted 17 lines
return 1 on success were left as-is to minimize changes.
Signed-off-by Ben Warren <[email protected]>--- cpu/ixp/npe/npe.c | 8 ++++---- cpu/mpc8xx/fec.c | 6 +++--- drivers/net/dc2114x.c | 4 ++-- drivers/net/eepro100.c | 4 ++-- drivers/net/macb.c | 4 ++-- drivers/net/pcnet.c | 4 ++-- drivers/net/rtl8139.c | 4 ++-- drivers/net/rtl8169.c | 5 +++-- drivers/net/tsec.c | 2 +- drivers/net/tsi108_eth.c | 4 ++-- drivers/net/uli526x.c | 6 +++--- net/eth.c | 2 +- 12 files changed, 27 insertions(+), 26 deletions(-)
Quoted 1 line
You forgot
drivers/qe/uec.c
(Maybe because) I already sent a tested patch for this. (?)
Cheers,
Emil.
Quoted 3 lines
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH 1/1 Fix Ethernet init() return codes
In reply to Timur TabiQuoted 28 lines · Timur Tabi
Quoted 12 lines · Ben Warren
Change return values of
init()functions in all Ethernet drivers to conform
to the following:Quoted 1 line
=0: Success
<0: Failure
All drivers going forward should return 0 on success. Current drivers that
return 1 on success were left as-is to minimize changes.Signed-off-by Ben Warren <[email protected]>Quoted 14 lines
--- cpu/ixp/npe/npe.c | 8 ++++---- cpu/mpc8xx/fec.c | 6 +++--- drivers/net/dc2114x.c | 4 ++-- drivers/net/eepro100.c | 4 ++-- drivers/net/macb.c | 4 ++-- drivers/net/pcnet.c | 4 ++-- drivers/net/rtl8139.c | 4 ++-- drivers/net/rtl8169.c | 5 +++-- drivers/net/tsec.c | 2 +- drivers/net/tsi108_eth.c | 4 ++-- drivers/net/uli526x.c | 6 +++--- net/eth.c | 2 +- 12 files changed, 27 insertions(+), 26 deletions(-)
Quoted 2 lines
You forgot
drivers/qe/uec.c
Arrrghhh! I only looked in cpu and drivers/net
More on the way, I guess...
regards,
Ben
PATCH 1/1 Fix Ethernet init() return codes
In reply to Ben WarrenQuoted 5 lines · Ben Warren
Change return values of
init()functions in all Ethernet drivers to conform
to the following:Quoted 1 line
=0: Success
Quoted 8 lines
<0: Failure
All drivers going forward should return 0 on success. Current drivers that
return 1 on success were left as-is to minimize changes.Signed-off-by Ben Warren <[email protected]>-
<snip>
This patch requires a lot of scrutiny, since it's pretty far-reaching and I obviously can't test all the drivers that were affected. If as many people as possible can test that would be great. Alternatively, we can pull the patch that caused this mess in the first place.
regards,
Ben
PATCH 1/1 Fix Ethernet init() return codes
Quoted 2 lines · Ben Warren
Alternatively, we
can pull the patch that caused this mess in the first place.
Well, this needs to be fixed, and we need to fix all the client drivers. I just wish the initial patch wasn't applied so hastily. I just can't be believe that patch was applied without any testing, because it's was obvious that it was going to break lots of client drivers.
Signature · 2 lines
Timur Tabi Linux kernel developer at Freescale
PATCH 1/1 Fix Ethernet init() return codes
Quoted 10 lines · Timur Tabi
Quoted 2 lines · Ben Warren
Alternatively, we can pull the patch that caused this mess in the first place.
Well, this needs to be fixed, and we need to fix all the client drivers. I just wish the initial patch wasn't applied so hastily. I just can't be believe that patch was applied without any testing, because it's was obvious that it was going to break lots of client drivers.
My fault. Sorry for causing so much heartache. Please test the second patch so we can move on.
regards,
Ben