Skip to content

Commit be3c096

Browse files
committed
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>
1 parent 35c1375 commit be3c096

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

‎drivers/ide/ide-disk.c‎

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -580,6 +580,19 @@ static int set_nowerr(ide_drive_t *drive, int arg)
580580
return 0;
581581
}
582582

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+
583596
static void update_ordered(ide_drive_t *drive)
584597
{
585598
u16 *id = drive->id;
@@ -619,19 +632,14 @@ ide_devset_get(wcache, wcache);
619632

620633
static int set_wcache(ide_drive_t *drive, int arg)
621634
{
622-
ide_task_t args;
623635
int err = 1;
624636

625637
if (arg < 0 || arg > 1)
626638
return -EINVAL;
627639

628640
if (ata_id_flush_enabled(drive->id)) {
629-
memset(&args, 0, sizeof(ide_task_t));
630-
args.tf.feature = arg ?
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);
641+
err = ide_do_setfeature(drive,
642+
arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0);
635643
if (err == 0)
636644
drive->wcache = arg;
637645
}
@@ -658,18 +666,14 @@ ide_devset_get(acoustic, acoustic);
658666

659667
static int set_acoustic(ide_drive_t *drive, int arg)
660668
{
661-
ide_task_t args;
662-
663669
if (arg < 0 || arg > 254)
664670
return -EINVAL;
665671

666-
memset(&args, 0, sizeof(ide_task_t));
667-
args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF;
668-
args.tf.nsect = arg;
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+
ide_do_setfeature(drive,
673+
arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF, arg);
674+
672675
drive->acoustic = arg;
676+
673677
return 0;
674678
}
675679

0 commit comments

Comments
 (0)