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>

authored by

FUJITA Tomonori and committed by
Bartlomiej Zolnierkiewicz
e27420d0 216f9a88

+15 -10
+15 -10
drivers/scsi/ide-scsi.c
··· 207 207 208 208 /* stuff a sense request in front of our current request */ 209 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 211 buf = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_ATOMIC); 212 212 if (!pc || !rq || !buf) { 213 213 kfree(buf); 214 - kfree(rq); 214 + if (rq) 215 + blk_put_request(rq); 215 216 kfree(pc); 216 217 return -ENOMEM; 217 218 } 218 - blk_rq_init(NULL, rq); 219 219 rq->special = (char *) pc; 220 220 pc->rq = rq; 221 221 pc->buf = buf; ··· 232 232 ide_scsi_hex_dump(pc->c, 6); 233 233 } 234 234 rq->rq_disk = scsi->disk; 235 + rq->ref_count++; 235 236 memcpy(rq->cmd, pc->c, 12); 236 237 ide_do_drive_cmd(drive, rq); 237 238 return 0; ··· 279 278 SCSI_SENSE_BUFFERSIZE); 280 279 kfree(pc->buf); 281 280 kfree(pc); 282 - kfree(rq); 281 + blk_put_request(rq); 283 282 pc = opc; 284 283 rq = pc->rq; 285 284 pc->scsi_cmd->result = (CHECK_CONDITION << 1) | ··· 310 309 pc->done(pc->scsi_cmd); 311 310 spin_unlock_irqrestore(host->host_lock, flags); 312 311 kfree(pc); 313 - kfree(rq); 312 + blk_put_request(rq); 314 313 scsi->pc = NULL; 315 314 return 0; 316 315 } ··· 584 583 ide_drive_t *drive = scsi->drive; 585 584 struct request *rq = NULL; 586 585 struct ide_atapi_pc *pc = NULL; 586 + int write = cmd->sc_data_direction == DMA_TO_DEVICE; 587 587 588 588 if (!drive) { 589 589 scmd_printk (KERN_ERR, cmd, "drive not present\n"); ··· 592 590 } 593 591 scsi = drive_to_idescsi(drive); 594 592 pc = kmalloc(sizeof(struct ide_atapi_pc), GFP_ATOMIC); 595 - rq = kmalloc(sizeof(struct request), GFP_ATOMIC); 593 + rq = blk_get_request(drive->queue, write, GFP_ATOMIC); 596 594 if (rq == NULL || pc == NULL) { 597 595 printk (KERN_ERR "ide-scsi: %s: out of memory\n", drive->name); 598 596 goto abort; ··· 622 620 } 623 621 } 624 622 625 - blk_rq_init(NULL, rq); 626 623 rq->special = (char *) pc; 627 624 rq->cmd_type = REQ_TYPE_SPECIAL; 628 625 spin_unlock_irq(host->host_lock); 626 + rq->ref_count++; 629 627 memcpy(rq->cmd, pc->c, 12); 630 628 blk_execute_rq_nowait(drive->queue, scsi->disk, rq, 0, NULL); 631 629 spin_lock_irq(host->host_lock); 632 630 return 0; 633 631 abort: 634 632 kfree (pc); 635 - kfree (rq); 633 + if (rq) 634 + blk_put_request(rq); 636 635 cmd->result = DID_ERROR << 16; 637 636 done(cmd); 638 637 return 0; ··· 681 678 682 679 if (blk_sense_request(scsi->pc->rq)) 683 680 kfree(scsi->pc->buf); 684 - kfree(scsi->pc->rq); 681 + /* we need to call blk_put_request twice. */ 682 + blk_put_request(scsi->pc->rq); 683 + blk_put_request(scsi->pc->rq); 685 684 kfree(scsi->pc); 686 685 scsi->pc = NULL; 687 686 ··· 735 730 kfree(scsi->pc->buf); 736 731 kfree(scsi->pc); 737 732 scsi->pc = NULL; 738 - kfree(req); 733 + blk_put_request(req); 739 734 740 735 /* now nuke the drive queue */ 741 736 while ((req = elv_next_request(drive->queue))) {