diff options
author | Jens Axboe <axboe@suse.de> | 2006-08-10 02:44:47 -0400 |
---|---|---|
committer | Jens Axboe <axboe@nelson.home.kernel.dk> | 2006-09-30 14:23:37 -0400 |
commit | 4aff5e2333c9a1609662f2091f55c3f6fffdad36 (patch) | |
tree | b73d8c2b7c1bdc03d3313c108da7dfc95ee95525 /drivers/ide/ide-cd.c | |
parent | 77ed74da26f50fa28471571ee7a2251b77526d84 (diff) |
[PATCH] Split struct request ->flags into two parts
Right now ->flags is a bit of a mess: some are request types, and
others are just modifiers. Clean this up by splitting it into
->cmd_type and ->cmd_flags. This allows introduction of generic
Linux block message types, useful for sending generic Linux commands
to block devices.
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'drivers/ide/ide-cd.c')
-rw-r--r-- | drivers/ide/ide-cd.c | 69 |
1 files changed, 35 insertions, 34 deletions
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c index 654d4cd09847..69bbb6206a00 100644 --- a/drivers/ide/ide-cd.c +++ b/drivers/ide/ide-cd.c | |||
@@ -372,7 +372,7 @@ static int cdrom_log_sense(ide_drive_t *drive, struct request *rq, | |||
372 | { | 372 | { |
373 | int log = 0; | 373 | int log = 0; |
374 | 374 | ||
375 | if (!sense || !rq || (rq->flags & REQ_QUIET)) | 375 | if (!sense || !rq || (rq->cmd_flags & REQ_QUIET)) |
376 | return 0; | 376 | return 0; |
377 | 377 | ||
378 | switch (sense->sense_key) { | 378 | switch (sense->sense_key) { |
@@ -597,7 +597,7 @@ static void cdrom_prepare_request(ide_drive_t *drive, struct request *rq) | |||
597 | struct cdrom_info *cd = drive->driver_data; | 597 | struct cdrom_info *cd = drive->driver_data; |
598 | 598 | ||
599 | ide_init_drive_cmd(rq); | 599 | ide_init_drive_cmd(rq); |
600 | rq->flags = REQ_PC; | 600 | rq->cmd_type = REQ_TYPE_BLOCK_PC; |
601 | rq->rq_disk = cd->disk; | 601 | rq->rq_disk = cd->disk; |
602 | } | 602 | } |
603 | 603 | ||
@@ -617,7 +617,7 @@ static void cdrom_queue_request_sense(ide_drive_t *drive, void *sense, | |||
617 | rq->cmd[0] = GPCMD_REQUEST_SENSE; | 617 | rq->cmd[0] = GPCMD_REQUEST_SENSE; |
618 | rq->cmd[4] = rq->data_len = 18; | 618 | rq->cmd[4] = rq->data_len = 18; |
619 | 619 | ||
620 | rq->flags = REQ_SENSE; | 620 | rq->cmd_type = REQ_TYPE_SENSE; |
621 | 621 | ||
622 | /* NOTE! Save the failed command in "rq->buffer" */ | 622 | /* NOTE! Save the failed command in "rq->buffer" */ |
623 | rq->buffer = (void *) failed_command; | 623 | rq->buffer = (void *) failed_command; |
@@ -630,10 +630,10 @@ static void cdrom_end_request (ide_drive_t *drive, int uptodate) | |||
630 | struct request *rq = HWGROUP(drive)->rq; | 630 | struct request *rq = HWGROUP(drive)->rq; |
631 | int nsectors = rq->hard_cur_sectors; | 631 | int nsectors = rq->hard_cur_sectors; |
632 | 632 | ||
633 | if ((rq->flags & REQ_SENSE) && uptodate) { | 633 | if (blk_sense_request(rq) && uptodate) { |
634 | /* | 634 | /* |
635 | * For REQ_SENSE, "rq->buffer" points to the original failed | 635 | * For REQ_TYPE_SENSE, "rq->buffer" points to the original |
636 | * request | 636 | * failed request |
637 | */ | 637 | */ |
638 | struct request *failed = (struct request *) rq->buffer; | 638 | struct request *failed = (struct request *) rq->buffer; |
639 | struct cdrom_info *info = drive->driver_data; | 639 | struct cdrom_info *info = drive->driver_data; |
@@ -706,17 +706,17 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
706 | return 1; | 706 | return 1; |
707 | } | 707 | } |
708 | 708 | ||
709 | if (rq->flags & REQ_SENSE) { | 709 | if (blk_sense_request(rq)) { |
710 | /* We got an error trying to get sense info | 710 | /* We got an error trying to get sense info |
711 | from the drive (probably while trying | 711 | from the drive (probably while trying |
712 | to recover from a former error). Just give up. */ | 712 | to recover from a former error). Just give up. */ |
713 | 713 | ||
714 | rq->flags |= REQ_FAILED; | 714 | rq->cmd_flags |= REQ_FAILED; |
715 | cdrom_end_request(drive, 0); | 715 | cdrom_end_request(drive, 0); |
716 | ide_error(drive, "request sense failure", stat); | 716 | ide_error(drive, "request sense failure", stat); |
717 | return 1; | 717 | return 1; |
718 | 718 | ||
719 | } else if (rq->flags & (REQ_PC | REQ_BLOCK_PC)) { | 719 | } else if (blk_pc_request(rq)) { |
720 | /* All other functions, except for READ. */ | 720 | /* All other functions, except for READ. */ |
721 | unsigned long flags; | 721 | unsigned long flags; |
722 | 722 | ||
@@ -724,7 +724,7 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
724 | * if we have an error, pass back CHECK_CONDITION as the | 724 | * if we have an error, pass back CHECK_CONDITION as the |
725 | * scsi status byte | 725 | * scsi status byte |
726 | */ | 726 | */ |
727 | if ((rq->flags & REQ_BLOCK_PC) && !rq->errors) | 727 | if (!rq->errors) |
728 | rq->errors = SAM_STAT_CHECK_CONDITION; | 728 | rq->errors = SAM_STAT_CHECK_CONDITION; |
729 | 729 | ||
730 | /* Check for tray open. */ | 730 | /* Check for tray open. */ |
@@ -735,12 +735,12 @@ static int cdrom_decode_status(ide_drive_t *drive, int good_stat, int *stat_ret) | |||
735 | cdrom_saw_media_change (drive); | 735 | cdrom_saw_media_change (drive); |
736 | /*printk("%s: media changed\n",drive->name);*/ | 736 | /*printk("%s: media changed\n",drive->name);*/ |
737 | return 0; | 737 | return 0; |
738 | } else if (!(rq->flags & REQ_QUIET)) { | 738 | } else if (!(rq->cmd_flags & REQ_QUIET)) { |
739 | /* Otherwise, print an error. */ | 739 | /* Otherwise, print an error. */ |
740 | ide_dump_status(drive, "packet command error", stat); | 740 | ide_dump_status(drive, "packet command error", stat); |
741 | } | 741 | } |
742 | 742 | ||
743 | rq->flags |= REQ_FAILED; | 743 | rq->cmd_flags |= REQ_FAILED; |
744 | 744 | ||
745 | /* | 745 | /* |
746 | * instead of playing games with moving completions around, | 746 | * instead of playing games with moving completions around, |
@@ -881,7 +881,7 @@ static int cdrom_timer_expiry(ide_drive_t *drive) | |||
881 | wait = ATAPI_WAIT_PC; | 881 | wait = ATAPI_WAIT_PC; |
882 | break; | 882 | break; |
883 | default: | 883 | default: |
884 | if (!(rq->flags & REQ_QUIET)) | 884 | if (!(rq->cmd_flags & REQ_QUIET)) |
885 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); | 885 | printk(KERN_INFO "ide-cd: cmd 0x%x timed out\n", rq->cmd[0]); |
886 | wait = 0; | 886 | wait = 0; |
887 | break; | 887 | break; |
@@ -1124,7 +1124,7 @@ static ide_startstop_t cdrom_read_intr (ide_drive_t *drive) | |||
1124 | if (rq->current_nr_sectors > 0) { | 1124 | if (rq->current_nr_sectors > 0) { |
1125 | printk (KERN_ERR "%s: cdrom_read_intr: data underrun (%d blocks)\n", | 1125 | printk (KERN_ERR "%s: cdrom_read_intr: data underrun (%d blocks)\n", |
1126 | drive->name, rq->current_nr_sectors); | 1126 | drive->name, rq->current_nr_sectors); |
1127 | rq->flags |= REQ_FAILED; | 1127 | rq->cmd_flags |= REQ_FAILED; |
1128 | cdrom_end_request(drive, 0); | 1128 | cdrom_end_request(drive, 0); |
1129 | } else | 1129 | } else |
1130 | cdrom_end_request(drive, 1); | 1130 | cdrom_end_request(drive, 1); |
@@ -1456,7 +1456,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | |||
1456 | printk ("%s: cdrom_pc_intr: data underrun %d\n", | 1456 | printk ("%s: cdrom_pc_intr: data underrun %d\n", |
1457 | drive->name, pc->buflen); | 1457 | drive->name, pc->buflen); |
1458 | */ | 1458 | */ |
1459 | rq->flags |= REQ_FAILED; | 1459 | rq->cmd_flags |= REQ_FAILED; |
1460 | cdrom_end_request(drive, 0); | 1460 | cdrom_end_request(drive, 0); |
1461 | } | 1461 | } |
1462 | return ide_stopped; | 1462 | return ide_stopped; |
@@ -1509,7 +1509,7 @@ static ide_startstop_t cdrom_pc_intr (ide_drive_t *drive) | |||
1509 | rq->data += thislen; | 1509 | rq->data += thislen; |
1510 | rq->data_len -= thislen; | 1510 | rq->data_len -= thislen; |
1511 | 1511 | ||
1512 | if (rq->flags & REQ_SENSE) | 1512 | if (blk_sense_request(rq)) |
1513 | rq->sense_len += thislen; | 1513 | rq->sense_len += thislen; |
1514 | } else { | 1514 | } else { |
1515 | confused: | 1515 | confused: |
@@ -1517,7 +1517,7 @@ confused: | |||
1517 | "appears confused (ireason = 0x%02x). " | 1517 | "appears confused (ireason = 0x%02x). " |
1518 | "Trying to recover by ending request.\n", | 1518 | "Trying to recover by ending request.\n", |
1519 | drive->name, ireason); | 1519 | drive->name, ireason); |
1520 | rq->flags |= REQ_FAILED; | 1520 | rq->cmd_flags |= REQ_FAILED; |
1521 | cdrom_end_request(drive, 0); | 1521 | cdrom_end_request(drive, 0); |
1522 | return ide_stopped; | 1522 | return ide_stopped; |
1523 | } | 1523 | } |
@@ -1546,7 +1546,7 @@ static ide_startstop_t cdrom_do_packet_command (ide_drive_t *drive) | |||
1546 | struct cdrom_info *info = drive->driver_data; | 1546 | struct cdrom_info *info = drive->driver_data; |
1547 | 1547 | ||
1548 | info->dma = 0; | 1548 | info->dma = 0; |
1549 | rq->flags &= ~REQ_FAILED; | 1549 | rq->cmd_flags &= ~REQ_FAILED; |
1550 | len = rq->data_len; | 1550 | len = rq->data_len; |
1551 | 1551 | ||
1552 | /* Start sending the command to the drive. */ | 1552 | /* Start sending the command to the drive. */ |
@@ -1558,7 +1558,7 @@ static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) | |||
1558 | { | 1558 | { |
1559 | struct request_sense sense; | 1559 | struct request_sense sense; |
1560 | int retries = 10; | 1560 | int retries = 10; |
1561 | unsigned int flags = rq->flags; | 1561 | unsigned int flags = rq->cmd_flags; |
1562 | 1562 | ||
1563 | if (rq->sense == NULL) | 1563 | if (rq->sense == NULL) |
1564 | rq->sense = &sense; | 1564 | rq->sense = &sense; |
@@ -1567,14 +1567,14 @@ static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) | |||
1567 | do { | 1567 | do { |
1568 | int error; | 1568 | int error; |
1569 | unsigned long time = jiffies; | 1569 | unsigned long time = jiffies; |
1570 | rq->flags = flags; | 1570 | rq->cmd_flags = flags; |
1571 | 1571 | ||
1572 | error = ide_do_drive_cmd(drive, rq, ide_wait); | 1572 | error = ide_do_drive_cmd(drive, rq, ide_wait); |
1573 | time = jiffies - time; | 1573 | time = jiffies - time; |
1574 | 1574 | ||
1575 | /* FIXME: we should probably abort/retry or something | 1575 | /* FIXME: we should probably abort/retry or something |
1576 | * in case of failure */ | 1576 | * in case of failure */ |
1577 | if (rq->flags & REQ_FAILED) { | 1577 | if (rq->cmd_flags & REQ_FAILED) { |
1578 | /* The request failed. Retry if it was due to a unit | 1578 | /* The request failed. Retry if it was due to a unit |
1579 | attention status | 1579 | attention status |
1580 | (usually means media was changed). */ | 1580 | (usually means media was changed). */ |
@@ -1596,10 +1596,10 @@ static int cdrom_queue_packet_command(ide_drive_t *drive, struct request *rq) | |||
1596 | } | 1596 | } |
1597 | 1597 | ||
1598 | /* End of retry loop. */ | 1598 | /* End of retry loop. */ |
1599 | } while ((rq->flags & REQ_FAILED) && retries >= 0); | 1599 | } while ((rq->cmd_flags & REQ_FAILED) && retries >= 0); |
1600 | 1600 | ||
1601 | /* Return an error if the command failed. */ | 1601 | /* Return an error if the command failed. */ |
1602 | return (rq->flags & REQ_FAILED) ? -EIO : 0; | 1602 | return (rq->cmd_flags & REQ_FAILED) ? -EIO : 0; |
1603 | } | 1603 | } |
1604 | 1604 | ||
1605 | /* | 1605 | /* |
@@ -1963,7 +1963,7 @@ static ide_startstop_t cdrom_do_block_pc(ide_drive_t *drive, struct request *rq) | |||
1963 | { | 1963 | { |
1964 | struct cdrom_info *info = drive->driver_data; | 1964 | struct cdrom_info *info = drive->driver_data; |
1965 | 1965 | ||
1966 | rq->flags |= REQ_QUIET; | 1966 | rq->cmd_flags |= REQ_QUIET; |
1967 | 1967 | ||
1968 | info->dma = 0; | 1968 | info->dma = 0; |
1969 | 1969 | ||
@@ -2023,11 +2023,11 @@ ide_do_rw_cdrom (ide_drive_t *drive, struct request *rq, sector_t block) | |||
2023 | } | 2023 | } |
2024 | info->last_block = block; | 2024 | info->last_block = block; |
2025 | return action; | 2025 | return action; |
2026 | } else if (rq->flags & (REQ_PC | REQ_SENSE)) { | 2026 | } else if (rq->cmd_type == REQ_TYPE_SENSE) { |
2027 | return cdrom_do_packet_command(drive); | 2027 | return cdrom_do_packet_command(drive); |
2028 | } else if (rq->flags & REQ_BLOCK_PC) { | 2028 | } else if (blk_pc_request(rq)) { |
2029 | return cdrom_do_block_pc(drive, rq); | 2029 | return cdrom_do_block_pc(drive, rq); |
2030 | } else if (rq->flags & REQ_SPECIAL) { | 2030 | } else if (blk_special_request(rq)) { |
2031 | /* | 2031 | /* |
2032 | * right now this can only be a reset... | 2032 | * right now this can only be a reset... |
2033 | */ | 2033 | */ |
@@ -2105,7 +2105,7 @@ static int cdrom_check_status(ide_drive_t *drive, struct request_sense *sense) | |||
2105 | 2105 | ||
2106 | req.sense = sense; | 2106 | req.sense = sense; |
2107 | req.cmd[0] = GPCMD_TEST_UNIT_READY; | 2107 | req.cmd[0] = GPCMD_TEST_UNIT_READY; |
2108 | req.flags |= REQ_QUIET; | 2108 | req.cmd_flags |= REQ_QUIET; |
2109 | 2109 | ||
2110 | #if ! STANDARD_ATAPI | 2110 | #if ! STANDARD_ATAPI |
2111 | /* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to | 2111 | /* the Sanyo 3 CD changer uses byte 7 of TEST_UNIT_READY to |
@@ -2207,7 +2207,7 @@ static int cdrom_read_capacity(ide_drive_t *drive, unsigned long *capacity, | |||
2207 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; | 2207 | req.cmd[0] = GPCMD_READ_CDVD_CAPACITY; |
2208 | req.data = (char *)&capbuf; | 2208 | req.data = (char *)&capbuf; |
2209 | req.data_len = sizeof(capbuf); | 2209 | req.data_len = sizeof(capbuf); |
2210 | req.flags |= REQ_QUIET; | 2210 | req.cmd_flags |= REQ_QUIET; |
2211 | 2211 | ||
2212 | stat = cdrom_queue_packet_command(drive, &req); | 2212 | stat = cdrom_queue_packet_command(drive, &req); |
2213 | if (stat == 0) { | 2213 | if (stat == 0) { |
@@ -2230,7 +2230,7 @@ static int cdrom_read_tocentry(ide_drive_t *drive, int trackno, int msf_flag, | |||
2230 | req.sense = sense; | 2230 | req.sense = sense; |
2231 | req.data = buf; | 2231 | req.data = buf; |
2232 | req.data_len = buflen; | 2232 | req.data_len = buflen; |
2233 | req.flags |= REQ_QUIET; | 2233 | req.cmd_flags |= REQ_QUIET; |
2234 | req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; | 2234 | req.cmd[0] = GPCMD_READ_TOC_PMA_ATIP; |
2235 | req.cmd[6] = trackno; | 2235 | req.cmd[6] = trackno; |
2236 | req.cmd[7] = (buflen >> 8); | 2236 | req.cmd[7] = (buflen >> 8); |
@@ -2531,7 +2531,7 @@ static int ide_cdrom_packet(struct cdrom_device_info *cdi, | |||
2531 | req.timeout = cgc->timeout; | 2531 | req.timeout = cgc->timeout; |
2532 | 2532 | ||
2533 | if (cgc->quiet) | 2533 | if (cgc->quiet) |
2534 | req.flags |= REQ_QUIET; | 2534 | req.cmd_flags |= REQ_QUIET; |
2535 | 2535 | ||
2536 | req.sense = cgc->sense; | 2536 | req.sense = cgc->sense; |
2537 | cgc->stat = cdrom_queue_packet_command(drive, &req); | 2537 | cgc->stat = cdrom_queue_packet_command(drive, &req); |
@@ -2629,7 +2629,8 @@ int ide_cdrom_reset (struct cdrom_device_info *cdi) | |||
2629 | int ret; | 2629 | int ret; |
2630 | 2630 | ||
2631 | cdrom_prepare_request(drive, &req); | 2631 | cdrom_prepare_request(drive, &req); |
2632 | req.flags = REQ_SPECIAL | REQ_QUIET; | 2632 | req.cmd_type = REQ_TYPE_SPECIAL; |
2633 | req.cmd_flags = REQ_QUIET; | ||
2633 | ret = ide_do_drive_cmd(drive, &req, ide_wait); | 2634 | ret = ide_do_drive_cmd(drive, &req, ide_wait); |
2634 | 2635 | ||
2635 | /* | 2636 | /* |
@@ -3116,9 +3117,9 @@ static int ide_cdrom_prep_pc(struct request *rq) | |||
3116 | 3117 | ||
3117 | static int ide_cdrom_prep_fn(request_queue_t *q, struct request *rq) | 3118 | static int ide_cdrom_prep_fn(request_queue_t *q, struct request *rq) |
3118 | { | 3119 | { |
3119 | if (rq->flags & REQ_CMD) | 3120 | if (blk_fs_request(rq)) |
3120 | return ide_cdrom_prep_fs(q, rq); | 3121 | return ide_cdrom_prep_fs(q, rq); |
3121 | else if (rq->flags & REQ_BLOCK_PC) | 3122 | else if (blk_pc_request(rq)) |
3122 | return ide_cdrom_prep_pc(rq); | 3123 | return ide_cdrom_prep_pc(rq); |
3123 | 3124 | ||
3124 | return 0; | 3125 | return 0; |