diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4000_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 121 |
1 files changed, 46 insertions, 75 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 5fdf18515433..02114a0bd0d9 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -46,7 +46,7 @@ | |||
46 | /* #define ATR_CSUM */ | 46 | /* #define ATR_CSUM */ |
47 | 47 | ||
48 | #ifdef PCMCIA_DEBUG | 48 | #ifdef PCMCIA_DEBUG |
49 | #define reader_to_dev(x) (&handle_to_dev(x->link.handle)) | 49 | #define reader_to_dev(x) (&handle_to_dev(x->p_dev->handle)) |
50 | static int pc_debug = PCMCIA_DEBUG; | 50 | static int pc_debug = PCMCIA_DEBUG; |
51 | module_param(pc_debug, int, 0600); | 51 | module_param(pc_debug, int, 0600); |
52 | #define DEBUGP(n, rdr, x, args...) do { \ | 52 | #define DEBUGP(n, rdr, x, args...) do { \ |
@@ -67,7 +67,7 @@ static char *version = "cm4000_cs.c v2.4.0gm6 - All bugs added by Harald Welte"; | |||
67 | #define T_100MSEC msecs_to_jiffies(100) | 67 | #define T_100MSEC msecs_to_jiffies(100) |
68 | #define T_500MSEC msecs_to_jiffies(500) | 68 | #define T_500MSEC msecs_to_jiffies(500) |
69 | 69 | ||
70 | static void cm4000_release(dev_link_t *link); | 70 | static void cm4000_release(struct pcmcia_device *link); |
71 | 71 | ||
72 | static int major; /* major number we get from the kernel */ | 72 | static int major; /* major number we get from the kernel */ |
73 | 73 | ||
@@ -106,7 +106,7 @@ static int major; /* major number we get from the kernel */ | |||
106 | #define REG_STOPBITS(x) (x + 7) | 106 | #define REG_STOPBITS(x) (x + 7) |
107 | 107 | ||
108 | struct cm4000_dev { | 108 | struct cm4000_dev { |
109 | dev_link_t link; /* pcmcia link */ | 109 | struct pcmcia_device *p_dev; |
110 | dev_node_t node; /* OS node (major,minor) */ | 110 | dev_node_t node; /* OS node (major,minor) */ |
111 | 111 | ||
112 | unsigned char atr[MAX_ATR]; | 112 | unsigned char atr[MAX_ATR]; |
@@ -149,14 +149,14 @@ struct cm4000_dev { | |||
149 | #define ZERO_DEV(dev) \ | 149 | #define ZERO_DEV(dev) \ |
150 | memset(&dev->atr_csum,0, \ | 150 | memset(&dev->atr_csum,0, \ |
151 | sizeof(struct cm4000_dev) - \ | 151 | sizeof(struct cm4000_dev) - \ |
152 | /*link*/ sizeof(dev_link_t) - \ | 152 | /*link*/ sizeof(struct pcmcia_device) - \ |
153 | /*node*/ sizeof(dev_node_t) - \ | 153 | /*node*/ sizeof(dev_node_t) - \ |
154 | /*atr*/ MAX_ATR*sizeof(char) - \ | 154 | /*atr*/ MAX_ATR*sizeof(char) - \ |
155 | /*rbuf*/ 512*sizeof(char) - \ | 155 | /*rbuf*/ 512*sizeof(char) - \ |
156 | /*sbuf*/ 512*sizeof(char) - \ | 156 | /*sbuf*/ 512*sizeof(char) - \ |
157 | /*queue*/ 4*sizeof(wait_queue_head_t)) | 157 | /*queue*/ 4*sizeof(wait_queue_head_t)) |
158 | 158 | ||
159 | static dev_link_t *dev_table[CM4000_MAX_DEV]; | 159 | static struct pcmcia_device *dev_table[CM4000_MAX_DEV]; |
160 | static struct class *cmm_class; | 160 | static struct class *cmm_class; |
161 | 161 | ||
162 | /* This table doesn't use spaces after the comma between fields and thus | 162 | /* This table doesn't use spaces after the comma between fields and thus |
@@ -454,7 +454,7 @@ static struct card_fixup card_fixups[] = { | |||
454 | static void set_cardparameter(struct cm4000_dev *dev) | 454 | static void set_cardparameter(struct cm4000_dev *dev) |
455 | { | 455 | { |
456 | int i; | 456 | int i; |
457 | ioaddr_t iobase = dev->link.io.BasePort1; | 457 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
458 | u_int8_t stopbits = 0x02; /* ISO default */ | 458 | u_int8_t stopbits = 0x02; /* ISO default */ |
459 | 459 | ||
460 | DEBUGP(3, dev, "-> set_cardparameter\n"); | 460 | DEBUGP(3, dev, "-> set_cardparameter\n"); |
@@ -487,7 +487,7 @@ static int set_protocol(struct cm4000_dev *dev, struct ptsreq *ptsreq) | |||
487 | unsigned short num_bytes_read; | 487 | unsigned short num_bytes_read; |
488 | unsigned char pts_reply[4]; | 488 | unsigned char pts_reply[4]; |
489 | ssize_t rc; | 489 | ssize_t rc; |
490 | ioaddr_t iobase = dev->link.io.BasePort1; | 490 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
491 | 491 | ||
492 | rc = 0; | 492 | rc = 0; |
493 | 493 | ||
@@ -699,7 +699,7 @@ static void terminate_monitor(struct cm4000_dev *dev) | |||
699 | static void monitor_card(unsigned long p) | 699 | static void monitor_card(unsigned long p) |
700 | { | 700 | { |
701 | struct cm4000_dev *dev = (struct cm4000_dev *) p; | 701 | struct cm4000_dev *dev = (struct cm4000_dev *) p; |
702 | ioaddr_t iobase = dev->link.io.BasePort1; | 702 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
703 | unsigned short s; | 703 | unsigned short s; |
704 | struct ptsreq ptsreq; | 704 | struct ptsreq ptsreq; |
705 | int i, atrc; | 705 | int i, atrc; |
@@ -962,7 +962,7 @@ static ssize_t cmm_read(struct file *filp, __user char *buf, size_t count, | |||
962 | loff_t *ppos) | 962 | loff_t *ppos) |
963 | { | 963 | { |
964 | struct cm4000_dev *dev = filp->private_data; | 964 | struct cm4000_dev *dev = filp->private_data; |
965 | ioaddr_t iobase = dev->link.io.BasePort1; | 965 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
966 | ssize_t rc; | 966 | ssize_t rc; |
967 | int i, j, k; | 967 | int i, j, k; |
968 | 968 | ||
@@ -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->link.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 | ||
@@ -1083,7 +1083,7 @@ static ssize_t cmm_write(struct file *filp, const char __user *buf, | |||
1083 | size_t count, loff_t *ppos) | 1083 | size_t count, loff_t *ppos) |
1084 | { | 1084 | { |
1085 | struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; | 1085 | struct cm4000_dev *dev = (struct cm4000_dev *) filp->private_data; |
1086 | ioaddr_t iobase = dev->link.io.BasePort1; | 1086 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
1087 | unsigned short s; | 1087 | unsigned short s; |
1088 | unsigned char tmp; | 1088 | unsigned char tmp; |
1089 | unsigned char infolen; | 1089 | unsigned char infolen; |
@@ -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->link.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 | ||
@@ -1440,8 +1440,8 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1440 | unsigned long arg) | 1440 | unsigned long arg) |
1441 | { | 1441 | { |
1442 | struct cm4000_dev *dev = filp->private_data; | 1442 | struct cm4000_dev *dev = filp->private_data; |
1443 | ioaddr_t iobase = dev->link.io.BasePort1; | 1443 | ioaddr_t iobase = dev->p_dev->io.BasePort1; |
1444 | dev_link_t *link; | 1444 | struct pcmcia_device *link; |
1445 | int size; | 1445 | int size; |
1446 | int rc; | 1446 | int rc; |
1447 | void __user *argp = (void __user *)arg; | 1447 | void __user *argp = (void __user *)arg; |
@@ -1458,7 +1458,7 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1458 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); | 1458 | iminor(inode), ioctl_names[_IOC_NR(cmd)]); |
1459 | 1459 | ||
1460 | link = dev_table[iminor(inode)]; | 1460 | link = dev_table[iminor(inode)]; |
1461 | if (!(DEV_OK(link))) { | 1461 | if (!pcmcia_dev_present(link)) { |
1462 | DEBUGP(4, dev, "DEV_OK false\n"); | 1462 | DEBUGP(4, dev, "DEV_OK false\n"); |
1463 | return -ENODEV; | 1463 | return -ENODEV; |
1464 | } | 1464 | } |
@@ -1660,14 +1660,14 @@ static int cmm_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, | |||
1660 | static int cmm_open(struct inode *inode, struct file *filp) | 1660 | static int cmm_open(struct inode *inode, struct file *filp) |
1661 | { | 1661 | { |
1662 | struct cm4000_dev *dev; | 1662 | struct cm4000_dev *dev; |
1663 | dev_link_t *link; | 1663 | struct pcmcia_device *link; |
1664 | int rc, minor = iminor(inode); | 1664 | int rc, minor = iminor(inode); |
1665 | 1665 | ||
1666 | if (minor >= CM4000_MAX_DEV) | 1666 | if (minor >= CM4000_MAX_DEV) |
1667 | return -ENODEV; | 1667 | return -ENODEV; |
1668 | 1668 | ||
1669 | link = dev_table[minor]; | 1669 | link = dev_table[minor]; |
1670 | if (link == NULL || !(DEV_OK(link))) | 1670 | if (link == NULL || !pcmcia_dev_present(link)) |
1671 | return -ENODEV; | 1671 | return -ENODEV; |
1672 | 1672 | ||
1673 | if (link->open) | 1673 | if (link->open) |
@@ -1709,7 +1709,7 @@ static int cmm_open(struct inode *inode, struct file *filp) | |||
1709 | static int cmm_close(struct inode *inode, struct file *filp) | 1709 | static int cmm_close(struct inode *inode, struct file *filp) |
1710 | { | 1710 | { |
1711 | struct cm4000_dev *dev; | 1711 | struct cm4000_dev *dev; |
1712 | dev_link_t *link; | 1712 | struct pcmcia_device *link; |
1713 | int minor = iminor(inode); | 1713 | int minor = iminor(inode); |
1714 | 1714 | ||
1715 | if (minor >= CM4000_MAX_DEV) | 1715 | if (minor >= CM4000_MAX_DEV) |
@@ -1735,7 +1735,7 @@ static int cmm_close(struct inode *inode, struct file *filp) | |||
1735 | return 0; | 1735 | return 0; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | static void cmm_cm4000_release(dev_link_t * link) | 1738 | static void cmm_cm4000_release(struct pcmcia_device * link) |
1739 | { | 1739 | { |
1740 | struct cm4000_dev *dev = link->priv; | 1740 | struct cm4000_dev *dev = link->priv; |
1741 | 1741 | ||
@@ -1759,13 +1759,11 @@ static void cmm_cm4000_release(dev_link_t * link) | |||
1759 | 1759 | ||
1760 | /*==== Interface to PCMCIA Layer =======================================*/ | 1760 | /*==== Interface to PCMCIA Layer =======================================*/ |
1761 | 1761 | ||
1762 | static void cm4000_config(dev_link_t * link, int devno) | 1762 | static int cm4000_config(struct pcmcia_device * link, int devno) |
1763 | { | 1763 | { |
1764 | client_handle_t handle = link->handle; | ||
1765 | struct cm4000_dev *dev; | 1764 | struct cm4000_dev *dev; |
1766 | tuple_t tuple; | 1765 | tuple_t tuple; |
1767 | cisparse_t parse; | 1766 | cisparse_t parse; |
1768 | config_info_t conf; | ||
1769 | u_char buf[64]; | 1767 | u_char buf[64]; |
1770 | int fail_fn, fail_rc; | 1768 | int fail_fn, fail_rc; |
1771 | int rc; | 1769 | int rc; |
@@ -1777,41 +1775,34 @@ static void cm4000_config(dev_link_t * link, int devno) | |||
1777 | tuple.TupleDataMax = sizeof(buf); | 1775 | tuple.TupleDataMax = sizeof(buf); |
1778 | tuple.TupleOffset = 0; | 1776 | tuple.TupleOffset = 0; |
1779 | 1777 | ||
1780 | if ((fail_rc = pcmcia_get_first_tuple(handle, &tuple)) != CS_SUCCESS) { | 1778 | if ((fail_rc = pcmcia_get_first_tuple(link, &tuple)) != CS_SUCCESS) { |
1781 | fail_fn = GetFirstTuple; | 1779 | fail_fn = GetFirstTuple; |
1782 | goto cs_failed; | 1780 | goto cs_failed; |
1783 | } | 1781 | } |
1784 | if ((fail_rc = pcmcia_get_tuple_data(handle, &tuple)) != CS_SUCCESS) { | 1782 | if ((fail_rc = pcmcia_get_tuple_data(link, &tuple)) != CS_SUCCESS) { |
1785 | fail_fn = GetTupleData; | 1783 | fail_fn = GetTupleData; |
1786 | goto cs_failed; | 1784 | goto cs_failed; |
1787 | } | 1785 | } |
1788 | if ((fail_rc = | 1786 | if ((fail_rc = |
1789 | pcmcia_parse_tuple(handle, &tuple, &parse)) != CS_SUCCESS) { | 1787 | pcmcia_parse_tuple(link, &tuple, &parse)) != CS_SUCCESS) { |
1790 | fail_fn = ParseTuple; | 1788 | fail_fn = ParseTuple; |
1791 | goto cs_failed; | 1789 | goto cs_failed; |
1792 | } | 1790 | } |
1793 | if ((fail_rc = | ||
1794 | pcmcia_get_configuration_info(handle, &conf)) != CS_SUCCESS) { | ||
1795 | fail_fn = GetConfigurationInfo; | ||
1796 | goto cs_failed; | ||
1797 | } | ||
1798 | 1791 | ||
1799 | link->state |= DEV_CONFIG; | ||
1800 | link->conf.ConfigBase = parse.config.base; | 1792 | link->conf.ConfigBase = parse.config.base; |
1801 | link->conf.Present = parse.config.rmask[0]; | 1793 | link->conf.Present = parse.config.rmask[0]; |
1802 | link->conf.Vcc = conf.Vcc; | ||
1803 | 1794 | ||
1804 | link->io.BasePort2 = 0; | 1795 | link->io.BasePort2 = 0; |
1805 | link->io.NumPorts2 = 0; | 1796 | link->io.NumPorts2 = 0; |
1806 | link->io.Attributes2 = 0; | 1797 | link->io.Attributes2 = 0; |
1807 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 1798 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
1808 | for (rc = pcmcia_get_first_tuple(handle, &tuple); | 1799 | for (rc = pcmcia_get_first_tuple(link, &tuple); |
1809 | rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(handle, &tuple)) { | 1800 | rc == CS_SUCCESS; rc = pcmcia_get_next_tuple(link, &tuple)) { |
1810 | 1801 | ||
1811 | rc = pcmcia_get_tuple_data(handle, &tuple); | 1802 | rc = pcmcia_get_tuple_data(link, &tuple); |
1812 | if (rc != CS_SUCCESS) | 1803 | if (rc != CS_SUCCESS) |
1813 | continue; | 1804 | continue; |
1814 | rc = pcmcia_parse_tuple(handle, &tuple, &parse); | 1805 | rc = pcmcia_parse_tuple(link, &tuple, &parse); |
1815 | if (rc != CS_SUCCESS) | 1806 | if (rc != CS_SUCCESS) |
1816 | continue; | 1807 | continue; |
1817 | 1808 | ||
@@ -1831,7 +1822,7 @@ static void cm4000_config(dev_link_t * link, int devno) | |||
1831 | link->io.IOAddrLines = parse.cftable_entry.io.flags | 1822 | link->io.IOAddrLines = parse.cftable_entry.io.flags |
1832 | & CISTPL_IO_LINES_MASK; | 1823 | & CISTPL_IO_LINES_MASK; |
1833 | 1824 | ||
1834 | rc = pcmcia_request_io(handle, &link->io); | 1825 | rc = pcmcia_request_io(link, &link->io); |
1835 | if (rc == CS_SUCCESS) | 1826 | if (rc == CS_SUCCESS) |
1836 | break; /* we are done */ | 1827 | break; /* we are done */ |
1837 | } | 1828 | } |
@@ -1841,7 +1832,7 @@ static void cm4000_config(dev_link_t * link, int devno) | |||
1841 | link->conf.IntType = 00000002; | 1832 | link->conf.IntType = 00000002; |
1842 | 1833 | ||
1843 | if ((fail_rc = | 1834 | if ((fail_rc = |
1844 | pcmcia_request_configuration(handle, &link->conf)) != CS_SUCCESS) { | 1835 | pcmcia_request_configuration(link, &link->conf)) != CS_SUCCESS) { |
1845 | fail_fn = RequestConfiguration; | 1836 | fail_fn = RequestConfiguration; |
1846 | goto cs_release; | 1837 | goto cs_release; |
1847 | } | 1838 | } |
@@ -1851,63 +1842,48 @@ static void cm4000_config(dev_link_t * link, int devno) | |||
1851 | dev->node.major = major; | 1842 | dev->node.major = major; |
1852 | dev->node.minor = devno; | 1843 | dev->node.minor = devno; |
1853 | dev->node.next = NULL; | 1844 | dev->node.next = NULL; |
1854 | link->dev = &dev->node; | 1845 | link->dev_node = &dev->node; |
1855 | link->state &= ~DEV_CONFIG_PENDING; | ||
1856 | 1846 | ||
1857 | return; | 1847 | return 0; |
1858 | 1848 | ||
1859 | cs_failed: | 1849 | cs_failed: |
1860 | cs_error(handle, fail_fn, fail_rc); | 1850 | cs_error(link, fail_fn, fail_rc); |
1861 | cs_release: | 1851 | cs_release: |
1862 | cm4000_release(link); | 1852 | cm4000_release(link); |
1863 | 1853 | return -ENODEV; | |
1864 | link->state &= ~DEV_CONFIG_PENDING; | ||
1865 | } | 1854 | } |
1866 | 1855 | ||
1867 | static int cm4000_suspend(struct pcmcia_device *p_dev) | 1856 | static int cm4000_suspend(struct pcmcia_device *link) |
1868 | { | 1857 | { |
1869 | dev_link_t *link = dev_to_instance(p_dev); | ||
1870 | struct cm4000_dev *dev; | 1858 | struct cm4000_dev *dev; |
1871 | 1859 | ||
1872 | dev = link->priv; | 1860 | dev = link->priv; |
1873 | |||
1874 | link->state |= DEV_SUSPEND; | ||
1875 | if (link->state & DEV_CONFIG) | ||
1876 | pcmcia_release_configuration(link->handle); | ||
1877 | stop_monitor(dev); | 1861 | stop_monitor(dev); |
1878 | 1862 | ||
1879 | return 0; | 1863 | return 0; |
1880 | } | 1864 | } |
1881 | 1865 | ||
1882 | static int cm4000_resume(struct pcmcia_device *p_dev) | 1866 | static int cm4000_resume(struct pcmcia_device *link) |
1883 | { | 1867 | { |
1884 | dev_link_t *link = dev_to_instance(p_dev); | ||
1885 | struct cm4000_dev *dev; | 1868 | struct cm4000_dev *dev; |
1886 | 1869 | ||
1887 | dev = link->priv; | 1870 | dev = link->priv; |
1888 | |||
1889 | link->state &= ~DEV_SUSPEND; | ||
1890 | if (link->state & DEV_CONFIG) | ||
1891 | pcmcia_request_configuration(link->handle, &link->conf); | ||
1892 | |||
1893 | if (link->open) | 1871 | if (link->open) |
1894 | start_monitor(dev); | 1872 | start_monitor(dev); |
1895 | 1873 | ||
1896 | return 0; | 1874 | return 0; |
1897 | } | 1875 | } |
1898 | 1876 | ||
1899 | static void cm4000_release(dev_link_t *link) | 1877 | static void cm4000_release(struct pcmcia_device *link) |
1900 | { | 1878 | { |
1901 | cmm_cm4000_release(link->priv); /* delay release until device closed */ | 1879 | cmm_cm4000_release(link->priv); /* delay release until device closed */ |
1902 | pcmcia_release_configuration(link->handle); | 1880 | pcmcia_disable_device(link); |
1903 | pcmcia_release_io(link->handle, &link->io); | ||
1904 | } | 1881 | } |
1905 | 1882 | ||
1906 | static int cm4000_attach(struct pcmcia_device *p_dev) | 1883 | static int cm4000_probe(struct pcmcia_device *link) |
1907 | { | 1884 | { |
1908 | struct cm4000_dev *dev; | 1885 | struct cm4000_dev *dev; |
1909 | dev_link_t *link; | 1886 | int i, ret; |
1910 | int i; | ||
1911 | 1887 | ||
1912 | for (i = 0; i < CM4000_MAX_DEV; i++) | 1888 | for (i = 0; i < CM4000_MAX_DEV; i++) |
1913 | if (dev_table[i] == NULL) | 1889 | if (dev_table[i] == NULL) |
@@ -1923,7 +1899,7 @@ static int cm4000_attach(struct pcmcia_device *p_dev) | |||
1923 | if (dev == NULL) | 1899 | if (dev == NULL) |
1924 | return -ENOMEM; | 1900 | return -ENOMEM; |
1925 | 1901 | ||
1926 | link = &dev->link; | 1902 | dev->p_dev = link; |
1927 | link->priv = dev; | 1903 | link->priv = dev; |
1928 | link->conf.IntType = INT_MEMORY_AND_IO; | 1904 | link->conf.IntType = INT_MEMORY_AND_IO; |
1929 | dev_table[i] = link; | 1905 | dev_table[i] = link; |
@@ -1933,11 +1909,9 @@ static int cm4000_attach(struct pcmcia_device *p_dev) | |||
1933 | init_waitqueue_head(&dev->atrq); | 1909 | init_waitqueue_head(&dev->atrq); |
1934 | init_waitqueue_head(&dev->readq); | 1910 | init_waitqueue_head(&dev->readq); |
1935 | 1911 | ||
1936 | link->handle = p_dev; | 1912 | ret = cm4000_config(link, i); |
1937 | p_dev->instance = link; | 1913 | if (ret) |
1938 | 1914 | return ret; | |
1939 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1940 | cm4000_config(link, i); | ||
1941 | 1915 | ||
1942 | class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, | 1916 | class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, |
1943 | "cmm%d", i); | 1917 | "cmm%d", i); |
@@ -1945,9 +1919,8 @@ static int cm4000_attach(struct pcmcia_device *p_dev) | |||
1945 | return 0; | 1919 | return 0; |
1946 | } | 1920 | } |
1947 | 1921 | ||
1948 | static void cm4000_detach(struct pcmcia_device *p_dev) | 1922 | static void cm4000_detach(struct pcmcia_device *link) |
1949 | { | 1923 | { |
1950 | dev_link_t *link = dev_to_instance(p_dev); | ||
1951 | struct cm4000_dev *dev = link->priv; | 1924 | struct cm4000_dev *dev = link->priv; |
1952 | int devno; | 1925 | int devno; |
1953 | 1926 | ||
@@ -1958,11 +1931,9 @@ static void cm4000_detach(struct pcmcia_device *p_dev) | |||
1958 | if (devno == CM4000_MAX_DEV) | 1931 | if (devno == CM4000_MAX_DEV) |
1959 | return; | 1932 | return; |
1960 | 1933 | ||
1961 | link->state &= ~DEV_PRESENT; | ||
1962 | stop_monitor(dev); | 1934 | stop_monitor(dev); |
1963 | 1935 | ||
1964 | if (link->state & DEV_CONFIG) | 1936 | cm4000_release(link); |
1965 | cm4000_release(link); | ||
1966 | 1937 | ||
1967 | dev_table[devno] = NULL; | 1938 | dev_table[devno] = NULL; |
1968 | kfree(dev); | 1939 | kfree(dev); |
@@ -1993,7 +1964,7 @@ static struct pcmcia_driver cm4000_driver = { | |||
1993 | .drv = { | 1964 | .drv = { |
1994 | .name = "cm4000_cs", | 1965 | .name = "cm4000_cs", |
1995 | }, | 1966 | }, |
1996 | .probe = cm4000_attach, | 1967 | .probe = cm4000_probe, |
1997 | .remove = cm4000_detach, | 1968 | .remove = cm4000_detach, |
1998 | .suspend = cm4000_suspend, | 1969 | .suspend = cm4000_suspend, |
1999 | .resume = cm4000_resume, | 1970 | .resume = cm4000_resume, |