From: Mark Einon Date: Sun, 25 Sep 2011 18:17:55 +0000 (+0100) Subject: staging: et131x: Create et131x_[dis|en]able_txrx() calls X-Git-Tag: upstream/snapshot3+hdmi~8929^2^2~354 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7fabca4d9183a449676648b93307e29299595866;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git staging: et131x: Create et131x_[dis|en]able_txrx() calls In et131x_netdev.c, a series of calls to enable and diasble the rx/tx engine and queue are being used in several different places. Create two functions to encapsulate these calls, and replace many calls with just the one. Signed-off-by: Mark Einon Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/et131x/et131x.h b/drivers/staging/et131x/et131x.h index f52fa18..6f8fef6 100644 --- a/drivers/staging/et131x/et131x.h +++ b/drivers/staging/et131x/et131x.h @@ -83,6 +83,8 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter); /* et131x_netdev.c */ struct net_device *et131x_device_alloc(void); +void et131x_enable_txrx(struct net_device *netdev); +void et131x_disable_txrx(struct net_device *netdev); /* et1310_pm.c */ void et1310_enable_phy_coma(struct et131x_adapter *adapter); diff --git a/drivers/staging/et131x/et131x_netdev.c b/drivers/staging/et131x/et131x_netdev.c index 5fb4056..6ec4a0f 100644 --- a/drivers/staging/et131x/et131x_netdev.c +++ b/drivers/staging/et131x/et131x_netdev.c @@ -137,6 +137,45 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev) } /** + * et131x_enable_txrx - Enable tx/rx queues + * @netdev: device to be enabled + */ +void et131x_enable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* Enable the Tx and Rx DMA engines (if not already enabled) */ + et131x_rx_dma_enable(adapter); + et131x_tx_dma_enable(adapter); + + /* Enable device interrupts */ + if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) + et131x_enable_interrupts(adapter); + + /* We're ready to move some data, so start the queue */ + netif_start_queue(netdev); +} + +/** + * et131x_disable_txrx - Disable tx/rx queues + * @netdev: device to be disabled + */ +void et131x_disable_txrx(struct net_device *netdev) +{ + struct et131x_adapter *adapter = netdev_priv(netdev); + + /* First thing is to stop the queue */ + netif_stop_queue(netdev); + + /* Stop the Tx and Rx DMA engines */ + et131x_rx_dma_disable(adapter); + et131x_tx_dma_disable(adapter); + + /* Disable device interrupts */ + et131x_disable_interrupts(adapter); +} + +/** * et131x_open - Open the device for use. * @netdev: device to be opened * @@ -159,19 +198,10 @@ int et131x_open(struct net_device *netdev) return result; } - /* Enable the Tx and Rx DMA engines (if not already enabled) */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - et131x_enable_interrupts(adapter); - adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE; - + et131x_enable_txrx(netdev); phy_start(adapter->phydev); - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); return result; } @@ -188,15 +218,7 @@ int et131x_close(struct net_device *netdev) /* Save the timestamp for the TX watchdog, prevent a timeout */ netdev->trans_start = jiffies; - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); /* Deregistering ISR */ adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE; @@ -442,29 +464,9 @@ void et131x_tx_timeout(struct net_device *netdev) adapter->net_stats.tx_errors++; - /* perform reset */ - /* First thing is to stop the queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); - - /* - * Enable the Tx and Rx DMA engines - * (if not already enabled) - */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Enable device interrupts */ - et131x_enable_interrupts(adapter); - - /* We're ready to move some data, so start the queue */ - netif_start_queue(netdev); + /* perform reset of tx/rx */ + et131x_disable_txrx(netdev); + et131x_enable_txrx(netdev); return; } } @@ -488,15 +490,7 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) if (new_mtu < 64 || new_mtu > 9216) return -EINVAL; - /* Stop the netif queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); et131x_handle_send_interrupt(adapter); et131x_handle_recv_interrupt(adapter); @@ -526,16 +520,8 @@ int et131x_change_mtu(struct net_device *netdev, int new_mtu) /* Init the device with the new settings */ et131x_adapter_setup(adapter); - /* Enable interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); + et131x_enable_txrx(netdev); - /* Restart the Tx and Rx DMA engines */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); - - /* Restart the netif queue */ - netif_wake_queue(netdev); return result; } @@ -563,15 +549,7 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) if (!is_valid_ether_addr(address->sa_data)) return -EINVAL; - /* Stop the netif queue */ - netif_stop_queue(netdev); - - /* Stop the Tx and Rx DMA engines */ - et131x_rx_dma_disable(adapter); - et131x_tx_dma_disable(adapter); - - /* Disable device interrupts */ - et131x_disable_interrupts(adapter); + et131x_disable_txrx(netdev); et131x_handle_send_interrupt(adapter); et131x_handle_recv_interrupt(adapter); @@ -603,16 +581,8 @@ int et131x_set_mac_addr(struct net_device *netdev, void *new_mac) /* Init the device with the new settings */ et131x_adapter_setup(adapter); - /* Enable interrupts */ - if (adapter->flags & fMP_ADAPTER_INTERRUPT_IN_USE) - et131x_enable_interrupts(adapter); - - /* Restart the Tx and Rx DMA engines */ - et131x_rx_dma_enable(adapter); - et131x_tx_dma_enable(adapter); + et131x_enable_txrx(netdev); - /* Restart the netif queue */ - netif_wake_queue(netdev); return result; }