diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2008-07-24 16:53:35 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-07-24 16:53:35 -0400 |
commit | e27420d046600cd3e4139ea1b6cba59a8b4050eb (patch) | |
tree | aaf60bb6c306d9c1bf75301a86465e7e63920ac3 | |
parent | 216f9a88feabf5ed574c3aa78447a6bd872910bc (diff) |
ide-scsi: remove kmalloced struct request
This converts ide-scsi to use blk_get/put_request instead of
kmalloc/kfree.
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/scsi/ide-scsi.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/scsi/ide-scsi.c b/drivers/scsi/ide-scsi.c index 318ef382448f..b40a673985aa 100644 --- a/drivers/scsi/ide-scsi.c +++ b/drivers/scsi/ide-scsi.c | |||
@@ -207,15 +207,15 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
207 | 207 | ||
208 | /* stuff a sense request in front of our current request */ | 208 | /* stuff a sense request in front of our current request */ |
209 | pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); | 209 | pc = kzalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); |
210 | rq = kmalloc(sizeof(struct request), GFP_ATOMIC); | 210 | rq = blk_get_request(drive->queue, READ, GFP_ATOMIC); |
211 | buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); | 211 | buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); |
212 | if (!pc || !rq || !buf) { | 212 | if (!pc || !rq || !buf) { |
213 | kfree(buf); | 213 | kfree(buf); |
214 | kfree(rq); | 214 | if (rq) |
215 | blk_put_request(rq); | ||
215 | kfree(pc); | 216 | kfree(pc); |
216 | return -ENOMEM; | 217 | return -ENOMEM; |
217 | } | 218 | } |
218 | blk_rq_init(NULL, rq); | ||
219 | rq->special = (char *) pc; | 219 | rq->special = (char *) pc; |
220 | pc->rq = rq; | 220 | pc->rq = rq; |
221 | pc->buf = buf; | 221 | pc->buf = buf; |
@@ -232,6 +232,7 @@ static int idescsi_check_condition(ide_drive_t *drive, | |||
232 | ide_scsi_hex_dump(pc->c, 6); | 232 | ide_scsi_hex_dump(pc->c, 6); |
233 | } | 233 | } |
234 | rq->rq_disk = scsi->disk; | 234 | rq->rq_disk = scsi->disk; |
235 | rq->ref_count++; | ||
235 | memcpy(rq->cmd, pc->c, 12); | 236 | memcpy(rq->cmd, pc->c, 12); |
236 | ide_do_drive_cmd(drive, rq); | 237 | ide_do_drive_cmd(drive, rq); |
237 | return 0; | 238 | return 0; |
@@ -278,7 +279,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) | |||
278 | SCSI_SENSE_BUFFERSIZE); | 279 | SCSI_SENSE_BUFFERSIZE); |
279 | kfree(pc->buf); | 280 | kfree(pc->buf); |
280 | kfree(pc); | 281 | kfree(pc); |
281 | kfree(rq); | 282 | blk_put_request(rq); |
282 | pc = opc; | 283 | pc = opc; |
283 | rq = pc->rq; | 284 | rq = pc->rq; |
284 | pc->scsi_cmd->result = (CHECK_CONDITION << 1) | | 285 | pc->scsi_cmd->result = (CHECK_CONDITION << 1) | |
@@ -309,7 +310,7 @@ static int idescsi_end_request (ide_drive_t *drive, int uptodate, int nrsecs) | |||
309 | pc->done(pc->scsi_cmd); | 310 | pc->done(pc->scsi_cmd); |
310 | spin_unlock_irqrestore(host->host_lock, flags); | 311 | spin_unlock_irqrestore(host->host_lock, flags); |
311 | kfree(pc); | 312 | kfree(pc); |
312 | kfree(rq); | 313 | blk_put_request(rq); |
313 | scsi->pc = NULL; | 314 | scsi->pc = NULL; |
314 | return 0; | 315 | return 0; |
315 | } | 316 | } |
@@ -583,6 +584,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
583 | ide_drive_t *drive = scsi->drive; | 584 | ide_drive_t *drive = scsi->drive; |
584 | struct request *rq = NULL; | 585 | struct request *rq = NULL; |
585 | struct ide_atapi_pc *pc = NULL; | 586 | struct ide_atapi_pc *pc = NULL; |
587 | int write = cmd->sc_data_direction == DMA_TO_DEVICE; | ||
586 | 588 | ||
587 | if (!drive) { | 589 | if (!drive) { |
588 | scmd_printk (KERN_ERR, cmd, "drive not present\n"); | 590 | scmd_printk (KERN_ERR, cmd, "drive not present\n"); |
@@ -590,7 +592,7 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
590 | } | 592 | } |
591 | scsi = drive_to_idescsi(drive); | 593 | scsi = drive_to_idescsi(drive); |
592 | pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); | 594 | pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); |
593 | rq = kmalloc(sizeof(struct request), GFP_ATOMIC); | 595 | rq = blk_get_request(drive->queue, write, GFP_ATOMIC); |
594 | if (rq == NULL || pc == NULL) { | 596 | if (rq == NULL || pc == NULL) { |
595 | printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); | 597 | printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); |
596 | goto abort; | 598 | goto abort; |
@@ -620,17 +622,18 @@ static int idescsi_queue (struct scsi_cmnd *cmd, | |||
620 | } | 622 | } |
621 | } | 623 | } |
622 | 624 | ||
623 | blk_rq_init(NULL, rq); | ||
624 | rq->special = (char *) pc; | 625 | rq->special = (char *) pc; |
625 | rq->cmd_type = REQ_TYPE_SPECIAL; | 626 | rq->cmd_type = REQ_TYPE_SPECIAL; |
626 | spin_unlock_irq(host->host_lock); | 627 | spin_unlock_irq(host->host_lock); |
628 | rq->ref_count++; | ||
627 | memcpy(rq->cmd, pc->c, 12); | 629 | memcpy(rq->cmd, pc->c, 12); |
628 | blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); | 630 | blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); |
629 | spin_lock_irq(host->host_lock); | 631 | spin_lock_irq(host->host_lock); |
630 | return 0; | 632 | return 0; |
631 | abort: | 633 | abort: |
632 | kfree (pc); | 634 | kfree (pc); |
633 | kfree (rq); | 635 | if (rq) |
636 | blk_put_request(rq); | ||
634 | cmd->result = DID_ERROR << 16; | 637 | cmd->result = DID_ERROR << 16; |
635 | done(cmd); | 638 | done(cmd); |
636 | return 0; | 639 | return 0; |
@@ -678,7 +681,9 @@ static int idescsi_eh_abort (struct scsi_cmnd *cmd) | |||
678 | 681 | ||
679 | if (blk_sense_request(scsi->pc->rq)) | 682 | if (blk_sense_request(scsi->pc->rq)) |
680 | kfree(scsi->pc->buf); | 683 | kfree(scsi->pc->buf); |
681 | kfree(scsi->pc->rq); | 684 | /* we need to call blk_put_request twice. */ |
685 | blk_put_request(scsi->pc->rq); | ||
686 | blk_put_request(scsi->pc->rq); | ||
682 | kfree(scsi->pc); | 687 | kfree(scsi->pc); |
683 | scsi->pc = NULL; | 688 | scsi->pc = NULL; |
684 | 689 | ||
@@ -730,7 +735,7 @@ static int idescsi_eh_reset (struct scsi_cmnd *cmd) | |||
730 | kfree(scsi->pc->buf); | 735 | kfree(scsi->pc->buf); |
731 | kfree(scsi->pc); | 736 | kfree(scsi->pc); |
732 | scsi->pc = NULL; | 737 | scsi->pc = NULL; |
733 | kfree(req); | 738 | blk_put_request(req); |
734 | 739 | ||
735 | /* now nuke the drive queue */ | 740 | /* now nuke the drive queue */ |
736 | while ((req = elv_next_request(drive->queue))) { | 741 | while ((req = elv_next_request(drive->queue))) { |