* [PATCH] USB: misplaced parenthesis @ 2010-02-15 22:40 Roel Kluin 2010-02-15 22:44 ` Joe Perches 0 siblings, 1 reply; 5+ messages in thread From: Roel Kluin @ 2010-02-15 22:40 UTC (permalink / raw) To: Matthew Dharm, linux-usb, usb-storage, Andrew Morton, LKML The parenthesis was misplaced Signed-off-by: Roel Kluin <roel.kluin@gmail.com> --- Is this maybe, as the comment states, why blanking a cdrw at speed 4 was unreliable? diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c index b62a288..b958db5 100644 --- a/drivers/usb/storage/shuttle_usbat.c +++ b/drivers/usb/storage/shuttle_usbat.c @@ -1645,8 +1645,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) if ((result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, - (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) != - USB_STOR_TRANSPORT_GOOD)) { + (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0)) != + USB_STOR_TRANSPORT_GOOD) { return result; } ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] USB: misplaced parenthesis 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 0 siblings, 1 reply; 5+ messages in thread From: Joe Perches @ 2010-02-15 22:44 UTC (permalink / raw) To: Roel Kluin; +Cc: Matthew Dharm, linux-usb, usb-storage, Andrew Morton, LKML On Mon, 2010-02-15 at 23:40 +0100, Roel Kluin wrote: > The parenthesis was misplaced > > Signed-off-by: Roel Kluin <roel.kluin@gmail.com> > --- > Is this maybe, as the comment states, why blanking a cdrw at speed 4 > was unreliable? > > diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c > index b62a288..b958db5 100644 > --- a/drivers/usb/storage/shuttle_usbat.c > +++ b/drivers/usb/storage/shuttle_usbat.c > @@ -1645,8 +1645,8 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us) > > if ((result = usbat_write_block(us, > USBAT_ATA, srb->cmnd, 12, > - (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) != > - USB_STOR_TRANSPORT_GOOD)) { > + (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0)) != > + USB_STOR_TRANSPORT_GOOD) { > return result; > } I think it'd be better if you hoisted the set'n'test out of the if() Isn't this the current logic? result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0); result = result != USB_STOR_TRANSPORT_GOOD; if (result) return result; I wonder if it should be: 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; ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] USB: misplaced parenthesis 2010-02-15 22:44 ` Joe Perches @ 2010-02-16 11:16 ` Roel Kluin 2010-02-16 15:52 ` Alan Stern 0 siblings, 1 reply; 5+ messages in thread From: Roel Kluin @ 2010-02-16 11:16 UTC (permalink / raw) To: Joe Perches; +Cc: Matthew Dharm, linux-usb, usb-storage, Andrew Morton, LKML > I think it'd be better if you hoisted the set'n'test out of the if() ok, I agree. > Isn't this the current logic? > > result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, > srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0); > result = result != USB_STOR_TRANSPORT_GOOD; > if (result) > return result; Thanks for your comments, Yes that was the current logic, which I thought was wrong, but now I think it could also be obscurely written but right: 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) */ With the current logic usbat_hp8200e_transport() returns TRANSPORT_FAILED, even if usbat_write_block() returned TRANSPORT_NO_SENSE or TRANSPORT_ERROR. This could be intended, but then the author chose a very obscure way to write: if (usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0) != USB_STOR_TRANSPORT_GOOD) return USB_STOR_TRANSPORT_FAILED; Or was the parenthesis misplaced and should it really be: 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; Maybe someone with the specs/more knowledge of this driver could look into this? Thanks, Roel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] USB: misplaced parenthesis 2010-02-16 11:16 ` Roel Kluin @ 2010-02-16 15:52 ` Alan Stern 2010-02-17 10:50 ` Roel Kluin 0 siblings, 1 reply; 5+ messages in thread From: Alan Stern @ 2010-02-16 15:52 UTC (permalink / raw) To: Roel Kluin Cc: Joe Perches, Matthew Dharm, linux-usb, usb-storage, Andrew Morton, LKML On Tue, 16 Feb 2010, Roel Kluin wrote: > > I think it'd be better if you hoisted the set'n'test out of the if() > > ok, I agree. > > > Isn't this the current logic? > > > > result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, > > srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0); > > result = result != USB_STOR_TRANSPORT_GOOD; > > if (result) > > return result; > > Thanks for your comments, Yes that was the current logic, which I thought > was wrong, but now I think it could also be obscurely written but right: > > 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) */ > > With the current logic usbat_hp8200e_transport() returns TRANSPORT_FAILED, > even if usbat_write_block() returned TRANSPORT_NO_SENSE or TRANSPORT_ERROR. > > This could be intended, but then the author chose a very obscure way to write: > > if (usbat_write_block(us, USBAT_ATA, srb->cmnd, 12, > srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0) != > USB_STOR_TRANSPORT_GOOD) > return USB_STOR_TRANSPORT_FAILED; > > Or was the parenthesis misplaced and should it really be: > > 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; > > Maybe someone with the specs/more knowledge of this driver could look into > this? 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. Compare with the code a few lines higher: if ( (result = usbat_multiple_write(us, registers, data, 7)) != USB_STOR_TRANSPORT_GOOD) { return result; } The meaning is clear, even though this also unnecessarily squeezes a function call and a test into one statement and includes unneeded {}'s. Alan Stern ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] USB: misplaced parenthesis 2010-02-16 15:52 ` Alan Stern @ 2010-02-17 10:50 ` Roel Kluin 0 siblings, 0 replies; 5+ messages in thread From: Roel Kluin @ 2010-02-17 10:50 UTC (permalink / raw) To: Alan Stern Cc: Joe Perches, Matthew Dharm, linux-usb, usb-storage, Andrew Morton, LKML 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. */ ^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-02-17 10:43 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 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.