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 <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Mark Einon 2011-09-25 19:17:55 +01:00 committed by Greg Kroah-Hartman
parent 268420aa84
commit 7fabca4d91
2 changed files with 50 additions and 78 deletions

View File

@ -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);

View File

@ -136,6 +136,45 @@ static struct net_device_stats *et131x_stats(struct net_device *netdev)
return stats;
}
/**
* 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);
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;
}