aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-disk.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r--drivers/ide/ide-disk.c87
1 files changed, 48 insertions, 39 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index 7a15907dce1d..2e43ae15fb1b 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -599,6 +599,8 @@ static void idedisk_prepare_flush(struct request_queue *q, struct request *rq)
599 rq->special = task; 599 rq->special = task;
600} 600}
601 601
602ide_devset_get(multcount, mult_count);
603
602/* 604/*
603 * This is tightly woven into the driver->do_special can not touch. 605 * This is tightly woven into the driver->do_special can not touch.
604 * DON'T do it again until a total personality rewrite is committed. 606 * DON'T do it again until a total personality rewrite is committed.
@@ -625,6 +627,8 @@ static int set_multcount(ide_drive_t *drive, int arg)
625 return (drive->mult_count == arg) ? 0 : -EIO; 627 return (drive->mult_count == arg) ? 0 : -EIO;
626} 628}
627 629
630ide_devset_get(nowerr, nowerr);
631
628static int set_nowerr(ide_drive_t *drive, int arg) 632static int set_nowerr(ide_drive_t *drive, int arg)
629{ 633{
630 if (arg < 0 || arg > 1) 634 if (arg < 0 || arg > 1)
@@ -673,7 +677,9 @@ static void update_ordered(ide_drive_t *drive)
673 blk_queue_ordered(drive->queue, ordered, prep_fn); 677 blk_queue_ordered(drive->queue, ordered, prep_fn);
674} 678}
675 679
676static int write_cache(ide_drive_t *drive, int arg) 680ide_devset_get(wcache, wcache);
681
682static int set_wcache(ide_drive_t *drive, int arg)
677{ 683{
678 ide_task_t args; 684 ide_task_t args;
679 int err = 1; 685 int err = 1;
@@ -710,6 +716,8 @@ static int do_idedisk_flushcache(ide_drive_t *drive)
710 return ide_no_data_taskfile(drive, &args); 716 return ide_no_data_taskfile(drive, &args);
711} 717}
712 718
719ide_devset_get(acoustic, acoustic);
720
713static int set_acoustic(ide_drive_t *drive, int arg) 721static int set_acoustic(ide_drive_t *drive, int arg)
714{ 722{
715 ide_task_t args; 723 ide_task_t args;
@@ -727,6 +735,8 @@ static int set_acoustic(ide_drive_t *drive, int arg)
727 return 0; 735 return 0;
728} 736}
729 737
738ide_devset_get(lba_addressing, addressing);
739
730/* 740/*
731 * drive->addressing: 741 * drive->addressing:
732 * 0: 28-bit 742 * 0: 28-bit
@@ -750,33 +760,33 @@ static int set_lba_addressing(ide_drive_t *drive, int arg)
750} 760}
751 761
752#ifdef CONFIG_IDE_PROC_FS 762#ifdef CONFIG_IDE_PROC_FS
753static void idedisk_add_settings(ide_drive_t *drive) 763ide_devset_rw_nolock(acoustic, 0, 254, acoustic);
754{ 764ide_devset_rw_nolock(address, 0, 2, lba_addressing);
755 ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, 765ide_devset_rw_nolock(multcount, 0, 16, multcount);
756 &drive->bios_cyl, NULL); 766ide_devset_rw_nolock(nowerr, 0, 1, nowerr);
757 ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, 767ide_devset_rw_nolock(wcache, 0, 1, wcache);
758 &drive->bios_head, NULL); 768
759 ide_add_setting(drive, "bios_sect", SETTING_RW, TYPE_BYTE, 0, 63, 1, 1, 769ide_devset_rw(bios_cyl, 0, 65535, bios_cyl);
760 &drive->bios_sect, NULL); 770ide_devset_rw(bios_head, 0, 255, bios_head);
761 ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, 771ide_devset_rw(bios_sect, 0, 63, bios_sect);
762 &drive->addressing, set_lba_addressing); 772ide_devset_rw(failures, 0, 65535, failures);
763 ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, 16, 1, 1, 773ide_devset_rw(lun, 0, 7, lun);
764 &drive->mult_count, set_multcount); 774ide_devset_rw(max_failures, 0, 65535, max_failures);
765 ide_add_setting(drive, "nowerr", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, 775
766 &drive->nowerr, set_nowerr); 776static const struct ide_devset *idedisk_settings[] = {
767 ide_add_setting(drive, "lun", SETTING_RW, TYPE_INT, 0, 7, 1, 1, 777 &ide_devset_acoustic,
768 &drive->lun, NULL); 778 &ide_devset_address,
769 ide_add_setting(drive, "wcache", SETTING_RW, TYPE_BYTE, 0, 1, 1, 1, 779 &ide_devset_bios_cyl,
770 &drive->wcache, write_cache); 780 &ide_devset_bios_head,
771 ide_add_setting(drive, "acoustic", SETTING_RW, TYPE_BYTE, 0, 254, 1, 1, 781 &ide_devset_bios_sect,
772 &drive->acoustic, set_acoustic); 782 &ide_devset_failures,
773 ide_add_setting(drive, "failures", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, 783 &ide_devset_lun,
774 &drive->failures, NULL); 784 &ide_devset_max_failures,
775 ide_add_setting(drive, "max_failures", SETTING_RW, TYPE_INT, 0, 65535, 785 &ide_devset_multcount,
776 1, 1, &drive->max_failures, NULL); 786 &ide_devset_nowerr,
777} 787 &ide_devset_wcache,
778#else 788 NULL
779static inline void idedisk_add_settings(ide_drive_t *drive) { ; } 789};
780#endif 790#endif
781 791
782static void idedisk_setup(ide_drive_t *drive) 792static void idedisk_setup(ide_drive_t *drive)
@@ -788,7 +798,6 @@ static void idedisk_setup(ide_drive_t *drive)
788 unsigned long long capacity; 798 unsigned long long capacity;
789 799
790 ide_proc_register_driver(drive, idkp->driver); 800 ide_proc_register_driver(drive, idkp->driver);
791 idedisk_add_settings(drive);
792 801
793 if (drive->id_read == 0) 802 if (drive->id_read == 0)
794 return; 803 return;
@@ -880,7 +889,7 @@ static void idedisk_setup(ide_drive_t *drive)
880 if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id)) 889 if ((id[ATA_ID_CSFO] & 1) || ata_id_wcache_enabled(id))
881 drive->wcache = 1; 890 drive->wcache = 1;
882 891
883 write_cache(drive, 1); 892 set_wcache(drive, 1);
884} 893}
885 894
886static void ide_cacheflush_p(ide_drive_t *drive) 895static void ide_cacheflush_p(ide_drive_t *drive)
@@ -976,6 +985,7 @@ static ide_driver_t idedisk_driver = {
976 .error = __ide_error, 985 .error = __ide_error,
977#ifdef CONFIG_IDE_PROC_FS 986#ifdef CONFIG_IDE_PROC_FS
978 .proc = idedisk_proc, 987 .proc = idedisk_proc,
988 .settings = idedisk_settings,
979#endif 989#endif
980}; 990};
981 991
@@ -1056,19 +1066,18 @@ static int idedisk_ioctl(struct inode *inode, struct file *file,
1056 struct block_device *bdev = inode->i_bdev; 1066 struct block_device *bdev = inode->i_bdev;
1057 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk); 1067 struct ide_disk_obj *idkp = ide_disk_g(bdev->bd_disk);
1058 ide_drive_t *drive = idkp->drive; 1068 ide_drive_t *drive = idkp->drive;
1059 int err, (*setfunc)(ide_drive_t *, int); 1069 int err, (*getfunc)(ide_drive_t *), (*setfunc)(ide_drive_t *, int);
1060 u8 *val;
1061 1070
1062 switch (cmd) { 1071 switch (cmd) {
1063 case HDIO_GET_ADDRESS: val = &drive->addressing; goto read_val; 1072 case HDIO_GET_ADDRESS: getfunc = get_lba_addressing; goto read_val;
1064 case HDIO_GET_MULTCOUNT: val = &drive->mult_count; goto read_val; 1073 case HDIO_GET_MULTCOUNT: getfunc = get_multcount; goto read_val;
1065 case HDIO_GET_NOWERR: val = &drive->nowerr; goto read_val; 1074 case HDIO_GET_NOWERR: getfunc = get_nowerr; goto read_val;
1066 case HDIO_GET_WCACHE: val = &drive->wcache; goto read_val; 1075 case HDIO_GET_WCACHE: getfunc = get_wcache; goto read_val;
1067 case HDIO_GET_ACOUSTIC: val = &drive->acoustic; goto read_val; 1076 case HDIO_GET_ACOUSTIC: getfunc = get_acoustic; goto read_val;
1068 case HDIO_SET_ADDRESS: setfunc = set_lba_addressing; goto set_val; 1077 case HDIO_SET_ADDRESS: setfunc = set_lba_addressing; goto set_val;
1069 case HDIO_SET_MULTCOUNT: setfunc = set_multcount; goto set_val; 1078 case HDIO_SET_MULTCOUNT: setfunc = set_multcount; goto set_val;
1070 case HDIO_SET_NOWERR: setfunc = set_nowerr; goto set_val; 1079 case HDIO_SET_NOWERR: setfunc = set_nowerr; goto set_val;
1071 case HDIO_SET_WCACHE: setfunc = write_cache; goto set_val; 1080 case HDIO_SET_WCACHE: setfunc = set_wcache; goto set_val;
1072 case HDIO_SET_ACOUSTIC: setfunc = set_acoustic; goto set_val; 1081 case HDIO_SET_ACOUSTIC: setfunc = set_acoustic; goto set_val;
1073 } 1082 }
1074 1083
@@ -1077,7 +1086,7 @@ static int idedisk_ioctl(struct inode *inode, struct file *file,
1077read_val: 1086read_val:
1078 mutex_lock(&ide_setting_mtx); 1087 mutex_lock(&ide_setting_mtx);
1079 spin_lock_irqsave(&ide_lock, flags); 1088 spin_lock_irqsave(&ide_lock, flags);
1080 err = *val; 1089 err = getfunc(drive);
1081 spin_unlock_irqrestore(&ide_lock, flags); 1090 spin_unlock_irqrestore(&ide_lock, flags);
1082 mutex_unlock(&ide_setting_mtx); 1091 mutex_unlock(&ide_setting_mtx);
1083 return err >= 0 ? put_user(err, (long __user *)arg) : err; 1092 return err >= 0 ? put_user(err, (long __user *)arg) : err;