diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4000_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 54 |
1 files changed, 18 insertions, 36 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index ec73d9f6d9ed..a7584860e9a7 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -30,11 +30,10 @@ | |||
30 | #include <linux/fs.h> | 30 | #include <linux/fs.h> |
31 | #include <linux/delay.h> | 31 | #include <linux/delay.h> |
32 | #include <linux/bitrev.h> | 32 | #include <linux/bitrev.h> |
33 | #include <linux/smp_lock.h> | 33 | #include <linux/mutex.h> |
34 | #include <linux/uaccess.h> | 34 | #include <linux/uaccess.h> |
35 | #include <linux/io.h> | 35 | #include <linux/io.h> |
36 | 36 | ||
37 | #include <pcmcia/cs.h> | ||
38 | #include <pcmcia/cistpl.h> | 37 | #include <pcmcia/cistpl.h> |
39 | #include <pcmcia/cisreg.h> | 38 | #include <pcmcia/cisreg.h> |
40 | #include <pcmcia/ciscode.h> | 39 | #include <pcmcia/ciscode.h> |
@@ -55,7 +54,7 @@ | |||
55 | __func__ , ## args); \ | 54 | __func__ , ## args); \ |
56 | } while (0) | 55 | } while (0) |
57 | 56 | ||
58 | static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; | 57 | static DEFINE_MUTEX(cmm_mutex); |
59 | 58 | ||
60 | #define T_1SEC (HZ) | 59 | #define T_1SEC (HZ) |
61 | #define T_10MSEC msecs_to_jiffies(10) | 60 | #define T_10MSEC msecs_to_jiffies(10) |
@@ -807,7 +806,7 @@ static void monitor_card(unsigned long p) | |||
807 | dev->flags1 = 0x01; | 806 | dev->flags1 = 0x01; |
808 | xoutb(dev->flags1, REG_FLAGS1(iobase)); | 807 | xoutb(dev->flags1, REG_FLAGS1(iobase)); |
809 | 808 | ||
810 | /* atr is present (which doesnt mean it's valid) */ | 809 | /* atr is present (which doesn't mean it's valid) */ |
811 | set_bit(IS_ATR_PRESENT, &dev->flags); | 810 | set_bit(IS_ATR_PRESENT, &dev->flags); |
812 | if (dev->atr[0] == 0x03) | 811 | if (dev->atr[0] == 0x03) |
813 | str_invert_revert(dev->atr, dev->atr_len); | 812 | str_invert_revert(dev->atr, dev->atr_len); |
@@ -831,8 +830,7 @@ static void monitor_card(unsigned long p) | |||
831 | test_bit(IS_ANY_T1, &dev->flags))) { | 830 | test_bit(IS_ANY_T1, &dev->flags))) { |
832 | DEBUGP(4, dev, "Perform AUTOPPS\n"); | 831 | DEBUGP(4, dev, "Perform AUTOPPS\n"); |
833 | set_bit(IS_AUTOPPS_ACT, &dev->flags); | 832 | set_bit(IS_AUTOPPS_ACT, &dev->flags); |
834 | ptsreq.protocol = ptsreq.protocol = | 833 | ptsreq.protocol = (0x01 << dev->proto); |
835 | (0x01 << dev->proto); | ||
836 | ptsreq.flags = 0x01; | 834 | ptsreq.flags = 0x01; |
837 | ptsreq.pts1 = 0x00; | 835 | ptsreq.pts1 = 0x00; |
838 | ptsreq.pts2 = 0x00; | 836 | ptsreq.pts2 = 0x00; |
@@ -980,8 +978,9 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count, | |||
980 | if (dev->flags0 & 1) { | 978 | if (dev->flags0 & 1) { |
981 | set_bit(IS_CMM_ABSENT, &dev->flags); | 979 | set_bit(IS_CMM_ABSENT, &dev->flags); |
982 | rc = -ENODEV; | 980 | rc = -ENODEV; |
981 | } else { | ||
982 | rc = -EIO; | ||
983 | } | 983 | } |
984 | rc = -EIO; | ||
985 | goto release_io; | 984 | goto release_io; |
986 | } | 985 | } |
987 | 986 | ||
@@ -1418,7 +1417,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
1418 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); | 1417 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); |
1419 | #endif | 1418 | #endif |
1420 | 1419 | ||
1421 | lock_kernel(); | 1420 | mutex_lock(&cmm_mutex); |
1422 | rc = -ENODEV; | 1421 | rc = -ENODEV; |
1423 | link = dev_table[iminor(inode)]; | 1422 | link = dev_table[iminor(inode)]; |
1424 | if (!pcmcia_dev_present(link)) { | 1423 | if (!pcmcia_dev_present(link)) { |
@@ -1626,7 +1625,7 @@ static long cmm_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) | |||
1626 | rc = -ENOTTY; | 1625 | rc = -ENOTTY; |
1627 | } | 1626 | } |
1628 | out: | 1627 | out: |
1629 | unlock_kernel(); | 1628 | mutex_unlock(&cmm_mutex); |
1630 | return rc; | 1629 | return rc; |
1631 | } | 1630 | } |
1632 | 1631 | ||
@@ -1640,7 +1639,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1640 | if (minor >= CM4000_MAX_DEV) | 1639 | if (minor >= CM4000_MAX_DEV) |
1641 | return -ENODEV; | 1640 | return -ENODEV; |
1642 | 1641 | ||
1643 | lock_kernel(); | 1642 | mutex_lock(&cmm_mutex); |
1644 | link = dev_table[minor]; | 1643 | link = dev_table[minor]; |
1645 | if (link == NULL || !pcmcia_dev_present(link)) { | 1644 | if (link == NULL || !pcmcia_dev_present(link)) { |
1646 | ret = -ENODEV; | 1645 | ret = -ENODEV; |
@@ -1667,7 +1666,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1667 | /* opening will always block since the | 1666 | /* opening will always block since the |
1668 | * monitor will be started by open, which | 1667 | * monitor will be started by open, which |
1669 | * means we have to wait for ATR becoming | 1668 | * means we have to wait for ATR becoming |
1670 | * vaild = block until valid (or card | 1669 | * valid = block until valid (or card |
1671 | * inserted) | 1670 | * inserted) |
1672 | */ | 1671 | */ |
1673 | if (filp->f_flags & O_NONBLOCK) { | 1672 | if (filp->f_flags & O_NONBLOCK) { |
@@ -1685,7 +1684,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1685 | DEBUGP(2, dev, "<- cmm_open\n"); | 1684 | DEBUGP(2, dev, "<- cmm_open\n"); |
1686 | ret = nonseekable_open(inode, filp); | 1685 | ret = nonseekable_open(inode, filp); |
1687 | out: | 1686 | out: |
1688 | unlock_kernel(); | 1687 | mutex_unlock(&cmm_mutex); |
1689 | return ret; | 1688 | return ret; |
1690 | } | 1689 | } |
1691 | 1690 | ||
@@ -1742,20 +1741,8 @@ static void cmm_cm4000_release(struct pcmcia_device * link) | |||
1742 | 1741 | ||
1743 | /*==== Interface to PCMCIA Layer =======================================*/ | 1742 | /*==== Interface to PCMCIA Layer =======================================*/ |
1744 | 1743 | ||
1745 | static int cm4000_config_check(struct pcmcia_device *p_dev, | 1744 | static int cm4000_config_check(struct pcmcia_device *p_dev, void *priv_data) |
1746 | cistpl_cftable_entry_t *cfg, | ||
1747 | cistpl_cftable_entry_t *dflt, | ||
1748 | unsigned int vcc, | ||
1749 | void *priv_data) | ||
1750 | { | 1745 | { |
1751 | if (!cfg->io.nwin) | ||
1752 | return -ENODEV; | ||
1753 | |||
1754 | p_dev->resource[0]->start = cfg->io.win[0].base; | ||
1755 | p_dev->resource[0]->end = cfg->io.win[0].len; | ||
1756 | p_dev->resource[0]->flags |= pcmcia_io_cfg_data_width(cfg->io.flags); | ||
1757 | p_dev->io_lines = cfg->io.flags & CISTPL_IO_LINES_MASK; | ||
1758 | |||
1759 | return pcmcia_request_io(p_dev); | 1746 | return pcmcia_request_io(p_dev); |
1760 | } | 1747 | } |
1761 | 1748 | ||
@@ -1763,13 +1750,13 @@ static int cm4000_config(struct pcmcia_device * link, int devno) | |||
1763 | { | 1750 | { |
1764 | struct cm4000_dev *dev; | 1751 | struct cm4000_dev *dev; |
1765 | 1752 | ||
1753 | link->config_flags |= CONF_AUTO_SET_IO; | ||
1754 | |||
1766 | /* read the config-tuples */ | 1755 | /* read the config-tuples */ |
1767 | if (pcmcia_loop_config(link, cm4000_config_check, NULL)) | 1756 | if (pcmcia_loop_config(link, cm4000_config_check, NULL)) |
1768 | goto cs_release; | 1757 | goto cs_release; |
1769 | 1758 | ||
1770 | link->conf.IntType = 00000002; | 1759 | if (pcmcia_enable_device(link)) |
1771 | |||
1772 | if (pcmcia_request_configuration(link, &link->conf)) | ||
1773 | goto cs_release; | 1760 | goto cs_release; |
1774 | 1761 | ||
1775 | dev = link->priv; | 1762 | dev = link->priv; |
@@ -1829,7 +1816,6 @@ static int cm4000_probe(struct pcmcia_device *link) | |||
1829 | 1816 | ||
1830 | dev->p_dev = link; | 1817 | dev->p_dev = link; |
1831 | link->priv = dev; | 1818 | link->priv = dev; |
1832 | link->conf.IntType = INT_MEMORY_AND_IO; | ||
1833 | dev_table[i] = link; | 1819 | dev_table[i] = link; |
1834 | 1820 | ||
1835 | init_waitqueue_head(&dev->devq); | 1821 | init_waitqueue_head(&dev->devq); |
@@ -1880,9 +1866,10 @@ static const struct file_operations cm4000_fops = { | |||
1880 | .unlocked_ioctl = cmm_ioctl, | 1866 | .unlocked_ioctl = cmm_ioctl, |
1881 | .open = cmm_open, | 1867 | .open = cmm_open, |
1882 | .release= cmm_close, | 1868 | .release= cmm_close, |
1869 | .llseek = no_llseek, | ||
1883 | }; | 1870 | }; |
1884 | 1871 | ||
1885 | static struct pcmcia_device_id cm4000_ids[] = { | 1872 | static const struct pcmcia_device_id cm4000_ids[] = { |
1886 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002), | 1873 | PCMCIA_DEVICE_MANF_CARD(0x0223, 0x0002), |
1887 | PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39), | 1874 | PCMCIA_DEVICE_PROD_ID12("CardMan", "4000", 0x2FB368CA, 0xA2BD8C39), |
1888 | PCMCIA_DEVICE_NULL, | 1875 | PCMCIA_DEVICE_NULL, |
@@ -1891,9 +1878,7 @@ MODULE_DEVICE_TABLE(pcmcia, cm4000_ids); | |||
1891 | 1878 | ||
1892 | static struct pcmcia_driver cm4000_driver = { | 1879 | static struct pcmcia_driver cm4000_driver = { |
1893 | .owner = THIS_MODULE, | 1880 | .owner = THIS_MODULE, |
1894 | .drv = { | 1881 | .name = "cm4000_cs", |
1895 | .name = "cm4000_cs", | ||
1896 | }, | ||
1897 | .probe = cm4000_probe, | 1882 | .probe = cm4000_probe, |
1898 | .remove = cm4000_detach, | 1883 | .remove = cm4000_detach, |
1899 | .suspend = cm4000_suspend, | 1884 | .suspend = cm4000_suspend, |
@@ -1905,8 +1890,6 @@ static int __init cmm_init(void) | |||
1905 | { | 1890 | { |
1906 | int rc; | 1891 | int rc; |
1907 | 1892 | ||
1908 | printk(KERN_INFO "%s\n", version); | ||
1909 | |||
1910 | cmm_class = class_create(THIS_MODULE, "cardman_4000"); | 1893 | cmm_class = class_create(THIS_MODULE, "cardman_4000"); |
1911 | if (IS_ERR(cmm_class)) | 1894 | if (IS_ERR(cmm_class)) |
1912 | return PTR_ERR(cmm_class); | 1895 | return PTR_ERR(cmm_class); |
@@ -1931,7 +1914,6 @@ static int __init cmm_init(void) | |||
1931 | 1914 | ||
1932 | static void __exit cmm_exit(void) | 1915 | static void __exit cmm_exit(void) |
1933 | { | 1916 | { |
1934 | printk(KERN_INFO MODULE_NAME ": unloading\n"); | ||
1935 | pcmcia_unregister_driver(&cm4000_driver); | 1917 | pcmcia_unregister_driver(&cm4000_driver); |
1936 | unregister_chrdev(major, DEVICE_NAME); | 1918 | unregister_chrdev(major, DEVICE_NAME); |
1937 | class_destroy(cmm_class); | 1919 | class_destroy(cmm_class); |