staging: et131x: Further tidy up of 131x_pci_setup()
PATCH 1/6 staging: et131x: Further tidy up of 131x_pci_setup()
* Removed unused bool variable.
* Eliminated mid-function returns, used gotos instead
--- drivers/staging/et131x/et131x_initpci.c | 58 ++++++++++++++---------------- drivers/staging/et131x/et131x_netdev.c | 2 +- 2 files changed, 28 insertions(+), 32 deletions(-)
drivers/staging/et131x/et131x_initpci.c +27 -31
@@ -512,10 +512,6 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,struct et131x_adapter *adapter; -/* Setup the fundamental net_device and private adapter structure -* elements */ -SET_NETDEV_DEV (netdev, &pdev->dev); -/* Allocate private adapter struct and copy in relevant information */ adapter =netdev_priv (netdev); adapter->pdev =pci_dev_get (pdev);
@@ -579,33 +575,29 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,static int __devinit et131x_pci_setup (struct pci_dev *pdev,const struct pci_device_id *ent) { -int result = -EBUSY ; +int result;int pm_cap; -bool pci_using_dac;struct net_device *netdev;struct et131x_adapter *adapter;/* Enable the device via the PCI subsystem */ -if (pci_enable_device (pdev) !=0 ) { -dev_err (&pdev->dev, -"pci_enable_device() failed\n" ); -return -EIO ; + result =pci_enable_device (pdev); +if (result) { +dev_err (&pdev->dev,"pci_enable_device() failed\n" ); + goto err_out; }/* Perform some basic PCI checks */ if (!(pci_resource_flags (pdev,0 ) &IORESOURCE_MEM )) { -dev_err (&pdev->dev, -"Can't find PCI device's base address\n" ); +dev_err (&pdev->dev,"Can't find PCI device's base address\n" ); goto err_disable; }if (pci_request_regions (pdev,DRIVER_NAME )) { -dev_err (&pdev->dev, -"Can't get PCI resources\n" ); +dev_err (&pdev->dev,"Can't get PCI resources\n" ); goto err_disable; } -/* Enable PCI bus mastering */ pci_set_master (pdev);/* Query PCI for Power Mgmt Capabilities
@@ -614,7 +606,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,* needed? */ pm_cap =pci_find_capability (pdev,PCI_CAP_ID_PM ); -if (pm_cap ==0 ) { +if (!pm_cap) {dev_err (&pdev->dev,"Cannot find Power Management capabilities\n" ); result = -EIO ;
@@ -623,37 +615,42 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,/* Check the DMA addressing support of this device */ if (!pci_set_dma_mask (pdev,DMA_BIT_MASK (64 ))) { - pci_using_dac = true; - result =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (64 )); -if (result !=0 ) { +if (result) {dev_err (&pdev->dev, -"Unable to obtain 64 bit DMA for consistent allocations\n" ); +"Unable to obtain 64 bit DMA for consistent allocations\n" ); goto err_release_res; } }else if (!pci_set_dma_mask (pdev,DMA_BIT_MASK (32 ))) { - pci_using_dac = false; + result =pci_set_consistent_dma_mask (pdev,DMA_BIT_MASK (32 )); +if (result) { +dev_err (&pdev->dev, +"Unable to obtain 32 bit DMA for consistent allocations\n" ); + goto err_release_res; + } }else { -dev_err (&pdev->dev, -"No usable DMA addressing method\n" ); +dev_err (&pdev->dev,"No usable DMA addressing method\n" ); result = -EIO ; goto err_release_res; }/* Allocate netdev and private adapter structs */ netdev =et131x_device_alloc (); -if (netdev ==NULL ) { +if (!netdev) {dev_err (&pdev->dev,"Couldn't alloc netdev struct\n" ); result = -ENOMEM ; goto err_release_res; } + +SET_NETDEV_DEV (netdev, &pdev->dev); + adapter =et131x_adapter_init (netdev, pdev);/* Initialise the PCI setup for the device */ et131x_pci_init (adapter, pdev);/* Map the bus-relative registers to system virtual memory */ adapter->regs =pci_ioremap_bar (pdev,0 ); -if (adapter->regs ==NULL ) { +if (!adapter->regs) {dev_err (&pdev->dev,"Cannot map device registers\n" ); result = -ENOMEM ; goto err_free_dev;
@@ -670,7 +667,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,/* Allocate DMA memory */ result =et131x_adapter_memory_alloc (adapter); -if (result !=0 ) { +if (result) {dev_err (&pdev->dev,"Could not alloc adapater memory (DMA)\n" ); goto err_iounmap; }
@@ -678,9 +675,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,/* Init send data structures */ et131x_init_send (adapter); -/* -* Set up the task structure for the ISR's deferred handler -*/ +/* Set up the task structure for the ISR's deferred handler */ INIT_WORK (&adapter->task, et131x_isr_handler);/* Copy address into the net_device struct */
@@ -699,8 +694,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,/* Initialize link state */ netif_carrier_off (adapter->netdev); -/* Initialize variable for counting how long we do not have -link status */ +/* Init variable for counting how long we do not have link status */ adapter->boot_coma =0 ;/* We can enable interrupts now
@@ -723,6 +717,7 @@ static int __devinit et131x_pci_setup(struct pci_dev *pdev,*/ pci_set_drvdata (pdev, netdev);pci_save_state (adapter->pdev); +return result; err_mem_free:
@@ -736,6 +731,7 @@ err_release_res:pci_release_regions (pdev); err_disable:pci_disable_device (pdev); +err_out:return result; }
drivers/staging/et131x/et131x_netdev.c +1 -1
@@ -687,7 +687,7 @@ struct net_device *et131x_device_alloc(void)/* Alloc net_device and adapter structs */ netdev =alloc_etherdev (sizeof (struct et131x_adapter )); -if (netdev ==NULL ) { +if (!netdev) {printk (KERN_ERR "et131x: Alloc of net_device struct failed\n" );return NULL ; }
Signature · 1 line
1.7.6
PATCH 2/6 MAINAINERS: Add details for drivers/staging/et131x
Adding myself as a maintainer for this driver, as I appear to have been the only interested party for some time. Not sure if Olaf Hartman is still interested? So will leave it up to him to add his name to the list.
--- MAINTAINERS | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
@@ -6172,6 +6172,11 @@ M: David Rowe <[email protected]> S: Odd Fixes F: drivers/staging/echo/ +STAGING - ET131X NETWORK DRIVER +M: Mark Einon <[email protected]> +S: Odd Fixes +F: drivers/staging/et131x/ + STAGING - FLARION FT1000 DRIVERS M: Marek Belisko <[email protected]> S: Odd Fixes
Signature · 1 line
1.7.6
PATCH 3/6 staging: et131x: Remove unused xcvr_id in struct ce_stats
In reply to Mark Einonxcvr_id holds the phy ID which is stored but never used in the driver.
--- drivers/staging/et131x/et1310_phy.c | 4 ---- drivers/staging/et131x/et131x_adapter.h | 1 - 2 files changed, 0 insertions(+), 5 deletions(-)
drivers/staging/et131x/et1310_phy.c +0 -4
@@ -242,7 +242,6 @@ int et131x_xcvr_find(struct et131x_adapter *adapter)u8 xcvr_addr;u16 idr1;u16 idr2; -u32 xcvr_id;/* We need to get xcvr id and address we just get the first one */ for (xcvr_addr =0 ; xcvr_addr <32 ; xcvr_addr++) {
@@ -254,10 +253,7 @@ int et131x_xcvr_find(struct et131x_adapter *adapter) (u8 ) offsetof(struct mi_regs , idr2), &idr2); - xcvr_id = (u32) ((idr1 <<16 ) | idr2); -if (idr1 !=0 && idr1 !=0xffff ) { - adapter->stats.xcvr_id = xcvr_id; adapter->stats.xcvr_addr = xcvr_addr;return 0 ; }
drivers/staging/et131x/et131x_adapter.h +0 -1
@@ -115,7 +115,6 @@ struct ce_stats {/* Transceiver state informations. */ u8 xcvr_addr; -u32 xcvr_id;/* Tx Statistics. */ u32 tx_underflows;
Signature · 1 line
1.7.6
PATCH 4/6 staging: et131x: Remove redundant replica loopback code
In reply to Mark EinonA mechanism used to set the phy in loopback mode is not present in the driver, making associated checks and variables redundant. Removing them.
--- drivers/staging/et131x/et1310_address_map.h | 6 +++--- drivers/staging/et131x/et1310_rx.c | 11 ----------- drivers/staging/et131x/et131x_adapter.h | 4 ---- drivers/staging/et131x/et131x_isr.c | 16 +++++++--------- 4 files changed, 10 insertions(+), 27 deletions(-)
drivers/staging/et131x/et1310_address_map.h +3 -3
@@ -1,6 +1,6 @@/* * Agere Systems Inc. -* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs +* 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved.
@@ -149,7 +149,7 @@* GLOBAL Module of JAGCore Address Mapping * Located at address 0x0000 */ -struct global_regs {/* Location: */ +struct global_regs {/* Location: */ u32 txq_start_addr;/* 0x0000 */ u32 txq_end_addr;/* 0x0004 */ u32 rxq_start_addr;/* 0x0008 */
@@ -163,7 +163,7 @@ struct global_regs { /* Location: */u32 sw_reset;/* 0x0028 */ u32 slv_timer;/* 0x002C */ u32 msi_config;/* 0x0030 */ -u32 loopback;/* 0x0034 */ +u32 loopback;/* 0x0034 */ u32 watchdog_timer;/* 0x0038 */ };
drivers/staging/et131x/et1310_rx.c +0 -11
@@ -988,17 +988,6 @@ static struct rfd *nic_rx_pkts(struct et131x_adapter *adapter) }if (len) { -if (adapter->replica_phy_loopbk ==1 ) { - buf = rx_local->fbr[ring_index]->virt[buff_index]; - -if (memcmp (&buf[6 ], adapter->addr,ETH_ALEN ) ==0 ) { -if (memcmp (&buf[42 ],"Replica packet" , -ETH_HLEN )) { - adapter->replica_phy_loopbk_passfail =1 ; - } - } - } -/* Determine if this is a multicast packet coming in */ if ((word0 &ALCATEL_MULTICAST_PKT ) && !(word0 &ALCATEL_BROADCAST_PKT )) {
drivers/staging/et131x/et131x_adapter.h +0 -4
@@ -222,10 +222,6 @@ struct et131x_adapter {/* Rx Memory Variables */ struct rx_ring rx_ring; -/* Loopback specifics */ -u8 replica_phy_loopbk;/* Replica Enable */ -u8 replica_phy_loopbk_passfail;/* Replica Enable Pass/Fail */ -/* Stats */ struct ce_stats stats;
drivers/staging/et131x/et131x_isr.c +7 -9
@@ -389,17 +389,15 @@ void et131x_isr_handler(struct work_struct *work) (uint8_t ) offsetof(struct mi_regs , isr), &myisr); -if (!adapter->replica_phy_loopbk) { -et131x_mii_read (adapter, - (uint8_t ) offsetof(struct mi_regs , bmsr), - &bmsr_data); +et131x_mii_read (adapter, + (uint8_t ) offsetof(struct mi_regs , bmsr), + &bmsr_data); - bmsr_ints = adapter->bmsr ^ bmsr_data; - adapter->bmsr = bmsr_data; + bmsr_ints = adapter->bmsr ^ bmsr_data; + adapter->bmsr = bmsr_data; -/* Do all the cable in / cable out stuff */ -et131x_mii_check (adapter, bmsr_data, bmsr_ints); - } +/* Do all the cable in / cable out stuff */ +et131x_mii_check (adapter, bmsr_data, bmsr_ints); }/* Let's move on to the TxMac */
Signature · 1 line
1.7.6
Re: [PATCH 4/6] staging: et131x: Remove redundant replica loopback code
This patch was sent with git-send-email but it's in base64 encoding.
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Why did that happen?
I'm in mutt and if I use decode-save then I can apply the patch, but if I just pipe the patch to my scripts then it doesn't work. Do other mutt users have a trick for handling base64 patches?
regards,
dan carpenter
Re: [PATCH 4/6] staging: et131x: Remove redundant replica loopback code
Quoted 6 lines · On Tue, 30 Aug 2011 13:08:34 +0300 Dan Carpenter <[email protected]> wrote:
This patch was sent with git-send-email but it's in base64 encoding.
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64Why did that happen?
Presumably it got re-encoded because a mail system in the path between him and you decided it was traversing a 7bit path and helpfully reprocessed it to avoid corruption.
If your mailer can't automatically handle utf-8/base64 perhaps you need a better one ;)
Alan
Re: [PATCH 4/6] staging: et131x: Remove redundant replica loopback code
Quoted 8 lines · Alan Cox
Quoted 5 lines · On Tue, 30 Aug 2011 13:08:34 +0300 Dan Carpenter <[email protected]> wrote:
This patch was sent with git-send-email but it's in base64 encoding.
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Quoted 8 lines
Quoted 1 line
Why did that happen?
Presumably it got re-encoded because a mail system in the path between him and you decided it was traversing a 7bit path and helpfully reprocessed it to avoid corruption.
If your mailer can't automatically handle utf-8/base64 perhaps you need a better one ;)
Maybe not - now you mention it, when git send-email got to this particular patch, it did ask me if I wanted to use UTF-8, which it's never done before.
I'm not aware of anything unusual I did with this patch set, but i've just done a format-patch and git send-email again to get:
git send-email [email protected] 0004-staging-et131x-Remove-redundant-replica-loopback-cod.patch 0004-staging-et131x-Remove-redundant-replica-loopback-cod.patch The following files are 8bit, but do not declare a Content-Transfer-Encoding.
0004-staging-et131x-Remove-redundant-replica-loopback-cod.patch
Which 8bit encoding should I declare [UTF-8]?
Not sure how that's happened.
Mark
PATCH 5/6 staging: et131x: Remove module_param et131x_speed_set
In reply to Mark EinonManual setting of speed/duplex will be achieved using ethtool. Remove the driver specific module_param that also does this.
--- drivers/staging/et131x/et131x_initpci.c | 50 +----------------------------- 1 files changed, 2 insertions(+), 48 deletions(-)
drivers/staging/et131x/et131x_initpci.c +2 -48
@@ -1,6 +1,6 @@/* * Agere Systems Inc. -* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs +* 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved.
@@ -97,30 +97,6 @@#define INTERNAL_MEM_SIZE 0x400/* 1024 of internal memory */ #define INTERNAL_MEM_RX_OFFSET 0x1FF/* 50% Tx, 50% Rx */ -/* Defines for Parameter Default/Min/Max vaules */ -#define PARM_SPEED_DUPLEX_MIN 0 -#define PARM_SPEED_DUPLEX_MAX 5 - -/* Module parameter for manual speed setting -* Set Link speed and dublex manually (0-5) [0] -* 1 : 10Mb Half-Duplex -* 2 : 10Mb Full-Duplex -* 3 : 100Mb Half-Duplex -* 4 : 100Mb Full-Duplex -* 5 : 1000Mb Full-Duplex -* 0 : Auto Speed Auto Duplex // default -*/ -static u32 et131x_speed_set; -module_param (et131x_speed_set, uint,0 ); -MODULE_PARM_DESC (et131x_speed_set, -"Set Link speed and dublex manually (0-5) [0]\n" -"1 : 10Mb Half-Duplex\n" -"2 : 10Mb Full-Duplex\n" -"3 : 100Mb Half-Duplex\n" -"4 : 100Mb Full-Duplex\n" -"5 : 1000Mb Full-Duplex\n" -"0 : Auto Speed Auto Dublex" ); -/** * et131x_hwaddr_init - set up the MAC Address on the ET1310 * @adapter: pointer to our private adapter structure
@@ -531,29 +507,12 @@ static struct et131x_adapter *et131x_adapter_init(struct net_device *netdev,spin_lock_init (&adapter->fbr_lock);spin_lock_init (&adapter->phy_lock); -/* Parse configuration parameters into the private adapter struct */ -if (et131x_speed_set) -dev_info (&adapter->pdev->dev, -"Speed set manually to : %d\n" , et131x_speed_set); - - adapter->speed_duplex = et131x_speed_set; + adapter->speed_duplex =0 ;/* Auto Speed Auto Duplex */ adapter->registry_jumbo_packet =1514 ;/* 1514-9216 */ /* Set the MAC address to a default */ memcpy (adapter->addr, default_mac,ETH_ALEN ); -/* Decode speed_duplex -* -* Set up as if we are auto negotiating always and then change if we -* go into force mode -* -* If we are the 10/100 device, and gigabit is somehow requested then -* knock it down to 100 full. -*/ -if (adapter->pdev->device ==ET131X_PCI_DEVICE_ID_FAST && - adapter->speed_duplex ==5 ) - adapter->speed_duplex =4 ; - adapter->ai_force_speed = speed[adapter->speed_duplex]; adapter->ai_force_duplex = duplex[adapter->speed_duplex];/* Auto FDX */
@@ -790,11 +749,6 @@ static struct pci_driver et131x_driver = {*/ static int __init et131x_init_module (void ) { -if (et131x_speed_set <PARM_SPEED_DUPLEX_MIN || - et131x_speed_set >PARM_SPEED_DUPLEX_MAX ) { -printk (KERN_WARNING "et131x: invalid speed setting ignored.\n" ); - et131x_speed_set =0 ; - }return pci_register_driver (&et131x_driver); }
Signature · 1 line
1.7.6
PATCH 6/6 staging: et131x: Use phy-device, mii_bus and ethtool_ops
In reply to Mark EinonAdding some basic ethtool ops and supporting functionality using a phy device.
--- drivers/staging/et131x/Makefile | 1 + drivers/staging/et131x/et1310_phy.c | 45 ++++++++-- drivers/staging/et131x/et1310_phy.h | 4 +- drivers/staging/et131x/et131x.h | 6 ++ drivers/staging/et131x/et131x_adapter.h | 3 +- drivers/staging/et131x/et131x_ethtool.c | 71 +++++++++++++++ drivers/staging/et131x/et131x_initpci.c | 147 +++++++++++++++++++++++++++---- drivers/staging/et131x/et131x_netdev.c | 7 +- 8 files changed, 254 insertions(+), 30 deletions(-) create mode 100644 drivers/staging/et131x/et131x_ethtool.c
drivers/staging/et131x/Makefile +1 -0
@@ -11,5 +11,6 @@ et131x-y := et1310_eeprom.o \ et1310_rx.o \ et1310_tx.o \ et131x_initpci.o \ + et131x_ethtool.o \ et131x_isr.o \ et131x_netdev.o
drivers/staging/et131x/et1310_phy.c +38 -7
86 lines not on this page · raw message
drivers/staging/et131x/et1310_phy.h +2 -2
@@ -121,8 +121,8 @@ struct mi_regs {u8 imr;/* Interrupt Mask Reg(Reg 0x18) */ u8 isr;/* Interrupt Status Reg(Reg 0x19) */ u8 psr;/* PHY Status Reg(Reg 0x1A) */ -u8 lcr1;/* LED Control 1 Reg(Reg 0x1B) */ -u8 lcr2;/* LED Control 2 Reg(Reg 0x1C) */ +u8 lcr1;/* LED Control 1 Reg(Reg 0x1B) */ +u8 lcr2;/* LED Control 2 Reg(Reg 0x1C) */ u8 mi_res4[3 ];/* Future use by MI working group(Reg 0x1D - 0x1F) */ };
drivers/staging/et131x/et131x.h +6 -0
@@ -116,6 +116,10 @@ int32_t et131x_mii_write(struct et131x_adapter *adapter,void et131x_mii_check (struct et131x_adapter *pAdapter,u16 bmsr,u16 bmsr_ints); +int et131x_mdio_read (struct mii_bus *bus,int phy_addr,int reg); +int et131x_mdio_write (struct mii_bus *bus,int phy_addr,int reg,u16 value); +int et131x_mdio_reset (struct mii_bus *bus); +/* et1310_rx.c */ int et131x_rx_dma_memory_alloc (struct et131x_adapter *adapter);void et131x_rx_dma_memory_free (struct et131x_adapter *adapter);
@@ -145,3 +149,5 @@ void et131x_handle_send_interrupt(struct et131x_adapter *adapter);void et131x_free_busy_send_packets (struct et131x_adapter *adapter);int et131x_send_packets (struct sk_buff *skb,struct net_device *netdev); +/* et131x_ethtool.c */ +void et131x_set_ethtool_ops (struct net_device *netdev);
drivers/staging/et131x/et131x_adapter.h +2 -1
@@ -144,7 +144,8 @@ struct ce_stats {struct et131x_adapter {struct net_device *netdev;struct pci_dev *pdev; - +struct mii_bus *mii_bus; +struct phy_device *phydev;struct work_struct task;/* Flags that indicate current state of the adapter */
drivers/staging/et131x/et131x_ethtool.c new file +71 -0
71 lines not on this page · raw message
drivers/staging/et131x/et131x_initpci.c +130 -17
216 lines not on this page · raw message
drivers/staging/et131x/et131x_netdev.c +4 -3
@@ -1,6 +1,6 @@/* * Agere Systems Inc. -* 10/100/1000 Base-T Ethernet Driver for the ET1301 and ET131x series MACs +* 10/100/1000 Base-T Ethernet Driver for the ET1310 and ET131x series MACs * * Copyright © 2005 Agere Systems Inc. * All rights reserved.
@@ -82,6 +82,7 @@#include <linux/skbuff.h> #include <linux/if_arp.h> #include <linux/ioport.h> +#include <linux/phy.h> #include "et1310_phy.h" #include "et1310_tx.h"
@@ -167,6 +168,8 @@ int et131x_open(struct net_device *netdev) adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; +phy_start (adapter->phydev); +/* We're ready to move some data, so start the queue */ netif_start_queue (netdev);return result;
@@ -699,8 +702,6 @@ struct net_device *et131x_device_alloc(void) netdev->watchdog_timeo =ET131X_TX_TIMEOUT ; netdev->netdev_ops = &et131x_netdev_ops; -/* netdev->ethtool_ops = &et131x_ethtool_ops; */ -/* Poll? */ /* netdev->poll = &et131x_poll; */ /* netdev->poll_controller = &et131x_poll_controller; */
Signature · 1 line
1.7.6