aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/hostap/hostap_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-01 18:09:29 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 10:26:33 -0500
commite2d4096365e06b9a3799afbadc28b4519c0b3526 (patch)
tree90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/net/wireless/hostap/hostap_cs.c
parentf6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (diff)
[PATCH] pcmcia: use bitfield instead of p_state and state
Instead of the two status values struct pcmcia_device->p_state and state, use descriptive bitfields. Most value-checking in drivers was invalid, as the core now only calls the ->remove() (a.k.a. detach) function in case the attachement _and_ configuration was successful. Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/hostap/hostap_cs.c')
-rw-r--r--drivers/net/wireless/hostap/hostap_cs.c56
1 files changed, 24 insertions, 32 deletions
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 88dc383a3da7..a2cb9b0fa3d6 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -210,9 +210,7 @@ static int prism2_config(struct pcmcia_device *link);
210static int prism2_pccard_card_present(local_info_t *local) 210static int prism2_pccard_card_present(local_info_t *local)
211{ 211{
212 struct hostap_cs_priv *hw_priv = local->hw_priv; 212 struct hostap_cs_priv *hw_priv = local->hw_priv;
213 if (hw_priv != NULL && hw_priv->link != NULL && 213 if (hw_priv != NULL && hw_priv->link != NULL && DEV_OK(hw_priv->link))
214 ((hw_priv->link->state & (DEV_PRESENT | DEV_CONFIG)) ==
215 (DEV_PRESENT | DEV_CONFIG)))
216 return 1; 214 return 1;
217 return 0; 215 return 0;
218} 216}
@@ -508,7 +506,6 @@ static int hostap_cs_probe(struct pcmcia_device *p_dev)
508 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info); 506 PDEBUG(DEBUG_HW, "%s: setting Vcc=33 (constant)\n", dev_info);
509 p_dev->conf.IntType = INT_MEMORY_AND_IO; 507 p_dev->conf.IntType = INT_MEMORY_AND_IO;
510 508
511 p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
512 ret = prism2_config(p_dev); 509 ret = prism2_config(p_dev);
513 if (ret) { 510 if (ret) {
514 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n"); 511 PDEBUG(DEBUG_EXTRA, "prism2_config() failed\n");
@@ -522,9 +519,7 @@ static void prism2_detach(struct pcmcia_device *link)
522{ 519{
523 PDEBUG(DEBUG_FLOW, "prism2_detach\n"); 520 PDEBUG(DEBUG_FLOW, "prism2_detach\n");
524 521
525 if (link->state & DEV_CONFIG) { 522 prism2_release((u_long)link);
526 prism2_release((u_long)link);
527 }
528 523
529 /* release net devices */ 524 /* release net devices */
530 if (link->priv) { 525 if (link->priv) {
@@ -746,9 +741,6 @@ static int prism2_config(struct pcmcia_device *link)
746 link->io.BasePort2+link->io.NumPorts2-1); 741 link->io.BasePort2+link->io.NumPorts2-1);
747 printk("\n"); 742 printk("\n");
748 743
749 link->state |= DEV_CONFIG;
750 link->state &= ~DEV_CONFIG_PENDING;
751
752 local->shutdown = 0; 744 local->shutdown = 0;
753 745
754 sandisk_enable_wireless(dev); 746 sandisk_enable_wireless(dev);
@@ -784,8 +776,7 @@ static void prism2_release(u_long arg)
784 struct hostap_interface *iface; 776 struct hostap_interface *iface;
785 777
786 iface = netdev_priv(dev); 778 iface = netdev_priv(dev);
787 if (link->state & DEV_CONFIG) 779 prism2_hw_shutdown(dev, 0);
788 prism2_hw_shutdown(dev, 0);
789 iface->local->shutdown = 1; 780 iface->local->shutdown = 1;
790 } 781 }
791 782
@@ -797,19 +788,19 @@ static int hostap_cs_suspend(struct pcmcia_device *link)
797{ 788{
798 struct net_device *dev = (struct net_device *) link->priv; 789 struct net_device *dev = (struct net_device *) link->priv;
799 int dev_open = 0; 790 int dev_open = 0;
791 struct hostap_interface *iface = NULL;
800 792
801 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info); 793 if (dev)
794 iface = netdev_priv(dev);
802 795
803 if (link->state & DEV_CONFIG) { 796 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_SUSPEND\n", dev_info);
804 struct hostap_interface *iface = netdev_priv(dev); 797 if (iface && iface->local)
805 if (iface && iface->local) 798 dev_open = iface->local->num_dev_open > 0;
806 dev_open = iface->local->num_dev_open > 0; 799 if (dev_open) {
807 if (dev_open) { 800 netif_stop_queue(dev);
808 netif_stop_queue(dev); 801 netif_device_detach(dev);
809 netif_device_detach(dev);
810 }
811 prism2_suspend(dev);
812 } 802 }
803 prism2_suspend(dev);
813 804
814 return 0; 805 return 0;
815} 806}
@@ -818,20 +809,21 @@ static int hostap_cs_resume(struct pcmcia_device *link)
818{ 809{
819 struct net_device *dev = (struct net_device *) link->priv; 810 struct net_device *dev = (struct net_device *) link->priv;
820 int dev_open = 0; 811 int dev_open = 0;
812 struct hostap_interface *iface = NULL;
813
814 if (dev)
815 iface = netdev_priv(dev);
821 816
822 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info); 817 PDEBUG(DEBUG_EXTRA, "%s: CS_EVENT_PM_RESUME\n", dev_info);
823 818
824 if (link->state & DEV_CONFIG) { 819 if (iface && iface->local)
825 struct hostap_interface *iface = netdev_priv(dev); 820 dev_open = iface->local->num_dev_open > 0;
826 if (iface && iface->local)
827 dev_open = iface->local->num_dev_open > 0;
828 821
829 prism2_hw_shutdown(dev, 1); 822 prism2_hw_shutdown(dev, 1);
830 prism2_hw_config(dev, dev_open ? 0 : 1); 823 prism2_hw_config(dev, dev_open ? 0 : 1);
831 if (dev_open) { 824 if (dev_open) {
832 netif_device_attach(dev); 825 netif_device_attach(dev);
833 netif_start_queue(dev); 826 netif_start_queue(dev);
834 }
835 } 827 }
836 828
837 return 0; 829 return 0;