diff options
Diffstat (limited to 'drivers/scsi/pcmcia/fdomain_stub.c')
-rw-r--r-- | drivers/scsi/pcmcia/fdomain_stub.c | 117 |
1 files changed, 37 insertions, 80 deletions
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c index db8f5cd85ffe..788c58d805f3 100644 --- a/drivers/scsi/pcmcia/fdomain_stub.c +++ b/drivers/scsi/pcmcia/fdomain_stub.c @@ -80,29 +80,19 @@ typedef struct scsi_info_t { static void fdomain_release(dev_link_t *link); -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args); +static void fdomain_detach(struct pcmcia_device *p_dev); +static void fdomain_config(dev_link_t *link); -static dev_link_t *fdomain_attach(void); -static void fdomain_detach(dev_link_t *); - - -static dev_link_t *dev_list = NULL; - -static dev_info_t dev_info = "fdomain_cs"; - -static dev_link_t *fdomain_attach(void) +static int fdomain_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; - + DEBUG(0, "fdomain_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (!info) return NULL; + if (!info) return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; link->io.NumPorts1 = 0x10; @@ -115,46 +105,27 @@ static dev_link_t *fdomain_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - client_reg.dev_info = &dev_info; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != 0) { - cs_error(link->handle, RegisterClient, ret); - fdomain_detach(link); - return NULL; - } - - return link; + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + fdomain_config(link); + + return 0; } /* fdomain_attach */ /*====================================================================*/ -static void fdomain_detach(dev_link_t *link) +static void fdomain_detach(struct pcmcia_device *p_dev) { - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); - DEBUG(0, "fdomain_detach(0x%p)\n", link); - - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) break; - if (*linkp == NULL) - return; + DEBUG(0, "fdomain_detach(0x%p)\n", link); - if (link->state & DEV_CONFIG) - fdomain_release(link); + if (link->state & DEV_CONFIG) + fdomain_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - - /* Unlink device structure, free bits */ - *linkp = link->next; - kfree(link->priv); - + kfree(link->priv); } /* fdomain_detach */ /*====================================================================*/ @@ -256,43 +227,29 @@ static void fdomain_release(dev_link_t *link) /*====================================================================*/ -static int fdomain_event(event_t event, int priority, - event_callback_args_t *args) +static int fdomain_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); - DEBUG(1, "fdomain_event(0x%06x)\n", event); - - switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - fdomain_release(link); - break; - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - fdomain_config(link); - break; - case CS_EVENT_PM_SUSPEND: link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: if (link->state & DEV_CONFIG) - pcmcia_release_configuration(link->handle); - break; - case CS_EVENT_PM_RESUME: + pcmcia_release_configuration(link->handle); + + return 0; +} + +static int fdomain_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - fdomain_16x0_bus_reset(NULL); + pcmcia_request_configuration(link->handle, &link->conf); + fdomain_16x0_bus_reset(NULL); } - break; - } - return 0; -} /* fdomain_event */ + return 0; +} static struct pcmcia_device_id fdomain_ids[] = { PCMCIA_DEVICE_PROD_ID12("IBM Corp.", "SCSI PCMCIA Card", 0xe3736c88, 0x859cad20), @@ -307,10 +264,11 @@ static struct pcmcia_driver fdomain_cs_driver = { .drv = { .name = "fdomain_cs", }, - .attach = fdomain_attach, - .event = fdomain_event, - .detach = fdomain_detach, + .probe = fdomain_attach, + .remove = fdomain_detach, .id_table = fdomain_ids, + .suspend = fdomain_suspend, + .resume = fdomain_resume, }; static int __init init_fdomain_cs(void) @@ -321,7 +279,6 @@ static int __init init_fdomain_cs(void) static void __exit exit_fdomain_cs(void) { pcmcia_unregister_driver(&fdomain_cs_driver); - BUG_ON(dev_list != NULL); } module_init(init_fdomain_cs); |