Skip to content

Commit

Permalink
staging: et131x: Remove error path from suspend/resume code
Browse files Browse the repository at this point in the history
Removing an error path from et131x suspend/resume functions.

Also added a call to phy_stop() to complement the phy_start() call
during device start/stop routine.

Thanks to Francois Romieu <romieu@fr.zoreil.com> for pointing this out.

Signed-off-by: Mark Einon <mark.einon@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Mark Einon authored and Greg Kroah-Hartman committed Oct 11, 2011
1 parent a9bd8dd commit a75fc17
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 32 deletions.
2 changes: 2 additions & 0 deletions drivers/staging/et131x/et131x.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ void et1310_setup_device_for_unicast(struct et131x_adapter *adapter);
/* et131x_netdev.c */
int et131x_open(struct net_device *netdev);
int et131x_close(struct net_device *netdev);
void et131x_up(struct net_device *netdev);
void et131x_down(struct net_device *netdev);
struct net_device *et131x_device_alloc(void);
void et131x_enable_txrx(struct net_device *netdev);
void et131x_disable_txrx(struct net_device *netdev);
Expand Down
35 changes: 12 additions & 23 deletions drivers/staging/et131x/et131x_initpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,39 +874,28 @@ static int et131x_pci_suspend(struct pci_dev *pdev, pm_message_t state)
{
struct net_device *netdev = pci_get_drvdata(pdev);

if (!netif_running(netdev))
return 0;

et131x_close(netdev);
netif_device_detach(netdev);

pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
if (netif_running(netdev)) {
netif_device_detach(netdev);
et131x_down(netdev);
pci_save_state(pdev);
pci_set_power_state(pdev, pci_choose_state(pdev, state));
}

return 0;
}

static int et131x_pci_resume(struct pci_dev *pdev)
{
struct net_device *netdev = pci_get_drvdata(pdev);
int err = 0;

if (!netif_running(netdev))
return 0;

pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);

err = et131x_open(netdev);
if (err) {
dev_err(&pdev->dev, "Can't resume interface!\n");
goto out;
if (netif_running(netdev)) {
pci_set_power_state(pdev, PCI_D0);
pci_restore_state(pdev);
et131x_up(netdev);
netif_device_attach(netdev);
}

netif_device_attach(netdev);

out:
return err;
return 0;
}

static struct pci_device_id et131x_pci_table[] __devinitdata = {
Expand Down
40 changes: 31 additions & 9 deletions drivers/staging/et131x/et131x_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,18 @@ void et131x_disable_txrx(struct net_device *netdev)
et131x_disable_interrupts(adapter);
}

/**
* et131x_up - Bring up a device for use.
* @netdev: device to be opened
*/
void et131x_up(struct net_device *netdev)
{
struct et131x_adapter *adapter = netdev_priv(netdev);

et131x_enable_txrx(netdev);
phy_start(adapter->phydev);
}

/**
* et131x_open - Open the device for use.
* @netdev: device to be opened
Expand Down Expand Up @@ -205,12 +217,27 @@ int et131x_open(struct net_device *netdev)
}

adapter->flags |= fMP_ADAPTER_INTERRUPT_IN_USE;
et131x_enable_txrx(netdev);
phy_start(adapter->phydev);

et131x_up(netdev);

return result;
}

/**
* et131x_down - Bring down the device
* @netdev: device to be broght down
*/
void et131x_down(struct net_device *netdev)
{
struct et131x_adapter *adapter = netdev_priv(netdev);

/* Save the timestamp for the TX watchdog, prevent a timeout */
netdev->trans_start = jiffies;

phy_stop(adapter->phydev);
et131x_disable_txrx(netdev);
}

/**
* et131x_close - Close the device
* @netdev: device to be closed
Expand All @@ -221,18 +248,13 @@ int et131x_close(struct net_device *netdev)
{
struct et131x_adapter *adapter = netdev_priv(netdev);

/* Save the timestamp for the TX watchdog, prevent a timeout */
netdev->trans_start = jiffies;

et131x_disable_txrx(netdev);
et131x_down(netdev);

/* Deregistering ISR */
adapter->flags &= ~fMP_ADAPTER_INTERRUPT_IN_USE;
free_irq(netdev->irq, netdev);

/* Stop the error timer */
del_timer_sync(&adapter->error_timer);
return 0;
return del_timer_sync(&adapter->error_timer);
}

/**
Expand Down

0 comments on commit a75fc17

Please sign in to comment.