aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:37 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2007-10-19 18:32:37 -0400
commit43e7c0c4bfdf750d956b4b5a617395d859f20353 (patch)
tree66063b5e90c8199c8859069c0d6d11cf62e57a4c /drivers/ide
parent892470b26c3f24c0955bd1bd120a5397b8caeb53 (diff)
ide-disk: add get_smart_data() helper
Merge get_smart_values() and get_smart_thresholds() into get_smart_data() helper. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide')
-rw-r--r--drivers/ide/ide-disk.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 2722d9165b6b..00123d99527a 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -593,28 +593,12 @@ static int smart_enable(ide_drive_t *drive)
593 return ide_raw_taskfile(drive, &args, NULL); 593 return ide_raw_taskfile(drive, &args, NULL);
594} 594}
595 595
596static int get_smart_values(ide_drive_t *drive, u8 *buf) 596static int get_smart_data(ide_drive_t *drive, u8 *buf, u8 sub_cmd)
597{ 597{
598 ide_task_t args; 598 ide_task_t args;
599 599
600 memset(&args, 0, sizeof(ide_task_t)); 600 memset(&args, 0, sizeof(ide_task_t));
601 args.tfRegister[IDE_FEATURE_OFFSET] = SMART_READ_VALUES; 601 args.tfRegister[IDE_FEATURE_OFFSET] = sub_cmd;
602 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01;
603 args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS;
604 args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS;
605 args.tfRegister[IDE_COMMAND_OFFSET] = WIN_SMART;
606 args.command_type = IDE_DRIVE_TASK_IN;
607 args.data_phase = TASKFILE_IN;
608 args.handler = &task_in_intr;
609 (void) smart_enable(drive);
610 return ide_raw_taskfile(drive, &args, buf);
611}
612
613static int get_smart_thresholds(ide_drive_t *drive, u8 *buf)
614{
615 ide_task_t args;
616 memset(&args, 0, sizeof(ide_task_t));
617 args.tfRegister[IDE_FEATURE_OFFSET] = SMART_READ_THRESHOLDS;
618 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01; 602 args.tfRegister[IDE_NSECTOR_OFFSET] = 0x01;
619 args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS; 603 args.tfRegister[IDE_LCYL_OFFSET] = SMART_LCYL_PASS;
620 args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS; 604 args.tfRegister[IDE_HCYL_OFFSET] = SMART_HCYL_PASS;
@@ -656,7 +640,7 @@ static int proc_idedisk_read_smart_thresholds
656 ide_drive_t *drive = (ide_drive_t *)data; 640 ide_drive_t *drive = (ide_drive_t *)data;
657 int len = 0, i = 0; 641 int len = 0, i = 0;
658 642
659 if (!get_smart_thresholds(drive, page)) { 643 if (get_smart_data(drive, page, SMART_READ_THRESHOLDS) == 0) {
660 unsigned short *val = (unsigned short *) page; 644 unsigned short *val = (unsigned short *) page;
661 char *out = ((char *)val) + (SECTOR_WORDS * 4); 645 char *out = ((char *)val) + (SECTOR_WORDS * 4);
662 page = out; 646 page = out;
@@ -675,7 +659,7 @@ static int proc_idedisk_read_smart_values
675 ide_drive_t *drive = (ide_drive_t *)data; 659 ide_drive_t *drive = (ide_drive_t *)data;
676 int len = 0, i = 0; 660 int len = 0, i = 0;
677 661
678 if (!get_smart_values(drive, page)) { 662 if (get_smart_data(drive, page, SMART_READ_VALUES) == 0) {
679 unsigned short *val = (unsigned short *) page; 663 unsigned short *val = (unsigned short *) page;
680 char *out = ((char *)val) + (SECTOR_WORDS * 4); 664 char *out = ((char *)val) + (SECTOR_WORDS * 4);
681 page = out; 665 page = out;