diff options
Diffstat (limited to 'drivers/scsi/pcmcia/sym53c500_cs.c')
-rw-r--r-- | drivers/scsi/pcmcia/sym53c500_cs.c | 133 |
1 files changed, 46 insertions, 87 deletions
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c index 98b64b2aa8ee..3a4dd6f5b81f 100644 --- a/drivers/scsi/pcmcia/sym53c500_cs.c +++ b/drivers/scsi/pcmcia/sym53c500_cs.c @@ -228,15 +228,6 @@ enum Phase { /* ================================================================== */ -/* -* Global (within this module) variables other than -* sym53c500_driver_template (the scsi_host_template). -*/ -static dev_link_t *dev_list; -static dev_info_t dev_info = "sym53c500_cs"; - -/* ================================================================== */ - static void chip_init(int io_port) { @@ -872,96 +863,70 @@ cs_failed: return; } /* SYM53C500_config */ -static int -SYM53C500_event(event_t event, int priority, event_callback_args_t *args) +static int sym53c500_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; - struct scsi_info_t *info = link->priv; + dev_link_t *link = dev_to_instance(dev); - DEBUG(1, "SYM53C500_event(0x%06x)\n", event); + link->state |= DEV_SUSPEND; + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); - switch (event) { - case CS_EVENT_CARD_REMOVAL: - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) - SYM53C500_release(link); - break; - case CS_EVENT_CARD_INSERTION: - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; - SYM53C500_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: - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - /* See earlier comment about manufacturer IDs. */ - if ((info->manf_id == MANFID_MACNICA) || - (info->manf_id == MANFID_PIONEER) || - (info->manf_id == 0x0098)) { - outb(0x80, link->io.BasePort1 + 0xd); - outb(0x24, link->io.BasePort1 + 0x9); - outb(0x04, link->io.BasePort1 + 0xd); - } - /* - * If things don't work after a "resume", - * this is a good place to start looking. - */ - SYM53C500_int_host_reset(link->io.BasePort1); + return 0; +} + +static int sym53c500_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + struct scsi_info_t *info = link->priv; + + link->state &= ~DEV_SUSPEND; + if (link->state & DEV_CONFIG) { + pcmcia_request_configuration(link->handle, &link->conf); + + /* See earlier comment about manufacturer IDs. */ + if ((info->manf_id == MANFID_MACNICA) || + (info->manf_id == MANFID_PIONEER) || + (info->manf_id == 0x0098)) { + outb(0x80, link->io.BasePort1 + 0xd); + outb(0x24, link->io.BasePort1 + 0x9); + outb(0x04, link->io.BasePort1 + 0xd); } - break; + /* + * If things don't work after a "resume", + * this is a good place to start looking. + */ + SYM53C500_int_host_reset(link->io.BasePort1); } + return 0; -} /* SYM53C500_event */ +} static void -SYM53C500_detach(dev_link_t *link) +SYM53C500_detach(struct pcmcia_device *p_dev) { - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); DEBUG(0, "SYM53C500_detach(0x%p)\n", link); - /* Locate device structure */ - for (linkp = &dev_list; *linkp; linkp = &(*linkp)->next) - if (*linkp == link) - break; - if (*linkp == NULL) - return; - if (link->state & DEV_CONFIG) SYM53C500_release(link); - if (link->handle) - pcmcia_deregister_client(link->handle); - - /* Unlink device structure, free bits. */ - *linkp = link->next; kfree(link->priv); link->priv = NULL; } /* SYM53C500_detach */ -static dev_link_t * -SYM53C500_attach(void) +static int +SYM53C500_attach(struct pcmcia_device *p_dev) { struct scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; DEBUG(0, "SYM53C500_attach()\n"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); if (!info) - return NULL; + return -ENOMEM; memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -975,20 +940,13 @@ SYM53C500_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); - SYM53C500_detach(link); - return NULL; - } + link->handle = p_dev; + p_dev->instance = link; + + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + SYM53C500_config(link); - return link; + return 0; } /* SYM53C500_attach */ MODULE_AUTHOR("Bob Tracy <rct@frus.com>"); @@ -1008,10 +966,11 @@ static struct pcmcia_driver sym53c500_cs_driver = { .drv = { .name = "sym53c500_cs", }, - .attach = SYM53C500_attach, - .event = SYM53C500_event, - .detach = SYM53C500_detach, + .probe = SYM53C500_attach, + .remove = SYM53C500_detach, .id_table = sym53c500_ids, + .suspend = sym53c500_suspend, + .resume = sym53c500_resume, }; static int __init |