diff options
author | Dominik Brodowski <linux@dominikbrodowski.net> | 2005-11-14 15:23:14 -0500 |
---|---|---|
committer | Dominik Brodowski <linux@dominikbrodowski.net> | 2006-01-05 18:03:10 -0500 |
commit | cc3b4866bee996c922e875b8c8efe9f0d8803aae (patch) | |
tree | 6632837b6986f33566f75ed971cecbdc210e3201 /drivers/char/pcmcia/cm4000_cs.c | |
parent | 8e9e793d68fcda6cc84c18cedf85ca0f91d801a8 (diff) |
[PATCH] pcmcia: unify detach, REMOVAL_EVENT handlers into one remove callback
Unify the "detach" and REMOVAL_EVENT handlers to one "remove" function.
Old functionality is preserved, for the moment.
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/char/pcmcia/cm4000_cs.c')
-rw-r--r-- | drivers/char/pcmcia/cm4000_cs.c | 55 |
1 files changed, 17 insertions, 38 deletions
diff --git a/drivers/char/pcmcia/cm4000_cs.c b/drivers/char/pcmcia/cm4000_cs.c index 05e93054c98c..8a064f2f005d 100644 --- a/drivers/char/pcmcia/cm4000_cs.c +++ b/drivers/char/pcmcia/cm4000_cs.c | |||
@@ -66,7 +66,7 @@ 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(dev_link_t *link); | 69 | static void cm4000_detach(struct pcmcia_device *p_dev); |
70 | static void cm4000_release(dev_link_t *link); | 70 | static void cm4000_release(dev_link_t *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 */ |
@@ -1888,11 +1888,6 @@ static int cm4000_event(event_t event, int priority, | |||
1888 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; | 1888 | link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; |
1889 | cm4000_config(link, devno); | 1889 | cm4000_config(link, devno); |
1890 | break; | 1890 | break; |
1891 | case CS_EVENT_CARD_REMOVAL: | ||
1892 | DEBUGP(5, dev, "CS_EVENT_CARD_REMOVAL\n"); | ||
1893 | link->state &= ~DEV_PRESENT; | ||
1894 | stop_monitor(dev); | ||
1895 | break; | ||
1896 | default: | 1891 | default: |
1897 | DEBUGP(5, dev, "unknown event %.2x\n", event); | 1892 | DEBUGP(5, dev, "unknown event %.2x\n", event); |
1898 | break; | 1893 | break; |
@@ -1978,7 +1973,7 @@ static dev_link_t *cm4000_attach(void) | |||
1978 | i = pcmcia_register_client(&link->handle, &client_reg); | 1973 | i = pcmcia_register_client(&link->handle, &client_reg); |
1979 | if (i) { | 1974 | if (i) { |
1980 | cs_error(link->handle, RegisterClient, i); | 1975 | cs_error(link->handle, RegisterClient, i); |
1981 | cm4000_detach(link); | 1976 | cm4000_detach(link->handle); |
1982 | return NULL; | 1977 | return NULL; |
1983 | } | 1978 | } |
1984 | 1979 | ||
@@ -1990,39 +1985,28 @@ static dev_link_t *cm4000_attach(void) | |||
1990 | return link; | 1985 | return link; |
1991 | } | 1986 | } |
1992 | 1987 | ||
1993 | static void cm4000_detach_by_devno(int devno, dev_link_t * link) | 1988 | static void cm4000_detach(struct pcmcia_device *p_dev) |
1994 | { | 1989 | { |
1990 | dev_link_t *link = dev_to_instance(p_dev); | ||
1995 | struct cm4000_dev *dev = link->priv; | 1991 | struct cm4000_dev *dev = link->priv; |
1992 | int devno; | ||
1996 | 1993 | ||
1997 | DEBUGP(3, dev, "-> detach_by_devno(devno=%d)\n", devno); | 1994 | /* find device */ |
1995 | for (devno = 0; devno < CM4000_MAX_DEV; devno++) | ||
1996 | if (dev_table[devno] == link) | ||
1997 | break; | ||
1998 | if (devno == CM4000_MAX_DEV) | ||
1999 | return; | ||
1998 | 2000 | ||
1999 | if (link->state & DEV_CONFIG) { | 2001 | link->state &= ~DEV_PRESENT; |
2000 | DEBUGP(5, dev, "device still configured (try to release it)\n"); | 2002 | stop_monitor(dev); |
2001 | cm4000_release(link); | ||
2002 | } | ||
2003 | 2003 | ||
2004 | if (link->handle) { | 2004 | if (link->state & DEV_CONFIG) |
2005 | pcmcia_deregister_client(link->handle); | 2005 | cm4000_release(link); |
2006 | } | ||
2007 | 2006 | ||
2008 | dev_table[devno] = NULL; | 2007 | dev_table[devno] = NULL; |
2009 | kfree(dev); | 2008 | kfree(dev); |
2010 | return; | ||
2011 | } | ||
2012 | |||
2013 | static void cm4000_detach(dev_link_t * link) | ||
2014 | { | ||
2015 | int i; | ||
2016 | 2009 | ||
2017 | /* find device */ | ||
2018 | for (i = 0; i < CM4000_MAX_DEV; i++) | ||
2019 | if (dev_table[i] == link) | ||
2020 | break; | ||
2021 | |||
2022 | if (i == CM4000_MAX_DEV) | ||
2023 | return; | ||
2024 | |||
2025 | cm4000_detach_by_devno(i, link); | ||
2026 | return; | 2010 | return; |
2027 | } | 2011 | } |
2028 | 2012 | ||
@@ -2048,7 +2032,7 @@ static struct pcmcia_driver cm4000_driver = { | |||
2048 | .name = "cm4000_cs", | 2032 | .name = "cm4000_cs", |
2049 | }, | 2033 | }, |
2050 | .attach = cm4000_attach, | 2034 | .attach = cm4000_attach, |
2051 | .detach = cm4000_detach, | 2035 | .remove = cm4000_detach, |
2052 | .suspend = cm4000_suspend, | 2036 | .suspend = cm4000_suspend, |
2053 | .resume = cm4000_resume, | 2037 | .resume = cm4000_resume, |
2054 | .event = cm4000_event, | 2038 | .event = cm4000_event, |
@@ -2071,13 +2055,8 @@ static int __init cmm_init(void) | |||
2071 | 2055 | ||
2072 | static void __exit cmm_exit(void) | 2056 | static void __exit cmm_exit(void) |
2073 | { | 2057 | { |
2074 | int i; | ||
2075 | |||
2076 | printk(KERN_INFO MODULE_NAME ": unloading\n"); | 2058 | printk(KERN_INFO MODULE_NAME ": unloading\n"); |
2077 | pcmcia_unregister_driver(&cm4000_driver); | 2059 | pcmcia_unregister_driver(&cm4000_driver); |
2078 | for (i = 0; i < CM4000_MAX_DEV; i++) | ||
2079 | if (dev_table[i]) | ||
2080 | cm4000_detach_by_devno(i, dev_table[i]); | ||
2081 | unregister_chrdev(major, DEVICE_NAME); | 2060 | unregister_chrdev(major, DEVICE_NAME); |
2082 | }; | 2061 | }; |
2083 | 2062 | ||