diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-24 18:22:44 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-03-24 18:22:44 -0400 |
commit | 1bc6daae4aba9194f8ff6801af8367a1a4718965 (patch) | |
tree | a2b2023bb19555658b940dd046330061f0f6a7fe /drivers | |
parent | 1866082339597930c5b77aad8de34ab4fbb5724f (diff) |
ide: factor out processing of special commands from ide_special_rq()
Factor out processing of special commands from ide_special_rq()
to ide_do_devset() and ide_do_park_unpark().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ide/ide-io.c | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 56be3375bee..c37883ae266 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c | |||
@@ -514,46 +514,53 @@ int ide_devset_execute(ide_drive_t *drive, const struct ide_devset *setting, | |||
514 | return ret; | 514 | return ret; |
515 | } | 515 | } |
516 | 516 | ||
517 | static ide_startstop_t ide_do_devset(ide_drive_t *drive, struct request *rq) | ||
518 | { | ||
519 | int err, (*setfunc)(ide_drive_t *, int) = rq->special; | ||
520 | |||
521 | err = setfunc(drive, *(int *)&rq->cmd[1]); | ||
522 | if (err) | ||
523 | rq->errors = err; | ||
524 | else | ||
525 | err = 1; | ||
526 | ide_end_request(drive, err, 0); | ||
527 | return ide_stopped; | ||
528 | } | ||
529 | |||
530 | static ide_startstop_t ide_do_park_unpark(ide_drive_t *drive, struct request *rq) | ||
531 | { | ||
532 | ide_task_t task; | ||
533 | struct ide_taskfile *tf = &task.tf; | ||
534 | |||
535 | memset(&task, 0, sizeof(task)); | ||
536 | if (rq->cmd[0] == REQ_PARK_HEADS) { | ||
537 | drive->sleep = *(unsigned long *)rq->special; | ||
538 | drive->dev_flags |= IDE_DFLAG_SLEEPING; | ||
539 | tf->command = ATA_CMD_IDLEIMMEDIATE; | ||
540 | tf->feature = 0x44; | ||
541 | tf->lbal = 0x4c; | ||
542 | tf->lbam = 0x4e; | ||
543 | tf->lbah = 0x55; | ||
544 | task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER; | ||
545 | } else /* cmd == REQ_UNPARK_HEADS */ | ||
546 | tf->command = ATA_CMD_CHK_POWER; | ||
547 | |||
548 | task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
549 | task.rq = rq; | ||
550 | drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA; | ||
551 | return do_rw_taskfile(drive, &task); | ||
552 | } | ||
553 | |||
517 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) | 554 | static ide_startstop_t ide_special_rq(ide_drive_t *drive, struct request *rq) |
518 | { | 555 | { |
519 | u8 cmd = rq->cmd[0]; | 556 | u8 cmd = rq->cmd[0]; |
520 | 557 | ||
521 | if (cmd == REQ_PARK_HEADS || cmd == REQ_UNPARK_HEADS) { | ||
522 | ide_task_t task; | ||
523 | struct ide_taskfile *tf = &task.tf; | ||
524 | |||
525 | memset(&task, 0, sizeof(task)); | ||
526 | if (cmd == REQ_PARK_HEADS) { | ||
527 | drive->sleep = *(unsigned long *)rq->special; | ||
528 | drive->dev_flags |= IDE_DFLAG_SLEEPING; | ||
529 | tf->command = ATA_CMD_IDLEIMMEDIATE; | ||
530 | tf->feature = 0x44; | ||
531 | tf->lbal = 0x4c; | ||
532 | tf->lbam = 0x4e; | ||
533 | tf->lbah = 0x55; | ||
534 | task.tf_flags |= IDE_TFLAG_CUSTOM_HANDLER; | ||
535 | } else /* cmd == REQ_UNPARK_HEADS */ | ||
536 | tf->command = ATA_CMD_CHK_POWER; | ||
537 | |||
538 | task.tf_flags |= IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
539 | task.rq = rq; | ||
540 | drive->hwif->data_phase = task.data_phase = TASKFILE_NO_DATA; | ||
541 | return do_rw_taskfile(drive, &task); | ||
542 | } | ||
543 | |||
544 | switch (cmd) { | 558 | switch (cmd) { |
559 | case REQ_PARK_HEADS: | ||
560 | case REQ_UNPARK_HEADS: | ||
561 | return ide_do_park_unpark(drive, rq); | ||
545 | case REQ_DEVSET_EXEC: | 562 | case REQ_DEVSET_EXEC: |
546 | { | 563 | return ide_do_devset(drive, rq); |
547 | int err, (*setfunc)(ide_drive_t *, int) = rq->special; | ||
548 | |||
549 | err = setfunc(drive, *(int *)&rq->cmd[1]); | ||
550 | if (err) | ||
551 | rq->errors = err; | ||
552 | else | ||
553 | err = 1; | ||
554 | ide_end_request(drive, err, 0); | ||
555 | return ide_stopped; | ||
556 | } | ||
557 | case REQ_DRIVE_RESET: | 564 | case REQ_DRIVE_RESET: |
558 | return ide_do_reset(drive); | 565 | return ide_do_reset(drive); |
559 | default: | 566 | default: |