X-Git-Url: http://pilppa.org/gitweb/gitweb.cgi?a=blobdiff_plain;f=drivers%2Fscsi%2Fpcmcia%2Fnsp_cs.c;h=9e3ab3fd53555528471ef7d489c877c001ffab58;hb=cc918c7ab7da017bfaf9661420bb5c462e057cfb;hp=91b3f28e7a19ddc3dd66942124c7bd5cd2fc786c;hpb=54522b6613a03807f057fd567794a31267ef85cb;p=linux-2.6-omap-h63xx.git diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index 91b3f28e7a1..9e3ab3fd535 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -51,7 +51,6 @@ #include #include -#include #include #include #include @@ -82,7 +81,7 @@ module_param(free_ports, bool, 0); MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))"); /* /usr/src/linux/drivers/scsi/hosts.h */ -static Scsi_Host_Template nsp_driver_template = { +static struct scsi_host_template nsp_driver_template = { .proc_name = "nsp_cs", .proc_info = nsp_proc_info, .name = "WorkBit NinjaSCSI-3/32Bi(16bit)", @@ -105,9 +104,6 @@ static Scsi_Host_Template nsp_driver_template = { #endif }; -static dev_link_t *dev_list = NULL; -static dev_info_t dev_info = {"nsp_cs"}; - static nsp_hw_data nsp_data_base; /* attach <-> detect glue */ @@ -202,7 +198,7 @@ static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) #ifdef NSP_DEBUG /*unsigned int host_id = SCpnt->device->host->this_id;*/ /*unsigned int base = SCpnt->device->host->io_port;*/ - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); #endif nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -374,7 +370,7 @@ static int nsphw_start_selection(Scsi_Cmnd *SCpnt) { unsigned int host_id = SCpnt->device->host->this_id; unsigned int base = SCpnt->device->host->io_port; - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; int time_out; unsigned char phase, arbit; @@ -453,7 +449,7 @@ static struct nsp_sync_table nsp_sync_table_20M[] = { */ static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) { - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); // unsigned char lun = SCpnt->device->lun; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; sync_data *sync = &(data->Sync[target]); @@ -678,7 +674,7 @@ static int nsp_reselected(Scsi_Cmnd *SCpnt) target++; } - if (SCpnt->device->id != target) { + if (scmd_id(SCpnt) != target) { nsp_msg(KERN_ERR, "XXX: reselect ID must be %d in this implementation.", target); } @@ -913,7 +909,7 @@ static void nsp_pio_write(Scsi_Cmnd *SCpnt) static int nsp_nexus(Scsi_Cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; - unsigned char target = SCpnt->device->id; + unsigned char target = scmd_id(SCpnt); // unsigned char lun = SCpnt->device->lun; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; sync_data *sync = &(data->Sync[target]); @@ -1311,7 +1307,7 @@ timer_out: /*----------------------------------------------------------------*/ /* look for ninja3 card and init if found */ /*----------------------------------------------------------------*/ -static struct Scsi_Host *nsp_detect(Scsi_Host_Template *sht) +static struct Scsi_Host *nsp_detect(struct scsi_host_template *sht) { struct Scsi_Host *host; /* registered host structure */ nsp_hw_data *data_b = &nsp_data_base, *data; @@ -1359,7 +1355,7 @@ static struct Scsi_Host *nsp_detect(Scsi_Host_Template *sht) } #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) -static int nsp_detect_old(Scsi_Host_Template *sht) +static int nsp_detect_old(struct scsi_host_template *sht) { if (nsp_detect(sht) == NULL) { return 0; @@ -1597,19 +1593,17 @@ static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) configure the card at this point -- we wait until we receive a card insertion event. ======================================================================*/ -static dev_link_t *nsp_cs_attach(void) +static int nsp_cs_attach(struct pcmcia_device *p_dev) { scsi_info_t *info; - client_reg_t client_reg; dev_link_t *link; - int ret; nsp_hw_data *data = &nsp_data_base; nsp_dbg(NSP_DEBUG_INIT, "in"); /* Create new SCSI device */ info = kmalloc(sizeof(*info), GFP_KERNEL); - if (info == NULL) { return NULL; } + if (info == NULL) { return -ENOMEM; } memset(info, 0, sizeof(*info)); link = &info->link; link->priv = info; @@ -1637,28 +1631,14 @@ static dev_link_t *nsp_cs_attach(void) link->conf.IntType = INT_MEMORY_AND_IO; link->conf.Present = PRESENT_OPTION; + link->handle = p_dev; + p_dev->instance = link; - /* Register with Card Services */ - link->next = dev_list; - dev_list = link; - client_reg.dev_info = &dev_info; - client_reg.EventMask = - CS_EVENT_CARD_INSERTION | CS_EVENT_CARD_REMOVAL | - CS_EVENT_RESET_PHYSICAL | CS_EVENT_CARD_RESET | - CS_EVENT_PM_SUSPEND | CS_EVENT_PM_RESUME ; - client_reg.event_handler = &nsp_cs_event; - client_reg.Version = 0x0210; - client_reg.event_callback_args.client_data = link; - ret = pcmcia_register_client(&link->handle, &client_reg); - if (ret != CS_SUCCESS) { - cs_error(link->handle, RegisterClient, ret); - nsp_cs_detach(link); - return NULL; - } - + link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; + nsp_cs_config(link); nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); - return link; + return 0; } /* nsp_cs_attach */ @@ -1668,35 +1648,19 @@ static dev_link_t *nsp_cs_attach(void) structures are freed. Otherwise, the structures will be freed when the device is released. ======================================================================*/ -static void nsp_cs_detach(dev_link_t *link) +static void nsp_cs_detach(struct pcmcia_device *p_dev) { - dev_link_t **linkp; + dev_link_t *link = dev_to_instance(p_dev); nsp_dbg(NSP_DEBUG_INIT, "in, link=0x%p", 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) + if (link->state & DEV_CONFIG) { + ((scsi_info_t *)link->priv)->stop = 1; nsp_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - pcmcia_deregister_client(link->handle); } - /* Unlink device structure, free bits */ - *linkp = link->next; kfree(link->priv); link->priv = NULL; - } /* nsp_cs_detach */ @@ -1723,7 +1687,7 @@ static void nsp_cs_config(dev_link_t *link) struct Scsi_Host *host; nsp_hw_data *data = &nsp_data_base; #if !(LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) - Scsi_Device *dev; + struct scsi_device *dev; dev_node_t **tail, *node; #endif @@ -2027,99 +1991,58 @@ static void nsp_cs_release(dev_link_t *link) #endif } /* nsp_cs_release */ -/*====================================================================== - - 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 nsp_cs_event(event_t event, - int priority, - event_callback_args_t *args) +static int nsp_cs_suspend(struct pcmcia_device *dev) { - dev_link_t *link = args->client_data; + dev_link_t *link = dev_to_instance(dev); scsi_info_t *info = link->priv; nsp_hw_data *data; - nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); + link->state |= DEV_SUSPEND; - switch (event) { - case CS_EVENT_CARD_REMOVAL: - nsp_dbg(NSP_DEBUG_INIT, "event: remove"); - link->state &= ~DEV_PRESENT; - if (link->state & DEV_CONFIG) { - ((scsi_info_t *)link->priv)->stop = 1; - nsp_cs_release(link); - } - break; + nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); - case CS_EVENT_CARD_INSERTION: - nsp_dbg(NSP_DEBUG_INIT, "event: insert"); - link->state |= DEV_PRESENT | DEV_CONFIG_PENDING; -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) - info->bus = args->bus; -#endif - nsp_cs_config(link); - break; + if (info->host != NULL) { + nsp_msg(KERN_INFO, "clear SDTR status"); - case CS_EVENT_PM_SUSPEND: - nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); - link->state |= DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_RESET_PHYSICAL: - /* Mark the device as stopped, to block IO until later */ - nsp_dbg(NSP_DEBUG_INIT, "event: reset physical"); + data = (nsp_hw_data *)info->host->hostdata; - if (info->host != NULL) { - nsp_msg(KERN_INFO, "clear SDTR status"); + nsphw_init_sync(data); + } - data = (nsp_hw_data *)info->host->hostdata; + info->stop = 1; - nsphw_init_sync(data); - } + if (link->state & DEV_CONFIG) + pcmcia_release_configuration(link->handle); - info->stop = 1; - if (link->state & DEV_CONFIG) { - pcmcia_release_configuration(link->handle); - } - break; + return 0; +} - case CS_EVENT_PM_RESUME: - nsp_dbg(NSP_DEBUG_INIT, "event: resume"); - link->state &= ~DEV_SUSPEND; - /* Fall through... */ - case CS_EVENT_CARD_RESET: - nsp_dbg(NSP_DEBUG_INIT, "event: reset"); - if (link->state & DEV_CONFIG) { - pcmcia_request_configuration(link->handle, &link->conf); - } - info->stop = 0; +static int nsp_cs_resume(struct pcmcia_device *dev) +{ + dev_link_t *link = dev_to_instance(dev); + scsi_info_t *info = link->priv; + nsp_hw_data *data; - if (info->host != NULL) { - nsp_msg(KERN_INFO, "reset host and bus"); + nsp_dbg(NSP_DEBUG_INIT, "event: resume"); - data = (nsp_hw_data *)info->host->hostdata; + link->state &= ~DEV_SUSPEND; - nsphw_init (data); - nsp_bus_reset(data); - } + if (link->state & DEV_CONFIG) + pcmcia_request_configuration(link->handle, &link->conf); - break; + info->stop = 0; - default: - nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); - break; + if (info->host != NULL) { + nsp_msg(KERN_INFO, "reset host and bus"); + + data = (nsp_hw_data *)info->host->hostdata; + + nsphw_init (data); + nsp_bus_reset(data); } - nsp_dbg(NSP_DEBUG_INIT, "end"); + return 0; -} /* nsp_cs_event */ +} /*======================================================================* * module entry point @@ -2138,13 +2061,15 @@ static struct pcmcia_device_id nsp_cs_ids[] = { MODULE_DEVICE_TABLE(pcmcia, nsp_cs_ids); static struct pcmcia_driver nsp_driver = { - .owner = THIS_MODULE, - .drv = { - .name = "nsp_cs", + .owner = THIS_MODULE, + .drv = { + .name = "nsp_cs", }, - .attach = nsp_cs_attach, - .detach = nsp_cs_detach, + .probe = nsp_cs_attach, + .remove = nsp_cs_detach, .id_table = nsp_cs_ids, + .suspend = nsp_cs_suspend, + .resume = nsp_cs_resume, }; #endif @@ -2176,7 +2101,6 @@ static void __exit nsp_cs_exit(void) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) pcmcia_unregister_driver(&nsp_driver); - BUG_ON(dev_list != NULL); #else unregister_pcmcia_driver(&dev_info); /* XXX: this really needs to move into generic code.. */