From: Roel Kluin <roel.kluin@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Joe Perches <joe@perches.com>,
Matthew Dharm <mdharm-usb@one-eyed-alien.net>,
linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] USB: misplaced parenthesis
Date: Wed, 17 Feb 2010 11:50:26 +0100 [thread overview]
Message-ID: <4B7BC9F2.6050703@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1002161047240.1716-100000@iolanthe.rowland.org>
Due to a misplaced parenthesis the usbat_write_block() return value was not
stored, but a boolean. USB_STOR_TRANSPORT_NO_SENSE and USB_STOR_TRANSPORT_ERROR
were returned as USB_STOR_TRANSPORT_FAILED.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
>> in drivers/usb/storage/transport.h line 100 note the definitions:
>>
>> #define USB_STOR_TRANSPORT_GOOD 0 /* Transport good, command good */
>> #define USB_STOR_TRANSPORT_FAILED 1 /* Transport good, command failed */
>> #define USB_STOR_TRANSPORT_NO_SENSE 2 /* Command failed, no auto-sense */
>> #define USB_STOR_TRANSPORT_ERROR 3 /* Transport bad (i.e. device dead) */
> It seems pretty clear that your patch was correct and the parens were
> misplaced. In usb-storage, transport routines like
> usbat_hp8200e_transport() are supposed to return one of the
> USB_STOR_TRANSPORT_* codes, not a Boolean value.
>
> I do agree with Joe that it would be better form to separate the
> function call and the "if" into two statements, as in your second
> version above.
Ok, thanks for comments, This should fix and separate the assignment as desired.
Roel
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index b62a288..bd3f415 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1628,10 +1628,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
return USB_STOR_TRANSPORT_ERROR;
}
- if ( (result = usbat_multiple_write(us,
- registers, data, 7)) != USB_STOR_TRANSPORT_GOOD) {
+ result = usbat_multiple_write(us, registers, data, 7);
+
+ if (result != USB_STOR_TRANSPORT_GOOD)
return result;
- }
/*
* Write the 12-byte command header.
@@ -1643,12 +1643,11 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
* AT SPEED 4 IS UNRELIABLE!!!
*/
- if ((result = usbat_write_block(us,
- USBAT_ATA, srb->cmnd, 12,
- (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) !=
- USB_STOR_TRANSPORT_GOOD)) {
+ result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12,
+ srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0);
+
+ if (result != USB_STOR_TRANSPORT_GOOD)
return result;
- }
/* If there is response data to be read in then do it here. */
prev parent reply other threads:[~2010-02-17 10:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-15 22:40 [PATCH] USB: misplaced parenthesis Roel Kluin
2010-02-15 22:44 ` Joe Perches
2010-02-16 11:16 ` Roel Kluin
2010-02-16 15:52 ` Alan Stern
2010-02-17 10:50 ` Roel Kluin [this message]
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=4B7BC9F2.6050703@gmail.com \
--to=roel.kluin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mdharm-usb@one-eyed-alien.net \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.