aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl3501_cs.c
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2005-11-14 15:25:51 -0500
committerDominik Brodowski <linux@dominikbrodowski.net>2006-01-05 18:03:24 -0500
commitf8cfa618dccbdc6dab5297f75779566a388a98fd (patch)
treeb91e0952038dafc6e03bf8b1d8948b1fdefec031 /drivers/net/wireless/wl3501_cs.c
parentb463581154f3f3eecda27cae60df813fefcd84d3 (diff)
[PATCH] pcmcia: unify attach, EVENT_CARD_INSERTION handlers into one probe callback
Unify the EVENT_CARD_INSERTION and "attach" callbacks to one unified probe() callback. As all in-kernel drivers are changed to this new callback, there will be no temporary backwards-compatibility. Inside a probe() function, each driver _must_ set struct pcmcia_device *p_dev->instance and instance->handle correctly. With these patches, the basic driver interface for 16-bit PCMCIA drivers now has the classic four callbacks known also from other buses: int (*probe) (struct pcmcia_device *dev); void (*remove) (struct pcmcia_device *dev); int (*suspend) (struct pcmcia_device *dev); int (*resume) (struct pcmcia_device *dev); Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
Diffstat (limited to 'drivers/net/wireless/wl3501_cs.c')
-rw-r--r--drivers/net/wireless/wl3501_cs.c60
1 files changed, 11 insertions, 49 deletions
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 21e498fe7b14..48e10b0c7e74 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -105,7 +105,6 @@ module_param(pc_debug, int, 0);
105 */ 105 */
106static void wl3501_config(dev_link_t *link); 106static void wl3501_config(dev_link_t *link);
107static void wl3501_release(dev_link_t *link); 107static void wl3501_release(dev_link_t *link);
108static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
109 108
110/* 109/*
111 * The dev_info variable is the "key" that is used to match up this 110 * The dev_info variable is the "key" that is used to match up this
@@ -1954,18 +1953,16 @@ static const struct iw_handler_def wl3501_handler_def = {
1954 * The dev_link structure is initialized, but we don't actually configure the 1953 * The dev_link structure is initialized, but we don't actually configure the
1955 * card at this point -- we wait until we receive a card insertion event. 1954 * card at this point -- we wait until we receive a card insertion event.
1956 */ 1955 */
1957static dev_link_t *wl3501_attach(void) 1956static int wl3501_attach(struct pcmcia_device *p_dev)
1958{ 1957{
1959 client_reg_t client_reg;
1960 dev_link_t *link; 1958 dev_link_t *link;
1961 struct net_device *dev; 1959 struct net_device *dev;
1962 struct wl3501_card *this; 1960 struct wl3501_card *this;
1963 int ret;
1964 1961
1965 /* Initialize the dev_link_t structure */ 1962 /* Initialize the dev_link_t structure */
1966 link = kzalloc(sizeof(*link), GFP_KERNEL); 1963 link = kzalloc(sizeof(*link), GFP_KERNEL);
1967 if (!link) 1964 if (!link)
1968 goto out; 1965 return -ENOMEM;
1969 1966
1970 /* The io structure describes IO port mapping */ 1967 /* The io structure describes IO port mapping */
1971 link->io.NumPorts1 = 16; 1968 link->io.NumPorts1 = 16;
@@ -2001,24 +1998,17 @@ static dev_link_t *wl3501_attach(void)
2001 netif_stop_queue(dev); 1998 netif_stop_queue(dev);
2002 link->priv = link->irq.Instance = dev; 1999 link->priv = link->irq.Instance = dev;
2003 2000
2004 /* Register with Card Services */ 2001 link->handle = p_dev;
2005 link->next = wl3501_dev_list; 2002 p_dev->instance = link;
2006 wl3501_dev_list = link; 2003
2007 client_reg.dev_info = &wl3501_dev_info; 2004 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2008 client_reg.Version = 0x0210; 2005 wl3501_config(link);
2009 client_reg.event_callback_args.client_data = link; 2006
2010 ret = pcmcia_register_client(&link->handle, &client_reg); 2007 return 0;
2011 if (ret) {
2012 cs_error(link->handle, RegisterClient, ret);
2013 wl3501_detach(link->handle);
2014 link = NULL;
2015 }
2016out:
2017 return link;
2018out_link: 2008out_link:
2019 kfree(link); 2009 kfree(link);
2020 link = NULL; 2010 link = NULL;
2021 goto out; 2011 return -ENOMEM;
2022} 2012}
2023 2013
2024#define CS_CHECK(fn, ret) \ 2014#define CS_CHECK(fn, ret) \
@@ -2206,33 +2196,6 @@ static int wl3501_resume(struct pcmcia_device *p_dev)
2206} 2196}
2207 2197
2208 2198
2209/**
2210 * wl3501_event - The card status event handler
2211 * @event - event
2212 * @pri - priority
2213 * @args - arguments for this event
2214 *
2215 * The card status event handler. Mostly, this schedules other stuff to run
2216 * after an event is received. A CARD_REMOVAL event also sets some flags to
2217 * discourage the net drivers from trying to talk to the card any more.
2218 *
2219 * When a CARD_REMOVAL event is received, we immediately set a flag to block
2220 * future accesses to this device. All the functions that actually access the
2221 * device should check this flag to make sure the card is still present.
2222 */
2223static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
2224{
2225 dev_link_t *link = args->client_data;
2226
2227 switch (event) {
2228 case CS_EVENT_CARD_INSERTION:
2229 link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
2230 wl3501_config(link);
2231 break;
2232 }
2233 return 0;
2234}
2235
2236static struct pcmcia_device_id wl3501_ids[] = { 2199static struct pcmcia_device_id wl3501_ids[] = {
2237 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001), 2200 PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
2238 PCMCIA_DEVICE_NULL 2201 PCMCIA_DEVICE_NULL
@@ -2244,8 +2207,7 @@ static struct pcmcia_driver wl3501_driver = {
2244 .drv = { 2207 .drv = {
2245 .name = "wl3501_cs", 2208 .name = "wl3501_cs",
2246 }, 2209 },
2247 .attach = wl3501_attach, 2210 .probe = wl3501_attach,
2248 .event = wl3501_event,
2249 .remove = wl3501_detach, 2211 .remove = wl3501_detach,
2250 .id_table = wl3501_ids, 2212 .id_table = wl3501_ids,
2251 .suspend = wl3501_suspend, 2213 .suspend = wl3501_suspend,