--- linux/drivers/scsi/scsi_debug.c 2003-09-28 14:25:06.000000000 +1000 +++ linux/drivers/scsi/scsi_debug.c260t6dpg2 2003-10-08 22:11:02.372435144 +1000 @@ -55,7 +55,7 @@ #include "scsi_logging.h" #include "scsi_debug.h" -static const char * scsi_debug_version_str = "Version: 1.70 (20030507)"; +static const char * scsi_debug_version_str = "Version: 1.72 (20031008)"; /* Additional Sense Code (ASC) used */ #define NO_ADDED_SENSE 0x0 @@ -249,6 +249,8 @@ static int sdebug_add_adapter(void); static void sdebug_remove_adapter(void); +static void sdebug_max_tgts_luns(void); + static struct device pseudo_primary; static struct bus_type pseudo_lld_bus; @@ -981,6 +983,18 @@ open_devip = devip; } } + if (NULL == open_devip) { /* try and make a new one */ + open_devip = kmalloc(sizeof(*open_devip),GFP_KERNEL); + if (NULL == open_devip) { + printk(KERN_ERR "%s: out of memory at line %d\n", + __FUNCTION__, __LINE__); + return NULL; + } + memset(open_devip, 0, sizeof(*open_devip)); + open_devip->sdbg_host = sdbg_host; + list_add_tail(&open_devip->dev_list, + &sdbg_host->dev_info_list); + } if (open_devip) { open_devip->channel = sdev->channel; open_devip->target = sdev->id; @@ -1369,6 +1383,7 @@ if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_num_tgts = n; + sdebug_max_tgts_luns(); return count; } return -EINVAL; @@ -1412,6 +1427,7 @@ if ((count > 0) && (1 == sscanf(buf, "%d", &n)) && (n >= 0)) { scsi_debug_max_luns = n; + sdebug_max_tgts_luns(); return count; } return -EINVAL; @@ -1541,7 +1557,7 @@ } if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) { - printk(KERN_INFO "scsi_debug: ... built %d host(s)\n", + printk(KERN_INFO "scsi_debug_init: built %d host(s)\n", scsi_debug_add_host); } return 0; @@ -1565,8 +1581,15 @@ device_initcall(scsi_debug_init); module_exit(scsi_debug_exit); +void pseudo_0_release(struct device * dev) +{ + if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts) + printk(KERN_INFO "scsi_debug: pseudo_0_release() called\n"); +} + static struct device pseudo_primary = { .bus_id = "pseudo_0", + .release = pseudo_0_release, }; static int pseudo_lld_bus_match(struct device *dev, @@ -1731,3 +1754,21 @@ scsi_host_put(sdbg_host->shost); return 0; } + +static void sdebug_max_tgts_luns(void) +{ + struct sdebug_host_info * sdbg_host; + struct Scsi_Host *hpnt; + + spin_lock(&sdebug_host_list_lock); + list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) { + hpnt = sdbg_host->shost; + if ((hpnt->this_id >= 0) && + (scsi_debug_num_tgts > hpnt->this_id)) + hpnt->max_id = scsi_debug_num_tgts + 1; + else + hpnt->max_id = scsi_debug_num_tgts; + hpnt->max_lun = scsi_debug_max_luns; + } + spin_unlock(&sdebug_host_list_lock); +}