public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] remove scsi_slave_attach/scsi_slave_detach
@ 2003-04-30 22:20 Christoph Hellwig
  0 siblings, 0 replies; only message in thread
From: Christoph Hellwig @ 2003-04-30 22:20 UTC (permalink / raw)
  To: James.Bottomley; +Cc: linux-scsi

I added those two to factor out common code from the upper drivers
a long time ago, but after Doug & Lubens nice work there's nothing
left but incrementing/decrementing a counter in struct scsi_device
that's never used except in the case were we not it must be NULL
because we just walked the chain of drivers to detach every single
one..


--- 1.42/drivers/scsi/osst.c	Fri Apr 18 11:58:31 2003
+++ edited/drivers/scsi/osst.c	Wed Apr 30 22:09:21 2003
@@ -5397,15 +5397,10 @@
 	if (SDp->type != TYPE_TAPE || !osst_supports(SDp))
 		return 1;
 
-	if (scsi_slave_attach(SDp)) {
-		printk(KERN_ERR "osst :E: Failed to attach scsi slave.\n");
-		return 1;
-	}
-
 	drive = alloc_disk(1);
 	if (!drive) {
 		printk(KERN_ERR "osst :E: Out of memory. Device not attached.\n");
-		goto out_slave_detach;
+		return 1;
 	}
 
 	/* if this is the first attach, build the infrastructure */
@@ -5581,8 +5576,6 @@
 
 out_put_disk:
         put_disk(drive);
-out_slave_detach:
-        scsi_slave_detach(SDp);
         return 1;
 };
 
@@ -5605,7 +5598,6 @@
 		devfs_unregister_tape(tpnt->drive->number);
 		put_disk(tpnt->drive);
 		os_scsi_tapes[i] = NULL;
-		scsi_slave_detach(SDp);
 		osst_nr_dev--;
 		write_unlock(&os_scsi_tapes_lock);
 		for (mode = 0; mode < ST_NBR_MODES; ++mode) {
--- 1.109/drivers/scsi/scsi.c	Tue Apr 29 13:40:45 2003
+++ edited/drivers/scsi/scsi.c	Wed Apr 30 22:09:21 2003
@@ -1274,39 +1277,6 @@
 	} else {
 		/* FIXME: Send online state change hotplug event */
 	}
-}
-
-/*
- * Function:	scsi_slave_attach()
- *
- * Purpose:	Called from the upper level driver attach to handle common
- * 		attach code.
- *
- * Arguments:	sdev - scsi_device to attach
- *
- * Returns:	1 on error, 0 on succes
- *
- * Lock Status:	Protected via scsi_devicelist_mutex.
- */
-int scsi_slave_attach(struct scsi_device *sdev)
-{
-	sdev->attached++;
-	return 0;
-}
-
-/*
- * Function:	scsi_slave_detach()
- *
- * Purpose:	Called from the upper level driver attach to handle common
- * 		detach code.
- *
- * Arguments:	sdev - struct scsi_device to detach
- *
- * Lock Status:	Protected via scsi_devicelist_mutex.
- */
-void scsi_slave_detach(struct scsi_device *sdev)
-{
-	sdev->attached--;
 }
 
 /*
--- 1.78/drivers/scsi/scsi.h	Sun Apr 27 06:45:24 2003
+++ edited/drivers/scsi/scsi.h	Wed Apr 30 22:47:43 2003
@@ -261,8 +261,6 @@
 extern void scsi_put_command(struct scsi_cmnd *cmd);
 extern void scsi_adjust_queue_depth(Scsi_Device *, int, int);
 extern int scsi_track_queue_full(Scsi_Device *, int);
-extern int scsi_slave_attach(struct scsi_device *);
-extern void scsi_slave_detach(struct scsi_device *);
 extern int scsi_device_get(struct scsi_device *);
 extern void scsi_device_put(struct scsi_device *);
 extern void scsi_set_device_offline(struct scsi_device *);
@@ -344,8 +342,6 @@
 					 * vendor-specific cmd's */
 	unsigned sector_size;	/* size in bytes */
 
-	int attached;		/* # of high level drivers attached to 
-				 * this */
 	int access_count;	/* Count of open channels/mounts */
 
 	void *hostdata;		/* available to low-level driver */
--- 1.82/drivers/scsi/scsi_scan.c	Sun Apr 27 05:12:47 2003
+++ edited/drivers/scsi/scsi_scan.c	Wed Apr 30 22:09:21 2003
@@ -1269,11 +1269,7 @@
 int scsi_remove_device(struct scsi_device *sdev)
 {
 	scsi_detach_device(sdev);
-	if (sdev->attached)
-		return -EINVAL;
-
 	scsi_device_unregister(sdev);
-
 	scsi_free_sdev(sdev);
 	return 0;
 }
--- 1.34/drivers/scsi/scsi_syms.c	Tue Apr 29 13:40:45 2003
+++ edited/drivers/scsi/scsi_syms.c	Wed Apr 30 22:09:21 2003
@@ -77,8 +78,6 @@
 
 EXPORT_SYMBOL(scsi_io_completion);
 
-EXPORT_SYMBOL(scsi_slave_attach);
-EXPORT_SYMBOL(scsi_slave_detach);
 EXPORT_SYMBOL(scsi_device_get);
 EXPORT_SYMBOL(scsi_device_put);
 EXPORT_SYMBOL(scsi_add_device);
--- 1.110/drivers/scsi/sd.c	Fri Apr 25 08:51:41 2003
+++ edited/drivers/scsi/sd.c	Wed Apr 30 22:09:22 2003
@@ -1302,14 +1302,10 @@
 	SCSI_LOG_HLQUEUE(3, printk("sd_attach: scsi device: <%d,%d,%d,%d>\n", 
 			 sdp->host->host_no, sdp->channel, sdp->id, sdp->lun));
 
-	error = scsi_slave_attach(sdp);
-	if (error)
-		goto out;
-
 	error = -ENOMEM;
 	sdkp = kmalloc(sizeof(*sdkp), GFP_KERNEL);
 	if (!sdkp)
-		goto out_detach;
+		goto out;
 
 	gd = alloc_disk(16);
 	if (!gd)
@@ -1368,8 +1364,6 @@
 	put_disk(gd);
 out_free:
 	kfree(sdkp);
-out_detach:
-	scsi_slave_detach(sdp);
 out:
 	return error;
 }
@@ -1406,7 +1400,6 @@
 
 	sd_devlist_remove(sdkp);
 	del_gendisk(sdkp->disk);
-	scsi_slave_detach(sdp);
 
 	spin_lock(&sd_index_lock);
 	clear_bit(sdkp->index, sd_index_bits);
--- 1.53/drivers/scsi/sg.c	Sat Apr 26 16:04:25 2003
+++ edited/drivers/scsi/sg.c	Wed Apr 30 22:09:22 2003
@@ -1359,10 +1359,6 @@
 	if (!disk)
 		return -ENOMEM;
 
-	error = scsi_slave_attach(scsidp);
-	if (error)
-		goto out_put;
-		
 	write_lock_irqsave(&sg_dev_arr_lock, iflags);
 	if (sg_nr_dev >= sg_dev_max) {	/* try to resize */
 		Sg_device **tmp_da;
@@ -1375,7 +1371,7 @@
 			printk(KERN_ERR
 			       "sg_attach: device array cannot be resized\n");
 			error = -ENOMEM;
-			goto out_detach;
+			goto out;
 		}
 		write_lock_irqsave(&sg_dev_arr_lock, iflags);
 		memset(tmp_da, 0, tmp_dev_max * sizeof (Sg_device *));
@@ -1400,7 +1396,7 @@
 		if (NULL != sdp)
 			vfree((char *) sdp);
 		error = -ENODEV;
-		goto out_detach;
+		goto out;
 	}
 	if (k < sg_dev_max) {
 		if (NULL == sdp) {
@@ -1416,7 +1412,7 @@
 		write_unlock_irqrestore(&sg_dev_arr_lock, iflags);
 		printk(KERN_ERR "sg_attach: Sg_device cannot be allocated\n");
 		error = -ENOMEM;
-		goto out_detach;
+		goto out;
 	}
 
 	SCSI_LOG_TIMEOUT(3, printk("sg_attach: dev=%d \n", k));
@@ -1473,9 +1469,7 @@
 	}
 	return 0;
 
-out_detach:
-	scsi_slave_detach(scsidp);
-out_put:
+out:
 	put_disk(disk);
 	return error;
 }
@@ -1526,7 +1520,6 @@
 			SCSI_LOG_TIMEOUT(3, printk("sg_detach: dev=%d\n", k));
 			sg_dev_arr[k] = NULL;
 		}
-		scsi_slave_detach(scsidp);
 		sg_nr_dev--;
 		break;
 	}
--- 1.77/drivers/scsi/sr.c	Sat Apr 26 16:04:25 2003
+++ edited/drivers/scsi/sr.c	Wed Apr 30 22:09:22 2003
@@ -515,10 +515,6 @@
 	if (sdev->type != TYPE_ROM && sdev->type != TYPE_WORM)
 		return 1;
 
-	error = scsi_slave_attach(sdev);
-	if (error)
-		return error;
-
 	error = -ENOMEM;
 	cd = kmalloc(sizeof(*cd), GFP_KERNEL);
 	if (!cd)
@@ -592,7 +588,6 @@
 fail_free:
 	kfree(cd);
 fail:
-	scsi_slave_detach(sdev);
 	return error;
 }
 
@@ -820,7 +815,6 @@
 		return;
 
 	sr_devlist_remove(cd);
-	scsi_slave_detach(SDp);
 	del_gendisk(cd->disk);
 
 	spin_lock(&sr_index_lock);
--- 1.60/drivers/scsi/st.c	Fri Apr 18 11:58:31 2003
+++ edited/drivers/scsi/st.c	Wed Apr 30 22:09:22 2003
@@ -3725,16 +3725,13 @@
 		return 1;
 	}
 
-	if (scsi_slave_attach(SDp))
-		return 1;
-
 	i = SDp->host->sg_tablesize;
 	if (st_max_sg_segs < i)
 		i = st_max_sg_segs;
 	buffer = new_tape_buffer(TRUE, (SDp->host)->unchecked_isa_dma, i);
 	if (buffer == NULL) {
 		printk(KERN_ERR "st: Can't allocate new tape buffer. Device not attached.\n");
-		goto out_slave_detach;
+		goto out;
 	}
 
 	disk = alloc_disk(1);
@@ -3923,8 +3920,7 @@
 	put_disk(disk);
 out_buffer_free:
 	kfree(buffer);
-out_slave_detach:
-	scsi_slave_detach(SDp);
+out:
 	return 1;
 };
 
@@ -3962,7 +3958,6 @@
 				normalize_buffer(tpnt->buffer);
 				kfree(tpnt->buffer);
 			}
-			scsi_slave_detach(SDp);
 			put_disk(tpnt->disk);
 			kfree(tpnt);
 			return;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-04-30 22:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-30 22:20 [PATCH] remove scsi_slave_attach/scsi_slave_detach Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox