Skip to contentSkip to conversation

kill of ->command

PATCH In review Christoph Hellwig 8 participants 14 messages Jun 9, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kill of ->command

It's unused now. Also kill off the stupid = NULL initializations in usb-storage that made this not compile the first time..

drivers/scsi/scsi.c +10 -21
diff -Nru a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
@@ -441,29 +441,18 @@
 		goto out;
 	}
 
-	if (host->can_queue) {
-		SCSI_LOG_MLQUEUE(3, printk("queuecommand : routine at %p\n",
-					   host->hostt->queuecommand));
+	SCSI_LOG_MLQUEUE(3, printk("queuecommand : routine at %p\n",
+				   host->hostt->queuecommand));
 
-		spin_lock_irqsave(host->host_lock, flags);
-		rtn = host->hostt->queuecommand(cmd, scsi_done);
-		spin_unlock_irqrestore(host->host_lock, flags);
-		if (rtn) {
-			scsi_queue_insert(cmd,
+	spin_lock_irqsave(host->host_lock, flags);
+	rtn = host->hostt->queuecommand(cmd, scsi_done);
+	spin_unlock_irqrestore(host->host_lock, flags);
+	if (rtn) {
+		scsi_queue_insert(cmd,
 				(rtn == SCSI_MLQUEUE_DEVICE_BUSY) ?
-					rtn : SCSI_MLQUEUE_HOST_BUSY);
-			SCSI_LOG_MLQUEUE(3,
-			    printk("queuecommand : request rejected\n"));
-		}
-	} else {
-		SCSI_LOG_MLQUEUE(3, printk("command() :  routine at %p\n",
-					host->hostt->command));
-
-		spin_lock_irqsave(host->host_lock, flags);
-		cmd->result = host->hostt->command(cmd);
-		scsi_done(cmd);
-		spin_unlock_irqrestore(host->host_lock, flags);
-		rtn = 0;
+				 rtn : SCSI_MLQUEUE_HOST_BUSY);
+		SCSI_LOG_MLQUEUE(3,
+		    printk("queuecommand : request rejected\n"));
 	}
 
  out:
drivers/scsi/scsi_error.c +37 -54

114 lines not on this page · raw message

drivers/usb/storage/scsiglue.c +0 -24
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
@@ -365,24 +365,15 @@
 	.name =				"usb-storage",
 	.proc_name =			"usb-storage",
 	.proc_info =			usb_storage_proc_info,
-	.proc_dir =			NULL,
 	.info =				usb_storage_info,
-	.ioctl =			NULL,
-
-	/* old-style detect and release */
-	.detect =			NULL,
-	.release =			NULL,
 
 	/* command interface -- queued only */
-	.command =			NULL,
 	.queuecommand =			usb_storage_queuecommand,
 
 	/* error and abort handlers */
 	.eh_abort_handler =		usb_storage_command_abort,
 	.eh_device_reset_handler =	usb_storage_device_reset,
 	.eh_bus_reset_handler =		usb_storage_bus_reset,
-	.eh_host_reset_handler =	NULL,
-	.eh_strategy_handler =		NULL,
 
 	/* queue commands only, only one command per LUN */
 	.can_queue =			1,
@@ -391,21 +382,9 @@
 	/* unknown initiator id */
 	.this_id =			-1,
 
-	/* no limit on commands */
-	.max_sectors =			0,
-	
-	/* pre- and post- device scan functions */
-	.slave_alloc =			NULL,
-	.slave_configure =		NULL,
-	.slave_destroy =		NULL,
-
 	/* lots of sg segments can be handled */
 	.sg_tablesize =			SG_ALL,
 
-	/* use 32-bit address space for DMA */
-	.unchecked_isa_dma =		FALSE,
-	.highmem_io =			FALSE,
-
 	/* merge commands... this seems to help performance, but
 	 * periodically someone should test to see which setting is more
 	 * optimal.
@@ -414,9 +393,6 @@
 
 	/* emulated HBA */
 	.emulated =			TRUE,
-
-	/* sorry, no BIOS to help us */
-	.bios_param =			NULL,
 
 	/* module management */
 	.module =			THIS_MODULE
include/scsi/scsi_host.h +1 -15
diff -Nru a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
@@ -95,24 +95,10 @@
 	 * I/O pressure in the system if there are no other outstanding
 	 * commands.
 	 *
-	 * STATUS: REQUIRED	(for exceptions see below)
+	 * STATUS: REQUIRED
 	 */
 	int (* queuecommand)(struct scsi_cmnd *,
 			     void (*done)(struct scsi_cmnd *));
-
-	/*
-	 * This is used instead of queuecommand if can_queue == 0;
-	 *
-	 * The return value has the following meaning:
-	 * Byte What:
-	 * 0    SCSI status code
-	 * 1    SCSI 1 byte message
-	 * 2    host error return.
-	 * 3    mid level error return
-	 *
-	 * Status: OBSOLETE
-	 */
-	int (* command)(struct scsi_cmnd *);
 
 	/*
 	 * This is an error handling strategy routine.  You don't need to
#1 lore raw
Quoted 2 lines · Christoph Hellwig

It's unused now. Also kill off the stupid = NULL initializations in usb-storage that made this not compile the first time..

It looks like drivers/scsi/NCR53c406a.c and drivers/scsi/arm/arxescsi.c can still set can_queue = 0. Correct?

Those two ought to be modified, and anyone setting can_queue = 0 disabled in hosts.c (scsi_add_host?).

-- Patrick Mansfield

#2 lore raw
Quoted 5 lines · Patrick Mansfield
Quoted 2 lines · Christoph Hellwig

It's unused now. Also kill off the stupid = NULL initializations in usb-storage that made this not compile the first time..

It looks like drivers/scsi/NCR53c406a.c

eek, this one would still need ->command for some devices it appears. Looks like I should crap this patch or just disable support for that hw until soneone steps up to fix it.

Quoted 2 lines

and drivers/scsi/arm/arxescsi.c
can still set can_queue = 0. Correct?

Russell, and idea why this one sets can_queue = 0 but implements ->queuecommand?

#3 lore raw
Quoted 3 lines · Christoph Hellwig

eek, this one would still need ->command for some devices it appears. Looks like I should crap this patch or just disable support for that hw until soneone steps up to fix it.

The patch is a good idea, we ought to keep it.

We could move the ->command code (check for can_queue == 0) into the drivers queuecommand function, and let them call their own "command" function.

-- Patrick Mansfield

#4 lore raw
Quoted 5 lines · Patrick Mansfield

The patch is a good idea, we ought to keep it.

We could move the ->command code (check for can_queue == 0) into the drivers queuecommand function, and let them call their own "command" function.

Well, the scsi midlayer handling for the two variants is a bit different. But I think just disabling support for the can_queue == 0 in NCR53c406a.c should be fine as it's a parameter whether to use irqs (can_queue == 1) or not.

I'd just love to hear a comment from rmk on arxescsi.c.

#5 lore raw
In reply to Christoph Hellwig
Quoted 5 lines · Christoph Hellwig
Quoted 2 lines

and drivers/scsi/arm/arxescsi.c
can still set can_queue = 0. Correct?

Russell, and idea why this one sets can_queue = 0 but implements ->queuecommand?

I would guess its because the author just did a cut and paste followed by minimum editing to make it work.

I'd need to look at the code, but I'd imagine we could probably do everything we need to inside ->queuecommand that's currently being done by ->command. My only concern would be calling the done function from within queuecommand.

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html
#6 lore raw
Quoted 4 lines · Russell King

I'd need to look at the code, but I'd imagine we could probably do everything we need to inside ->queuecommand that's currently being done by ->command. My only concern would be calling the done function from within queuecommand.

Calling done from queuecommand() is perfectly legal, as long as you return 0 from queuecommand.

James

#7 lore raw
Quoted 8 lines · James Bottomley
Quoted 4 lines · Russell King

I'd need to look at the code, but I'd imagine we could probably do everything we need to inside ->queuecommand that's currently being done by ->command. My only concern would be calling the done function from within queuecommand.

Calling done from queuecommand() is perfectly legal, as long as you return 0 from queuecommand.

In which case I don't see why we can't convert this driver to use just queuecommand().

Signature · 2 lines
Russell King ([email protected])                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html
#8 lore raw
In reply to Christoph Hellwig
Quoted 51 lines · Christoph Hellwig

diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c

drivers/usb/storage/scsiglue.c +0 -21
@@ -365,24 +365,15 @@
 	.name =				"usb-storage",
 	.proc_name =			"usb-storage",
 	.proc_info =			usb_storage_proc_info,
-	.proc_dir =			NULL,
 	.info =				usb_storage_info,
-	.ioctl =			NULL,
-
-	/* old-style detect and release */
-	.detect =			NULL,
-	.release =			NULL,
 
 	/* command interface -- queued only */
-	.command =			NULL,
 	.queuecommand =			usb_storage_queuecommand,
 
 	/* error and abort handlers */
 	.eh_abort_handler =		usb_storage_command_abort,
 	.eh_device_reset_handler =	usb_storage_device_reset,
 	.eh_bus_reset_handler =		usb_storage_bus_reset,
-	.eh_host_reset_handler =	NULL,
-	.eh_strategy_handler =		NULL,
 
 	/* queue commands only, only one command per LUN */
 	.can_queue =			1,
@@ -391,21 +382,9 @@
 	/* unknown initiator id */
 	.this_id =			-1,
 
-	/* no limit on commands */
-	.max_sectors =			0,
-	
-	/* pre- and post- device scan functions */
-	.slave_alloc =			NULL,
-	.slave_configure =		NULL,
-	.slave_destroy =		NULL,
-
 	/* lots of sg segments can be handled */
 	.sg_tablesize =			SG_ALL,
 
-	/* use 32-bit address space for DMA */
-	.unchecked_isa_dma =		FALSE,
-	.highmem_io =			FALSE,
-
 	/* merge commands... this seems to help performance, but
 	 * periodically someone should test to see which setting is more
 	 * optimal.

drivers/usb/storage/scsiglue.c line 398

Quoted 9 lines
drivers/usb/storage/scsiglue.c +0 -3
@@ -414,9 +393,6 @@
 
 	/* emulated HBA */
 	.emulated =			TRUE,
-
-	/* sorry, no BIOS to help us */
-	.bios_param =			NULL,
 
 	/* module management */
 	.module =			THIS_MODULE

Could you please not kill all these fields? If you want to remove command, go ahead, but leave the others.

Matt

Signature · 6 lines
Matthew Dharm                              Home: [email protected] 
Maintainer, Linux USB Mass Storage Driver

I'm a pink gumdrop! How can anything be worse?!!
					-- Erwin
User Friendly, 10/4/1998
#9 lore raw
Quoted 2 lines · Matthew Dharm

Could you please not kill all these fields? If you want to remove command, go ahead, but leave the others.

No, this is intentional. C99 initializers exist for a reason and once of them is to keep people away from fields they don't care about.

#10 lore raw
In reply to Matthew Dharm
Quoted 2 lines · Matthew Dharm

Could you please not kill all these fields? If you want to remove command, go ahead, but leave the others.

What's wrong with the patch?

It's just killing explicit zero-inits...

Jeff

#11 lore raw
Quoted 7 lines · Jeff Garzik
Quoted 2 lines · Matthew Dharm

Could you please not kill all these fields? If you want to remove command, go ahead, but leave the others.

What's wrong with the patch?

It's just killing explicit zero-inits...

I've just been bitten on the ass by lack of specific initialization before, so I'm overly careful.

BTW, is NULL == (void*)0 everywhere? I seem to recall places where it isn't....

Matt

Signature · 6 lines
Matthew Dharm                              Home: [email protected] 
Maintainer, Linux USB Mass Storage Driver

I want my GPFs!!!
					-- Stef
User Friendly, 11/9/1998
#12 lore raw
Quoted 2 lines · Matthew Dharm

I've just been bitten on the ass by lack of specific initialization before, so I'm overly careful.

Linux encourages lack of specific initialization. It's an important feature in several areas, so that is what we prefer.

Quoted 2 lines

BTW, is NULL == (void*)0 everywhere? I seem to recall places where it isn't....

Yes, NULL==0.

Jeff

#13 lore raw
In reply to Matthew Dharm
Quoted 4 lines

BTW, is NULL == (void*)0 everywhere? I seem to recall places where it isn't....

From the recesses of my memory, NULL is always equivalent to (void*)0, but

that doesn't necessarily mean that a NULL pointer has a bit pattern of all zeros as stored in the computer's memory. NULL is replaced with (void*)0 by the preprocessor, and then the compiler for the target architecture determines the appropriate bit pattern for (void*)0. You can think of (void*)0 as just a name for the null pointer which doesn't determine its actual value. On some old architectures, memset to zero does not automatically set pointers to NULL. I do not remember the specific architectures which are affected, but I doubt Linux runs or will ever run on any of them.

For modern code, it is safe to assume that memset to zero will set pointers to NULL.

Anthony J. Battersby
Cybernetics