X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=drivers%2Fscsi%2Fpcmcia%2Fnsp_cs.c;h=e16fe361436e845f1a295ba8ae433f3ff7901d2a;hb=refs%2Fheads%2Fvserver;hp=f38faabf963211f8330dfe715c620902fb0540e9;hpb=9213980e6a70d8473e0ffd4b39ab5b6caaba9ff5;p=linux-2.6.git diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c index f38faabf9..e16fe3614 100644 --- a/drivers/scsi/pcmcia/nsp_cs.c +++ b/drivers/scsi/pcmcia/nsp_cs.c @@ -46,12 +46,11 @@ #include #include <../drivers/scsi/scsi.h> -#include <../drivers/scsi/hosts.h> +#include #include #include -#include #include #include #include @@ -72,25 +71,16 @@ MODULE_LICENSE("GPL"); /*====================================================================*/ /* Parameters that can be set with 'insmod' */ -static unsigned int irq_mask = 0xffff; -MODULE_PARM (irq_mask, "i"); -MODULE_PARM_DESC(irq_mask, "IRQ mask bits (default: 0xffff)"); - -static int irq_list[4] = { -1 }; -MODULE_PARM (irq_list, "1-4i"); -MODULE_PARM_DESC(irq_list, "Use specified IRQ number. (default: auto select)"); - static int nsp_burst_mode = BURST_MEM32; -MODULE_PARM (nsp_burst_mode, "i"); +module_param(nsp_burst_mode, int, 0); MODULE_PARM_DESC(nsp_burst_mode, "Burst transfer mode (0=io8, 1=io32, 2=mem32(default))"); /* Release IO ports after configuration? */ static int free_ports = 0; -MODULE_PARM (free_ports, "i"); +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)", @@ -100,9 +90,7 @@ static Scsi_Host_Template nsp_driver_template = { #endif .info = nsp_info, .queuecommand = nsp_queuecommand, -/* .eh_strategy_handler = nsp_eh_strategy,*/ /* .eh_abort_handler = nsp_eh_abort,*/ -/* .eh_device_reset_handler = nsp_eh_device_reset,*/ .eh_bus_reset_handler = nsp_eh_bus_reset, .eh_host_reset_handler = nsp_eh_host_reset, .can_queue = 1, @@ -115,9 +103,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 */ @@ -198,7 +183,7 @@ static void nsp_cs_dmessage(const char *func, int line, int mask, char *fmt, ... * Clenaup parameters and call done() functions. * You must be set SCpnt->result before call this function. */ -static void nsp_scsi_done(Scsi_Cmnd *SCpnt) +static void nsp_scsi_done(struct scsi_cmnd *SCpnt) { nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -207,12 +192,13 @@ static void nsp_scsi_done(Scsi_Cmnd *SCpnt) SCpnt->scsi_done(SCpnt); } -static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) +static int nsp_queuecommand(struct scsi_cmnd *SCpnt, + void (*done)(struct 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; @@ -226,7 +212,7 @@ static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) nsp_msg(KERN_DEBUG, "CurrentSC!=NULL this can't be happen"); SCpnt->result = DID_BAD_TARGET << 16; nsp_scsi_done(SCpnt); - return SCSI_MLQUEUE_HOST_BUSY; + return 0; } #if 0 @@ -273,7 +259,7 @@ static int nsp_queuecommand(Scsi_Cmnd *SCpnt, void (*done)(Scsi_Cmnd *)) nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "selection fail"); SCpnt->result = DID_BUS_BUSY << 16; nsp_scsi_done(SCpnt); - return SCSI_MLQUEUE_DEVICE_BUSY; + return 0; } @@ -380,11 +366,11 @@ static int nsphw_init(nsp_hw_data *data) /* * Start selection phase */ -static int nsphw_start_selection(Scsi_Cmnd *SCpnt) +static int nsphw_start_selection(struct 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; @@ -461,9 +447,9 @@ static struct nsp_sync_table nsp_sync_table_20M[] = { /* * setup synchronous data transfer mode */ -static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) +static int nsp_analyze_sdtr(struct 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]); @@ -519,7 +505,7 @@ static int nsp_analyze_sdtr(Scsi_Cmnd *SCpnt) /* * start ninja hardware timer */ -static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time) +static void nsp_start_timer(struct scsi_cmnd *SCpnt, int time) { unsigned int base = SCpnt->device->host->io_port; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -532,7 +518,8 @@ static void nsp_start_timer(Scsi_Cmnd *SCpnt, int time) /* * wait for bus phase change */ -static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str) +static int nsp_negate_signal(struct scsi_cmnd *SCpnt, unsigned char mask, + char *str) { unsigned int base = SCpnt->device->host->io_port; unsigned char reg; @@ -559,9 +546,9 @@ static int nsp_negate_signal(Scsi_Cmnd *SCpnt, unsigned char mask, char *str) /* * expect Ninja Irq */ -static int nsp_expect_signal(Scsi_Cmnd *SCpnt, - unsigned char current_phase, - unsigned char mask) +static int nsp_expect_signal(struct scsi_cmnd *SCpnt, + unsigned char current_phase, + unsigned char mask) { unsigned int base = SCpnt->device->host->io_port; int time_out; @@ -594,7 +581,7 @@ static int nsp_expect_signal(Scsi_Cmnd *SCpnt, /* * transfer SCSI message */ -static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase) +static int nsp_xfer(struct scsi_cmnd *SCpnt, int phase) { unsigned int base = SCpnt->device->host->io_port; nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -634,7 +621,7 @@ static int nsp_xfer(Scsi_Cmnd *SCpnt, int phase) /* * get extra SCSI data from fifo */ -static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt) +static int nsp_dataphase_bypass(struct scsi_cmnd *SCpnt) { nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; unsigned int count; @@ -666,7 +653,7 @@ static int nsp_dataphase_bypass(Scsi_Cmnd *SCpnt) /* * accept reselection */ -static int nsp_reselected(Scsi_Cmnd *SCpnt) +static int nsp_reselected(struct scsi_cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; unsigned int host_id = SCpnt->device->host->this_id; @@ -688,7 +675,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); } @@ -705,7 +692,7 @@ static int nsp_reselected(Scsi_Cmnd *SCpnt) /* * count how many data transferd */ -static int nsp_fifo_count(Scsi_Cmnd *SCpnt) +static int nsp_fifo_count(struct scsi_cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; unsigned int count; @@ -732,7 +719,7 @@ static int nsp_fifo_count(Scsi_Cmnd *SCpnt) /* * read data in DATA IN phase */ -static void nsp_pio_read(Scsi_Cmnd *SCpnt) +static void nsp_pio_read(struct scsi_cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; unsigned long mmio_base = SCpnt->device->host->base; @@ -827,7 +814,7 @@ static void nsp_pio_read(Scsi_Cmnd *SCpnt) /* * write data in DATA OUT phase */ -static void nsp_pio_write(Scsi_Cmnd *SCpnt) +static void nsp_pio_write(struct scsi_cmnd *SCpnt) { unsigned int base = SCpnt->device->host->io_port; unsigned long mmio_base = SCpnt->device->host->base; @@ -920,10 +907,10 @@ static void nsp_pio_write(Scsi_Cmnd *SCpnt) /* * setup synchronous/asynchronous data transfer mode */ -static int nsp_nexus(Scsi_Cmnd *SCpnt) +static int nsp_nexus(struct 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]); @@ -963,11 +950,11 @@ static int nsp_nexus(Scsi_Cmnd *SCpnt) /* * interrupt handler */ -static irqreturn_t nspintr(int irq, void *dev_id, struct pt_regs *regs) +static irqreturn_t nspintr(int irq, void *dev_id) { unsigned int base; unsigned char irq_status, irq_phase, phase; - Scsi_Cmnd *tmpSC; + struct scsi_cmnd *tmpSC; unsigned char target, lun; unsigned int *sync_neg; int i, tmp; @@ -1321,7 +1308,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; @@ -1369,7 +1356,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; @@ -1528,7 +1515,7 @@ nsp_proc_info( thislength = pos - (buffer + offset); if(thislength < 0) { - *start = 0; + *start = NULL; return 0; } @@ -1544,27 +1531,14 @@ nsp_proc_info( /* error handler */ /*---------------------------------------------------------------*/ -/*static int nsp_eh_strategy(struct Scsi_Host *Shost) -{ - return FAILED; -}*/ - /* -static int nsp_eh_abort(Scsi_Cmnd *SCpnt) +static int nsp_eh_abort(struct scsi_cmnd *SCpnt) { nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt); return nsp_eh_bus_reset(SCpnt); }*/ -/* -static int nsp_eh_device_reset(Scsi_Cmnd *SCpnt) -{ - nsp_dbg(NSP_DEBUG_BUSRESET, "%s: SCpnt=0x%p", SCpnt); - - return FAILED; -}*/ - static int nsp_bus_reset(nsp_hw_data *data) { unsigned int base = data->BaseAddress; @@ -1586,7 +1560,7 @@ static int nsp_bus_reset(nsp_hw_data *data) return SUCCESS; } -static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt) +static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt) { nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -1595,7 +1569,7 @@ static int nsp_eh_bus_reset(Scsi_Cmnd *SCpnt) return nsp_bus_reset(data); } -static int nsp_eh_host_reset(Scsi_Cmnd *SCpnt) +static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt) { nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata; @@ -1620,21 +1594,19 @@ 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_probe(struct pcmcia_device *link) { scsi_info_t *info; - client_reg_t client_reg; - dev_link_t *link; - int ret, i; nsp_hw_data *data = &nsp_data_base; + int ret; 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; + info->p_dev = link; link->priv = info; data->ScsiInfo = info; @@ -1647,49 +1619,21 @@ static dev_link_t *nsp_cs_attach(void) /* Interrupt setup */ link->irq.Attributes = IRQ_TYPE_EXCLUSIVE | IRQ_HANDLE_PRESENT; - link->irq.IRQInfo1 = IRQ_INFO2_VALID | IRQ_LEVEL_ID; - if (irq_list[0] == -1) { - link->irq.IRQInfo2 = irq_mask; - } else { - for (i = 0; i < 4; i++) { - link->irq.IRQInfo2 |= BIT(irq_list[i]); - } - } + link->irq.IRQInfo1 = IRQ_LEVEL_ID; /* Interrupt handler */ link->irq.Handler = &nspintr; link->irq.Instance = info; - link->irq.Attributes |= (SA_SHIRQ | SA_SAMPLE_RANDOM); + link->irq.Attributes |= IRQF_SHARED; /* General socket configuration */ link->conf.Attributes = CONF_ENABLE_IRQ; - link->conf.Vcc = 50; 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.Attributes = INFO_IO_CLIENT | INFO_CARD_SHARE; - 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; - } + ret = nsp_cs_config(link); nsp_dbg(NSP_DEBUG_INIT, "link=0x%p", link); - return link; + return ret; } /* nsp_cs_attach */ @@ -1699,35 +1643,15 @@ 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 *link) { - dev_link_t **linkp; - 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) - nsp_cs_release(link); - - /* Break the link with Card Services */ - if (link->handle) { - pcmcia_deregister_client(link->handle); - } + ((scsi_info_t *)link->priv)->stop = 1; + nsp_cs_release(link); - /* Unlink device structure, free bits */ - *linkp = link->next; kfree(link->priv); link->priv = NULL; - } /* nsp_cs_detach */ @@ -1739,9 +1663,9 @@ static void nsp_cs_detach(dev_link_t *link) #define CS_CHECK(fn, ret) \ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) /*====================================================================*/ -static void nsp_cs_config(dev_link_t *link) +static int nsp_cs_config(struct pcmcia_device *link) { - client_handle_t handle = link->handle; + int ret; scsi_info_t *info = link->priv; tuple_t tuple; cisparse_t parse; @@ -1754,37 +1678,27 @@ 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 nsp_dbg(NSP_DEBUG_INIT, "in"); - tuple.DesiredTuple = CISTPL_CONFIG; tuple.Attributes = 0; tuple.TupleData = tuple_data; tuple.TupleDataMax = sizeof(tuple_data); tuple.TupleOffset = 0; - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); - CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); - CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, &parse)); - link->conf.ConfigBase = parse.config.base; - link->conf.Present = parse.config.rmask[0]; - - /* Configure card */ - link->state |= DEV_CONFIG; /* Look up the current Vcc */ - CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); - link->conf.Vcc = conf.Vcc; + CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(link, &conf)); tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; - CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); + CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); while (1) { cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); - if (pcmcia_get_tuple_data(handle, &tuple) != 0 || - pcmcia_parse_tuple(handle, &tuple, &parse) != 0) + if (pcmcia_get_tuple_data(link, &tuple) != 0 || + pcmcia_parse_tuple(link, &tuple, &parse) != 0) goto next_entry; if (cfg->flags & CISTPL_CFTABLE_DEFAULT) { dflt = *cfg; } @@ -1810,10 +1724,10 @@ static void nsp_cs_config(dev_link_t *link) } if (cfg->vpp1.present & (1 << CISTPL_POWER_VNOM)) { - link->conf.Vpp1 = link->conf.Vpp2 = + link->conf.Vpp = cfg->vpp1.param[CISTPL_POWER_VNOM] / 10000; } else if (dflt.vpp1.present & (1 << CISTPL_POWER_VNOM)) { - link->conf.Vpp1 = link->conf.Vpp2 = + link->conf.Vpp = dflt.vpp1.param[CISTPL_POWER_VNOM] / 10000; } @@ -1840,7 +1754,7 @@ static void nsp_cs_config(dev_link_t *link) link->io.NumPorts2 = io->win[1].len; } /* This reserves IO space but doesn't actually enable it */ - if (pcmcia_request_io(link->handle, &link->io) != 0) + if (pcmcia_request_io(link, &link->io) != 0) goto next_entry; } @@ -1855,7 +1769,7 @@ static void nsp_cs_config(dev_link_t *link) req.Size = 0x1000; } req.AccessSpeed = 0; - if (pcmcia_request_window(&link->handle, &req, &link->win) != 0) + if (pcmcia_request_window(&link, &req, &link->win) != 0) goto next_entry; map.Page = 0; map.CardOffset = mem->win[0].card_addr; if (pcmcia_map_mem_page(link->win, &map) != 0) @@ -1869,17 +1783,14 @@ static void nsp_cs_config(dev_link_t *link) next_entry: nsp_dbg(NSP_DEBUG_INIT, "next"); - - if (link->io.NumPorts1) { - pcmcia_release_io(link->handle, &link->io); - } - CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(handle, &tuple)); + pcmcia_disable_device(link); + CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple)); } if (link->conf.Attributes & CONF_ENABLE_IRQ) { - CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); + CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); } - CS_CHECK(RequestConfiguration, pcmcia_request_configuration(handle, &link->conf)); + CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); if (free_ports) { if (link->io.BasePort1) { @@ -1921,25 +1832,28 @@ static void nsp_cs_config(dev_link_t *link) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,74)) - scsi_add_host (host, NULL); + ret = scsi_add_host (host, NULL); + if (ret) + goto cs_failed; + scsi_scan_host(host); snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no); - link->dev = &info->node; + link->dev_node = &info->node; info->host = host; #else nsp_dbg(NSP_DEBUG_INIT, "GET_SCSI_INFO"); - tail = &link->dev; + tail = &link->dev_node; info->ndev = 0; nsp_dbg(NSP_DEBUG_INIT, "host=0x%p", host); for (dev = host->host_queue; dev != NULL; dev = dev->next) { - unsigned long arg[2], id; - kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg); - id = (arg[0] & 0x0f) + ((arg[0] >> 4) & 0xf0) + - ((arg[0] >> 8) & 0xf00) + ((arg[0] >> 12) & 0xf000); + unsigned long id; + id = (dev->id & 0x0f) + ((dev->lun & 0x0f) << 4) + + ((dev->channel & 0x0f) << 8) + + ((dev->host->host_no & 0x0f) << 12); node = &info->node[info->ndev]; node->minor = 0; switch (dev->type) { @@ -1975,11 +1889,10 @@ static void nsp_cs_config(dev_link_t *link) #endif /* Finally, report what we've done */ - printk(KERN_INFO "nsp_cs: index 0x%02x: Vcc %d.%d", - link->conf.ConfigIndex, - link->conf.Vcc/10, link->conf.Vcc%10); - if (link->conf.Vpp1) { - printk(", Vpp %d.%d", link->conf.Vpp1/10, link->conf.Vpp1%10); + printk(KERN_INFO "nsp_cs: index 0x%02x: ", + link->conf.ConfigIndex); + if (link->conf.Vpp) { + printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10); } if (link->conf.Attributes & CONF_ENABLE_IRQ) { printk(", irq %d", link->irq.AssignedIRQ); @@ -1996,15 +1909,14 @@ static void nsp_cs_config(dev_link_t *link) req.Base+req.Size-1); printk("\n"); - link->state &= ~DEV_CONFIG_PENDING; - return; + return 0; cs_failed: nsp_dbg(NSP_DEBUG_INIT, "config fail"); - cs_error(link->handle, last_fn, last_ret); + cs_error(link, last_fn, last_ret); nsp_cs_release(link); - return; + return -ENODEV; } /* nsp_cs_config */ #undef CS_CHECK @@ -2014,7 +1926,7 @@ static void nsp_cs_config(dev_link_t *link) device, and release the PCMCIA configuration. If the device is still open, this will be postponed until it is closed. ======================================================================*/ -static void nsp_cs_release(dev_link_t *link) +static void nsp_cs_release(struct pcmcia_device *link) { scsi_info_t *info = link->priv; nsp_hw_data *data = NULL; @@ -2035,22 +1947,15 @@ static void nsp_cs_release(dev_link_t *link) #else scsi_unregister_host(&nsp_driver_template); #endif - link->dev = NULL; + link->dev_node = NULL; if (link->win) { if (data != NULL) { iounmap((void *)(data->MmioAddress)); } - pcmcia_release_window(link->win); - } - pcmcia_release_configuration(link->handle); - if (link->io.NumPorts1) { - pcmcia_release_io(link->handle, &link->io); - } - if (link->irq.AssignedIRQ) { - pcmcia_release_irq(link->handle, &link->irq); } - link->state &= ~DEV_CONFIG; + pcmcia_disable_device(link); + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,2)) if (info->host != NULL) { scsi_host_put(info->host); @@ -2058,111 +1963,73 @@ 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 *link) { - dev_link_t *link = args->client_data; scsi_info_t *info = link->priv; nsp_hw_data *data; - nsp_dbg(NSP_DEBUG_INIT, "in, event=0x%08x", event); - - 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; - - 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; + nsp_dbg(NSP_DEBUG_INIT, "event: suspend"); - 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"); + if (info->host != NULL) { + nsp_msg(KERN_INFO, "clear SDTR status"); - if (info->host != NULL) { - nsp_msg(KERN_INFO, "clear SDTR status"); + data = (nsp_hw_data *)info->host->hostdata; - data = (nsp_hw_data *)info->host->hostdata; + nsphw_init_sync(data); + } - nsphw_init_sync(data); - } + info->stop = 1; - 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 *link) +{ + 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; + info->stop = 0; - nsphw_init (data); - nsp_bus_reset(data); - } + if (info->host != NULL) { + nsp_msg(KERN_INFO, "reset host and bus"); - break; + data = (nsp_hw_data *)info->host->hostdata; - default: - nsp_dbg(NSP_DEBUG_INIT, "event: unknown"); - break; + nsphw_init (data); + nsp_bus_reset(data); } - nsp_dbg(NSP_DEBUG_INIT, "end"); + return 0; -} /* nsp_cs_event */ +} /*======================================================================* * module entry point *====================================================================*/ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) +static struct pcmcia_device_id nsp_cs_ids[] = { + PCMCIA_DEVICE_PROD_ID123("IO DATA", "CBSC16 ", "1", 0x547e66dc, 0x0d63a3fd, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-001", "1", 0x534c02bc, 0x52008408, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-002", "1", 0x534c02bc, 0xcb09d5b2, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-003", "1", 0x534c02bc, 0xbc0ee524, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("KME ", "SCSI-CARD-004", "1", 0x534c02bc, 0x226a7087, 0x51de003a), + PCMCIA_DEVICE_PROD_ID123("WBT", "NinjaSCSI-3", "R1.0", 0xc7ba805f, 0xfdc7c97d, 0x6973710e), + PCMCIA_DEVICE_PROD_ID123("WORKBIT", "UltraNinja-16", "1", 0x28191418, 0xb70f4b09, 0x51de003a), + PCMCIA_DEVICE_NULL +}; +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_probe, + .remove = nsp_cs_detach, + .id_table = nsp_cs_ids, + .suspend = nsp_cs_suspend, + .resume = nsp_cs_resume, }; #endif @@ -2191,20 +2058,7 @@ static int __init nsp_cs_init(void) static void __exit nsp_cs_exit(void) { nsp_msg(KERN_INFO, "unloading..."); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,68)) pcmcia_unregister_driver(&nsp_driver); -#else - unregister_pcmcia_driver(&dev_info); -#endif - - /* XXX: this really needs to move into generic code.. */ - while (dev_list != NULL) { - if (dev_list->state & DEV_CONFIG) { - nsp_cs_release(dev_list); - } - nsp_cs_detach(dev_list); - } }