diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-01 18:09:29 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-03-31 10:26:33 -0500 |
commit | e2d4096365e06b9a3799afbadc28b4519c0b3526 (patch) | |
tree | 90ec691d71f9c0309048714e359b8ba351b533f7 /drivers/char | |
parent | f6fbe01ac976f3ec618cd5fb71ad9ce2cfa7ab2b (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')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 13 | ||||
-rw-r--r-- | drivers/char/pcmcia/cm4040_cs.c | 16 | ||||
-rw-r--r-- | drivers/char/pcmcia/synclink_cs.c | 28 |
3 files changed, 17 insertions, 40 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 22dce9d47b2b..16e105d8d70c 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, | |||
971 | if (count == 0) /* according to manpage */ | 971 | if (count == 0) /* according to manpage */ |
972 | return 0; | 972 | return 0; |
973 | 973 | ||
974 | if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */ | 974 | if (!pcmcia_dev_present(dev->p_dev) || /* device removed */ |
975 | test_bit(IS_CMM_ABSENT, &dev->flags)) | 975 | test_bit(IS_CMM_ABSENT, &dev->flags)) |
976 | return -ENODEV; | 976 | return -ENODEV; |
977 | 977 | ||
@@ -1108,7 +1108,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf, | |||
1108 | 1108 | ||
1109 | sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; | 1109 | sendT0 = dev->proto ? 0 : nr > 5 ? 0x08 : 0; |
1110 | 1110 | ||
1111 | if ((dev->p_dev->state & DEV_PRESENT) == 0 || /* socket removed */ | 1111 | if (!pcmcia_dev_present(dev->p_dev) || /* device removed */ |
1112 | test_bit(IS_CMM_ABSENT, &dev->flags)) | 1112 | test_bit(IS_CMM_ABSENT, &dev->flags)) |
1113 | return -ENODEV; | 1113 | return -ENODEV; |
1114 | 1114 | ||
@@ -1789,7 +1789,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno) | |||
1789 | goto cs_failed; | 1789 | goto cs_failed; |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | link->state |= DEV_CONFIG; | ||
1793 | link->conf.ConfigBase = parse.config.base; | 1792 | link->conf.ConfigBase = parse.config.base; |
1794 | link->conf.Present = parse.config.rmask[0]; | 1793 | link->conf.Present = parse.config.rmask[0]; |
1795 | 1794 | ||
@@ -1844,7 +1843,6 @@ static int cm4000_config(struct pcmcia_device * link, int devno) | |||
1844 | dev->node.minor = devno; | 1843 | dev->node.minor = devno; |
1845 | dev->node.next = NULL; | 1844 | dev->node.next = NULL; |
1846 | link->dev_node = &dev->node; | 1845 | link->dev_node = &dev->node; |
1847 | link->state &= ~DEV_CONFIG_PENDING; | ||
1848 | 1846 | ||
1849 | return 0; | 1847 | return 0; |
1850 | 1848 | ||
@@ -1852,8 +1850,6 @@ cs_failed: | |||
1852 | cs_error(link, fail_fn, fail_rc); | 1850 | cs_error(link, fail_fn, fail_rc); |
1853 | cs_release: | 1851 | cs_release: |
1854 | cm4000_release(link); | 1852 | cm4000_release(link); |
1855 | |||
1856 | link->state &= ~DEV_CONFIG_PENDING; | ||
1857 | return -ENODEV; | 1853 | return -ENODEV; |
1858 | } | 1854 | } |
1859 | 1855 | ||
@@ -1913,7 +1909,6 @@ static int cm4000_probe(struct pcmcia_device *link) | |||
1913 | init_waitqueue_head(&dev->atrq); | 1909 | init_waitqueue_head(&dev->atrq); |
1914 | init_waitqueue_head(&dev->readq); | 1910 | init_waitqueue_head(&dev->readq); |
1915 | 1911 | ||
1916 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1917 | ret = cm4000_config(link, i); | 1912 | ret = cm4000_config(link, i); |
1918 | if (ret) | 1913 | if (ret) |
1919 | return ret; | 1914 | return ret; |
@@ -1936,11 +1931,9 @@ static void cm4000_detach(struct pcmcia_device *link) | |||
1936 | if (devno == CM4000_MAX_DEV) | 1931 | if (devno == CM4000_MAX_DEV) |
1937 | return; | 1932 | return; |
1938 | 1933 | ||
1939 | link->state &= ~DEV_PRESENT; | ||
1940 | stop_monitor(dev); | 1934 | stop_monitor(dev); |
1941 | 1935 | ||
1942 | if (link->state & DEV_CONFIG) | 1936 | cm4000_release(link); |
1943 | cm4000_release(link); | ||
1944 | 1937 | ||
1945 | dev_table[devno] = NULL; | 1938 | dev_table[devno] = NULL; |
1946 | kfree(dev); | 1939 | kfree(dev); |
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); |
617 | cs_release: | 614 | cs_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); |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index ef7a81314f0c..07213454c458 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) | |||
578 | link->conf.Attributes = 0; | 578 | link->conf.Attributes = 0; |
579 | link->conf.IntType = INT_MEMORY_AND_IO; | 579 | link->conf.IntType = INT_MEMORY_AND_IO; |
580 | 580 | ||
581 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
582 | ret = mgslpc_config(link); | 581 | ret = mgslpc_config(link); |
583 | if (ret) | 582 | if (ret) |
584 | return ret; | 583 | return ret; |
@@ -618,9 +617,6 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
618 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); | 617 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, &parse)); |
619 | link->conf.ConfigBase = parse.config.base; | 618 | link->conf.ConfigBase = parse.config.base; |
620 | link->conf.Present = parse.config.rmask[0]; | 619 | link->conf.Present = parse.config.rmask[0]; |
621 | |||
622 | /* Configure card */ | ||
623 | link->state |= DEV_CONFIG; | ||
624 | 620 | ||
625 | /* get CIS configuration entry */ | 621 | /* get CIS configuration entry */ |
626 | 622 | ||
@@ -681,8 +677,6 @@ static int mgslpc_config(struct pcmcia_device *link) | |||
681 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, | 677 | printk(", io 0x%04x-0x%04x", link->io.BasePort1, |
682 | link->io.BasePort1+link->io.NumPorts1-1); | 678 | link->io.BasePort1+link->io.NumPorts1-1); |
683 | printk("\n"); | 679 | printk("\n"); |
684 | |||
685 | link->state &= ~DEV_CONFIG_PENDING; | ||
686 | return 0; | 680 | return 0; |
687 | 681 | ||
688 | cs_failed: | 682 | cs_failed: |
@@ -697,25 +691,23 @@ cs_failed: | |||
697 | */ | 691 | */ |
698 | static void mgslpc_release(u_long arg) | 692 | static void mgslpc_release(u_long arg) |
699 | { | 693 | { |
700 | struct pcmcia_device *link = (struct pcmcia_device *)arg; | 694 | struct pcmcia_device *link = (struct pcmcia_device *)arg; |
701 | 695 | ||
702 | if (debug_level >= DEBUG_LEVEL_INFO) | 696 | if (debug_level >= DEBUG_LEVEL_INFO) |
703 | printk("mgslpc_release(0x%p)\n", link); | 697 | printk("mgslpc_release(0x%p)\n", link); |
704 | 698 | ||
705 | pcmcia_disable_device(link); | 699 | pcmcia_disable_device(link); |
706 | } | 700 | } |
707 | 701 | ||
708 | static void mgslpc_detach(struct pcmcia_device *link) | 702 | static void mgslpc_detach(struct pcmcia_device *link) |
709 | { | 703 | { |
710 | if (debug_level >= DEBUG_LEVEL_INFO) | 704 | if (debug_level >= DEBUG_LEVEL_INFO) |
711 | printk("mgslpc_detach(0x%p)\n", link); | 705 | printk("mgslpc_detach(0x%p)\n", link); |
712 | 706 | ||
713 | if (link->state & DEV_CONFIG) { | 707 | ((MGSLPC_INFO *)link->priv)->stop = 1; |
714 | ((MGSLPC_INFO *)link->priv)->stop = 1; | 708 | mgslpc_release((u_long)link); |
715 | mgslpc_release((u_long)link); | ||
716 | } | ||
717 | 709 | ||
718 | mgslpc_remove_device((MGSLPC_INFO *)link->priv); | 710 | mgslpc_remove_device((MGSLPC_INFO *)link->priv); |
719 | } | 711 | } |
720 | 712 | ||
721 | static int mgslpc_suspend(struct pcmcia_device *link) | 713 | 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) | |||
1254 | if (!info) | 1246 | if (!info) |
1255 | return IRQ_NONE; | 1247 | return IRQ_NONE; |
1256 | 1248 | ||
1257 | if (!(info->p_dev->state & DEV_CONFIG)) | 1249 | if (!(info->p_dev->_locked)) |
1258 | return IRQ_HANDLED; | 1250 | return IRQ_HANDLED; |
1259 | 1251 | ||
1260 | spin_lock(&info->lock); | 1252 | spin_lock(&info->lock); |