Commit f0a86f5a authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.6-pre1 IDE cleanup 10

This is finishing the cleanup parts already started in ide-clean-9.

It kills the ide_register_module() and ide_unregister_module() as well
as associated idiosyncracies alltogether. It turns out
that this patch is actually fixing a bug which was present in the
driver before: the sub-module initialization functions where called
at least twice - which is an abundance.

Tough there is a bit of global namespace pollution caused by this
patch - but I'm aware of it and will fix it just a bit later.
(The terminology used inside the IDE code is anyway nothing common
else in the linux universum...)

The next targets will be:

1. Code obfuscation by "wrappers" around generic BIO level functions.

2. ide_hwgroup_t - which is only used to serialize multiple
discs on the same interrupt and similar. This is however a tough one.

3. There is a plenty of code waste in the chipset drivers, where there
is baroque informative code for the proc file system for static stuff,
which in fact belongs just to syslog(). In fact the default RedHat
distribution kernel is killing this gratitious abuse of the /proc
concept since a long long time...

I'm still awaiting the day of /proc/GPL, where GPL contains the
full text of it...
parent 38b20d21
...@@ -2906,7 +2906,6 @@ int ide_cdrom_cleanup(ide_drive_t *drive) ...@@ -2906,7 +2906,6 @@ int ide_cdrom_cleanup(ide_drive_t *drive)
return 0; return 0;
} }
int ide_cdrom_init(void);
int ide_cdrom_reinit (ide_drive_t *drive); int ide_cdrom_reinit (ide_drive_t *drive);
static ide_driver_t ide_cdrom_driver = { static ide_driver_t ide_cdrom_driver = {
...@@ -2929,7 +2928,6 @@ static ide_driver_t ide_cdrom_driver = { ...@@ -2929,7 +2928,6 @@ static ide_driver_t ide_cdrom_driver = {
capacity: ide_cdrom_capacity, capacity: ide_cdrom_capacity,
special: NULL, special: NULL,
proc: NULL, proc: NULL,
driver_init: ide_cdrom_init,
driver_reinit: ide_cdrom_reinit, driver_reinit: ide_cdrom_reinit,
}; };
...@@ -2967,7 +2965,7 @@ int ide_cdrom_reinit (ide_drive_t *drive) ...@@ -2967,7 +2965,7 @@ int ide_cdrom_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
ide_register_module(&ide_cdrom_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -2982,7 +2980,6 @@ static void __exit ide_cdrom_exit(void) ...@@ -2982,7 +2980,6 @@ static void __exit ide_cdrom_exit(void)
printk ("%s: cleanup_module() called while still busy\n", drive->name); printk ("%s: cleanup_module() called while still busy\n", drive->name);
failed++; failed++;
} }
ide_unregister_module (&ide_cdrom_driver);
} }
int ide_cdrom_init(void) int ide_cdrom_init(void)
...@@ -3026,7 +3023,7 @@ int ide_cdrom_init(void) ...@@ -3026,7 +3023,7 @@ int ide_cdrom_init(void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&ide_cdrom_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -1030,7 +1030,6 @@ static int idedisk_cleanup (ide_drive_t *drive) ...@@ -1030,7 +1030,6 @@ static int idedisk_cleanup (ide_drive_t *drive)
return ide_unregister_subdriver(drive); return ide_unregister_subdriver(drive);
} }
int idedisk_init (void);
int idedisk_reinit(ide_drive_t *drive); int idedisk_reinit(ide_drive_t *drive);
/* /*
...@@ -1056,7 +1055,6 @@ static ide_driver_t idedisk_driver = { ...@@ -1056,7 +1055,6 @@ static ide_driver_t idedisk_driver = {
capacity: idedisk_capacity, capacity: idedisk_capacity,
special: idedisk_special, special: idedisk_special,
proc: idedisk_proc, proc: idedisk_proc,
driver_init: idedisk_init,
driver_reinit: idedisk_reinit, driver_reinit: idedisk_reinit,
}; };
...@@ -1083,7 +1081,7 @@ int idedisk_reinit (ide_drive_t *drive) ...@@ -1083,7 +1081,7 @@ int idedisk_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
ide_register_module(&idedisk_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -1105,7 +1103,6 @@ static void __exit idedisk_exit (void) ...@@ -1105,7 +1103,6 @@ static void __exit idedisk_exit (void)
ide_remove_proc_entries(drive->proc, idedisk_proc); ide_remove_proc_entries(drive->proc, idedisk_proc);
#endif #endif
} }
ide_unregister_module(&idedisk_driver);
} }
int idedisk_init (void) int idedisk_init (void)
...@@ -1130,7 +1127,7 @@ int idedisk_init (void) ...@@ -1130,7 +1127,7 @@ int idedisk_init (void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idedisk_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -2046,7 +2046,6 @@ static ide_proc_entry_t idefloppy_proc[] = { ...@@ -2046,7 +2046,6 @@ static ide_proc_entry_t idefloppy_proc[] = {
#endif /* CONFIG_PROC_FS */ #endif /* CONFIG_PROC_FS */
int idefloppy_init(void);
int idefloppy_reinit(ide_drive_t *drive); int idefloppy_reinit(ide_drive_t *drive);
/* /*
...@@ -2072,7 +2071,6 @@ static ide_driver_t idefloppy_driver = { ...@@ -2072,7 +2071,6 @@ static ide_driver_t idefloppy_driver = {
capacity: idefloppy_capacity, capacity: idefloppy_capacity,
special: NULL, special: NULL,
proc: idefloppy_proc, proc: idefloppy_proc,
driver_init: idefloppy_init,
driver_reinit: idefloppy_reinit, driver_reinit: idefloppy_reinit,
}; };
...@@ -2105,7 +2103,7 @@ int idefloppy_reinit (ide_drive_t *drive) ...@@ -2105,7 +2103,7 @@ int idefloppy_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idefloppy_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -2130,7 +2128,6 @@ static void __exit idefloppy_exit (void) ...@@ -2130,7 +2128,6 @@ static void __exit idefloppy_exit (void)
ide_remove_proc_entries(drive->proc, idefloppy_proc); ide_remove_proc_entries(drive->proc, idefloppy_proc);
#endif #endif
} }
ide_unregister_module(&idefloppy_driver);
} }
/* /*
...@@ -2167,7 +2164,7 @@ int idefloppy_init (void) ...@@ -2167,7 +2164,7 @@ int idefloppy_init (void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idefloppy_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -373,20 +373,6 @@ static int ide_getdigit(char c) ...@@ -373,20 +373,6 @@ static int ide_getdigit(char c)
return digit; return digit;
} }
static int proc_ide_read_drivers
(char *page, char **start, off_t off, int count, int *eof, void *data)
{
char *out = page;
int len;
struct ide_driver_s * driver;
for (driver = ide_drivers; driver; driver = driver->next) {
out += sprintf(out, "%s\n",driver->name);
}
len = out - page;
PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
}
static int proc_ide_read_imodel static int proc_ide_read_imodel
(char *page, char **start, off_t off, int count, int *eof, void *data) (char *page, char **start, off_t off, int count, int *eof, void *data)
{ {
...@@ -852,9 +838,6 @@ void proc_ide_create(void) ...@@ -852,9 +838,6 @@ void proc_ide_create(void)
create_proc_ide_interfaces(); create_proc_ide_interfaces();
create_proc_read_entry("drivers", 0, proc_ide_root,
proc_ide_read_drivers, NULL);
#ifdef CONFIG_BLK_DEV_AEC62XX #ifdef CONFIG_BLK_DEV_AEC62XX
if ((aec62xx_display_info) && (aec62xx_proc)) if ((aec62xx_display_info) && (aec62xx_proc))
create_proc_info_entry("aec62xx", 0, proc_ide_root, aec62xx_display_info); create_proc_info_entry("aec62xx", 0, proc_ide_root, aec62xx_display_info);
......
...@@ -6137,7 +6137,6 @@ static ide_proc_entry_t idetape_proc[] = { ...@@ -6137,7 +6137,6 @@ static ide_proc_entry_t idetape_proc[] = {
#endif #endif
int idetape_init (void);
int idetape_reinit(ide_drive_t *drive); int idetape_reinit(ide_drive_t *drive);
/* /*
...@@ -6162,7 +6161,6 @@ static ide_driver_t idetape_driver = { ...@@ -6162,7 +6161,6 @@ static ide_driver_t idetape_driver = {
pre_reset: idetape_pre_reset, pre_reset: idetape_pre_reset,
capacity: NULL, capacity: NULL,
proc: idetape_proc, proc: idetape_proc,
driver_init: idetape_init,
driver_reinit: idetape_reinit, driver_reinit: idetape_reinit,
}; };
...@@ -6193,7 +6191,7 @@ int idetape_reinit (ide_drive_t *drive) ...@@ -6193,7 +6191,7 @@ int idetape_reinit (ide_drive_t *drive)
idetape_chrdevs[minor].drive = NULL; idetape_chrdevs[minor].drive = NULL;
if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) { if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) {
ide_register_module (&idetape_module); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG #if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n"); printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
...@@ -6252,7 +6250,7 @@ int idetape_reinit (ide_drive_t *drive) ...@@ -6252,7 +6250,7 @@ int idetape_reinit (ide_drive_t *drive)
devfs_unregister_chrdev (IDETAPE_MAJOR, "ht"); devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
} else } else
idetape_chrdev_present = 1; idetape_chrdev_present = 1;
ide_register_module (&idetape_module); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG #if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n"); printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
...@@ -6277,7 +6275,6 @@ static void __exit idetape_exit (void) ...@@ -6277,7 +6275,6 @@ static void __exit idetape_exit (void)
if (drive != NULL && idetape_cleanup (drive)) if (drive != NULL && idetape_cleanup (drive))
printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name); printk (KERN_ERR "ide-tape: %s: cleanup_module() called while still busy\n", drive->name);
} }
ide_unregister_module(&idetape_driver);
} }
/* /*
...@@ -6298,7 +6295,7 @@ int idetape_init (void) ...@@ -6298,7 +6295,7 @@ int idetape_init (void)
idetape_chrdevs[minor].drive = NULL; idetape_chrdevs[minor].drive = NULL;
if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) { if ((drive = ide_scan_devices (ide_tape, idetape_driver.name, NULL, failed++)) == NULL) {
ide_register_module (&idetape_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG #if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n"); printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
...@@ -6357,7 +6354,7 @@ int idetape_init (void) ...@@ -6357,7 +6354,7 @@ int idetape_init (void)
devfs_unregister_chrdev (IDETAPE_MAJOR, "ht"); devfs_unregister_chrdev (IDETAPE_MAJOR, "ht");
} else } else
idetape_chrdev_present = 1; idetape_chrdev_present = 1;
ide_register_module (&idetape_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
#if ONSTREAM_DEBUG #if ONSTREAM_DEBUG
printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n"); printk(KERN_INFO "ide-tape: MOD_DEC_USE_COUNT in idetape_init\n");
......
...@@ -195,11 +195,6 @@ static int ide_intr_lock; ...@@ -195,11 +195,6 @@ static int ide_intr_lock;
int noautodma = 0; int noautodma = 0;
/*
* This is the anchor of the single linked list of ide device type drivers.
*/
struct ide_driver_s *ide_drivers;
/* /*
* This is declared extern in ide.h, for access by other IDE modules: * This is declared extern in ide.h, for access by other IDE modules:
*/ */
...@@ -1842,7 +1837,11 @@ int ide_revalidate_disk (kdev_t i_rdev) ...@@ -1842,7 +1837,11 @@ int ide_revalidate_disk (kdev_t i_rdev)
return res; return res;
} }
static void revalidate_drives (void) /*
* Look again for all drives in the system on all interfaces. This is used
* after a new driver cathegory has been loaded as module.
*/
void revalidate_drives (void)
{ {
ide_hwif_t *hwif; ide_hwif_t *hwif;
ide_drive_t *drive; ide_drive_t *drive;
...@@ -1870,15 +1869,12 @@ static void ide_probe_module (void) ...@@ -1870,15 +1869,12 @@ static void ide_probe_module (void)
static void ide_driver_module (void) static void ide_driver_module (void)
{ {
int index; int index;
struct ide_driver_s *d;
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
if (ide_hwifs[index].present) if (ide_hwifs[index].present)
goto search; goto search;
ide_probe_module(); ide_probe_module();
search: search:
for (d = ide_drivers; d != NULL; d = d->next)
d->driver_init();
revalidate_drives(); revalidate_drives();
} }
...@@ -3610,30 +3606,6 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -3610,30 +3606,6 @@ int ide_unregister_subdriver (ide_drive_t *drive)
return 0; return 0;
} }
int ide_register_module (struct ide_driver_s *d)
{
struct ide_driver_s *p = ide_drivers;
while (p) {
if (p == d)
return 1;
p = p->next;
}
d->next = ide_drivers;
ide_drivers = d;
revalidate_drives();
return 0;
}
void ide_unregister_module (struct ide_driver_s *d)
{
struct ide_driver_s **p;
for (p = &ide_drivers; (*p) && (*p) != d; p = &((*p)->next));
if (*p)
*p = (*p)->next;
}
struct block_device_operations ide_fops[] = {{ struct block_device_operations ide_fops[] = {{
owner: THIS_MODULE, owner: THIS_MODULE,
open: ide_open, open: ide_open,
...@@ -3644,9 +3616,8 @@ struct block_device_operations ide_fops[] = {{ ...@@ -3644,9 +3616,8 @@ struct block_device_operations ide_fops[] = {{
}}; }};
EXPORT_SYMBOL(ide_hwifs); EXPORT_SYMBOL(ide_hwifs);
EXPORT_SYMBOL(ide_register_module);
EXPORT_SYMBOL(ide_unregister_module);
EXPORT_SYMBOL(ide_spin_wait_hwgroup); EXPORT_SYMBOL(ide_spin_wait_hwgroup);
EXPORT_SYMBOL(revalidate_drives);
/* /*
* Probe module * Probe module
......
...@@ -535,7 +535,6 @@ static int idescsi_cleanup (ide_drive_t *drive) ...@@ -535,7 +535,6 @@ static int idescsi_cleanup (ide_drive_t *drive)
return 0; return 0;
} }
int idescsi_init(void);
int idescsi_reinit(ide_drive_t *drive); int idescsi_reinit(ide_drive_t *drive);
/* /*
...@@ -561,7 +560,6 @@ static ide_driver_t idescsi_driver = { ...@@ -561,7 +560,6 @@ static ide_driver_t idescsi_driver = {
capacity: NULL, capacity: NULL,
special: NULL, special: NULL,
proc: NULL, proc: NULL,
driver_init: idescsi_init,
driver_reinit: idescsi_reinit, driver_reinit: idescsi_reinit,
}; };
...@@ -596,7 +594,7 @@ int idescsi_reinit (ide_drive_t *drive) ...@@ -596,7 +594,7 @@ int idescsi_reinit (ide_drive_t *drive)
failed--; failed--;
} }
} }
ide_register_module(&idescsi_module); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
#endif #endif
return 0; return 0;
...@@ -636,7 +634,7 @@ int idescsi_init (void) ...@@ -636,7 +634,7 @@ int idescsi_init (void)
failed--; failed--;
} }
} }
ide_register_module(&idescsi_driver); revalidate_drives();
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -906,7 +904,6 @@ static void __exit exit_idescsi_module(void) ...@@ -906,7 +904,6 @@ static void __exit exit_idescsi_module(void)
failed++; failed++;
} }
} }
ide_unregister_module(&idescsi_driver);
} }
module_init(init_idescsi_module); module_init(init_idescsi_module);
......
...@@ -722,12 +722,7 @@ typedef struct ide_driver_s { ...@@ -722,12 +722,7 @@ typedef struct ide_driver_s {
unsigned long (*capacity)(ide_drive_t *); unsigned long (*capacity)(ide_drive_t *);
ide_startstop_t (*special)(ide_drive_t *); ide_startstop_t (*special)(ide_drive_t *);
ide_proc_entry_t *proc; ide_proc_entry_t *proc;
int (*driver_init)(void);
int (*driver_reinit)(ide_drive_t *); int (*driver_reinit)(ide_drive_t *);
/* FIXME: Single linked list of drivers for iteration.
*/
struct ide_driver_s *next;
} ide_driver_t; } ide_driver_t;
#define DRIVER(drive) ((drive)->driver) #define DRIVER(drive) ((drive)->driver)
...@@ -742,7 +737,6 @@ typedef struct ide_driver_s { ...@@ -742,7 +737,6 @@ typedef struct ide_driver_s {
*/ */
#ifndef _IDE_C #ifndef _IDE_C
extern struct hwif_s ide_hwifs[]; /* master data repository */ extern struct hwif_s ide_hwifs[]; /* master data repository */
extern struct ide_driver_s *ide_drivers;
#endif #endif
extern int noautodma; extern int noautodma;
...@@ -1072,8 +1066,6 @@ int idescsi_init (void); ...@@ -1072,8 +1066,6 @@ int idescsi_init (void);
#endif /* CONFIG_BLK_DEV_IDESCSI */ #endif /* CONFIG_BLK_DEV_IDESCSI */
#endif /* _IDE_C */ #endif /* _IDE_C */
extern int ide_register_module (struct ide_driver_s *d);
extern void ide_unregister_module (struct ide_driver_s *d);
ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *driver, int n); 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); extern int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver);
extern int ide_unregister_subdriver(ide_drive_t *drive); extern int ide_unregister_subdriver(ide_drive_t *drive);
...@@ -1108,5 +1100,6 @@ extern unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif, int extra, const ...@@ -1108,5 +1100,6 @@ extern unsigned long ide_get_or_set_dma_base (ide_hwif_t *hwif, int extra, const
extern spinlock_t ide_lock; extern spinlock_t ide_lock;
extern int drive_is_ready(ide_drive_t *drive); extern int drive_is_ready(ide_drive_t *drive);
extern void revalidate_drives(void);
#endif /* _IDE_H */ #endif /* _IDE_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment