On Sun, 2005-06-05 at 09:40 -0500, James Bottomley wrote:
Finally, there's coming up with a replacement API for scsi_do_req that
returns via the end_io callback ... since that doesn't do a wait/wake,
perhaps this should be the core API upon which the others are built?
OK, well, the API is easy ... it's attached. Converting sg and st to
use it is quite another matter. sg in particular is a nasty tangle when
it comes to doing its own sg mapping, which the block layer will now do
for it.
James
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -177,6 +177,23 @@ int scsi_queue_insert(struct scsi_cmnd *
return 0;
}
+struct scsi_do_req_cb {
+ void (*done)(void *, int);
+ void *data;
+};
+
+static void scsi_do_req_end_io(struct request *req)
+{
+ int result = req->errors;
+ struct scsi_do_req_cb *cb = req->end_io_data;
+
+ BUG_ON(cb == NULL);
+ if (result)
+ result |= DRIVER_ERROR << 24;
+ blk_put_request(req);
+ cb->done(cb->data, result);
+ kfree(cb);
+}
/*
* Function: scsi_do_req
*
@@ -203,38 +220,49 @@ int scsi_queue_insert(struct scsi_cmnd *
* now inject requests on the *head* of the device queue
* rather than the tail.
*/
-void scsi_do_req(struct scsi_request *sreq, const void *cmnd,
- void *buffer, unsigned bufflen,
- void (*done)(struct scsi_cmnd *),
- int timeout, int retries)
+void scsi_do_command(struct scsi_device *sdev, const void *cmnd, int cmd_len,
+ void *buffer, unsigned bufflen, void *data,
+ void (*done)(void *, int),
+ char *sense_buffer, int timeout, int retries,
+ enum dma_data_direction dir)