[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/serial/serial_cs.c b/drivers/serial/serial_cs.c
index e787509..eec05a0 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -128,38 +128,27 @@
 	struct serial_info *info = link->priv;
 	int i;
 
-	link->state &= ~DEV_PRESENT;
-
 	DEBUG(0, "serial_release(0x%p)\n", link);
 
 	/*
 	 * Recheck to see if the device is still configured.
 	 */
-	if (info->p_dev->state & DEV_CONFIG) {
-		for (i = 0; i < info->ndev; i++)
-			serial8250_unregister_port(info->line[i]);
+	for (i = 0; i < info->ndev; i++)
+		serial8250_unregister_port(info->line[i]);
 
-		info->p_dev->dev_node = NULL;
+	info->p_dev->dev_node = NULL;
 
-		if (!info->slave)
-			pcmcia_disable_device(link);
-
-		info->p_dev->state &= ~DEV_CONFIG;
-	}
+	if (!info->slave)
+		pcmcia_disable_device(link);
 }
 
 static int serial_suspend(struct pcmcia_device *link)
 {
-	if (link->state & DEV_CONFIG) {
-		struct serial_info *info = link->priv;
-		int i;
+	struct serial_info *info = link->priv;
+	int i;
 
-		for (i = 0; i < info->ndev; i++)
-			serial8250_suspend_port(info->line[i]);
-
-		if (info->slave)
-			link->state &= DEV_SUSPEND_NORELEASE;
-	}
+	for (i = 0; i < info->ndev; i++)
+		serial8250_suspend_port(info->line[i]);
 
 	return 0;
 }
@@ -210,7 +199,6 @@
 	}
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
-	link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
 	return serial_config(link);
 }
 
@@ -586,9 +574,6 @@
 	link->conf.ConfigBase = parse->config.base;
 	link->conf.Present = parse->config.rmask[0];
 
-	/* Configure card */
-	link->state |= DEV_CONFIG;
-
 	/* Is this a compliant multifunction card? */
 	tuple->DesiredTuple = CISTPL_LONGLINK_MFC;
 	tuple->Attributes = TUPLE_RETURN_COMMON | TUPLE_RETURN_LINK;
@@ -648,7 +633,6 @@
 	}
 
 	link->dev_node = &info->node[0];
-	link->state &= ~DEV_CONFIG_PENDING;
 	kfree(cfg_mem);
 	return 0;
 
@@ -656,7 +640,6 @@
 	cs_error(link, last_fn, last_ret);
  failed:
 	serial_remove(link);
-	link->state &= ~DEV_CONFIG_PENDING;
 	kfree(cfg_mem);
 	return -ENODEV;
 }