Re: [PATCH 04/15] libata: ata_scsi_queuecmd cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff Garzik wrote:
> Brian King wrote:
>> Encapsulate part of ata_scsi_queuecmd so that it can be
>> reused by future SAS patches.
>>
>> +static void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
> 
> static inline, please

ok.


>>  /**
>>   *	ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
>>   *	@cmd: SCSI command to be sent
>> @@ -2605,16 +2620,7 @@ int ata_scsi_queuecmd(struct scsi_cmnd *
>>  		goto out_unlock;
>>  	}
>>  
>> -	if (dev->class == ATA_DEV_ATA) {
>> -		ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
>> -							      cmd->cmnd[0]);
>> -
>> -		if (xlat_func)
>> -			ata_scsi_translate(ap, dev, cmd, done, xlat_func);
>> -		else
>> -			ata_scsi_simulate(ap, dev, cmd, done);
>> -	} else
>> -		ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
>> +	__ata_scsi_queuecmd(cmd, done, ap, dev);
> 
> might as well kill the out_unlock goto target, and do something like
> 
> 	if (likely(dev))
> 		__ata_scsi_queuecmd()
> 	else
> 		BAD TARGET

ok. How about the following patch?

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center
Encapsulate part of ata_scsi_queuecmd so that it can be
reused by future SAS patches.

Signed-off-by: Brian King <brking@xxxxxxxxxx>
---

 libata-dev-bjking1/drivers/scsi/libata-scsi.c |   32 ++++++++++++++------------
 1 files changed, 18 insertions(+), 14 deletions(-)

diff -puN drivers/scsi/libata-scsi.c~libata_scsi_queuecmd drivers/scsi/libata-scsi.c
--- libata-dev/drivers/scsi/libata-scsi.c~libata_scsi_queuecmd	2006-03-22 08:58:46.000000000 -0600
+++ libata-dev-bjking1/drivers/scsi/libata-scsi.c	2006-03-22 09:00:15.000000000 -0600
@@ -2587,6 +2587,21 @@ static inline void ata_scsi_dump_cdb(str
 #endif
 }
 
+static inline void __ata_scsi_queuecmd(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *),
+				       struct ata_port *ap, struct ata_device *dev)
+{
+	if (dev->class == ATA_DEV_ATA) {
+		ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
+							      cmd->cmnd[0]);
+
+		if (xlat_func)
+			ata_scsi_translate(ap, dev, cmd, done, xlat_func);
+		else
+			ata_scsi_simulate(ap, dev, cmd, done);
+	} else
+		ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
+}
+
 /**
  *	ata_scsi_queuecmd - Issue SCSI cdb to libata-managed device
  *	@cmd: SCSI command to be sent
@@ -2621,24 +2636,13 @@ int ata_scsi_queuecmd(struct scsi_cmnd *
 	ata_scsi_dump_cdb(ap, cmd);
 
 	dev = ata_scsi_find_dev(ap, scsidev);
-	if (unlikely(!dev)) {
+	if (likely(dev))
+		__ata_scsi_queuecmd(cmd, done, ap, dev);
+	else {
 		cmd->result = (DID_BAD_TARGET << 16);
 		done(cmd);
-		goto out_unlock;
 	}
 
-	if (dev->class == ATA_DEV_ATA) {
-		ata_xlat_func_t xlat_func = ata_get_xlat_func(dev,
-							      cmd->cmnd[0]);
-
-		if (xlat_func)
-			ata_scsi_translate(ap, dev, cmd, done, xlat_func);
-		else
-			ata_scsi_simulate(ap, dev, cmd, done);
-	} else
-		ata_scsi_translate(ap, dev, cmd, done, atapi_xlat);
-
-out_unlock:
 	spin_unlock(&ap->host_set->lock);
 	spin_lock(shost->host_lock);
 	return 0;
_

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux