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: default avatarSergei Shtylyov <sshtylyov@ru.mvista.com>
Signed-off-by: default avatarBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
parent 35c13753
...@@ -580,6 +580,19 @@ static int set_nowerr(ide_drive_t *drive, int arg) ...@@ -580,6 +580,19 @@ static int set_nowerr(ide_drive_t *drive, int arg)
return 0; return 0;
} }
static int ide_do_setfeature(ide_drive_t *drive, u8 feature, u8 nsect)
{
ide_task_t task;
memset(&task, 0, sizeof(task));
task.tf.feature = feature;
task.tf.nsect = nsect;
task.tf.command = ATA_CMD_SET_FEATURES;
task.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
return ide_no_data_taskfile(drive, &task);
}
static void update_ordered(ide_drive_t *drive) static void update_ordered(ide_drive_t *drive)
{ {
u16 *id = drive->id; u16 *id = drive->id;
...@@ -619,19 +632,14 @@ ide_devset_get(wcache, wcache); ...@@ -619,19 +632,14 @@ ide_devset_get(wcache, wcache);
static int set_wcache(ide_drive_t *drive, int arg) static int set_wcache(ide_drive_t *drive, int arg)
{ {
ide_task_t args;
int err = 1; int err = 1;
if (arg < 0 || arg > 1) if (arg < 0 || arg > 1)
return -EINVAL; return -EINVAL;
if (ata_id_flush_enabled(drive->id)) { if (ata_id_flush_enabled(drive->id)) {
memset(&args, 0, sizeof(ide_task_t)); err = ide_do_setfeature(drive,
args.tf.feature = arg ? arg ? SETFEATURES_WC_ON : SETFEATURES_WC_OFF, 0);
SETFEATURES_WC_ON : SETFEATURES_WC_OFF;
args.tf.command = ATA_CMD_SET_FEATURES;
args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
err = ide_no_data_taskfile(drive, &args);
if (err == 0) if (err == 0)
drive->wcache = arg; drive->wcache = arg;
} }
...@@ -658,18 +666,14 @@ ide_devset_get(acoustic, acoustic); ...@@ -658,18 +666,14 @@ ide_devset_get(acoustic, acoustic);
static int set_acoustic(ide_drive_t *drive, int arg) static int set_acoustic(ide_drive_t *drive, int arg)
{ {
ide_task_t args;
if (arg < 0 || arg > 254) if (arg < 0 || arg > 254)
return -EINVAL; return -EINVAL;
memset(&args, 0, sizeof(ide_task_t)); ide_do_setfeature(drive,
args.tf.feature = arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF; arg ? SETFEATURES_AAM_ON : SETFEATURES_AAM_OFF, arg);
args.tf.nsect = arg;
args.tf.command = ATA_CMD_SET_FEATURES;
args.tf_flags = IDE_TFLAG_TF | IDE_TFLAG_DEVICE;
ide_no_data_taskfile(drive, &args);
drive->acoustic = arg; drive->acoustic = arg;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment