diff options
author | David Kilroy <kilroyd@googlemail.com> | 2009-06-18 18:21:30 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-07-10 15:01:46 -0400 |
commit | 6415f7df10573bf1ec42644f42bef565127114a1 (patch) | |
tree | 6aa981f181010faca22989ffd70ef89b0d32ff07 /drivers/net/wireless/orinoco/main.c | |
parent | ef96b5c9ed6ba4b45fd4cf45810c34978bb8d8bb (diff) |
orinoco: Handle suspend/restore in core driver
Each device does almost exactly the same things on suspend and resume
when upping and downing the interface. So move this logic into a common
routine.
Signed-off-by: David Kilroy <kilroyd@googlemail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/orinoco/main.c')
-rw-r--r-- | drivers/net/wireless/orinoco/main.c | 61 |
1 files changed, 55 insertions, 6 deletions
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c index 361cf09d6b70..0727b41a397e 100644 --- a/drivers/net/wireless/orinoco/main.c +++ b/drivers/net/wireless/orinoco/main.c | |||
@@ -211,6 +211,8 @@ struct orinoco_rx_data { | |||
211 | /********************************************************************/ | 211 | /********************************************************************/ |
212 | 212 | ||
213 | static void __orinoco_set_multicast_list(struct net_device *dev); | 213 | static void __orinoco_set_multicast_list(struct net_device *dev); |
214 | static int __orinoco_up(struct orinoco_private *priv); | ||
215 | static int __orinoco_down(struct orinoco_private *priv); | ||
214 | 216 | ||
215 | /********************************************************************/ | 217 | /********************************************************************/ |
216 | /* Internal helper functions */ | 218 | /* Internal helper functions */ |
@@ -1514,7 +1516,7 @@ static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) | |||
1514 | /* Internal hardware control routines */ | 1516 | /* Internal hardware control routines */ |
1515 | /********************************************************************/ | 1517 | /********************************************************************/ |
1516 | 1518 | ||
1517 | int __orinoco_up(struct orinoco_private *priv) | 1519 | static int __orinoco_up(struct orinoco_private *priv) |
1518 | { | 1520 | { |
1519 | struct net_device *dev = priv->ndev; | 1521 | struct net_device *dev = priv->ndev; |
1520 | struct hermes *hw = &priv->hw; | 1522 | struct hermes *hw = &priv->hw; |
@@ -1542,9 +1544,8 @@ int __orinoco_up(struct orinoco_private *priv) | |||
1542 | 1544 | ||
1543 | return 0; | 1545 | return 0; |
1544 | } | 1546 | } |
1545 | EXPORT_SYMBOL(__orinoco_up); | ||
1546 | 1547 | ||
1547 | int __orinoco_down(struct orinoco_private *priv) | 1548 | static int __orinoco_down(struct orinoco_private *priv) |
1548 | { | 1549 | { |
1549 | struct net_device *dev = priv->ndev; | 1550 | struct net_device *dev = priv->ndev; |
1550 | struct hermes *hw = &priv->hw; | 1551 | struct hermes *hw = &priv->hw; |
@@ -1574,9 +1575,8 @@ int __orinoco_down(struct orinoco_private *priv) | |||
1574 | 1575 | ||
1575 | return 0; | 1576 | return 0; |
1576 | } | 1577 | } |
1577 | EXPORT_SYMBOL(__orinoco_down); | ||
1578 | 1578 | ||
1579 | int orinoco_reinit_firmware(struct orinoco_private *priv) | 1579 | static int orinoco_reinit_firmware(struct orinoco_private *priv) |
1580 | { | 1580 | { |
1581 | struct hermes *hw = &priv->hw; | 1581 | struct hermes *hw = &priv->hw; |
1582 | int err; | 1582 | int err; |
@@ -1592,7 +1592,6 @@ int orinoco_reinit_firmware(struct orinoco_private *priv) | |||
1592 | 1592 | ||
1593 | return err; | 1593 | return err; |
1594 | } | 1594 | } |
1595 | EXPORT_SYMBOL(orinoco_reinit_firmware); | ||
1596 | 1595 | ||
1597 | int __orinoco_program_rids(struct net_device *dev) | 1596 | int __orinoco_program_rids(struct net_device *dev) |
1598 | { | 1597 | { |
@@ -2389,6 +2388,56 @@ void free_orinocodev(struct orinoco_private *priv) | |||
2389 | } | 2388 | } |
2390 | EXPORT_SYMBOL(free_orinocodev); | 2389 | EXPORT_SYMBOL(free_orinocodev); |
2391 | 2390 | ||
2391 | int orinoco_up(struct orinoco_private *priv) | ||
2392 | { | ||
2393 | struct net_device *dev = priv->ndev; | ||
2394 | unsigned long flags; | ||
2395 | int err; | ||
2396 | |||
2397 | spin_lock_irqsave(&priv->lock, flags); | ||
2398 | |||
2399 | err = orinoco_reinit_firmware(priv); | ||
2400 | if (err) { | ||
2401 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", | ||
2402 | dev->name, err); | ||
2403 | goto exit; | ||
2404 | } | ||
2405 | |||
2406 | netif_device_attach(dev); | ||
2407 | priv->hw_unavailable--; | ||
2408 | |||
2409 | if (priv->open && !priv->hw_unavailable) { | ||
2410 | err = __orinoco_up(priv); | ||
2411 | if (err) | ||
2412 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
2413 | dev->name, err); | ||
2414 | } | ||
2415 | |||
2416 | exit: | ||
2417 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2418 | |||
2419 | return 0; | ||
2420 | } | ||
2421 | EXPORT_SYMBOL(orinoco_up); | ||
2422 | |||
2423 | void orinoco_down(struct orinoco_private *priv) | ||
2424 | { | ||
2425 | struct net_device *dev = priv->ndev; | ||
2426 | unsigned long flags; | ||
2427 | int err; | ||
2428 | |||
2429 | spin_lock_irqsave(&priv->lock, flags); | ||
2430 | err = __orinoco_down(priv); | ||
2431 | if (err) | ||
2432 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
2433 | dev->name, err); | ||
2434 | |||
2435 | netif_device_detach(dev); | ||
2436 | priv->hw_unavailable++; | ||
2437 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2438 | } | ||
2439 | EXPORT_SYMBOL(orinoco_down); | ||
2440 | |||
2392 | static void orinoco_get_drvinfo(struct net_device *dev, | 2441 | static void orinoco_get_drvinfo(struct net_device *dev, |
2393 | struct ethtool_drvinfo *info) | 2442 | struct ethtool_drvinfo *info) |
2394 | { | 2443 | { |