Commit 67e0453e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley

[PATCH] update nsp_cs to use scsi_add_host / scsi_remove_host

On Wed, Feb 26, 2003 at 08:20:05PM +0100, Christoph Hellwig wrote:
> This patch updates nsp_cs to use scsi_add_host / scsi_remove_host when
> compiledfor Linux 2.5 which allows to get rid of the scsi host list
> walks and is a preparation for allowing to support multiple cards of
> this type.

Sorry, I sent you the wrong paetch, here's the right one:
parent 11e9a69a
...@@ -128,7 +128,7 @@ MODULE_PARM(free_ports, "i"); ...@@ -128,7 +128,7 @@ MODULE_PARM(free_ports, "i");
MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))"); MODULE_PARM_DESC(free_ports, "Release IO ports after configuration? (default: 0 (=no))");
/* /usr/src/linux/drivers/scsi/hosts.h */ /* /usr/src/linux/drivers/scsi/hosts.h */
static Scsi_Host_Template driver_template = { static Scsi_Host_Template nsp_driver_template = {
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
.proc_name = "nsp_cs", /* kernel 2.4 */ .proc_name = "nsp_cs", /* kernel 2.4 */
#else #else
...@@ -136,8 +136,10 @@ static Scsi_Host_Template driver_template = { ...@@ -136,8 +136,10 @@ static Scsi_Host_Template driver_template = {
#endif #endif
.proc_info = nsp_proc_info, .proc_info = nsp_proc_info,
.name = "WorkBit NinjaSCSI-3/32Bi(16bit)", .name = "WorkBit NinjaSCSI-3/32Bi(16bit)",
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
.detect = nsp_detect, .detect = nsp_detect,
.release = nsp_release, .release = nsp_release,
#endif
.info = nsp_info, .info = nsp_info,
.queuecommand = nsp_queuecommand, .queuecommand = nsp_queuecommand,
/* .eh_strategy_handler = nsp_eh_strategy,*/ /* .eh_strategy_handler = nsp_eh_strategy,*/
...@@ -1215,7 +1217,7 @@ static void nspintr(int irq, void *dev_id, struct pt_regs *regs) ...@@ -1215,7 +1217,7 @@ static void nspintr(int irq, void *dev_id, struct pt_regs *regs)
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/* look for ninja3 card and init if found */ /* look for ninja3 card and init if found */
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
static int nsp_detect(Scsi_Host_Template *sht) static struct Scsi_Host *__nsp_detect(Scsi_Host_Template *sht)
{ {
struct Scsi_Host *host; /* registered host structure */ struct Scsi_Host *host; /* registered host structure */
nsp_hw_data *data = &nsp_data; nsp_hw_data *data = &nsp_data;
...@@ -1225,7 +1227,7 @@ static int nsp_detect(Scsi_Host_Template *sht) ...@@ -1225,7 +1227,7 @@ static int nsp_detect(Scsi_Host_Template *sht)
request_region(data->BaseAddress, data->NumAddress, "nsp_cs"); request_region(data->BaseAddress, data->NumAddress, "nsp_cs");
host = scsi_register(sht, 0); host = scsi_register(sht, 0);
if(host == NULL) if(host == NULL)
return 0; return NULL;
host->unique_id = data->BaseAddress; host->unique_id = data->BaseAddress;
host->io_port = data->BaseAddress; host->io_port = data->BaseAddress;
...@@ -1252,7 +1254,13 @@ static int nsp_detect(Scsi_Host_Template *sht) ...@@ -1252,7 +1254,13 @@ static int nsp_detect(Scsi_Host_Template *sht)
//MOD_INC_USE_COUNT; //MOD_INC_USE_COUNT;
return 1; /* detect done. */ return host;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
static int nsp_detect(Scsi_Host_Template *sht)
{
return (__nsp_detect(sht) != NULL);
} }
static int nsp_release(struct Scsi_Host *shpnt) static int nsp_release(struct Scsi_Host *shpnt)
...@@ -1271,6 +1279,7 @@ static int nsp_release(struct Scsi_Host *shpnt) ...@@ -1271,6 +1279,7 @@ static int nsp_release(struct Scsi_Host *shpnt)
return 0; return 0;
} }
#endif
/*----------------------------------------------------------------*/ /*----------------------------------------------------------------*/
/* return info string */ /* return info string */
...@@ -1763,22 +1772,21 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1763,22 +1772,21 @@ static void nsp_cs_config(dev_link_t *link)
} }
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2))
scsi_register_host(&driver_template); host = __nsp_detect(&nsp_driver_template);
#else #else
scsi_register_module(MODULE_SCSI_HA, &driver_template); scsi_register_module(MODULE_SCSI_HA, &nsp_driver_template);
for (host = scsi_hostlist; host != NULL; host = host->next) {
if (host->hostt == &nsp_driver_template)
break;
#endif #endif
if (!host)
goto cs_failed;
DEBUG(0, "GET_SCSI_INFO\n"); DEBUG(0, "GET_SCSI_INFO\n");
tail = &link->dev; tail = &link->dev;
info->ndev = 0; info->ndev = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,45))
for (host = scsi_host_get_next(NULL); host;
host = scsi_host_get_next(host)) {
#else
for (host = scsi_hostlist; host != NULL; host = host->next) {
#endif
if (host->hostt == &driver_template) {
list_for_each_entry (dev, &host->my_devices, siblings) { list_for_each_entry (dev, &host->my_devices, siblings) {
u_long arg[2], id; u_long arg[2], id;
kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg); kernel_scsi_ioctl(dev, SCSI_IOCTL_GET_IDLUN, arg);
...@@ -1810,8 +1818,7 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1810,8 +1818,7 @@ static void nsp_cs_config(dev_link_t *link)
info->ndev++; info->ndev++;
info->host = dev->host; info->host = dev->host;
} }
}
}
*tail = NULL; *tail = NULL;
if (info->ndev == 0) { if (info->ndev == 0) {
printk(KERN_INFO "nsp_cs: no SCSI devices found\n"); printk(KERN_INFO "nsp_cs: no SCSI devices found\n");
...@@ -1839,6 +1846,10 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1839,6 +1846,10 @@ static void nsp_cs_config(dev_link_t *link)
req.Base+req.Size-1); req.Base+req.Size-1);
printk("\n"); printk("\n");
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0))
scsi_add_host(host, NULL);
#endif
link->state &= ~DEV_CONFIG_PENDING; link->state &= ~DEV_CONFIG_PENDING;
return; return;
...@@ -1859,6 +1870,7 @@ static void nsp_cs_config(dev_link_t *link) ...@@ -1859,6 +1870,7 @@ static void nsp_cs_config(dev_link_t *link)
static void nsp_cs_release(u_long arg) static void nsp_cs_release(u_long arg)
{ {
dev_link_t *link = (dev_link_t *)arg; dev_link_t *link = (dev_link_t *)arg;
scsi_info_t *info = link->priv;
DEBUG(0, "%s(0x%p)\n", __FUNCTION__, link); DEBUG(0, "%s(0x%p)\n", __FUNCTION__, link);
...@@ -1874,10 +1886,11 @@ static void nsp_cs_release(u_long arg) ...@@ -1874,10 +1886,11 @@ static void nsp_cs_release(u_long arg)
} }
/* Unlink the device chain */ /* Unlink the device chain */
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,2)) #if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,5,2))
scsi_unregister_host(&driver_template); scsi_unregister_module(MODULE_SCSI_HA, &nsp_driver_template);
#else #else
scsi_unregister_module(MODULE_SCSI_HA, &driver_template); scsi_remove_host(info->host);
scsi_unregister(info->host);
#endif #endif
link->dev = NULL; link->dev = NULL;
......
...@@ -280,8 +280,6 @@ static void nsp_cs_detach(dev_link_t *); ...@@ -280,8 +280,6 @@ static void nsp_cs_detach(dev_link_t *);
static unsigned int nsphw_start_selection(Scsi_Cmnd *SCpnt, nsp_hw_data *data); static unsigned int nsphw_start_selection(Scsi_Cmnd *SCpnt, nsp_hw_data *data);
static void nsp_start_timer(Scsi_Cmnd *SCpnt, nsp_hw_data *data, int time); static void nsp_start_timer(Scsi_Cmnd *SCpnt, nsp_hw_data *data, int time);
static int nsp_detect(Scsi_Host_Template * );
static int nsp_release(struct Scsi_Host *shpnt);
static const char *nsp_info(struct Scsi_Host *shpnt); static const char *nsp_info(struct Scsi_Host *shpnt);
static int nsp_proc_info(char *buffer, char **start, off_t offset, static int nsp_proc_info(char *buffer, char **start, off_t offset,
int length, int hostno, int inout); int length, int hostno, int inout);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment