[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>
This commit is contained in:
Dominik Brodowski
2006-03-02 00:09:29 +01:00
parent f6fbe01ac9
commit e2d4096365
49 changed files with 337 additions and 684 deletions

View File

@@ -245,7 +245,7 @@ spectrum_reset(struct pcmcia_device *link, int idle)
u_int save_cor;
/* Doing it if hardware is gone is guaranteed crash */
if (!(link->state & DEV_CONFIG))
if (pcmcia_dev_present(link))
return -ENODEV;
/* Save original COR value */
@@ -613,7 +613,6 @@ spectrum_cs_probe(struct pcmcia_device *link)
link->conf.Attributes = 0;
link->conf.IntType = INT_MEMORY_AND_IO;
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
return spectrum_cs_config(link);
} /* spectrum_cs_attach */
@@ -627,8 +626,7 @@ static void spectrum_cs_detach(struct pcmcia_device *link)
{
struct net_device *dev = link->priv;
if (link->state & DEV_CONFIG)
spectrum_cs_release(link);
spectrum_cs_release(link);
DEBUG(0, PFX "detach: link=%p link->dev_node=%p\n", link, link->dev_node);
if (link->dev_node) {
@@ -677,9 +675,6 @@ spectrum_cs_config(struct pcmcia_device *link)
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
/* Configure card */
link->state |= DEV_CONFIG;
/* Look up the current Vcc */
CS_CHECK(GetConfigurationInfo,
pcmcia_get_configuration_info(link, &conf));
@@ -838,7 +833,6 @@ spectrum_cs_config(struct pcmcia_device *link)
link->dev_node = &card->node; /* link->dev_node being non-NULL is also
used to indicate that the
net_device has been registered */
link->state &= ~DEV_CONFIG_PENDING;
/* Finally, report what we've done */
printk(KERN_DEBUG "%s: index 0x%02x: ",
@@ -898,19 +892,17 @@ spectrum_cs_suspend(struct pcmcia_device *link)
int err = 0;
/* Mark the device as stopped, to block IO until later */
if (link->state & DEV_CONFIG) {
spin_lock_irqsave(&priv->lock, flags);
spin_lock_irqsave(&priv->lock, flags);
err = __orinoco_down(dev);
if (err)
printk(KERN_WARNING "%s: Error %d downing interface\n",
dev->name, err);
err = __orinoco_down(dev);
if (err)
printk(KERN_WARNING "%s: Error %d downing interface\n",
dev->name, err);
netif_device_detach(dev);
priv->hw_unavailable++;
netif_device_detach(dev);
priv->hw_unavailable++;
spin_unlock_irqrestore(&priv->lock, flags);
}
spin_unlock_irqrestore(&priv->lock, flags);
return 0;
}
@@ -921,11 +913,10 @@ spectrum_cs_resume(struct pcmcia_device *link)
struct net_device *dev = link->priv;
struct orinoco_private *priv = netdev_priv(dev);
if (link->state & DEV_CONFIG) {
netif_device_attach(dev);
priv->hw_unavailable--;
schedule_work(&priv->reset_work);
}
netif_device_attach(dev);
priv->hw_unavailable--;
schedule_work(&priv->reset_work);
return 0;
}