From acb0c332aad552faee4da571b9948177a610d0e0 Mon Sep 17 00:00:00 2001 From: Bartlomiej Zolnierkiewicz Date: Mon, 29 Sep 2003 02:15:23 -0700 Subject: [PATCH] [PATCH] update dtc2278 driver - common dtc2278_init() for built-in and module - touch hwifs only if hwif->chipset == ide_unknown for both ports, so we don't thrash already used hwifs when loading module - release hwif only if hwif->chipset == ide_dtc2278 - mark exit functions with __exit - do not use ide_hwifs[] directly - minor cleanups --- drivers/ide/ide.c | 4 +- drivers/ide/legacy/dtc2278.c | 111 ++++++++++++++++------------------- 2 files changed, 53 insertions(+), 62 deletions(-) diff --git a/drivers/ide/ide.c b/drivers/ide/ide.c index c4e8c32b31278..7981920ac44a8 100644 --- a/drivers/ide/ide.c +++ b/drivers/ide/ide.c @@ -1812,7 +1812,7 @@ extern void init_umc8672(void); #endif #ifdef CONFIG_BLK_DEV_DTC2278 static int __initdata probe_dtc2278; -extern void init_dtc2278(void); +extern int dtc2278_init(void); #endif #ifdef CONFIG_BLK_DEV_HT6560B static int __initdata probe_ht6560b; @@ -2609,7 +2609,7 @@ int __init ide_init (void) #endif #ifdef CONFIG_BLK_DEV_DTC2278 if (probe_dtc2278) - init_dtc2278(); + (void)dtc2278_init(); #endif #ifdef CONFIG_BLK_DEV_HT6560B if (probe_ht6560b) diff --git a/drivers/ide/legacy/dtc2278.c b/drivers/ide/legacy/dtc2278.c index 7e30b0933f05e..91fa8584db31b 100644 --- a/drivers/ide/legacy/dtc2278.c +++ b/drivers/ide/legacy/dtc2278.c @@ -95,9 +95,16 @@ static void tune_dtc2278 (ide_drive_t *drive, u8 pio) HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1; } -void __init probe_dtc2278 (void) +static int __init probe_dtc2278(void) { unsigned long flags; + ide_hwif_t *hwif, *mate; + + hwif = &ide_hwifs[0]; + mate = &ide_hwifs[1]; + + if (hwif->chipset != ide_unknown || mate->chipset != ide_unknown) + return 1; local_irq_save(flags); /* @@ -117,76 +124,60 @@ void __init probe_dtc2278 (void) #endif local_irq_restore(flags); - ide_hwifs[0].serialized = 1; - ide_hwifs[1].serialized = 1; - ide_hwifs[0].chipset = ide_dtc2278; - ide_hwifs[1].chipset = ide_dtc2278; - ide_hwifs[0].tuneproc = &tune_dtc2278; - ide_hwifs[0].drives[0].no_unmask = 1; - ide_hwifs[0].drives[1].no_unmask = 1; - ide_hwifs[1].drives[0].no_unmask = 1; - ide_hwifs[1].drives[1].no_unmask = 1; - ide_hwifs[0].mate = &ide_hwifs[1]; - ide_hwifs[1].mate = &ide_hwifs[0]; - ide_hwifs[1].channel = 1; - - probe_hwif_init(&ide_hwifs[0]); - probe_hwif_init(&ide_hwifs[1]); -} + hwif->serialized = 1; + hwif->chipset = ide_dtc2278; + hwif->tuneproc = &tune_dtc2278; + hwif->drives[0].no_unmask = 1; + hwif->drives[1].no_unmask = 1; + hwif->mate = mate; -static void dtc2278_release (void) -{ - if (ide_hwifs[0].chipset != ide_dtc2278 && - ide_hwifs[1].chipset != ide_dtc2278) - return; + mate->serialized = 1; + mate->chipset = ide_dtc2278; + mate->drives[0].no_unmask = 1; + mate->drives[1].no_unmask = 1; + mate->mate = hwif; + mate->channel = 1; - ide_hwifs[0].serialized = 0; - ide_hwifs[1].serialized = 0; - ide_hwifs[0].chipset = ide_unknown; - ide_hwifs[1].chipset = ide_unknown; - ide_hwifs[0].tuneproc = NULL; - ide_hwifs[0].drives[0].no_unmask = 0; - ide_hwifs[0].drives[1].no_unmask = 0; - ide_hwifs[1].drives[0].no_unmask = 0; - ide_hwifs[1].drives[1].no_unmask = 0; - ide_hwifs[0].mate = NULL; - ide_hwifs[1].mate = NULL; -} + probe_hwif_init(hwif); + probe_hwif_init(mate); -#ifndef MODULE -/* - * init_dtc2278: - * - * called by ide.c when parsing command line - */ - -void __init init_dtc2278 (void) -{ - probe_dtc2278(); + return 0; } -#else - -MODULE_AUTHOR("See Local File"); -MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets"); -MODULE_LICENSE("GPL"); - -static int __init dtc2278_mod_init(void) +/* Can be called directly from ide.c. */ +int __init dtc2278_init(void) { - probe_dtc2278(); - if (ide_hwifs[0].chipset != ide_dtc2278 && - ide_hwifs[1].chipset != ide_dtc2278) { - dtc2278_release(); - return -ENODEV; + if (probe_dtc2278()) { + printk(KERN_ERR "dtc2278: ide interfaces already in use!\n"); + return -EBUSY; } return 0; } -module_init(dtc2278_mod_init); -static void __exit dtc2278_mod_exit(void) +#ifdef MODULE +static void __exit dtc2278_release_hwif(ide_hwif_t *hwif) { - dtc2278_release(); + if (hwif->chipset != ide_dtc2278) + return; + + hwif->serialized = 0; + hwif->chipset = ide_unknown; + hwif->tuneproc = NULL; + hwif->drives[0].no_unmask = 0; + hwif->drives[1].no_unmask = 0; + hwif->mate = NULL; } -module_exit(dtc2278_mod_exit); + +static void __exit dtc2278_exit(void) +{ + dtc2278_release_hwif(&ide_hwifs[0]); + dtc2278_release_hwif(&ide_hwifs[1]); +} + +module_init(dtc2278_init); +module_exit(dtc2278_exit); #endif +MODULE_AUTHOR("See Local File"); +MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets"); +MODULE_LICENSE("GPL"); -- 2.53.0