[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>
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index d09b147..25fb919 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -181,7 +181,6 @@
}
p_dev->priv = local;
- p_dev->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
return atmel_config(p_dev);
} /* atmel_attach */
@@ -198,8 +197,7 @@
{
DEBUG(0, "atmel_detach(0x%p)\n", link);
- if (link->state & DEV_CONFIG)
- atmel_release(link);
+ atmel_release(link);
kfree(link->priv);
}
@@ -222,7 +220,7 @@
struct pcmcia_device *link = (struct pcmcia_device *)arg;
if (link->suspended)
return 0;
- else if (link->state & DEV_PRESENT)
+ else if (pcmcia_dev_present(link))
return 1;
return 0;
@@ -257,10 +255,7 @@
CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse));
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
-
- /* Configure card */
- link->state |= DEV_CONFIG;
-
+
/*
In this loop, we scan the CIS for configuration table entries,
each of which describes a valid card configuration, including
@@ -373,10 +368,9 @@
strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
dev->node.major = dev->node.minor = 0;
link->dev_node = &dev->node;
-
- link->state &= ~DEV_CONFIG_PENDING;
+
return 0;
-
+
cs_failed:
cs_error(link, last_fn, last_ret);
atmel_release(link);
@@ -408,8 +402,7 @@
{
local_info_t *local = link->priv;
- if (link->state & DEV_CONFIG)
- netif_device_detach(local->eth_dev);
+ netif_device_detach(local->eth_dev);
return 0;
}
@@ -418,10 +411,8 @@
{
local_info_t *local = link->priv;
- if (link->state & DEV_CONFIG) {
- atmel_open(local->eth_dev);
- netif_device_attach(local->eth_dev);
- }
+ atmel_open(local->eth_dev);
+ netif_device_attach(local->eth_dev);
return 0;
}