aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/pcmcia/cm4040_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/char/pcmcia/cm4040_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/char/pcmcia/cm4040_cs.c')
-rw-r--r--drivers/char/pcmcia/cm4040_cs.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index 6ccca8cbabc1..74609c3b2b5f 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,
246 return -EAGAIN; 246 return -EAGAIN;
247 } 247 }
248 248
249 if ((dev->p_dev->state & DEV_PRESENT)==0) 249 if (!pcmcia_dev_present(dev->p_dev))
250 return -ENODEV; 250 return -ENODEV;
251 251
252 for (i = 0; i < 5; i++) { 252 for (i = 0; i < 5; i++) {
@@ -351,7 +351,7 @@ static ssize_t cm4040_write(struct file *filp, const char __user *buf,
351 return -EAGAIN; 351 return -EAGAIN;
352 } 352 }
353 353
354 if ((dev->p_dev->state & DEV_PRESENT) == 0) 354 if (!pcmcia_dev_present(dev->p_dev))
355 return -ENODEV; 355 return -ENODEV;
356 356
357 bytes_to_write = count; 357 bytes_to_write = count;
@@ -543,7 +543,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
543 goto cs_failed; 543 goto cs_failed;
544 } 544 }
545 545
546 link->state |= DEV_CONFIG;
547 link->conf.ConfigBase = parse.config.base; 546 link->conf.ConfigBase = parse.config.base;
548 link->conf.Present = parse.config.rmask[0]; 547 link->conf.Present = parse.config.rmask[0];
549 548
@@ -602,9 +601,7 @@ static int reader_config(struct pcmcia_device *link, int devno)
602 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno); 601 sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
603 dev->node.major = major; 602 dev->node.major = major;
604 dev->node.minor = devno; 603 dev->node.minor = devno;
605 dev->node.next = NULL; 604 dev->node.next = &dev->node;
606 link->dev_node = &dev->node;
607 link->state &= ~DEV_CONFIG_PENDING;
608 605
609 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno, 606 DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
610 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1); 607 link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
@@ -616,7 +613,6 @@ cs_failed:
616 cs_error(link, fail_fn, fail_rc); 613 cs_error(link, fail_fn, fail_rc);
617cs_release: 614cs_release:
618 reader_release(link); 615 reader_release(link);
619 link->state &= ~DEV_CONFIG_PENDING;
620 return -ENODEV; 616 return -ENODEV;
621} 617}
622 618
@@ -659,7 +655,6 @@ static int reader_probe(struct pcmcia_device *link)
659 init_timer(&dev->poll_timer); 655 init_timer(&dev->poll_timer);
660 dev->poll_timer.function = &cm4040_do_poll; 656 dev->poll_timer.function = &cm4040_do_poll;
661 657
662 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
663 ret = reader_config(link, i); 658 ret = reader_config(link, i);
664 if (ret) 659 if (ret)
665 return ret; 660 return ret;
@@ -683,10 +678,7 @@ static void reader_detach(struct pcmcia_device *link)
683 if (devno == CM_MAX_DEV) 678 if (devno == CM_MAX_DEV)
684 return; 679 return;
685 680
686 link->state &= ~DEV_PRESENT; 681 reader_release(link);
687
688 if (link->state & DEV_CONFIG)
689 reader_release(link);
690 682
691 dev_table[devno] = NULL; 683 dev_table[devno] = NULL;
692 kfree(dev); 684 kfree(dev);