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