[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>
This commit is contained in:
@@ -105,7 +105,6 @@ module_param(pc_debug, int, 0);
|
||||
*/
|
||||
static void wl3501_config(dev_link_t *link);
|
||||
static void wl3501_release(dev_link_t *link);
|
||||
static int wl3501_event(event_t event, int pri, event_callback_args_t *args);
|
||||
|
||||
/*
|
||||
* 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 = {
|
||||
* The dev_link structure is initialized, but we don't actually configure the
|
||||
* card at this point -- we wait until we receive a card insertion event.
|
||||
*/
|
||||
static dev_link_t *wl3501_attach(void)
|
||||
static int wl3501_attach(struct pcmcia_device *p_dev)
|
||||
{
|
||||
client_reg_t client_reg;
|
||||
dev_link_t *link;
|
||||
struct net_device *dev;
|
||||
struct wl3501_card *this;
|
||||
int ret;
|
||||
|
||||
/* Initialize the dev_link_t structure */
|
||||
link = kzalloc(sizeof(*link), GFP_KERNEL);
|
||||
if (!link)
|
||||
goto out;
|
||||
return -ENOMEM;
|
||||
|
||||
/* The io structure describes IO port mapping */
|
||||
link->io.NumPorts1 = 16;
|
||||
@@ -2001,24 +1998,17 @@ static dev_link_t *wl3501_attach(void)
|
||||
netif_stop_queue(dev);
|
||||
link->priv = link->irq.Instance = dev;
|
||||
|
||||
/* Register with Card Services */
|
||||
link->next = wl3501_dev_list;
|
||||
wl3501_dev_list = link;
|
||||
client_reg.dev_info = &wl3501_dev_info;
|
||||
client_reg.Version = 0x0210;
|
||||
client_reg.event_callback_args.client_data = link;
|
||||
ret = pcmcia_register_client(&link->handle, &client_reg);
|
||||
if (ret) {
|
||||
cs_error(link->handle, RegisterClient, ret);
|
||||
wl3501_detach(link->handle);
|
||||
link = NULL;
|
||||
}
|
||||
out:
|
||||
return link;
|
||||
link->handle = p_dev;
|
||||
p_dev->instance = link;
|
||||
|
||||
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
|
||||
wl3501_config(link);
|
||||
|
||||
return 0;
|
||||
out_link:
|
||||
kfree(link);
|
||||
link = NULL;
|
||||
goto out;
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#define CS_CHECK(fn, ret) \
|
||||
@@ -2206,33 +2196,6 @@ static int wl3501_resume(struct pcmcia_device *p_dev)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* wl3501_event - The card status event handler
|
||||
* @event - event
|
||||
* @pri - priority
|
||||
* @args - arguments for this event
|
||||
*
|
||||
* The card status event handler. Mostly, this schedules other stuff to run
|
||||
* after an event is received. A CARD_REMOVAL event also sets some flags to
|
||||
* discourage the net drivers from trying to talk to the card any more.
|
||||
*
|
||||
* When a CARD_REMOVAL event is received, we immediately set a flag to block
|
||||
* future accesses to this device. All the functions that actually access the
|
||||
* device should check this flag to make sure the card is still present.
|
||||
*/
|
||||
static int wl3501_event(event_t event, int pri, event_callback_args_t *args)
|
||||
{
|
||||
dev_link_t *link = args->client_data;
|
||||
|
||||
switch (event) {
|
||||
case CS_EVENT_CARD_INSERTION:
|
||||
link->state |= DEV_PRESENT | DEV_CONFIG_PENDING;
|
||||
wl3501_config(link);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct pcmcia_device_id wl3501_ids[] = {
|
||||
PCMCIA_DEVICE_MANF_CARD(0xd601, 0x0001),
|
||||
PCMCIA_DEVICE_NULL
|
||||
@@ -2244,8 +2207,7 @@ static struct pcmcia_driver wl3501_driver = {
|
||||
.drv = {
|
||||
.name = "wl3501_cs",
|
||||
},
|
||||
.attach = wl3501_attach,
|
||||
.event = wl3501_event,
|
||||
.probe = wl3501_attach,
|
||||
.remove = wl3501_detach,
|
||||
.id_table = wl3501_ids,
|
||||
.suspend = wl3501_suspend,
|
||||
|
Reference in New Issue
Block a user