diff options
| author | Martin Dalecki <dalecki@evision-ventures.com> | 2002-02-27 20:15:37 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@penguin.transmeta.com> | 2002-02-27 20:15:37 -0800 |
| commit | 48ba6e981971315be2610d57be73b501a66c996e (patch) | |
| tree | d6e5af286db653ec82c8464c6d2157725dc6be21 /include/linux | |
| parent | b62bbbcb76be3e67c17f092cb9f502d92548c14d (diff) | |
[PATCH] 2.5.6-pre1 IDE clean 14
Most importantly this patch is making ide.c use the
new automagic for module initialization lists and further
preparing the rest of the code in question here for proper
module separation. Despite this the CMOS probe has been removed
as well... *Iff*, which I don't expect, this breaks anything
it can be reintroduced easely. During this effort an actual bug
in the initialization of the main module has been uncovered as well.
a quite serious BUG has been tagged in ide-scsi.c as well, but
as far as now I just didn't get along to actually fixing it.
(The patch is big enough as it is).
Details follow:
- Kill *unused* ide_media_verbose() funciton.
- Remove the unnecessary media and supports_dma fields from
ide_driver_t.
- Remove the global name field from ide_driver_t struct by pushing it
down to the places where it's actually used.
- Remove the unused hwif_data field from ide_hwif_t.
- Push the supports_dsc_overlap condition up to the level where it
belongs: disk type as well.
- Make the initialization of ide main ide.c work with the new module
initialization auto-magic instead of calling it explicitly in
ll_rw_block.c This prevents the ide_init() from being called twice. We
have BTW. renamed it to ata_module_init(), since ata is more adequate
then ide and xxx_module_init corresponds better to the naming
conventions used elsewhere throughout the kernel.
This BUG was there before any ide-clean. It was worked around by a
magic variable preventing the second call to succeed. We have removed
this variable in one of the previous patches and thus uncovered it.
- Kill proc_ide_read_driver() and proc_ide_write_driver(). The drivers
already report on syslog which drives they have taken care of. (Or
at least they should). In esp. the proc_ide_write_driver() was just
too offending for me. Beleve it or not the purpose of it was to
*request a particular* driver for a device, by echoing some magic
values to a magic file...
More importantly this "back door" was getting in the way of a properly
done modularization of the IDE stuff.
- Made some not externally used functions static or not EXPORT-ed.
- Provide the start of a proper modularization between the main module
and drivers for particular device types. Changing the name-space
polluting DRIVER() macro to ata_ops() showed how inconsistently the
busy (read: module busy!) field from ide_driver_t
is currently used across the different device type modules.
This has to be fixed soon.
- Make the ide code use the similar device type ID numbers as the SCSI
code :-). This is just tedious, but it will help in a distant
feature. It helps reading the code anyway.
- Mark repettitive code with /* ATA-PATTERN */ comments for later
consolidation at places where we did came across it.
- Various comments and notes added where some explanations was missing.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/ide.h | 92 |
1 files changed, 55 insertions, 37 deletions
diff --git a/include/linux/ide.h b/include/linux/ide.h index c35f531eeb4e..30f881404625 100644 --- a/include/linux/ide.h +++ b/include/linux/ide.h @@ -1,9 +1,7 @@ #ifndef _IDE_H #define _IDE_H /* - * linux/include/linux/ide.h - * - * Copyright (C) 1994-1998 Linus Torvalds & authors + * Copyright (C) 1994-2002 Linus Torvalds & authors */ #include <linux/config.h> @@ -350,12 +348,13 @@ void ide_setup_ports( hw_regs_t *hw, * Now for the data we need to maintain per-drive: ide_drive_t */ -#define ide_scsi 0x21 -#define ide_disk 0x20 -#define ide_optical 0x7 -#define ide_cdrom 0x5 -#define ide_tape 0x1 -#define ide_floppy 0x0 +#define ATA_DISK 0x20 +#define ATA_TAPE 0x01 +#define ATA_ROM 0x05 /* CD-ROM */ +#define ATA_MOD 0x07 /* optical */ +#define ATA_FLOPPY 0x00 +#define ATA_SCSI 0x21 +#define ATA_NO_LUN 0x7f typedef union { unsigned all : 8; /* all of the bits together */ @@ -371,7 +370,14 @@ typedef union { struct ide_settings_s; typedef struct ide_drive_s { - request_queue_t queue; /* request queue */ + char type; /* distingiush different devices: disk, cdrom, tape, floppy, ... */ + + /* NOTE: If we had proper separation between channel and host chip, we + * could move this to the chanell and many sync problems would + * magically just go away. + */ + request_queue_t queue; /* per device request queue */ + struct ide_drive_s *next; /* circular list of hwgroup drives */ unsigned long sleep; /* sleep until this time */ unsigned long service_start; /* time we started last request */ @@ -406,7 +412,6 @@ typedef struct ide_drive_s { unsigned ata_flash : 1; /* 1=present, 0=default */ unsigned addressing; /* : 2; 0=28-bit, 1=48-bit, 2=64-bit */ byte scsi; /* 0=default, 1=skip current ide-subdriver for ide-scsi emulation */ - byte media; /* disk, cdrom, tape, floppy, ... */ select_t select; /* basic drive/head select reg value */ byte ctl; /* "normal" value for IDE_CONTROL_REG */ byte ready_stat; /* min status value for drive ready */ @@ -432,7 +437,7 @@ typedef struct ide_drive_s { struct hd_driveid *id; /* drive model identification info */ struct hd_struct *part; /* drive partition table */ char name[4]; /* drive name, such as "hda" */ - struct ide_driver_s *driver; /* (ide_driver_t *) */ + struct ata_operations *driver; void *driver_data; /* extra driver data */ devfs_handle_t de; /* directory for device */ struct proc_dir_entry *proc; /* /proc/ide/ directory entry */ @@ -570,7 +575,6 @@ typedef struct hwif_s { unsigned long last_time; /* time when previous rq was done */ #endif byte straight8; /* Alan's straight 8 check */ - void *hwif_data; /* extra hwif data */ ide_busproc_t *busproc; /* driver soft-power interface */ byte bus_state; /* power state of the IDE bus */ struct device device; /* global device tree handle */ @@ -663,8 +667,6 @@ typedef struct { #ifdef CONFIG_PROC_FS void proc_ide_create(void); void proc_ide_destroy(void); -void recreate_proc_ide_device(ide_hwif_t *, ide_drive_t *); -void destroy_proc_ide_device(ide_hwif_t *, ide_drive_t *); void destroy_proc_ide_drives(ide_hwif_t *); void create_proc_ide_interfaces(void); void ide_add_proc_entries(struct proc_dir_entry *dir, ide_proc_entry_t *p, void *data); @@ -692,32 +694,54 @@ read_proc_t proc_ide_read_geometry; #endif /* - * Subdrivers support. + * This structure describes the operations possible on a particular device type + * (CD-ROM, tape, DISK and so on). + * + * This is the main hook for device type support submodules. */ -typedef struct ide_driver_s { - const char *name; - byte media; - unsigned busy : 1; - unsigned supports_dma : 1; - unsigned supports_dsc_overlap : 1; + +struct ata_operations { + struct module *owner; + unsigned busy: 1; /* FIXME: this will go soon away... */ int (*cleanup)(ide_drive_t *); int (*standby)(ide_drive_t *); int (*flushcache)(ide_drive_t *); ide_startstop_t (*do_request)(ide_drive_t *, struct request *, unsigned long); int (*end_request)(ide_drive_t *drive, int uptodate); + int (*ioctl)(ide_drive_t *, struct inode *, struct file *, unsigned int, unsigned long); int (*open)(struct inode *, struct file *, ide_drive_t *); void (*release)(struct inode *, struct file *, ide_drive_t *); int (*media_change)(ide_drive_t *); void (*revalidate)(ide_drive_t *); + void (*pre_reset)(ide_drive_t *); unsigned long (*capacity)(ide_drive_t *); ide_startstop_t (*special)(ide_drive_t *); ide_proc_entry_t *proc; int (*driver_reinit)(ide_drive_t *); -} ide_driver_t; +}; + +/* Alas, no aliases. Too much hassle with bringing module.h everywhere */ +#define ata_get(ata) \ + (((ata) && (ata)->owner) \ + ? ( try_inc_mod_count((ata)->owner) ? (ata) : NULL ) \ + : (ata)) + +#define ata_put(ata) \ +do { \ + if ((ata) && (ata)->owner) \ + __MOD_DEC_USE_COUNT((ata)->owner); \ +} while(0) -#define DRIVER(drive) ((drive)->driver) + +/* FIXME: Actually implement and use them as soon as possible! to make the + * ide_scan_devices() go away! */ + +extern int unregister_ata_driver(unsigned int type, struct ata_operations *driver); +extern int register_ata_driver(unsigned int type, struct ata_operations *driver); + +#define ata_ops(drive) ((drive)->driver) /* * ide_hwifs[] is the master data structure used to keep track @@ -994,30 +1018,24 @@ extern ide_proc_entry_t generic_subdriver_entries[]; extern int ideprobe_init (void); #endif #ifdef CONFIG_BLK_DEV_IDEDISK -extern int idedisk_reinit (ide_drive_t *drive); extern int idedisk_init (void); -#endif /* CONFIG_BLK_DEV_IDEDISK */ +#endif #ifdef CONFIG_BLK_DEV_IDECD -extern int ide_cdrom_reinit (ide_drive_t *drive); extern int ide_cdrom_init (void); -#endif /* CONFIG_BLK_DEV_IDECD */ +#endif #ifdef CONFIG_BLK_DEV_IDETAPE -extern int idetape_reinit (ide_drive_t *drive); extern int idetape_init (void); -#endif /* CONFIG_BLK_DEV_IDETAPE */ +#endif #ifdef CONFIG_BLK_DEV_IDEFLOPPY -extern int idefloppy_reinit (ide_drive_t *drive); extern int idefloppy_init (void); -#endif /* CONFIG_BLK_DEV_IDEFLOPPY */ +#endif #ifdef CONFIG_BLK_DEV_IDESCSI -extern int idescsi_reinit (ide_drive_t *drive); extern int idescsi_init (void); -#endif /* CONFIG_BLK_DEV_IDESCSI */ +#endif -ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n); -extern int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver); +ide_drive_t *ide_scan_devices (byte media, const char *name, struct ata_operations *driver, int n); +extern int ide_register_subdriver(ide_drive_t *drive, struct ata_operations *driver); extern int ide_unregister_subdriver(ide_drive_t *drive); -extern int ide_replace_subdriver(ide_drive_t *drive, const char *driver); #ifdef CONFIG_BLK_DEV_IDEPCI #define ON_BOARD 1 |
