diff options
author | Mike Miller <mike.miller@hp.com> | 2010-06-02 15:57:58 -0400 |
---|---|---|
committer | Jens Axboe <jaxboe@fusionio.com> | 2010-08-07 12:12:32 -0400 |
commit | 664a717d3ac5871efc1fd3bb5a32c552dc339d3f (patch) | |
tree | ffe4d3537dccd8aaf2662002ec50b2b297ae604e /drivers/block/cciss.c | |
parent | 9fe6206f400646a2322096b56c59891d530e8d51 (diff) |
cciss: enqueue and submit io
Clean up some code where we subit our io. The same 5 lines appeared
several times. Also helps for a following patch.
Signed-off-by: Mike Miller <mike.miller@hp.com>
Cc: Stephen M. Cameron <scameron@beardog.cce.hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
Diffstat (limited to 'drivers/block/cciss.c')
-rw-r--r-- | drivers/block/cciss.c | 38 |
1 files changed, 15 insertions, 23 deletions
diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c index 51ceaee98f9f..6db790c2802f 100644 --- a/drivers/block/cciss.c +++ b/drivers/block/cciss.c | |||
@@ -257,6 +257,17 @@ static inline void removeQ(CommandList_struct *c) | |||
257 | hlist_del_init(&c->list); | 257 | hlist_del_init(&c->list); |
258 | } | 258 | } |
259 | 259 | ||
260 | static void enqueue_cmd_and_start_io(ctlr_info_t *h, | ||
261 | CommandList_struct *c) | ||
262 | { | ||
263 | unsigned long flags; | ||
264 | spin_lock_irqsave(&h->lock, flags); | ||
265 | addQ(&h->reqQ, c); | ||
266 | h->Qdepth++; | ||
267 | start_io(h); | ||
268 | spin_unlock_irqrestore(&h->lock, flags); | ||
269 | } | ||
270 | |||
260 | static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list, | 271 | static void cciss_free_sg_chain_blocks(SGDescriptor_struct **cmd_sg_list, |
261 | int nr_cmds) | 272 | int nr_cmds) |
262 | { | 273 | { |
@@ -1377,7 +1388,6 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1377 | CommandList_struct *c; | 1388 | CommandList_struct *c; |
1378 | char *buff = NULL; | 1389 | char *buff = NULL; |
1379 | u64bit temp64; | 1390 | u64bit temp64; |
1380 | unsigned long flags; | ||
1381 | DECLARE_COMPLETION_ONSTACK(wait); | 1391 | DECLARE_COMPLETION_ONSTACK(wait); |
1382 | 1392 | ||
1383 | if (!arg) | 1393 | if (!arg) |
@@ -1449,13 +1459,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1449 | } | 1459 | } |
1450 | c->waiting = &wait; | 1460 | c->waiting = &wait; |
1451 | 1461 | ||
1452 | /* Put the request on the tail of the request queue */ | 1462 | enqueue_cmd_and_start_io(host, c); |
1453 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | ||
1454 | addQ(&host->reqQ, c); | ||
1455 | host->Qdepth++; | ||
1456 | start_io(host); | ||
1457 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
1458 | |||
1459 | wait_for_completion(&wait); | 1463 | wait_for_completion(&wait); |
1460 | 1464 | ||
1461 | /* unlock the buffers from DMA */ | 1465 | /* unlock the buffers from DMA */ |
@@ -1495,7 +1499,6 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1495 | unsigned char **buff = NULL; | 1499 | unsigned char **buff = NULL; |
1496 | int *buff_size = NULL; | 1500 | int *buff_size = NULL; |
1497 | u64bit temp64; | 1501 | u64bit temp64; |
1498 | unsigned long flags; | ||
1499 | BYTE sg_used = 0; | 1502 | BYTE sg_used = 0; |
1500 | int status = 0; | 1503 | int status = 0; |
1501 | int i; | 1504 | int i; |
@@ -1602,12 +1605,7 @@ static int cciss_ioctl(struct block_device *bdev, fmode_t mode, | |||
1602 | } | 1605 | } |
1603 | } | 1606 | } |
1604 | c->waiting = &wait; | 1607 | c->waiting = &wait; |
1605 | /* Put the request on the tail of the request queue */ | 1608 | enqueue_cmd_and_start_io(host, c); |
1606 | spin_lock_irqsave(CCISS_LOCK(ctlr), flags); | ||
1607 | addQ(&host->reqQ, c); | ||
1608 | host->Qdepth++; | ||
1609 | start_io(host); | ||
1610 | spin_unlock_irqrestore(CCISS_LOCK(ctlr), flags); | ||
1611 | wait_for_completion(&wait); | 1609 | wait_for_completion(&wait); |
1612 | /* unlock the buffers from DMA */ | 1610 | /* unlock the buffers from DMA */ |
1613 | for (i = 0; i < sg_used; i++) { | 1611 | for (i = 0; i < sg_used; i++) { |
@@ -1729,8 +1727,8 @@ static void cciss_softirq_done(struct request *rq) | |||
1729 | CommandList_struct *cmd = rq->completion_data; | 1727 | CommandList_struct *cmd = rq->completion_data; |
1730 | ctlr_info_t *h = hba[cmd->ctlr]; | 1728 | ctlr_info_t *h = hba[cmd->ctlr]; |
1731 | SGDescriptor_struct *curr_sg = cmd->SG; | 1729 | SGDescriptor_struct *curr_sg = cmd->SG; |
1732 | unsigned long flags; | ||
1733 | u64bit temp64; | 1730 | u64bit temp64; |
1731 | unsigned long flags; | ||
1734 | int i, ddir; | 1732 | int i, ddir; |
1735 | int sg_index = 0; | 1733 | int sg_index = 0; |
1736 | 1734 | ||
@@ -2679,17 +2677,11 @@ static int sendcmd_withirq_core(ctlr_info_t *h, CommandList_struct *c, | |||
2679 | { | 2677 | { |
2680 | DECLARE_COMPLETION_ONSTACK(wait); | 2678 | DECLARE_COMPLETION_ONSTACK(wait); |
2681 | u64bit buff_dma_handle; | 2679 | u64bit buff_dma_handle; |
2682 | unsigned long flags; | ||
2683 | int return_status = IO_OK; | 2680 | int return_status = IO_OK; |
2684 | 2681 | ||
2685 | resend_cmd2: | 2682 | resend_cmd2: |
2686 | c->waiting = &wait; | 2683 | c->waiting = &wait; |
2687 | /* Put the request on the tail of the queue and send it */ | 2684 | enqueue_cmd_and_start_io(h, c); |
2688 | spin_lock_irqsave(CCISS_LOCK(h->ctlr), flags); | ||
2689 | addQ(&h->reqQ, c); | ||
2690 | h->Qdepth++; | ||
2691 | start_io(h); | ||
2692 | spin_unlock_irqrestore(CCISS_LOCK(h->ctlr), flags); | ||
2693 | 2685 | ||
2694 | wait_for_completion(&wait); | 2686 | wait_for_completion(&wait); |
2695 | 2687 | ||