Commit 209297f1 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[PATCH] update ali14xx driver

- common ali14xx_init() for built-in and module
- do not call findPort() twice
- touch hwifs only if chipset was found and initialized
- release hwif only if hwif->chipset == ide_ali14xx
- when releasing hwif, restore hwif->channel to the default value
- mark exit functions with __exit
- do not use ide_hwifs[] directly
- minor cleanups
parent 6fa0801a
...@@ -1804,7 +1804,7 @@ extern void init_pdc4030(void); ...@@ -1804,7 +1804,7 @@ extern void init_pdc4030(void);
#endif #endif
#ifdef CONFIG_BLK_DEV_ALI14XX #ifdef CONFIG_BLK_DEV_ALI14XX
static int __initdata probe_ali14xx; static int __initdata probe_ali14xx;
extern void init_ali14xx(void); extern int ali14xx_init(void);
#endif #endif
#ifdef CONFIG_BLK_DEV_UMC8672 #ifdef CONFIG_BLK_DEV_UMC8672
static int __initdata probe_umc8672; static int __initdata probe_umc8672;
...@@ -2601,7 +2601,7 @@ int __init ide_init (void) ...@@ -2601,7 +2601,7 @@ int __init ide_init (void)
#endif #endif
#ifdef CONFIG_BLK_DEV_ALI14XX #ifdef CONFIG_BLK_DEV_ALI14XX
if (probe_ali14xx) if (probe_ali14xx)
init_ali14xx(); (void)ali14xx_init();
#endif #endif
#ifdef CONFIG_BLK_DEV_UMC8672 #ifdef CONFIG_BLK_DEV_UMC8672
if (probe_umc8672) if (probe_umc8672)
......
...@@ -198,22 +198,12 @@ static int __init initRegisters (void) { ...@@ -198,22 +198,12 @@ static int __init initRegisters (void) {
return t; return t;
} }
int __init probe_ali14xx (void) static int __init ali14xx_probe(void)
{ {
/* auto-detect IDE controller port */ ide_hwif_t *hwif, *mate;
if (!findPort()) {
printk(KERN_ERR "ali14xx: not found.\n");
return 1;
}
printk(KERN_DEBUG "ali14xx: base= 0x%03x, regOn = 0x%02x.\n", basePort, regOn); printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
ide_hwifs[0].chipset = ide_ali14xx; basePort, regOn);
ide_hwifs[1].chipset = ide_ali14xx;
ide_hwifs[0].tuneproc = &ali14xx_tune_drive;
ide_hwifs[1].tuneproc = &ali14xx_tune_drive;
ide_hwifs[0].mate = &ide_hwifs[1];
ide_hwifs[1].mate = &ide_hwifs[0];
ide_hwifs[1].channel = 1;
/* initialize controller registers */ /* initialize controller registers */
if (!initRegisters()) { if (!initRegisters()) {
...@@ -221,74 +211,59 @@ int __init probe_ali14xx (void) ...@@ -221,74 +211,59 @@ int __init probe_ali14xx (void)
return 1; return 1;
} }
probe_hwif_init(&ide_hwifs[0]); hwif = &ide_hwifs[0];
probe_hwif_init(&ide_hwifs[1]); mate = &ide_hwifs[1];
return 0; hwif->chipset = ide_ali14xx;
} hwif->tuneproc = &ali14xx_tune_drive;
hwif->mate = mate;
static void ali14xx_release (void) mate->chipset = ide_ali14xx;
{ mate->tuneproc = &ali14xx_tune_drive;
if (ide_hwifs[0].chipset != ide_ali14xx && mate->mate = hwif;
ide_hwifs[1].chipset != ide_ali14xx) mate->channel = 1;
return;
ide_hwifs[0].chipset = ide_unknown; probe_hwif_init(hwif);
ide_hwifs[1].chipset = ide_unknown; probe_hwif_init(mate);
ide_hwifs[0].tuneproc = NULL;
ide_hwifs[1].tuneproc = NULL;
ide_hwifs[0].mate = NULL;
ide_hwifs[1].mate = NULL;
}
#ifndef MODULE return 0;
/* }
* init_ali14xx:
*
* called by ide.c when parsing command line
*/
void __init init_ali14xx (void) /* Can be called directly from ide.c. */
int __init ali14xx_init(void)
{ {
/* auto-detect IDE controller port */ /* auto-detect IDE controller port */
if (findPort()) if (findPort()) {
if (probe_ali14xx()) if (ali14xx_probe())
goto no_detect; return -ENODEV;
return; return 0;
}
no_detect:
printk(KERN_ERR "ali14xx: not found.\n"); printk(KERN_ERR "ali14xx: not found.\n");
ali14xx_release(); return -ENODEV;
} }
#else #ifdef MODULE
static void __exit ali14xx_release_hwif(ide_hwif_t *hwif)
MODULE_AUTHOR("see local file");
MODULE_DESCRIPTION("support of ALI 14XX IDE chipsets");
MODULE_LICENSE("GPL");
static int __init ali14xx_mod_init(void)
{ {
/* auto-detect IDE controller port */ if (hwif->chipset != ide_ali14xx)
if (findPort()) return;
if (probe_ali14xx()) {
ali14xx_release();
return -ENODEV;
}
if (ide_hwifs[0].chipset != ide_ali14xx && hwif->chipset = ide_unknown;
ide_hwifs[1].chipset != ide_ali14xx) { hwif->tuneproc = NULL;
ali14xx_release(); hwif->mate = NULL;
return -ENODEV; hwif->channel = 0;
}
return 0;
} }
module_init(ali14xx_mod_init);
static void __exit ali14xx_mod_exit(void) static void __exit ali14xx_exit(void)
{ {
ali14xx_release(); ali14xx_release_hwif(&ide_hwifs[0]);
ali14xx_release_hwif(&ide_hwifs[1]);
} }
module_exit(ali14xx_mod_exit);
module_init(ali14xx_init);
module_exit(ali14xx_exit);
#endif #endif
MODULE_AUTHOR("see local file");
MODULE_DESCRIPTION("support of ALI 14XX IDE chipsets");
MODULE_LICENSE("GPL");
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