diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:36 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-13 15:39:36 -0400 |
commit | be3c096ebdbe3c828aacb5473751a22840753eff (patch) | |
tree | 941bca77404c00cd02211b4ba53ff532ae24a73c | |
parent | 35c137531245118962eb40a550661afe317bec03 (diff) |
ide-disk: add ide_do_setfeature() helper
Add ide_do_setfeature() helper and convert set_{wcache,acoustic}()
to use it.
There should be no functional changes caused by this patch.
Acked-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
-rw-r--r-- | drivers/ide/ide-disk.c | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c index 65c499aab664..7ea075299bd9 100644 --- a/drivers/ide/ide-disk.c +++ b/drivers/ide/ide-disk.c | |||
@@ -580,6 +580,19 @@ static int set_nowerr(ide_drive_t *drive, int arg) | |||
580 | return 0; | 580 | return 0; |
581 | } | 581 | } |
582 | 582 | ||
583 | static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect) | ||
584 | { | ||
585 | ide_task_t task; | ||
586 | |||
587 | memset(&task, 0, sizeof(task)); | ||
588 | task.tf.feature = feature; | ||
589 | task.tf.nsect = nsect; | ||
590 | task.tf.command = ATA_CMD_SET_FEATURES; | ||
591 | task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
592 | |||
593 | return ide_no_data_taskfile(drive, &task); | ||
594 | } | ||
595 | |||
583 | static void update_ordered(ide_drive_t *drive) | 596 | static void update_ordered(ide_drive_t *drive) |
584 | { | 597 | { |
585 | u16 *id = drive->id; | 598 | u16 *id = drive->id; |
@@ -619,19 +632,14 @@ ide_devset_get(wcache, wcache); | |||
619 | 632 | ||
620 | static int set_wcache(ide_drive_t *drive, int arg) | 633 | static int set_wcache(ide_drive_t *drive, int arg) |
621 | { | 634 | { |
622 | ide_task_t args; | ||
623 | int err = 1; | 635 | int err = 1; |
624 | 636 | ||
625 | if (arg < 0 || arg > 1) | 637 | if (arg < 0 || arg > 1) |
626 | return -EINVAL; | 638 | return -EINVAL; |
627 | 639 | ||
628 | if (ata_id_flush_enabled(drive->id)) { | 640 | if (ata_id_flush_enabled(drive->id)) { |
629 | memset(&args, 0, sizeof(ide_task_t)); | 641 | err = ide_do_setfeature(drive, |
630 | args.tf.feature = arg ? | 642 | arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0); |
631 | SETFEATURES_WC_ON : SETFEATURES_WC_OFF; | ||
632 | args.tf.command = ATA_CMD_SET_FEATURES; | ||
633 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
634 | err = ide_no_data_taskfile(drive, &args); | ||
635 | if (err == 0) | 643 | if (err == 0) |
636 | drive->wcache = arg; | 644 | drive->wcache = arg; |
637 | } | 645 | } |
@@ -658,18 +666,14 @@ ide_devset_get(acoustic, acoustic); | |||
658 | 666 | ||
659 | static int set_acoustic(ide_drive_t *drive, int arg) | 667 | static int set_acoustic(ide_drive_t *drive, int arg) |
660 | { | 668 | { |
661 | ide_task_t args; | ||
662 | |||
663 | if (arg < 0 || arg > 254) | 669 | if (arg < 0 || arg > 254) |
664 | return -EINVAL; | 670 | return -EINVAL; |
665 | 671 | ||
666 | memset(&args, 0, sizeof(ide_task_t)); | 672 | ide_do_setfeature(drive, |
667 | args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF; | 673 | arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF, arg); |
668 | args.tf.nsect = arg; | 674 | |
669 | args.tf.command = ATA_CMD_SET_FEATURES; | ||
670 | args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE; | ||
671 | ide_no_data_taskfile(drive, &args); | ||
672 | drive->acoustic = arg; | 675 | drive->acoustic = arg; |
676 | |||
673 | return 0; | 677 | return 0; |
674 | } | 678 | } |
675 | 679 | ||