Commit 69f0d4b0 authored by Martin Dalecki's avatar Martin Dalecki Committed by Linus Torvalds

[PATCH] 2.5.5-pre1 IDE cleanup 9

1.  Kill the ide-probe-mod by merging it with ide-mod. There is *really*
    no reaons for having this stuff split up into two different
    modules unless you wan't to create artificial module dependancies
    and waste space of page boundaries during memmory allocation for the
    modules

2.  Kill the ide_module_t - which is unnecessary and presents a
    "reimplementation" of module handling inside the ide driver.  This
    is achieved by attaching the initialization routine ot the
    ide_driver_t, which will be gone next time, since there is no sane
    reason apparently, which this couldn't be done during the
    module-generic initialization of the corresponding driver module.

3.  Kill unnecessary tagging of "subdriver" with IDE_SUBDRIVER_VERSION -
    we have plenty of other mechanisms for module consistency checking.
    And anyway the ide code didn't any consistence checks on this value
    at all.

NOTE: The ide_(un)register_module() functions will be killed in next round.
parent 706afa06
...@@ -11,14 +11,14 @@ ...@@ -11,14 +11,14 @@
O_TARGET := idedriver.o O_TARGET := idedriver.o
export-objs := ide-taskfile.o ide.o ide-features.o ide-probe.o ataraid.o export-objs := ide-taskfile.o ide.o ide-features.o ide-probe.o ataraid.o
list-multi := ide-mod.o ide-probe-mod.o list-multi := ide-mod.o
obj-y := obj-y :=
obj-m := obj-m :=
ide-obj-y := ide-obj-y :=
obj-$(CONFIG_BLK_DEV_HD) += hd.o obj-$(CONFIG_BLK_DEV_HD) += hd.o
obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o ide-probe-mod.o obj-$(CONFIG_BLK_DEV_IDE) += ide-mod.o
obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o obj-$(CONFIG_BLK_DEV_IDECS) += ide-cs.o
obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o obj-$(CONFIG_BLK_DEV_IDEDISK) += ide-disk.o
obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o obj-$(CONFIG_BLK_DEV_IDECD) += ide-cd.o
...@@ -76,13 +76,9 @@ obj-$(CONFIG_BLK_DEV_ATARAID_HPT) += hptraid.o ...@@ -76,13 +76,9 @@ obj-$(CONFIG_BLK_DEV_ATARAID_HPT) += hptraid.o
ide-obj-$(CONFIG_PROC_FS) += ide-proc.o ide-obj-$(CONFIG_PROC_FS) += ide-proc.o
ide-mod-objs := ide-taskfile.o ide.o ide-features.o $(ide-obj-y) ide-mod-objs := ide-taskfile.o ide.o ide-probe.o ide-geometry.o ide-features.o $(ide-obj-y)
ide-probe-mod-objs := ide-probe.o ide-geometry.o
include $(TOPDIR)/Rules.make include $(TOPDIR)/Rules.make
ide-mod.o: $(ide-mod-objs) ide-mod.o: $(ide-mod-objs)
$(LD) -r -o $@ $(ide-mod-objs) $(LD) -r -o $@ $(ide-mod-objs)
ide-probe-mod.o: $(ide-probe-mod-objs)
$(LD) -r -o $@ $(ide-probe-mod-objs)
...@@ -2906,6 +2906,7 @@ int ide_cdrom_cleanup(ide_drive_t *drive) ...@@ -2906,6 +2906,7 @@ 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 = {
...@@ -2928,17 +2929,10 @@ static ide_driver_t ide_cdrom_driver = { ...@@ -2928,17 +2929,10 @@ 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,
}; };
int ide_cdrom_init(void);
static ide_module_t ide_cdrom_module = {
IDE_DRIVER_MODULE,
ide_cdrom_init,
&ide_cdrom_driver,
NULL
};
/* options */ /* options */
char *ignore = NULL; char *ignore = NULL;
...@@ -2956,7 +2950,7 @@ int ide_cdrom_reinit (ide_drive_t *drive) ...@@ -2956,7 +2950,7 @@ int ide_cdrom_reinit (ide_drive_t *drive)
printk ("%s: Can't allocate a cdrom structure\n", drive->name); printk ("%s: Can't allocate a cdrom structure\n", drive->name);
return 1; return 1;
} }
if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
printk ("%s: Failed to register the driver with ide.c\n", drive->name); printk ("%s: Failed to register the driver with ide.c\n", drive->name);
kfree (info); kfree (info);
return 1; return 1;
...@@ -2973,7 +2967,7 @@ int ide_cdrom_reinit (ide_drive_t *drive) ...@@ -2973,7 +2967,7 @@ int ide_cdrom_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
ide_register_module(&ide_cdrom_module); ide_register_module(&ide_cdrom_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -2988,7 +2982,7 @@ static void __exit ide_cdrom_exit(void) ...@@ -2988,7 +2982,7 @@ 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_module); ide_unregister_module (&ide_cdrom_driver);
} }
int ide_cdrom_init(void) int ide_cdrom_init(void)
...@@ -3015,7 +3009,7 @@ int ide_cdrom_init(void) ...@@ -3015,7 +3009,7 @@ int ide_cdrom_init(void)
printk ("%s: Can't allocate a cdrom structure\n", drive->name); printk ("%s: Can't allocate a cdrom structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &ide_cdrom_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &ide_cdrom_driver)) {
printk ("%s: Failed to register the driver with ide.c\n", drive->name); printk ("%s: Failed to register the driver with ide.c\n", drive->name);
kfree (info); kfree (info);
continue; continue;
...@@ -3032,7 +3026,7 @@ int ide_cdrom_init(void) ...@@ -3032,7 +3026,7 @@ int ide_cdrom_init(void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&ide_cdrom_module); ide_register_module(&ide_cdrom_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -1030,6 +1030,7 @@ static int idedisk_cleanup (ide_drive_t *drive) ...@@ -1030,6 +1030,7 @@ 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);
/* /*
...@@ -1055,17 +1056,10 @@ static ide_driver_t idedisk_driver = { ...@@ -1055,17 +1056,10 @@ 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,
}; };
int idedisk_init (void);
static ide_module_t idedisk_module = {
IDE_DRIVER_MODULE,
idedisk_init,
&idedisk_driver,
NULL
};
MODULE_DESCRIPTION("ATA DISK Driver"); MODULE_DESCRIPTION("ATA DISK Driver");
int idedisk_reinit (ide_drive_t *drive) int idedisk_reinit (ide_drive_t *drive)
...@@ -1074,7 +1068,7 @@ int idedisk_reinit (ide_drive_t *drive) ...@@ -1074,7 +1068,7 @@ int idedisk_reinit (ide_drive_t *drive)
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
if (ide_register_subdriver (drive, &idedisk_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idedisk_driver)) {
printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
return 1; return 1;
} }
...@@ -1089,7 +1083,7 @@ int idedisk_reinit (ide_drive_t *drive) ...@@ -1089,7 +1083,7 @@ int idedisk_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
ide_register_module(&idedisk_module); ide_register_module(&idedisk_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -1111,7 +1105,7 @@ static void __exit idedisk_exit (void) ...@@ -1111,7 +1105,7 @@ 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_module); ide_unregister_module(&idedisk_driver);
} }
int idedisk_init (void) int idedisk_init (void)
...@@ -1121,7 +1115,7 @@ int idedisk_init (void) ...@@ -1121,7 +1115,7 @@ int idedisk_init (void)
MOD_INC_USE_COUNT; MOD_INC_USE_COUNT;
while ((drive = ide_scan_devices (ide_disk, idedisk_driver.name, NULL, failed++)) != NULL) { while ((drive = ide_scan_devices (ide_disk, idedisk_driver.name, NULL, failed++)) != NULL) {
if (ide_register_subdriver (drive, &idedisk_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idedisk_driver)) {
printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-disk: %s: Failed to register the driver with ide.c\n", drive->name);
continue; continue;
} }
...@@ -1136,7 +1130,7 @@ int idedisk_init (void) ...@@ -1136,7 +1130,7 @@ int idedisk_init (void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idedisk_module); ide_register_module(&idedisk_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -2046,6 +2046,7 @@ static ide_proc_entry_t idefloppy_proc[] = { ...@@ -2046,6 +2046,7 @@ 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);
/* /*
...@@ -2071,17 +2072,10 @@ static ide_driver_t idefloppy_driver = { ...@@ -2071,17 +2072,10 @@ 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,
}; };
int idefloppy_init (void);
static ide_module_t idefloppy_module = {
IDE_DRIVER_MODULE,
idefloppy_init,
&idefloppy_driver,
NULL
};
int idefloppy_reinit (ide_drive_t *drive) int idefloppy_reinit (ide_drive_t *drive)
{ {
idefloppy_floppy_t *floppy; idefloppy_floppy_t *floppy;
...@@ -2101,7 +2095,7 @@ int idefloppy_reinit (ide_drive_t *drive) ...@@ -2101,7 +2095,7 @@ int idefloppy_reinit (ide_drive_t *drive)
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idefloppy_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idefloppy_driver)) {
printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (floppy); kfree (floppy);
continue; continue;
...@@ -2111,7 +2105,7 @@ int idefloppy_reinit (ide_drive_t *drive) ...@@ -2111,7 +2105,7 @@ int idefloppy_reinit (ide_drive_t *drive)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idefloppy_module); ide_register_module(&idefloppy_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -2136,7 +2130,7 @@ static void __exit idefloppy_exit (void) ...@@ -2136,7 +2130,7 @@ 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_module); ide_unregister_module(&idefloppy_driver);
} }
/* /*
...@@ -2163,7 +2157,7 @@ int idefloppy_init (void) ...@@ -2163,7 +2157,7 @@ int idefloppy_init (void)
printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name); printk (KERN_ERR "ide-floppy: %s: Can't allocate a floppy structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idefloppy_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idefloppy_driver)) {
printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-floppy: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (floppy); kfree (floppy);
continue; continue;
...@@ -2173,7 +2167,7 @@ int idefloppy_init (void) ...@@ -2173,7 +2167,7 @@ int idefloppy_init (void)
DRIVER(drive)->busy--; DRIVER(drive)->busy--;
failed--; failed--;
} }
ide_register_module(&idefloppy_module); ide_register_module(&idefloppy_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
......
...@@ -927,19 +927,11 @@ static int hwif_init (ide_hwif_t *hwif) ...@@ -927,19 +927,11 @@ static int hwif_init (ide_hwif_t *hwif)
return hwif->present; return hwif->present;
} }
int ideprobe_init (void);
static ide_module_t ideprobe_module = {
IDE_PROBE_MODULE,
ideprobe_init,
NULL
};
int ideprobe_init (void) int ideprobe_init (void)
{ {
unsigned int index; unsigned int index;
int probe[MAX_HWIFS]; int probe[MAX_HWIFS];
MOD_INC_USE_COUNT;
memset(probe, 0, MAX_HWIFS * sizeof(int)); memset(probe, 0, MAX_HWIFS * sizeof(int));
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
probe[index] = !ide_hwifs[index].present; probe[index] = !ide_hwifs[index].present;
...@@ -953,31 +945,5 @@ int ideprobe_init (void) ...@@ -953,31 +945,5 @@ int ideprobe_init (void)
for (index = 0; index < MAX_HWIFS; ++index) for (index = 0; index < MAX_HWIFS; ++index)
if (probe[index]) if (probe[index])
hwif_init(&ide_hwifs[index]); hwif_init(&ide_hwifs[index]);
if (!ide_probe)
ide_probe = &ideprobe_module;
MOD_DEC_USE_COUNT;
return 0;
}
#ifdef MODULE
extern int (*ide_xlate_1024_hook)(kdev_t, int, int, const char *);
int init_module (void)
{
unsigned int index;
for (index = 0; index < MAX_HWIFS; ++index)
ide_unregister(index);
ideprobe_init();
create_proc_ide_interfaces();
ide_xlate_1024_hook = ide_xlate_1024;
return 0; return 0;
} }
void cleanup_module (void)
{
ide_probe = NULL;
ide_xlate_1024_hook = 0;
}
MODULE_LICENSE("GPL");
#endif /* MODULE */
...@@ -378,14 +378,10 @@ static int proc_ide_read_drivers ...@@ -378,14 +378,10 @@ static int proc_ide_read_drivers
{ {
char *out = page; char *out = page;
int len; int len;
ide_module_t *p = ide_modules; struct ide_driver_s * driver;
ide_driver_t *driver;
while (p) { for (driver = ide_drivers; driver; driver = driver->next) {
driver = (ide_driver_t *) p->info; out += sprintf(out, "%s\n",driver->name);
if (driver)
out += sprintf(out, "%s\n",driver->name);
p = p->next;
} }
len = out - page; len = out - page;
PROC_IDE_READ_RETURN(page,start,off,count,eof,len); PROC_IDE_READ_RETURN(page,start,off,count,eof,len);
......
...@@ -6137,6 +6137,7 @@ static ide_proc_entry_t idetape_proc[] = { ...@@ -6137,6 +6137,7 @@ 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);
/* /*
...@@ -6161,17 +6162,10 @@ static ide_driver_t idetape_driver = { ...@@ -6161,17 +6162,10 @@ 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,
}; };
int idetape_init (void);
static ide_module_t idetape_module = {
IDE_DRIVER_MODULE,
idetape_init,
&idetape_driver,
NULL
};
/* /*
* Our character device supporting functions, passed to register_chrdev. * Our character device supporting functions, passed to register_chrdev.
*/ */
...@@ -6233,7 +6227,7 @@ int idetape_reinit (ide_drive_t *drive) ...@@ -6233,7 +6227,7 @@ int idetape_reinit (ide_drive_t *drive)
printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idetape_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idetape_driver)) {
printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (tape); kfree (tape);
continue; continue;
...@@ -6283,7 +6277,7 @@ static void __exit idetape_exit (void) ...@@ -6283,7 +6277,7 @@ 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_module); ide_unregister_module(&idetape_driver);
} }
/* /*
...@@ -6304,7 +6298,7 @@ int idetape_init (void) ...@@ -6304,7 +6298,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_module); ide_register_module (&idetape_driver);
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");
...@@ -6338,7 +6332,7 @@ int idetape_init (void) ...@@ -6338,7 +6332,7 @@ int idetape_init (void)
printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name); printk (KERN_ERR "ide-tape: %s: Can't allocate a tape structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idetape_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idetape_driver)) {
printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-tape: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (tape); kfree (tape);
continue; continue;
...@@ -6363,7 +6357,7 @@ int idetape_init (void) ...@@ -6363,7 +6357,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_module); ide_register_module (&idetape_driver);
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");
......
...@@ -196,10 +196,9 @@ static int ide_intr_lock; ...@@ -196,10 +196,9 @@ static int ide_intr_lock;
int noautodma = 0; int noautodma = 0;
/* /*
* ide_modules keeps track of the available IDE chipset/probe/driver modules. * This is the anchor of the single linked list of ide device type drivers.
*/ */
ide_module_t *ide_modules; struct ide_driver_s *ide_drivers;
ide_module_t *ide_probe;
/* /*
* 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:
...@@ -1864,30 +1863,23 @@ static void revalidate_drives (void) ...@@ -1864,30 +1863,23 @@ static void revalidate_drives (void)
static void ide_probe_module (void) static void ide_probe_module (void)
{ {
if (!ide_probe) { ideprobe_init();
#if defined(CONFIG_KMOD) && defined(CONFIG_BLK_DEV_IDE_MODULE)
(void) request_module("ide-probe-mod");
#endif /* (CONFIG_KMOD) && (CONFIG_BLK_DEV_IDE_MODULE) */
} else {
(void) ide_probe->init();
}
revalidate_drives(); revalidate_drives();
} }
static void ide_driver_module (void) static void ide_driver_module (void)
{ {
int index; int index;
ide_module_t *module = ide_modules; 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:
while (module) { for (d = ide_drivers; d != NULL; d = d->next)
(void) module->init(); d->driver_init();
module = module->next;
}
revalidate_drives(); revalidate_drives();
} }
...@@ -3528,13 +3520,13 @@ ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *drive ...@@ -3528,13 +3520,13 @@ ide_drive_t *ide_scan_devices (byte media, const char *name, ide_driver_t *drive
return NULL; return NULL;
} }
int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version) int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); /* all CPUs */ save_flags(flags); /* all CPUs */
cli(); /* all CPUs */ cli(); /* all CPUs */
if (version != IDE_SUBDRIVER_VERSION || !drive->present || drive->driver != NULL || drive->busy || drive->usage) { if (!drive->present || drive->driver != NULL || drive->busy || drive->usage) {
restore_flags(flags); /* all CPUs */ restore_flags(flags); /* all CPUs */
return 1; return 1;
} }
...@@ -3618,26 +3610,26 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -3618,26 +3610,26 @@ int ide_unregister_subdriver (ide_drive_t *drive)
return 0; return 0;
} }
int ide_register_module (ide_module_t *module) int ide_register_module (struct ide_driver_s *d)
{ {
ide_module_t *p = ide_modules; struct ide_driver_s *p = ide_drivers;
while (p) { while (p) {
if (p == module) if (p == d)
return 1; return 1;
p = p->next; p = p->next;
} }
module->next = ide_modules; d->next = ide_drivers;
ide_modules = module; ide_drivers = d;
revalidate_drives(); revalidate_drives();
return 0; return 0;
} }
void ide_unregister_module (ide_module_t *module) void ide_unregister_module (struct ide_driver_s *d)
{ {
ide_module_t **p; struct ide_driver_s **p;
for (p = &ide_modules; (*p) && (*p) != module; p = &((*p)->next)); for (p = &ide_drivers; (*p) && (*p) != d; p = &((*p)->next));
if (*p) if (*p)
*p = (*p)->next; *p = (*p)->next;
} }
...@@ -3662,7 +3654,6 @@ EXPORT_SYMBOL(ide_spin_wait_hwgroup); ...@@ -3662,7 +3654,6 @@ EXPORT_SYMBOL(ide_spin_wait_hwgroup);
devfs_handle_t ide_devfs_handle; devfs_handle_t ide_devfs_handle;
EXPORT_SYMBOL(ide_lock); EXPORT_SYMBOL(ide_lock);
EXPORT_SYMBOL(ide_probe);
EXPORT_SYMBOL(drive_is_flashcard); EXPORT_SYMBOL(drive_is_flashcard);
EXPORT_SYMBOL(ide_timer_expiry); EXPORT_SYMBOL(ide_timer_expiry);
EXPORT_SYMBOL(ide_intr); EXPORT_SYMBOL(ide_intr);
......
...@@ -535,6 +535,7 @@ static int idescsi_cleanup (ide_drive_t *drive) ...@@ -535,6 +535,7 @@ 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);
/* /*
...@@ -560,17 +561,10 @@ static ide_driver_t idescsi_driver = { ...@@ -560,17 +561,10 @@ 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,
}; };
int idescsi_init (void);
static ide_module_t idescsi_module = {
IDE_DRIVER_MODULE,
idescsi_init,
&idescsi_driver,
NULL
};
int idescsi_reinit (ide_drive_t *drive) int idescsi_reinit (ide_drive_t *drive)
{ {
#if 0 #if 0
...@@ -592,7 +586,7 @@ int idescsi_reinit (ide_drive_t *drive) ...@@ -592,7 +586,7 @@ int idescsi_reinit (ide_drive_t *drive)
printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name); printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idescsi_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idescsi_driver)) {
printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (scsi); kfree (scsi);
continue; continue;
...@@ -632,7 +626,7 @@ int idescsi_init (void) ...@@ -632,7 +626,7 @@ int idescsi_init (void)
printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name); printk (KERN_ERR "ide-scsi: %s: Can't allocate a scsi structure\n", drive->name);
continue; continue;
} }
if (ide_register_subdriver (drive, &idescsi_driver, IDE_SUBDRIVER_VERSION)) { if (ide_register_subdriver (drive, &idescsi_driver)) {
printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name); printk (KERN_ERR "ide-scsi: %s: Failed to register the driver with ide.c\n", drive->name);
kfree (scsi); kfree (scsi);
continue; continue;
...@@ -642,7 +636,7 @@ int idescsi_init (void) ...@@ -642,7 +636,7 @@ int idescsi_init (void)
failed--; failed--;
} }
} }
ide_register_module(&idescsi_module); ide_register_module(&idescsi_driver);
MOD_DEC_USE_COUNT; MOD_DEC_USE_COUNT;
return 0; return 0;
} }
...@@ -912,7 +906,7 @@ static void __exit exit_idescsi_module(void) ...@@ -912,7 +906,7 @@ static void __exit exit_idescsi_module(void)
failed++; failed++;
} }
} }
ide_unregister_module(&idescsi_module); ide_unregister_module(&idescsi_driver);
} }
module_init(init_idescsi_module); module_init(init_idescsi_module);
......
...@@ -99,8 +99,8 @@ typedef unsigned char byte; /* used everywhere */ ...@@ -99,8 +99,8 @@ typedef unsigned char byte; /* used everywhere */
#undef REALLY_FAST_IO #undef REALLY_FAST_IO
#endif #endif
#define HWIF(drive) ((ide_hwif_t *)((drive)->hwif)) #define HWIF(drive) ((drive)->hwif)
#define HWGROUP(drive) ((ide_hwgroup_t *)(HWIF(drive)->hwgroup)) #define HWGROUP(drive) (HWIF(drive)->hwgroup)
/* /*
* Definitions for accessing IDE controller registers * Definitions for accessing IDE controller registers
...@@ -371,7 +371,7 @@ struct ide_settings_s; ...@@ -371,7 +371,7 @@ struct ide_settings_s;
typedef struct ide_drive_s { typedef struct ide_drive_s {
request_queue_t queue; /* request queue */ request_queue_t queue; /* request queue */
struct ide_drive_s *next; /* circular list of hwgroup drives */ struct ide_drive_s *next; /* circular list of hwgroup drives */
unsigned long sleep; /* sleep until this time */ unsigned long sleep; /* sleep until this time */
unsigned long service_start; /* time we started last request */ unsigned long service_start; /* time we started last request */
unsigned long service_time; /* service time of last request */ unsigned long service_time; /* service time of last request */
...@@ -531,7 +531,7 @@ typedef struct ide_pci_devid_s { ...@@ -531,7 +531,7 @@ typedef struct ide_pci_devid_s {
typedef struct hwif_s { typedef struct hwif_s {
struct hwif_s *next; /* for linked-list in ide_hwgroup_t */ struct hwif_s *next; /* for linked-list in ide_hwgroup_t */
void *hwgroup; /* actually (ide_hwgroup_t *) */ struct hwgroup_s *hwgroup; /* actually (ide_hwgroup_t *) */
ide_ioreg_t io_ports[IDE_NR_PORTS]; /* task file registers */ ide_ioreg_t io_ports[IDE_NR_PORTS]; /* task file registers */
hw_regs_t hw; /* Hardware info */ hw_regs_t hw; /* Hardware info */
ide_drive_t drives[MAX_DRIVES]; /* drive info */ ide_drive_t drives[MAX_DRIVES]; /* drive info */
...@@ -702,10 +702,6 @@ read_proc_t proc_ide_read_geometry; ...@@ -702,10 +702,6 @@ read_proc_t proc_ide_read_geometry;
/* /*
* Subdrivers support. * Subdrivers support.
*/ */
#define IDE_SUBDRIVER_VERSION 1
typedef void (ide_setting_proc)(ide_drive_t *);
typedef struct ide_driver_s { typedef struct ide_driver_s {
const char *name; const char *name;
byte media; byte media;
...@@ -726,25 +722,15 @@ typedef struct ide_driver_s { ...@@ -726,25 +722,15 @@ 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 *);
} ide_driver_t;
#define DRIVER(drive) ((ide_driver_t *)((drive)->driver))
/*
* IDE modules.
*/
#define IDE_CHIPSET_MODULE 0 /* not supported yet */
#define IDE_PROBE_MODULE 1
#define IDE_DRIVER_MODULE 2
/* FIXME: Single linked list of drivers for iteration.
*/
struct ide_driver_s *next;
} ide_driver_t;
typedef struct ide_module_s { #define DRIVER(drive) ((drive)->driver)
int type;
int (*init)(void);
void *info;
struct ide_module_s *next;
} ide_module_t;
/* /*
* ide_hwifs[] is the master data structure used to keep track * ide_hwifs[] is the master data structure used to keep track
...@@ -755,9 +741,8 @@ typedef struct ide_module_s { ...@@ -755,9 +741,8 @@ typedef struct ide_module_s {
* *
*/ */
#ifndef _IDE_C #ifndef _IDE_C
extern ide_hwif_t ide_hwifs[]; /* master data repository */ extern struct hwif_s ide_hwifs[]; /* master data repository */
extern ide_module_t *ide_modules; extern struct ide_driver_s *ide_drivers;
extern ide_module_t *ide_probe;
#endif #endif
extern int noautodma; extern int noautodma;
...@@ -1060,9 +1045,11 @@ extern ide_proc_entry_t generic_subdriver_entries[]; ...@@ -1060,9 +1045,11 @@ extern ide_proc_entry_t generic_subdriver_entries[];
int ide_reinit_drive (ide_drive_t *drive); int ide_reinit_drive (ide_drive_t *drive);
#ifdef _IDE_C #ifdef _IDE_C
#ifdef CONFIG_BLK_DEV_IDE # ifdef CONFIG_BLK_DEV_IDE
int ideprobe_init (void); /* Probe for devices attached to the systems host controllers.
#endif /* CONFIG_BLK_DEV_IDE */ */
extern int ideprobe_init (void);
# endif
#ifdef CONFIG_BLK_DEV_IDEDISK #ifdef CONFIG_BLK_DEV_IDEDISK
int idedisk_reinit (ide_drive_t *drive); int idedisk_reinit (ide_drive_t *drive);
int idedisk_init (void); int idedisk_init (void);
...@@ -1085,12 +1072,12 @@ int idescsi_init (void); ...@@ -1085,12 +1072,12 @@ int idescsi_init (void);
#endif /* CONFIG_BLK_DEV_IDESCSI */ #endif /* CONFIG_BLK_DEV_IDESCSI */
#endif /* _IDE_C */ #endif /* _IDE_C */
int ide_register_module (ide_module_t *module); extern int ide_register_module (struct ide_driver_s *d);
void ide_unregister_module (ide_module_t *module); 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);
int ide_register_subdriver (ide_drive_t *drive, ide_driver_t *driver, int version); extern int ide_register_subdriver(ide_drive_t *drive, ide_driver_t *driver);
int ide_unregister_subdriver (ide_drive_t *drive); extern int ide_unregister_subdriver(ide_drive_t *drive);
int ide_replace_subdriver(ide_drive_t *drive, const char *driver); extern int ide_replace_subdriver(ide_drive_t *drive, const char *driver);
#ifdef CONFIG_BLK_DEV_IDEPCI #ifdef CONFIG_BLK_DEV_IDEPCI
#define ON_BOARD 1 #define ON_BOARD 1
......
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