linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian King <brking@us.ibm.com>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: [PATCH 04/15] libata: ata_scsi_queuecmd cleanup
Date: Wed, 22 Mar 2006 17:20:24 -0600	[thread overview]
Message-ID: <4421DBB8.1030908@us.ibm.com> (raw)
In-Reply-To: <4420ADB0.10904@pobox.com>

[-- Attachment #1: Type: text/plain, Size: 1105 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: libata_scsi_queuecmd.patch --]
[-- Type: text/x-patch; name="libata_scsi_queuecmd.patch", Size: 1911 bytes --]


Encapsulate part of ata_scsi_queuecmd so that it can be
reused by future SAS patches.

Signed-off-by: Brian King <brking@us.ibm.com>
---

 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;
_

  reply	other threads:[~2006-03-22 23:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-17 23:04 [PATCH 04/15] libata: ata_scsi_queuecmd cleanup Brian King
2006-03-22  1:51 ` Jeff Garzik
2006-03-22 23:20   ` Brian King [this message]
2006-03-22 23:34     ` Jeff Garzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4421DBB8.1030908@us.ibm.com \
    --to=brking@us.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).