On Mon, 31 Jan 2005 16:38:05 -0800, Greg KH <[EMAIL PROTECTED]> wrote:
> On Thu, Jan 27, 2005 at 12:43:25AM -0800, Pete Zaitcev wrote:
> > This patch adds support for ioctls to ub, with the help of scsi_ioctl_cmd().
> > Now ub can eject CDs. But do not try to burn CDs yet, it's not tested.
> >
> > Original patch from Peter Jones (aka deviant-).
> >
> > Signed-off-by: Pete Zaitcev
>
> Applied, thanks.
>
> greg k-h
I am awfully sorry, but that patch contained a bug. The code dereferenced
cmd->back as if it were a pointer to a request even when it wasn't. It worked
by accident, because rq->flags overlapped with a zeroed memory in other case.
Here is a corrective patch.
Signed-off-by: Pete Zaitcev
--- linux-2.6.11-rc2-lem-gregkh/drivers/block/ub.c 2005-02-02
22:25:04.000000000 -0800
+++ linux-2.6.11-rc2-lem/drivers/block/ub.c 2005-02-02 22:22:19.000000000
-0800
@@ -775,6 +775,12 @@
request_queue_t *q = disk->queue;
int uptodate;
+ if (blk_pc_request(rq)) {
+ /* UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE */
+ memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE);
+ rq->sense_len = UB_SENSE_SIZE;
+ }
+
if (cmd->error == 0)
uptodate = 1;
else
@@ -833,6 +839,17 @@
bcb = &sc->work_bcb;
+ /*
+ * ``If the allocation length is eighteen or greater, and a device
+ * server returns less than eithteen bytes of data, the application
+ * client should assume that the bytes not transferred would have been
+ * zeroes had the device server returned those bytes.''
+ *
+ * We zero sense for all commands so that when a packet request
+ * fails it does not return a stale sense.
+ */
+ memset(&sc->top_sense, 0, UB_SENSE_SIZE);
+
/* set up the command wrapper */
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->Tag = cmd->tag; /* Endianness is not important */
@@ -938,7 +955,6 @@
{
struct urb *urb = &sc->work_urb;
struct bulk_cs_wrap *bcs;
- struct request *rq = cmd->back;
int pipe;
int rc;
@@ -1192,13 +1208,6 @@
(*cmd->done)(sc, cmd);
} else if (cmd->state == UB_CMDST_SENSE) {
- if (blk_pc_request(rq)) {
- /*
- * UB_SENSE_SIZE is smaller than SCSI_SENSE_BUFFERSIZE
- */
- memcpy(rq->sense, sc->top_sense, UB_SENSE_SIZE);
- rq->sense_len = UB_SENSE_SIZE;
- }
ub_state_done(sc, cmd, -EIO);
} else {
@@ -1284,14 +1293,6 @@
goto error;
}
- /*
- * ``If the allocation length is eighteen or greater, and a device
- * server returns less than eithteen bytes of data, the application
- * client should assume that the bytes not transferred would have been
- * zeroes had the device server returned those bytes.''
- */
- memset(&sc->top_sense, 0, UB_SENSE_SIZE);
-
scmd = &sc->top_rqs_cmd;
scmd->cdb[0] = REQUEST_SENSE;
scmd->cdb[4] = UB_SENSE_SIZE;
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel