introduce scsi_host_alloc
Subsystems (12)
PATCH 1/1 introduce scsi_host_alloc
Currently this is juist a new name for scsi_register, but we make sure new-style drivers never call scsi_register/scsi_unregister but always scsi_host_alloc/scsi_host_put in this patch so the next patch can introduce code specific to legacy drivers in the former. Also cleanup scsi_register/scsi_host_alloc a bit.
drivers/block/cciss_scsi.c +2 -2
@@ -698,7 +698,7 @@ {struct Scsi_Host *sh; - sh =scsi_register (&cciss_driver_template,sizeof (struct ctlr_info *)); + sh =scsi_host_alloc (&cciss_driver_template,sizeof (struct ctlr_info *));if (sh ==NULL )return 0 ;
@@ -1357,7 +1357,7 @@if (sa->registered) {spin_unlock_irqrestore (CCISS_LOCK (ctlr), flags);scsi_remove_host (sa->scsi_host); -scsi_unregister (sa->scsi_host); +scsi_host_put (sa->scsi_host);spin_lock_irqsave (CCISS_LOCK (ctlr), flags); }
drivers/ieee1394/sbp2.c +4 -4
@@ -705,7 +705,7 @@return hi;/* Register our host with the SCSI stack. */ - scsi_host =scsi_register (&scsi_driver_template,0 ); + scsi_host =scsi_host_alloc (&scsi_driver_template,0 );if (!scsi_host) {SBP2_ERR ("failed to register scsi host" );return NULL ;
@@ -714,7 +714,7 @@ hi =hpsb_create_hostinfo (&sbp2_highlevel, host,sizeof (*hi));if (!hi) {SBP2_ERR ("failed to allocate hostinfo" ); -scsi_unregister (hi->scsi_host); +scsi_host_put (hi->scsi_host); }hpsb_set_hostinfo_key (&sbp2_highlevel, host, (unsigned long )scsi_host);
@@ -730,7 +730,7 @@* enabled (scsi-host uses classdata member of the device). */ if (scsi_add_host (hi->scsi_host,NULL )) {SBP2_ERR ("failed to add scsi host" ); -scsi_unregister (hi->scsi_host); +scsi_host_put (hi->scsi_host);hpsb_destroy_hostinfo (&sbp2_highlevel, host); }
@@ -751,7 +751,7 @@if (hi) {scsi_remove_host (hi->scsi_host); -scsi_unregister (hi->scsi_host); +scsi_host_put (hi->scsi_host); } }
drivers/scsi/53c700.c +2 -1
@@ -293,7 +293,8 @@ tpnt->proc_name ="53c700" ; -if ((host =scsi_register (tpnt,4 )) ==NULL ) + host =scsi_host_alloc (tpnt,4 ); +if (!host)return NULL ;memset (hostdata->slots,0 ,sizeof (struct NCR_700_command_slot ) *NCR_700_COMMAND_SLOTS_PER_HOST );
drivers/scsi/NCR_D700.c +1 -1
@@ -223,7 +223,7 @@return 0 ; irq_failed: -scsi_unregister (host); +scsi_host_put (host);NCR_700_release (host); detect_failed:release_region (host->base,64 );
drivers/scsi/aic7xxx/aic79xx_osm.c +2 -2
@@ -2098,7 +2098,7 @@u_long target; template->name = ahd->description; - host =scsi_register (template,sizeof (struct ahd_softc *)); + host =scsi_host_alloc (template,sizeof (struct ahd_softc *));if (host ==NULL )return (ENOMEM );
@@ -2308,7 +2308,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,5 ,0 )scsi_remove_host (ahd->platform_data->host);#endif -scsi_unregister (ahd->platform_data->host); +scsi_host_put (ahd->platform_data->host); }/* destroy all of the device and target objects */
drivers/scsi/aic7xxx/aic7xxx_osm.c +2 -2
@@ -1725,7 +1725,7 @@u_int targ_offset; template->name = ahc->description; - host =scsi_register (template,sizeof (struct ahc_softc *)); + host =scsi_host_alloc (template,sizeof (struct ahc_softc *));if (host ==NULL )return (ENOMEM );
@@ -1978,7 +1978,7 @@#if LINUX_VERSION_CODE >=KERNEL_VERSION (2 ,5 ,0 )scsi_remove_host (ahc->platform_data->host);#endif -scsi_unregister (ahc->platform_data->host); +scsi_host_put (ahc->platform_data->host); }/* destroy all of the device and target objects */
drivers/scsi/arm/acornscsi.c +3 -2
@@ -2993,7 +2993,7 @@AS_Host *ashost;int ret = -ENOMEM ; - host =scsi_register (&acornscsi_template,sizeof (AS_Host)); + host =scsi_host_alloc (&acornscsi_template,sizeof (AS_Host));if (!host) goto out;
@@ -3060,7 +3060,7 @@ err_2:release_region (host->io_port +0x800 ,2 ); err_1: -scsi_unregister (host); +scsi_host_put (host); out:return ret; }
@@ -3089,6 +3089,7 @@msgqueue_free (&ashost->scsi.msgs);queue_free (&ashost->queues.disconnected);queue_free (&ashost->queues.issue); +scsi_host_put (host); }static const struct ecard_id acornscsi_cids[] = {
drivers/scsi/arm/cumana_1.c +3 -3
@@ -262,7 +262,7 @@struct Scsi_Host *host;int ret = -ENOMEM ; - host =scsi_register (&cumanascsi_template,sizeof (struct NCR5380_hostdata )); + host =scsi_host_alloc (&cumanascsi_template,sizeof (struct NCR5380_hostdata ));if (!host) goto out;
@@ -304,7 +304,7 @@ out_release:release_region (host->io_port, host->n_io_port); out_free: -scsi_unregister (host); +scsi_host_put (host); out:return ret; }
@@ -318,7 +318,7 @@scsi_remove_host (host);free_irq (host->irq, host);release_region (host->io_port, host->n_io_port); -scsi_unregister (host); +scsi_host_put (host); }static const struct ecard_id cumanascsi1_cids[] = {
drivers/scsi/arm/ecoscsi.c +3 -3
@@ -177,7 +177,7 @@static int __init ecoscsi_init (void ) { - host =scsi_register (tpnt,sizeof (struct NCR5380_hostdata )); + host =scsi_host_alloc (tpnt,sizeof (struct NCR5380_hostdata ));if (!host)return 0 ;
@@ -211,7 +211,7 @@ release_reg:release_region (host->io_port, host->n_io_port); unregister_scsi: -scsi_unregister (host); +scsi_host_put (host);return -ENODEV ; }
@@ -224,7 +224,7 @@if (shpnt->io_port)release_region (shpnt->io_port, shpnt->n_io_port); -scsi_unregister (host); +scsi_host_put (host);return 0 ; }
drivers/scsi/arm/fas216.c +1 -0
@@ -2942,6 +2942,7 @@scsi_remove_host (host);fas216_writeb (info,REG_CMD ,CMD_RESETCHIP ); +scsi_host_put (host); }/**
drivers/scsi/arm/oak.c +3 -3
@@ -135,7 +135,7 @@struct Scsi_Host *host;int ret = -ENOMEM ; - host =scsi_register (&oakscsi_template,sizeof (struct NCR5380_hostdata )); + host =scsi_host_alloc (&oakscsi_template,sizeof (struct NCR5380_hostdata ));if (!host) goto out;
@@ -163,7 +163,7 @@release_region (host->io_port, host->n_io_port); unreg: -scsi_unregister (host); +scsi_host_put (host); out:return ret; }
@@ -176,7 +176,7 @@scsi_remove_host (host);release_region (host->io_port, host->n_io_port); -scsi_unregister (host); +scsi_host_put (host); }static const struct ecard_id oakscsi_cids[] = {
drivers/scsi/hosts.c +68 -92
219 lines not on this page · raw message
drivers/scsi/hosts.h +8 -11
@@ -560,23 +560,20 @@#define scsi_unregister_interface (intf) \ class_interface_unregister(intf) -/* -* HBA allocation/freeing. -*/ -extern struct Scsi_Host *scsi_register (Scsi_Host_Template *,int ); -extern void scsi_unregister (struct Scsi_Host *); -/* -* HBA registration/unregistration. -*/ +extern struct Scsi_Host *scsi_host_alloc (Scsi_Host_Template *,int );extern int scsi_add_host (struct Scsi_Host *,struct device *);extern int scsi_remove_host (struct Scsi_Host *); +extern void scsi_host_get (struct Scsi_Host *); +extern void scsi_host_put (struct Scsi_Host *t); +extern struct Scsi_Host *scsi_host_lookup (unsigned short ); -/* -* Legacy HBA template registration/unregistration. -*/ +/* legacy interfaces */ extern int scsi_register_host (Scsi_Host_Template *);extern int scsi_unregister_host (Scsi_Host_Template *); +extern struct Scsi_Host *scsi_register (Scsi_Host_Template *,int ); +extern void scsi_unregister (struct Scsi_Host *); +/** * scsi_find_device - find a device given the host
drivers/scsi/ide-scsi.c +3 -3
@@ -612,7 +612,7 @@ drive->disk->fops = ide_fops;scsi_remove_host (scsihost); -scsi_unregister (scsihost); +scsi_host_put (scsihost);return 0 ; }
@@ -964,7 +964,7 @@if (!strstr ("ide-scsi" , drive->driver_req) || !drive->present || drive->media == ide_disk || - !(host =scsi_register (&idescsi_template,sizeof (idescsi_scsi_t)))) + !(host =scsi_host_alloc (&idescsi_template,sizeof (idescsi_scsi_t))))return 1 ; host->max_id =1 ;
@@ -984,7 +984,7 @@ide_unregister_subdriver (drive); } -scsi_unregister (host); +scsi_host_put (host);return err; }
drivers/scsi/lasi700.c +1 -1
@@ -186,7 +186,7 @@if (request_irq (dev->irq, NCR_700_intr,SA_SHIRQ , driver_name, host)) {printk (KERN_ERR "%s: irq problem, detaching\n" , driver_name); -scsi_unregister (host); +scsi_host_put (host);NCR_700_release (host);return 1 ; }
drivers/scsi/nsp32.c +2 -2
@@ -1621,7 +1621,7 @@/* * register this HBA as SCSI device */ - host =scsi_register (&nsp32_template,sizeof (nsp32_hw_data)); + host =scsi_host_alloc (&nsp32_template,sizeof (nsp32_hw_data));if (host ==NULL ) {nsp32_msg (KERN_ERR ,"failed to scsi register" ); goto err;
@@ -1840,7 +1840,7 @@kfree (data->lunt_list); scsi_unregister: -scsi_unregister (host); +scsi_host_put (host); err:return 1 ;
drivers/scsi/pcmcia/nsp_cs.c +1 -1
@@ -1222,7 +1222,7 @@DEBUG (0 ,"%s: this_id=%d\n" , __FUNCTION__, sht->this_id);request_region (data->BaseAddress, data->NumAddress,"nsp_cs" ); - host =scsi_register (sht,0 ); + host =scsi_host_alloc (sht,0 );if (host ==NULL )return NULL ;
drivers/scsi/scsi_debug.c +3 -4
@@ -1681,7 +1681,7 @@ sdbg_host =to_sdebug_host (dev); - hpnt =scsi_register (&sdebug_driver_template,sizeof (sdbg_host)); + hpnt =scsi_host_alloc (&sdebug_driver_template,sizeof (sdbg_host));if (NULL == hpnt) {printk (KERN_ERR "%s: scsi_register failed\n" , __FUNCTION__); error = -ENODEV ;
@@ -1700,7 +1700,7 @@if (error) {printk (KERN_ERR "%s: scsi_add_host failed\n" , __FUNCTION__); error = -ENODEV ; -scsi_unregister (hpnt); +scsi_host_put (hpnt); }
@@ -1726,8 +1726,6 @@return -EBUSY ; } -scsi_unregister (sdbg_host->shost); -list_for_each_safe (lh, lh_sf, &sdbg_host->dev_info_list) { sdbg_devinfo = list_entry(lh, struct sdebug_dev_info, dev_list);
@@ -1735,5 +1733,6 @@kfree (sdbg_devinfo); } +scsi_host_put (sdbg_host->shost);return 0 ; }
drivers/scsi/scsi_priv.h +3 -7
@@ -55,9 +55,6 @@/* hosts.c */ extern void scsi_host_busy_inc (struct Scsi_Host *,Scsi_Device *);extern void scsi_host_busy_dec_and_test (struct Scsi_Host *,Scsi_Device *); -extern struct Scsi_Host *scsi_host_lookup (unsigned short ); -extern void scsi_host_put (struct Scsi_Host *); -extern void scsi_host_init (void );/* scsi.c */ extern int scsi_dispatch_cmd (struct scsi_cmnd *cmd);
@@ -107,12 +104,11 @@#endif /* CONFIG_PROC_FS */ /* scsi_scan.c */ -extern void scsi_scan_host (struct Scsi_Host *shost); -extern void scsi_forget_host (struct Scsi_Host *shost); +extern void scsi_scan_host (struct Scsi_Host *); +extern void scsi_forget_host (struct Scsi_Host *);extern void scsi_free_sdev (struct scsi_device *);extern void scsi_free_shost (struct Scsi_Host *); -extern void scsi_host_get (struct Scsi_Host *); -extern void scsi_rescan_device (struct device *dev); +extern void scsi_rescan_device (struct device *);/* scsi_sysfs.c */ extern int scsi_device_register (struct scsi_device *);
drivers/scsi/scsi_syms.c +4 -0
@@ -33,8 +33,12 @@EXPORT_SYMBOL (scsi_register_interface);EXPORT_SYMBOL (scsi_register_host);EXPORT_SYMBOL (scsi_unregister_host); +EXPORT_SYMBOL (scsi_host_alloc);EXPORT_SYMBOL (scsi_add_host);EXPORT_SYMBOL (scsi_remove_host); +EXPORT_SYMBOL (scsi_host_get); +EXPORT_SYMBOL (scsi_host_put); +EXPORT_SYMBOL (scsi_host_lookup);EXPORT_SYMBOL (scsi_register);EXPORT_SYMBOL (scsi_unregister);EXPORT_SYMBOL (scsicam_bios_param);
drivers/scsi/sim710.c +1 -1
@@ -143,7 +143,7 @@return 0 ; out_unregister: -scsi_unregister (host); +scsi_host_put (host); out_release:release_region (host->base,64 ); out_free:
drivers/usb/storage/usb.c +2 -2
@@ -868,7 +868,7 @@up (&(us->dev_semaphore));/* now register */ - us->host =scsi_register (&usb_stor_host_template,sizeof (us)); + us->host =scsi_host_alloc (&usb_stor_host_template,sizeof (us));if (!us->host) { printk(KERN_WARNING USB_STORAGE "Unable to register the scsi host\n");
@@ -965,7 +965,7 @@ };/* finish SCSI host removal sequence */ -scsi_unregister (us->host); +scsi_host_put (us->host);/* Kill the control threads *
I ran your series of patches. The ips driver was missed in your updates I attached the patch below. David Jeffery may want a wrapper for 2.4/2.5 compatibility.
Review
Quoted 10 lines · Christoph Hellwig [[email protected]] wrote:
Currently this is juist a new name for
scsi_register, but we make sure new-style drivers never call scsi_register/scsi_unregister but always scsi_host_alloc/scsi_host_put in this patch so the next patch can introduce code specific to legacy drivers in the former. Also cleanup scsi_register/scsi_host_alloc a bit.(quoted diff) +2
-0+ + shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */
We could move the host_no to scsi_sysfs_init_host and use the class->subsys.rwsem to protect this.
-andmike
--
Michael Anderson
[email protected]
drivers/scsi/ips.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/ips.c renamed from drivers/scsi/ips.c~ips_scsi_alloc_fix +3 -3
@@ -725,7 +725,7 @@ ips_release(struct Scsi_Host *sh) {free_irq (ha->irq, ha);IPS_REMOVE_HOST (sh); -scsi_unregister (sh); +scsi_host_put (sh); ips_released_controllers++;
@@ -6732,7 +6732,7 @@ static int ips_register_scsi( int index){struct Scsi_Host *sh;ips_ha_t *ha, *oldha = ips_ha[index]; - sh =scsi_register (&ips_driver_template,sizeof (ips_ha_t)); + sh =scsi_host_alloc (&ips_driver_template,sizeof (ips_ha_t));if (!sh) {IPS_PRINTK (KERN_WARNING , oldha->pcidev,"Unable to register controller with SCSI subsystem\n" );return -1 ;
@@ -6743,7 +6743,7 @@ ips_register_scsi( int index){/* Install the interrupt handler with the new ha */ if (request_irq (ha->irq, do_ipsintr,SA_SHIRQ , ips_name, ha)) {IPS_PRINTK (KERN_WARNING , ha->pcidev,"Unable to install interrupt handler\n" ); -scsi_unregister (sh); +scsi_host_put (sh);return -1 ; }
_
Quoted 2 lines · Mike Anderson
We could move the
host_notoscsi_sysfs_init_hostand use theclass->subsys.rwsemto protect this.
I think the best idea would be to just use a separate sinlock for this.