summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2006-03-02 00:09:29 +0100
committerDominik Brodowski <linux@dominikbrodowski.net>2006-03-31 17:26:33 +0200
commite2d4096365e06b9a3799afbadc28b4519c0b3526 (patch)
tree90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/char
parentf6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (diff)
downloadop-kernel-dev-e2d4096365e06b9a3799afbadc28b4519c0b3526.zip
op-kernel-dev-e2d4096365e06b9a3799afbadc28b4519c0b3526.tar.gz
[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/char')
-rw-r--r--drivers/char/pcmcia/cm4000_cs.c13
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c16
-rw-r--r--drivers/char/pcmcia/synclink_cs.c28
3 files changed, 17 insertions, 40 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c
index 22dce9d..16e105d 100644
--- a/drivers/char/pcmcia/cm4000_cs.c
+++ b/drivers/char/pcmcia/cm4000_cs.c
@@ -971,7 +971,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count,
if (count == 0) /* according to manpage */
return 0;
- if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
+ if (!pcmcia_dev_present(dev->p_dev) || /* device removed */
test_bit(IS_CMM_ABSENT, &dev->flags))
return -ENODEV;
@@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf,
sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0;
- if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */
+ if (!pcmcia_dev_present(dev->p_dev) || /* device removed */
test_bit(IS_CMM_ABSENT, &dev->flags))
return -ENODEV;
@@ -1789,7 +1789,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
goto cs_failed;
}
- link->state |= DEV_CONFIG;
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
@@ -1844,7 +1843,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno)
dev->node.minor = devno;
dev->node.next = NULL;
link->dev_node = &dev->node;
- link->state &= ~DEV_CONFIG_PENDING;
return 0;
@@ -1852,8 +1850,6 @@ cs_failed:
cs_error(link, fail_fn, fail_rc);
cs_release:
cm4000_release(link);
-
- link->state &= ~DEV_CONFIG_PENDING;
return -ENODEV;
}
@@ -1913,7 +1909,6 @@ static int cm4000_probe(struct pcmcia_device *link)
init_waitqueue_head(&dev->atrq);
init_waitqueue_head(&dev->readq);
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
ret = cm4000_config(link, i);
if (ret)
return ret;
@@ -1936,11 +1931,9 @@ static void cm4000_detach(struct pcmcia_device *link)
if (devno == CM4000_MAX_DEV)
return;
- link->state &= ~DEV_PRESENT;
stop_monitor(dev);
- if (link->state & DEV_CONFIG)
- cm4000_release(link);
+ cm4000_release(link);
dev_table[devno] = NULL;
kfree(dev);
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 6ccca8c..74609c3 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -246,7 +246,7 @@ static ssize_t cm4040_read(struct file *filp, char __user *buf,
return -EAGAIN;
}
- if ((dev->p_dev->state & DEV_PRESENT)==0)
+ if (!pcmcia_dev_present(dev->p_dev))
return -ENODEV;
for (i = 0; i < 5; i++) {
@@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
return -EAGAIN;
}
- if ((dev->p_dev->state & DEV_PRESENT) == 0)
+ if (!pcmcia_dev_present(dev->p_dev))
return -ENODEV;
bytes_to_write = count;
@@ -543,7 +543,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
goto cs_failed;
}
- link->state |= DEV_CONFIG;
link->conf.ConfigBase = parse.config.base;
link->conf.Present = parse.config.rmask[0];
@@ -602,9 +601,7 @@ static int reader_config(struct pcmcia_device *link, int devno)
sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
dev->node.major = major;
dev->node.minor = devno;
- dev->node.next = NULL;
- link->dev_node = &dev->node;
- link->state &= ~DEV_CONFIG_PENDING;
+ dev->node.next = &dev->node;
DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
@@ -616,7 +613,6 @@ cs_failed:
cs_error(link, fail_fn, fail_rc);
cs_release:
reader_release(link);
- link->state &= ~DEV_CONFIG_PENDING;
return -ENODEV;
}
@@ -659,7 +655,6 @@ static int reader_probe(struct pcmcia_device *link)
init_timer(&dev->poll_timer);
dev->poll_timer.function = &cm4040_do_poll;
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
ret = reader_config(link, i);
if (ret)
return ret;
@@ -683,10 +678,7 @@ static void reader_detach(struct pcmcia_device *link)
if (devno == CM_MAX_DEV)
return;
- link->state &= ~DEV_PRESENT;
-
- if (link->state & DEV_CONFIG)
- reader_release(link);
+ reader_release(link);
dev_table[devno] = NULL;
kfree(dev);
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index ef7a813..0721345 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -578,7 +578,6 @@ static int mgslpc_probe(struct pcmcia_device *link)
link->conf.Attributes = 0;
link->conf.IntType = INT_MEMORY_AND_IO;
- link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
ret = mgslpc_config(link);
if (ret)
return ret;
@@ -618,9 +617,6 @@ static int mgslpc_config(struct pcmcia_device *link)
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;
/* get CIS configuration entry */
@@ -681,8 +677,6 @@ static int mgslpc_config(struct pcmcia_device *link)
printk(", io 0x%04x-0x%04x", link->io.BasePort1,
link->io.BasePort1+link->io.NumPorts1-1);
printk("\n");
-
- link->state &= ~DEV_CONFIG_PENDING;
return 0;
cs_failed:
@@ -697,25 +691,23 @@ cs_failed:
*/
static void mgslpc_release(u_long arg)
{
- struct pcmcia_device *link = (struct pcmcia_device *)arg;
+ struct pcmcia_device *link = (struct pcmcia_device *)arg;
- if (debug_level >= DEBUG_LEVEL_INFO)
- printk("mgslpc_release(0x%p)\n", link);
+ if (debug_level >= DEBUG_LEVEL_INFO)
+ printk("mgslpc_release(0x%p)\n", link);
- pcmcia_disable_device(link);
+ pcmcia_disable_device(link);
}
static void mgslpc_detach(struct pcmcia_device *link)
{
- if (debug_level >= DEBUG_LEVEL_INFO)
- printk("mgslpc_detach(0x%p)\n", link);
+ if (debug_level >= DEBUG_LEVEL_INFO)
+ printk("mgslpc_detach(0x%p)\n", link);
- if (link->state & DEV_CONFIG) {
- ((MGSLPC_INFO *)link->priv)->stop = 1;
- mgslpc_release((u_long)link);
- }
+ ((MGSLPC_INFO *)link->priv)->stop = 1;
+ mgslpc_release((u_long)link);
- mgslpc_remove_device((MGSLPC_INFO *)link->priv);
+ mgslpc_remove_device((MGSLPC_INFO *)link->priv);
}
static int mgslpc_suspend(struct pcmcia_device *link)
@@ -1254,7 +1246,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id, struct pt_regs * regs)
if (!info)
return IRQ_NONE;
- if (!(info->p_dev->state & DEV_CONFIG))
+ if (!(info->p_dev->_locked))
return IRQ_HANDLED;
spin_lock(&info->lock);
OpenPOWER on IntegriCloud