diff options
Diffstat (limited to 'drivers/char/pcmcia/cm4000_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 68 |
1 files changed, 11 insertions, 57 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 8a064f2f005d..649677b5dc36 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -66,7 +66,6 @@ static char *version = "cm4000_cs.c v2.4.0gm5 - All bugs added by Harald Welte"; | |||
66 | #define T_100MSEC msecs_to_jiffies(100) | 66 | #define T_100MSEC msecs_to_jiffies(100) |
67 | #define T_500MSEC msecs_to_jiffies(500) | 67 | #define T_500MSEC msecs_to_jiffies(500) |
68 | 68 | ||
69 | static void cm4000_detach(struct pcmcia_device *p_dev); | ||
70 | static void cm4000_release(dev_link_t *link); | 69 | static void cm4000_release(dev_link_t *link); |
71 | 70 | ||
72 | static int major; /* major number we get from the kernel */ | 71 | static int major; /* major number we get from the kernel */ |
@@ -156,7 +155,6 @@ struct cm4000_dev { | |||
156 | /*sbuf*/ 512*sizeof(char) - \ | 155 | /*sbuf*/ 512*sizeof(char) - \ |
157 | /*queue*/ 4*sizeof(wait_queue_head_t)) | 156 | /*queue*/ 4*sizeof(wait_queue_head_t)) |
158 | 157 | ||
159 | static dev_info_t dev_info = MODULE_NAME; | ||
160 | static dev_link_t *dev_table[CM4000_MAX_DEV]; | 158 | static dev_link_t *dev_table[CM4000_MAX_DEV]; |
161 | 159 | ||
162 | /* This table doesn't use spaces after the comma between fields and thus | 160 | /* This table doesn't use spaces after the comma between fields and thus |
@@ -1864,38 +1862,6 @@ cs_release: | |||
1864 | link->state &= ~DEV_CONFIG_PENDING; | 1862 | link->state &= ~DEV_CONFIG_PENDING; |
1865 | } | 1863 | } |
1866 | 1864 | ||
1867 | static int cm4000_event(event_t event, int priority, | ||
1868 | event_callback_args_t *args) | ||
1869 | { | ||
1870 | dev_link_t *link; | ||
1871 | struct cm4000_dev *dev; | ||
1872 | int devno; | ||
1873 | |||
1874 | link = args->client_data; | ||
1875 | dev = link->priv; | ||
1876 | |||
1877 | DEBUGP(3, dev, "-> cm4000_event\n"); | ||
1878 | for (devno = 0; devno < CM4000_MAX_DEV; devno++) | ||
1879 | if (dev_table[devno] == link) | ||
1880 | break; | ||
1881 | |||
1882 | if (devno == CM4000_MAX_DEV) | ||
1883 | return CS_BAD_ADAPTER; | ||
1884 | |||
1885 | switch (event) { | ||
1886 | case CS_EVENT_CARD_INSERTION: | ||
1887 | DEBUGP(5, dev, "CS_EVENT_CARD_INSERTION\n"); | ||
1888 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1889 | cm4000_config(link, devno); | ||
1890 | break; | ||
1891 | default: | ||
1892 | DEBUGP(5, dev, "unknown event %.2x\n", event); | ||
1893 | break; | ||
1894 | } | ||
1895 | DEBUGP(3, dev, "<- cm4000_event\n"); | ||
1896 | return CS_SUCCESS; | ||
1897 | } | ||
1898 | |||
1899 | static int cm4000_suspend(struct pcmcia_device *p_dev) | 1865 | static int cm4000_suspend(struct pcmcia_device *p_dev) |
1900 | { | 1866 | { |
1901 | dev_link_t *link = dev_to_instance(p_dev); | 1867 | dev_link_t *link = dev_to_instance(p_dev); |
@@ -1935,11 +1901,10 @@ static void cm4000_release(dev_link_t *link) | |||
1935 | pcmcia_release_io(link->handle, &link->io); | 1901 | pcmcia_release_io(link->handle, &link->io); |
1936 | } | 1902 | } |
1937 | 1903 | ||
1938 | static dev_link_t *cm4000_attach(void) | 1904 | static int cm4000_attach(struct pcmcia_device *p_dev) |
1939 | { | 1905 | { |
1940 | struct cm4000_dev *dev; | 1906 | struct cm4000_dev *dev; |
1941 | dev_link_t *link; | 1907 | dev_link_t *link; |
1942 | client_reg_t client_reg; | ||
1943 | int i; | 1908 | int i; |
1944 | 1909 | ||
1945 | for (i = 0; i < CM4000_MAX_DEV; i++) | 1910 | for (i = 0; i < CM4000_MAX_DEV; i++) |
@@ -1948,41 +1913,31 @@ static dev_link_t *cm4000_attach(void) | |||
1948 | 1913 | ||
1949 | if (i == CM4000_MAX_DEV) { | 1914 | if (i == CM4000_MAX_DEV) { |
1950 | printk(KERN_NOTICE MODULE_NAME ": all devices in use\n"); | 1915 | printk(KERN_NOTICE MODULE_NAME ": all devices in use\n"); |
1951 | return NULL; | 1916 | return -ENODEV; |
1952 | } | 1917 | } |
1953 | 1918 | ||
1954 | /* create a new cm4000_cs device */ | 1919 | /* create a new cm4000_cs device */ |
1955 | dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL); | 1920 | dev = kzalloc(sizeof(struct cm4000_dev), GFP_KERNEL); |
1956 | if (dev == NULL) | 1921 | if (dev == NULL) |
1957 | return NULL; | 1922 | return -ENOMEM; |
1958 | 1923 | ||
1959 | link = &dev->link; | 1924 | link = &dev->link; |
1960 | link->priv = dev; | 1925 | link->priv = dev; |
1961 | link->conf.IntType = INT_MEMORY_AND_IO; | 1926 | link->conf.IntType = INT_MEMORY_AND_IO; |
1962 | dev_table[i] = link; | 1927 | dev_table[i] = link; |
1963 | 1928 | ||
1964 | /* register with card services */ | ||
1965 | client_reg.dev_info = &dev_info; | ||
1966 | client_reg.EventMask = | ||
1967 | CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | | ||
1968 | CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | | ||
1969 | CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME; | ||
1970 | client_reg.Version = 0x0210; | ||
1971 | client_reg.event_callback_args.client_data = link; | ||
1972 | |||
1973 | i = pcmcia_register_client(&link->handle, &client_reg); | ||
1974 | if (i) { | ||
1975 | cs_error(link->handle, RegisterClient, i); | ||
1976 | cm4000_detach(link->handle); | ||
1977 | return NULL; | ||
1978 | } | ||
1979 | |||
1980 | init_waitqueue_head(&dev->devq); | 1929 | init_waitqueue_head(&dev->devq); |
1981 | init_waitqueue_head(&dev->ioq); | 1930 | init_waitqueue_head(&dev->ioq); |
1982 | init_waitqueue_head(&dev->atrq); | 1931 | init_waitqueue_head(&dev->atrq); |
1983 | init_waitqueue_head(&dev->readq); | 1932 | init_waitqueue_head(&dev->readq); |
1984 | 1933 | ||
1985 | return link; | 1934 | link->handle = p_dev; |
1935 | p_dev->instance = link; | ||
1936 | |||
1937 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | ||
1938 | cm4000_config(link, i); | ||
1939 | |||
1940 | return 0; | ||
1986 | } | 1941 | } |
1987 | 1942 | ||
1988 | static void cm4000_detach(struct pcmcia_device *p_dev) | 1943 | static void cm4000_detach(struct pcmcia_device *p_dev) |
@@ -2031,11 +1986,10 @@ static struct pcmcia_driver cm4000_driver = { | |||
2031 | .drv = { | 1986 | .drv = { |
2032 | .name = "cm4000_cs", | 1987 | .name = "cm4000_cs", |
2033 | }, | 1988 | }, |
2034 | .attach = cm4000_attach, | 1989 | .probe = cm4000_attach, |
2035 | .remove = cm4000_detach, | 1990 | .remove = cm4000_detach, |
2036 | .suspend = cm4000_suspend, | 1991 | .suspend = cm4000_suspend, |
2037 | .resume = cm4000_resume, | 1992 | .resume = cm4000_resume, |
2038 | .event = cm4000_event, | ||
2039 | .id_table = cm4000_ids, | 1993 | .id_table = cm4000_ids, |
2040 | }; | 1994 | }; |
2041 | 1995 | ||