]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/scsi/scsi_cmnd.h
SG: Convert SCSI to use scatterlist helpers for sg chaining
[linux-2.6-omap-h63xx.git] / include / scsi / scsi_cmnd.h
index 53e170586c26c190a304c9a7c5f8100de1fd866a..a457fca66f6156c4b3629c06d10a71e4c453c5ee 100644 (file)
@@ -5,9 +5,9 @@
 #include <linux/list.h>
 #include <linux/types.h>
 #include <linux/timer.h>
+#include <linux/scatterlist.h>
 
 struct request;
-struct scatterlist;
 struct Scsi_Host;
 struct scsi_device;
 
@@ -33,20 +33,17 @@ struct scsi_cmnd {
        struct list_head list;  /* scsi_cmnd participates in queue lists */
        struct list_head eh_entry; /* entry for the host eh_cmd_q */
        int eh_eflags;          /* Used by error handlr */
-       void (*done) (struct scsi_cmnd *);      /* Mid-level done function */
 
        /*
         * A SCSI Command is assigned a nonzero serial_number before passed
         * to the driver's queue command function.  The serial_number is
         * cleared when scsi_done is entered indicating that the command
-        * has been completed.  It currently doesn't have much use other
-        * than printk's.  Some lldd's use this number for other purposes.
-        * It's almost certain that such usages are either incorrect or
-        * meaningless.  Please kill all usages other than printk's.  Also,
-        * as this number is always identical to ->pid, please convert
-        * printk's to use ->pid, so that we can kill this field.
+        * has been completed.  It is a bug for LLDDs to use this number
+        * for purposes other than printk (and even that is only useful
+        * for debugging).
         */
        unsigned long serial_number;
+
        /*
         * This is set to jiffies as it was when the command was first
         * allocated.  It is used to time how long the command has
@@ -70,8 +67,8 @@ struct scsi_cmnd {
        void *request_buffer;           /* Actual requested buffer */
 
        /* These elements define the operation we ultimately want to perform */
+       struct sg_table sg_table;
        unsigned short use_sg;  /* Number of pieces of scatter-gather */
-       unsigned short sglist_len;      /* size of malloc'd scatter-gather list */
 
        unsigned underflow;     /* Return error if less than
                                   this amount is transferred */
@@ -90,7 +87,7 @@ struct scsi_cmnd {
                                           working on */
 
 #define SCSI_SENSE_BUFFERSIZE  96
-       unsigned char sense_buffer[SCSI_SENSE_BUFFERSIZE];
+       unsigned char *sense_buffer;
                                /* obtained by REQUEST SENSE when
                                 * CHECK CONDITION is received on original
                                 * command (auto-sense) */
@@ -116,7 +113,6 @@ struct scsi_cmnd {
        int result;             /* Status code from lower level driver */
 
        unsigned char tag;      /* SCSI-II queued command tag */
-       unsigned long pid;      /* Process ID, starts at 0. Unique per host. */
 };
 
 extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
@@ -124,7 +120,6 @@ extern struct scsi_cmnd *__scsi_get_command(struct Scsi_Host *, gfp_t);
 extern void scsi_put_command(struct scsi_cmnd *);
 extern void __scsi_put_command(struct Scsi_Host *, struct scsi_cmnd *,
                               struct device *);
-extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
 extern void scsi_req_abort_cmd(struct scsi_cmnd *cmd);
 
@@ -132,14 +127,14 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count,
                                 size_t *offset, size_t *len);
 extern void scsi_kunmap_atomic_sg(void *virt);
 
-extern struct scatterlist *scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
-extern void scsi_free_sgtable(struct scatterlist *, int);
+extern int scsi_alloc_sgtable(struct scsi_cmnd *, gfp_t);
+extern void scsi_free_sgtable(struct scsi_cmnd *);
 
 extern int scsi_dma_map(struct scsi_cmnd *cmd);
 extern void scsi_dma_unmap(struct scsi_cmnd *cmd);
 
 #define scsi_sg_count(cmd) ((cmd)->use_sg)
-#define scsi_sglist(cmd) ((struct scatterlist *)(cmd)->request_buffer)
+#define scsi_sglist(cmd) ((cmd)->sg_table.sgl)
 #define scsi_bufflen(cmd) ((cmd)->request_bufflen)
 
 static inline void scsi_set_resid(struct scsi_cmnd *cmd, int resid)
@@ -153,6 +148,6 @@ static inline int scsi_get_resid(struct scsi_cmnd *cmd)
 }
 
 #define scsi_for_each_sg(cmd, sg, nseg, __i)                   \
-       for (__i = 0, sg = scsi_sglist(cmd); __i < (nseg); __i++, (sg)++)
+       for_each_sg(scsi_sglist(cmd), sg, nseg, __i)
 
 #endif /* _SCSI_SCSI_CMND_H */