aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:28 -0400
committerBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2008-10-10 16:39:28 -0400
commit8185d5aa93e0a5c111adc4952a5b87193a68ae5b (patch)
tree431aeb09a448b7b07a353e12f4fe931ebb8555cd /include
parent263138a0ad6e38de7f6526b7de037ed4511308ef (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 'include')
-rw-r--r--include/linux/ide.h110
1 files changed, 74 insertions, 36 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h
index ad09e7c81ae9..4667ec8aeebb 100644
--- a/include/linux/ide.h
+++ b/include/linux/ide.h
@@ -304,8 +304,8 @@ typedef enum {
304 ide_started, /* a drive operation was started, handler was set */ 304 ide_started, /* a drive operation was started, handler was set */
305} ide_startstop_t; 305} ide_startstop_t;
306 306
307struct ide_devset;
307struct ide_driver_s; 308struct ide_driver_s;
308struct ide_settings_s;
309 309
310#ifdef CONFIG_BLK_DEV_IDEACPI 310#ifdef CONFIG_BLK_DEV_IDEACPI
311struct ide_acpi_drive_link; 311struct ide_acpi_drive_link;
@@ -384,7 +384,7 @@ struct ide_drive_s {
384 u16 *id; /* identification info */ 384 u16 *id; /* identification info */
385#ifdef CONFIG_IDE_PROC_FS 385#ifdef CONFIG_IDE_PROC_FS
386 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ 386 struct proc_dir_entry *proc; /* /proc/ide/ directory entry */
387 struct ide_settings_s *settings;/* /proc/ide/ drive settings */ 387 const struct ide_devset **settings; /* /proc/ide/ drive settings */
388#endif 388#endif
389 struct hwif_s *hwif; /* actually (ide_hwif_t *) */ 389 struct hwif_s *hwif; /* actually (ide_hwif_t *) */
390 390
@@ -396,16 +396,16 @@ struct ide_drive_s {
396 special_t special; /* special action flags */ 396 special_t special; /* special action flags */
397 select_t select; /* basic drive/head select reg value */ 397 select_t select; /* basic drive/head select reg value */
398 398
399 u8 keep_settings; /* restore settings after drive reset */
400 u8 using_dma; /* disk is using dma for read/write */
401 u8 retry_pio; /* retrying dma capable host in pio */ 399 u8 retry_pio; /* retrying dma capable host in pio */
402 u8 state; /* retry state */ 400 u8 state; /* retry state */
403 u8 waiting_for_dma; /* dma currently in progress */ 401 u8 waiting_for_dma; /* dma currently in progress */
404 u8 unmask; /* okay to unmask other irqs */
405 u8 noflush; /* don't attempt flushes */
406 u8 dsc_overlap; /* DSC overlap */
407 u8 nice1; /* give potential excess bandwidth */
408 402
403 unsigned keep_settings : 1; /* restore settings after drive reset */
404 unsigned using_dma : 1; /* disk is using dma for read/write */
405 unsigned unmask : 1; /* okay to unmask other irqs */
406 unsigned noflush : 1; /* don't attempt flushes */
407 unsigned dsc_overlap : 1; /* DSC overlap */
408 unsigned nice1 : 1; /* give potential excess bandwidth */
409 unsigned present : 1; /* drive is physically present */ 409 unsigned present : 1; /* drive is physically present */
410 unsigned dead : 1; /* device ejected hint */ 410 unsigned dead : 1; /* device ejected hint */
411 unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */ 411 unsigned id_read : 1; /* 1=id read from disk 0 = synthetic */
@@ -423,14 +423,15 @@ struct ide_drive_s {
423 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */ 423 unsigned sleeping : 1; /* 1=sleeping & sleep field valid */
424 unsigned post_reset : 1; 424 unsigned post_reset : 1;
425 unsigned udma33_warned : 1; 425 unsigned udma33_warned : 1;
426 unsigned addressing : 2; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */
427 unsigned wcache : 1; /* status of write cache */
428 unsigned nowerr : 1; /* used for ignoring ATA_DF */
426 429
427 u8 addressing; /* 0=28-bit, 1=48-bit, 2=48-bit doing 28-bit */
428 u8 quirk_list; /* considered quirky, set for a specific host */ 430 u8 quirk_list; /* considered quirky, set for a specific host */
429 u8 init_speed; /* transfer rate set at boot */ 431 u8 init_speed; /* transfer rate set at boot */
430 u8 current_speed; /* current transfer rate set */ 432 u8 current_speed; /* current transfer rate set */
431 u8 desired_speed; /* desired transfer rate set */ 433 u8 desired_speed; /* desired transfer rate set */
432 u8 dn; /* now wide spread use */ 434 u8 dn; /* now wide spread use */
433 u8 wcache; /* status of write cache */
434 u8 acoustic; /* acoustic management */ 435 u8 acoustic; /* acoustic management */
435 u8 media; /* disk, cdrom, tape, floppy, ... */ 436 u8 media; /* disk, cdrom, tape, floppy, ... */
436 u8 ready_stat; /* min status value for drive ready */ 437 u8 ready_stat; /* min status value for drive ready */
@@ -439,7 +440,6 @@ struct ide_drive_s {
439 u8 tune_req; /* requested drive tuning setting */ 440 u8 tune_req; /* requested drive tuning setting */
440 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */ 441 u8 io_32bit; /* 0=16-bit, 1=32-bit, 2/3=32bit+sync */
441 u8 bad_wstat; /* used for ignoring ATA_DF */ 442 u8 bad_wstat; /* used for ignoring ATA_DF */
442 u8 nowerr; /* used for ignoring ATA_DF */
443 u8 head; /* "real" number of heads */ 443 u8 head; /* "real" number of heads */
444 u8 sect; /* "real" sectors per track */ 444 u8 sect; /* "real" sectors per track */
445 u8 bios_head; /* BIOS/fdisk/LILO number of heads */ 445 u8 bios_head; /* BIOS/fdisk/LILO number of heads */
@@ -687,12 +687,29 @@ typedef struct ide_driver_s ide_driver_t;
687 687
688extern struct mutex ide_setting_mtx; 688extern struct mutex ide_setting_mtx;
689 689
690int get_io_32bit(ide_drive_t *);
690int set_io_32bit(ide_drive_t *, int); 691int set_io_32bit(ide_drive_t *, int);
692int get_ksettings(ide_drive_t *);
691int set_ksettings(ide_drive_t *, int); 693int set_ksettings(ide_drive_t *, int);
692int set_pio_mode(ide_drive_t *, int); 694int set_pio_mode(ide_drive_t *, int);
695int get_unmaskirq(ide_drive_t *);
693int set_unmaskirq(ide_drive_t *, int); 696int set_unmaskirq(ide_drive_t *, int);
697int get_using_dma(ide_drive_t *);
694int set_using_dma(ide_drive_t *, int); 698int set_using_dma(ide_drive_t *, int);
695 699
700#define ide_devset_get(name, field) \
701int get_##name(ide_drive_t *drive) \
702{ \
703 return drive->field; \
704}
705
706#define ide_devset_set(name, field) \
707int set_##name(ide_drive_t *drive, int arg) \
708{ \
709 drive->field = arg; \
710 return 0; \
711}
712
696/* ATAPI packet command flags */ 713/* ATAPI packet command flags */
697enum { 714enum {
698 /* set when an error is considered normal - no retry (ide-tape) */ 715 /* set when an error is considered normal - no retry (ide-tape) */
@@ -757,30 +774,53 @@ struct ide_atapi_pc {
757 * configurable drive settings 774 * configurable drive settings
758 */ 775 */
759 776
760#define TYPE_INT 0 777#define S_READ (1 << 0)
761#define TYPE_BYTE 1 778#define S_WRITE (1 << 1)
762#define TYPE_SHORT 2 779#define S_RW (S_READ | S_WRITE)
780#define S_NOLOCK (1 << 2)
763 781
764#define SETTING_READ (1 << 0) 782struct ide_devset {
765#define SETTING_WRITE (1 << 1) 783 const char *name;
766#define SETTING_RW (SETTING_READ | SETTING_WRITE) 784 unsigned int flags;
785 int min, max;
786 int (*get)(ide_drive_t *);
787 int (*set)(ide_drive_t *, int);
788 int (*mulf)(ide_drive_t *);
789 int (*divf)(ide_drive_t *);
790};
767 791
768typedef int (ide_procset_t)(ide_drive_t *, int); 792#define __DEVSET(_name, _flags, _min, _max, _get, _set, _mulf, _divf) { \
769typedef struct ide_settings_s { 793 .name = __stringify(_name), \
770 char *name; 794 .flags = _flags, \
771 int rw; 795 .min = _min, \
772 int data_type; 796 .max = _max, \
773 int min; 797 .get = _get, \
774 int max; 798 .set = _set, \
775 int mul_factor; 799 .mulf = _mulf, \
776 int div_factor; 800 .divf = _divf, \
777 void *data; 801}
778 ide_procset_t *set; 802
779 int auto_remove; 803#define __IDE_DEVSET(_name, _flags, _min, _max, _get, _set, _mulf, _divf) \
780 struct ide_settings_s *next; 804static const struct ide_devset ide_devset_##_name = \
781} ide_settings_t; 805 __DEVSET(_name, _flags, _min, _max, _get, _set, _mulf, _divf)
782 806
783int ide_add_setting(ide_drive_t *, const char *, int, int, int, int, int, int, void *, ide_procset_t *set); 807#define IDE_DEVSET(_name, _flags, _min, _max, _get, _set) \
808__IDE_DEVSET(_name, _flags, _min, _max, _get, _set, NULL, NULL)
809
810#define ide_devset_rw_nolock(_name, _min, _max, _func) \
811IDE_DEVSET(_name, S_RW | S_NOLOCK, _min, _max, get_##_func, set_##_func)
812
813#define ide_devset_w_nolock(_name, _min, _max, _func) \
814IDE_DEVSET(_name, S_WRITE | S_NOLOCK, _min, _max, NULL, set_##_func)
815
816#define ide_devset_rw(_name, _min, _max, _field) \
817static ide_devset_get(_name, _field); \
818static ide_devset_set(_name, _field); \
819IDE_DEVSET(_name, S_RW, _min, _max, get_##_name, set_##_name)
820
821#define ide_devset_r(_name, _min, _max, _field) \
822ide_devset_get(_name, _field) \
823IDE_DEVSET(_name, S_READ, _min, _max, get_##_name, NULL)
784 824
785/* 825/*
786 * /proc/ide interface 826 * /proc/ide interface
@@ -801,8 +841,6 @@ void ide_proc_unregister_port(ide_hwif_t *);
801void ide_proc_register_driver(ide_drive_t *, ide_driver_t *); 841void ide_proc_register_driver(ide_drive_t *, ide_driver_t *);
802void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *); 842void ide_proc_unregister_driver(ide_drive_t *, ide_driver_t *);
803 843
804void ide_add_generic_settings(ide_drive_t *);
805
806read_proc_t proc_ide_read_capacity; 844read_proc_t proc_ide_read_capacity;
807read_proc_t proc_ide_read_geometry; 845read_proc_t proc_ide_read_geometry;
808 846
@@ -830,7 +868,6 @@ static inline void ide_proc_unregister_device(ide_drive_t *drive) { ; }
830static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; } 868static inline void ide_proc_unregister_port(ide_hwif_t *hwif) { ; }
831static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 869static inline void ide_proc_register_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
832static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; } 870static inline void ide_proc_unregister_driver(ide_drive_t *drive, ide_driver_t *driver) { ; }
833static inline void ide_add_generic_settings(ide_drive_t *drive) { ; }
834#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0; 871#define PROC_IDE_READ_RETURN(page,start,off,count,eof,len) return 0;
835#endif 872#endif
836 873
@@ -887,6 +924,7 @@ struct ide_driver_s {
887 void (*shutdown)(ide_drive_t *); 924 void (*shutdown)(ide_drive_t *);
888#ifdef CONFIG_IDE_PROC_FS 925#ifdef CONFIG_IDE_PROC_FS
889 ide_proc_entry_t *proc; 926 ide_proc_entry_t *proc;
927 const struct ide_devset **settings;
890#endif 928#endif
891}; 929};
892 930