diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:28 -0400 |
---|---|---|
committer | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2008-10-10 16:39:28 -0400 |
commit | 8185d5aa93e0a5c111adc4952a5b87193a68ae5b (patch) | |
tree | 431aeb09a448b7b07a353e12f4fe931ebb8555cd /drivers/ide/ide-disk.c | |
parent | 263138a0ad6e38de7f6526b7de037ed4511308ef (diff) |
ide: /proc/ide/hd*/settings rework
* Add struct ide_devset, S_* flags, *DEVSET() & ide*_devset_*() macros.
* Add 'const struct ide_devset **settings' to ide_driver_t.
* Use 'const struct ide_devset **settings' in ide_drive_t instead of
'struct ide_settings_s *settings'. Then convert core code and device
drivers to use struct ide_devset and co.:
- device settings are no longer allocated dynamically for each device
but instead there is an unique struct ide_devset instance per setting
- device driver keeps the pointer to the table of pointers to its
settings in ide_driver_t.settings
- generic settings are kept in ide_generic_setting[]
- ide_proc_[un]register_driver(), ide_find_setting_by_name(),
ide_{read,write}_setting() and proc_ide_{read,write}_settings()
are updated accordingly
- ide*_add_settings() are removed
* Remove no longer used __ide_add_setting(), ide_add_setting(),
__ide_remove_setting() and auto_remove_settings().
* Remove no longer used TYPE_*, SETTING_*, ide_procset_t
and ide_settings_t.
* ->keep_settings, ->using_dma, ->unmask, ->noflush, ->dsc_overlap,
->nice1, ->addressing, ->wcache and ->nowerr ide_drive_t fields
can now be bitfield flags.
While at it:
* Rename ide_find_setting_by_name() to ide_find_setting().
* Rename write_wcache() to set_wcache().
There should be no functional changes caused by this patch.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Diffstat (limited to 'drivers/ide/ide-disk.c')
-rw-r--r-- | drivers/ide/ide-disk.c | 87 |
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 | ||
602 | ide_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 | ||
630 | ide_devset_get(nowerr, nowerr); | ||
631 | |||
628 | static int set_nowerr(ide_drive_t *drive, int arg) | 632 | static 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 | ||
676 | static int write_cache(ide_drive_t *drive, int arg) | 680 | ide_devset_get(wcache, wcache); |
681 | |||
682 | static 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 | ||
719 | ide_devset_get(acoustic, acoustic); | ||
720 | |||
713 | static int set_acoustic(ide_drive_t *drive, int arg) | 721 | static 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 | ||
738 | ide_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 |
753 | static void idedisk_add_settings(ide_drive_t *drive) | 763 | ide_devset_rw_nolock(acoustic, 0, 254, acoustic); |
754 | { | 764 | ide_devset_rw_nolock(address, 0, 2, lba_addressing); |
755 | ide_add_setting(drive, "bios_cyl", SETTING_RW, TYPE_INT, 0, 65535, 1, 1, | 765 | ide_devset_rw_nolock(multcount, 0, 16, multcount); |
756 | &drive->bios_cyl, NULL); | 766 | ide_devset_rw_nolock(nowerr, 0, 1, nowerr); |
757 | ide_add_setting(drive, "bios_head", SETTING_RW, TYPE_BYTE, 0, 255, 1, 1, | 767 | ide_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, | 769 | ide_devset_rw(bios_cyl, 0, 65535, bios_cyl); |
760 | &drive->bios_sect, NULL); | 770 | ide_devset_rw(bios_head, 0, 255, bios_head); |
761 | ide_add_setting(drive, "address", SETTING_RW, TYPE_BYTE, 0, 2, 1, 1, | 771 | ide_devset_rw(bios_sect, 0, 63, bios_sect); |
762 | &drive->addressing, set_lba_addressing); | 772 | ide_devset_rw(failures, 0, 65535, failures); |
763 | ide_add_setting(drive, "multcount", SETTING_RW, TYPE_BYTE, 0, 16, 1, 1, | 773 | ide_devset_rw(lun, 0, 7, lun); |
764 | &drive->mult_count, set_multcount); | 774 | ide_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); | 776 | static 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 |
779 | static inline void idedisk_add_settings(ide_drive_t *drive) { ; } | 789 | }; |
780 | #endif | 790 | #endif |
781 | 791 | ||
782 | static void idedisk_setup(ide_drive_t *drive) | 792 | static 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 | ||
886 | static void ide_cacheflush_p(ide_drive_t *drive) | 895 | static 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, | |||
1077 | read_val: | 1086 | read_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; |