diff options
Diffstat (limited to 'drivers/scsi/libsrp.c')
-rw-r--r-- | drivers/scsi/libsrp.c | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/scsi/libsrp.c b/drivers/scsi/libsrp.c index 9ad38e81e343..ff6a28ce9b69 100644 --- a/drivers/scsi/libsrp.c +++ b/drivers/scsi/libsrp.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * SCSI RDAM Protocol lib functions | 2 | * SCSI RDMA Protocol lib functions |
3 | * | 3 | * |
4 | * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org> | 4 | * Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org> |
5 | * | 5 | * |
@@ -19,6 +19,7 @@ | |||
19 | * 02110-1301 USA | 19 | * 02110-1301 USA |
20 | */ | 20 | */ |
21 | #include <linux/err.h> | 21 | #include <linux/err.h> |
22 | #include <linux/slab.h> | ||
22 | #include <linux/kfifo.h> | 23 | #include <linux/kfifo.h> |
23 | #include <linux/scatterlist.h> | 24 | #include <linux/scatterlist.h> |
24 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
@@ -58,19 +59,15 @@ static int srp_iu_pool_alloc(struct srp_queue *q, size_t max, | |||
58 | goto free_pool; | 59 | goto free_pool; |
59 | 60 | ||
60 | spin_lock_init(&q->lock); | 61 | spin_lock_init(&q->lock); |
61 | q->queue = kfifo_init((void *) q->pool, max * sizeof(void *), | 62 | kfifo_init(&q->queue, (void *) q->pool, max * sizeof(void *)); |
62 | GFP_KERNEL, &q->lock); | ||
63 | if (IS_ERR(q->queue)) | ||
64 | goto free_item; | ||
65 | 63 | ||
66 | for (i = 0, iue = q->items; i < max; i++) { | 64 | for (i = 0, iue = q->items; i < max; i++) { |
67 | __kfifo_put(q->queue, (void *) &iue, sizeof(void *)); | 65 | kfifo_in(&q->queue, (void *) &iue, sizeof(void *)); |
68 | iue->sbuf = ring[i]; | 66 | iue->sbuf = ring[i]; |
69 | iue++; | 67 | iue++; |
70 | } | 68 | } |
71 | return 0; | 69 | return 0; |
72 | 70 | ||
73 | free_item: | ||
74 | kfree(q->items); | 71 | kfree(q->items); |
75 | free_pool: | 72 | free_pool: |
76 | kfree(q->pool); | 73 | kfree(q->pool); |
@@ -167,7 +164,11 @@ struct iu_entry *srp_iu_get(struct srp_target *target) | |||
167 | { | 164 | { |
168 | struct iu_entry *iue = NULL; | 165 | struct iu_entry *iue = NULL; |
169 | 166 | ||
170 | kfifo_get(target->iu_queue.queue, (void *) &iue, sizeof(void *)); | 167 | if (kfifo_out_locked(&target->iu_queue.queue, (void *) &iue, |
168 | sizeof(void *), &target->iu_queue.lock) != sizeof(void *)) { | ||
169 | WARN_ONCE(1, "unexpected fifo state"); | ||
170 | return NULL; | ||
171 | } | ||
171 | if (!iue) | 172 | if (!iue) |
172 | return iue; | 173 | return iue; |
173 | iue->target = target; | 174 | iue->target = target; |
@@ -179,7 +180,8 @@ EXPORT_SYMBOL_GPL(srp_iu_get); | |||
179 | 180 | ||
180 | void srp_iu_put(struct iu_entry *iue) | 181 | void srp_iu_put(struct iu_entry *iue) |
181 | { | 182 | { |
182 | kfifo_put(iue->target->iu_queue.queue, (void *) &iue, sizeof(void *)); | 183 | kfifo_in_locked(&iue->target->iu_queue.queue, (void *) &iue, |
184 | sizeof(void *), &iue->target->iu_queue.lock); | ||
183 | } | 185 | } |
184 | EXPORT_SYMBOL_GPL(srp_iu_put); | 186 | EXPORT_SYMBOL_GPL(srp_iu_put); |
185 | 187 | ||
@@ -327,7 +329,7 @@ int srp_transfer_data(struct scsi_cmnd *sc, struct srp_cmd *cmd, | |||
327 | int offset, err = 0; | 329 | int offset, err = 0; |
328 | u8 format; | 330 | u8 format; |
329 | 331 | ||
330 | offset = cmd->add_cdb_len * 4; | 332 | offset = cmd->add_cdb_len & ~3; |
331 | 333 | ||
332 | dir = srp_cmd_direction(cmd); | 334 | dir = srp_cmd_direction(cmd); |
333 | if (dir == DMA_FROM_DEVICE) | 335 | if (dir == DMA_FROM_DEVICE) |
@@ -365,7 +367,7 @@ static int vscsis_data_length(struct srp_cmd *cmd, enum dma_data_direction dir) | |||
365 | { | 367 | { |
366 | struct srp_direct_buf *md; | 368 | struct srp_direct_buf *md; |
367 | struct srp_indirect_buf *id; | 369 | struct srp_indirect_buf *id; |
368 | int len = 0, offset = cmd->add_cdb_len * 4; | 370 | int len = 0, offset = cmd->add_cdb_len & ~3; |
369 | u8 fmt; | 371 | u8 fmt; |
370 | 372 | ||
371 | if (dir == DMA_TO_DEVICE) | 373 | if (dir == DMA_TO_DEVICE) |
@@ -439,6 +441,6 @@ int srp_cmd_queue(struct Scsi_Host *shost, struct srp_cmd *cmd, void *info, | |||
439 | } | 441 | } |
440 | EXPORT_SYMBOL_GPL(srp_cmd_queue); | 442 | EXPORT_SYMBOL_GPL(srp_cmd_queue); |
441 | 443 | ||
442 | MODULE_DESCRIPTION("SCSI RDAM Protocol lib functions"); | 444 | MODULE_DESCRIPTION("SCSI RDMA Protocol lib functions"); |
443 | MODULE_AUTHOR("FUJITA Tomonori"); | 445 | MODULE_AUTHOR("FUJITA Tomonori"); |
444 | MODULE_LICENSE("GPL"); | 446 | MODULE_LICENSE("GPL"); |