mmc-omap: add support for 16-bit and 32-bit registers
[safe/jmp/linux-2.6] / drivers / scsi / libsrp.c
index 8424b86..ff6a28c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * SCSI RDAM Protocol lib functions
+ * SCSI RDMA Protocol lib functions
  *
  * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
  *
@@ -19,6 +19,7 @@
  * 02110-1301 USA
  */
 #include <linux/err.h>
+#include <linux/slab.h>
 #include <linux/kfifo.h>
 #include <linux/scatterlist.h>
 #include <linux/dma-mapping.h>
@@ -163,8 +164,11 @@ struct iu_entry *srp_iu_get(struct srp_target *target)
 {
        struct iu_entry *iue = NULL;
 
-       kfifo_out_locked(&target->iu_queue.queue, (void *) &iue,
-                       sizeof(void *), &target->iu_queue.lock);
+       if (kfifo_out_locked(&target->iu_queue.queue, (void *) &iue,
+               sizeof(void *), &target->iu_queue.lock) != sizeof(void *)) {
+                       WARN_ONCE(1, "unexpected fifo state");
+                       return NULL;
+       }
        if (!iue)
                return iue;
        iue->target = target;
@@ -325,7 +329,7 @@ int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
        int offset, err = 0;
        u8 format;
 
-       offset = cmd->add_cdb_len * 4;
+       offset = cmd->add_cdb_len & ~3;
 
        dir = srp_cmd_direction(cmd);
        if (dir == DMA_FROM_DEVICE)
@@ -363,7 +367,7 @@ static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir)
 {
        struct srp_direct_buf *md;
        struct srp_indirect_buf *id;
-       int len = 0, offset = cmd->add_cdb_len * 4;
+       int len = 0, offset = cmd->add_cdb_len & ~3;
        u8 fmt;
 
        if (dir == DMA_TO_DEVICE)
@@ -437,6 +441,6 @@ int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info,
 }
 EXPORT_SYMBOL_GPL(srp_cmd_queue);
 
-MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions");
+MODULE_DESCRIPTION("SCSI RDMA Protocol lib functions");
 MODULE_AUTHOR("FUJITA Tomonori");
 MODULE_LICENSE("GPL");