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);
#endif
#ifdef CONFIG_BLK_DEV_ALI14XX
static int __initdata probe_ali14xx;
extern void init_ali14xx(void);
extern int ali14xx_init(void);
#endif
#ifdef CONFIG_BLK_DEV_UMC8672
static int __initdata probe_umc8672;
......@@ -2601,7 +2601,7 @@ int __init ide_init (void)
#endif
#ifdef CONFIG_BLK_DEV_ALI14XX
if (probe_ali14xx)
init_ali14xx();
(void)ali14xx_init();
#endif
#ifdef CONFIG_BLK_DEV_UMC8672
if (probe_umc8672)
......
......@@ -198,22 +198,12 @@ static int __init initRegisters (void) {
return t;
}
int __init probe_ali14xx (void)
static int __init ali14xx_probe(void)
{
/* auto-detect IDE controller port */
if (!findPort()) {
printk(KERN_ERR "ali14xx: not found.\n");
return 1;
}
ide_hwif_t *hwif, *mate;
printk(KERN_DEBUG "ali14xx: base= 0x%03x, regOn = 0x%02x.\n", basePort, regOn);
ide_hwifs[0].chipset = ide_ali14xx;
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;
printk(KERN_DEBUG "ali14xx: base=0x%03x, regOn=0x%02x.\n",
basePort, regOn);
/* initialize controller registers */
if (!initRegisters()) {
......@@ -221,74 +211,59 @@ int __init probe_ali14xx (void)
return 1;
}
probe_hwif_init(&ide_hwifs[0]);
probe_hwif_init(&ide_hwifs[1]);
hwif = &ide_hwifs[0];
mate = &ide_hwifs[1];
return 0;
}
hwif->chipset = ide_ali14xx;
hwif->tuneproc = &ali14xx_tune_drive;
hwif->mate = mate;
static void ali14xx_release (void)
{
if (ide_hwifs[0].chipset != ide_ali14xx &&
ide_hwifs[1].chipset != ide_ali14xx)
return;
mate->chipset = ide_ali14xx;
mate->tuneproc = &ali14xx_tune_drive;
mate->mate = hwif;
mate->channel = 1;
ide_hwifs[0].chipset = ide_unknown;
ide_hwifs[1].chipset = ide_unknown;
ide_hwifs[0].tuneproc = NULL;
ide_hwifs[1].tuneproc = NULL;
ide_hwifs[0].mate = NULL;
ide_hwifs[1].mate = NULL;
}
probe_hwif_init(hwif);
probe_hwif_init(mate);
#ifndef MODULE
/*
* init_ali14xx:
*
* called by ide.c when parsing command line
*/
return 0;
}
void __init init_ali14xx (void)
/* Can be called directly from ide.c. */
int __init ali14xx_init(void)
{
/* auto-detect IDE controller port */
if (findPort())
if (probe_ali14xx())
goto no_detect;
return;
no_detect:
if (findPort()) {
if (ali14xx_probe())
return -ENODEV;
return 0;
}
printk(KERN_ERR "ali14xx: not found.\n");
ali14xx_release();
return -ENODEV;
}
#else
MODULE_AUTHOR("see local file");
MODULE_DESCRIPTION("support of ALI 14XX IDE chipsets");
MODULE_LICENSE("GPL");
static int __init ali14xx_mod_init(void)
#ifdef MODULE
static void __exit ali14xx_release_hwif(ide_hwif_t *hwif)
{
/* auto-detect IDE controller port */
if (findPort())
if (probe_ali14xx()) {
ali14xx_release();
return -ENODEV;
}
if (hwif->chipset != ide_ali14xx)
return;
if (ide_hwifs[0].chipset != ide_ali14xx &&
ide_hwifs[1].chipset != ide_ali14xx) {
ali14xx_release();
return -ENODEV;
}
return 0;
hwif->chipset = ide_unknown;
hwif->tuneproc = NULL;
hwif->mate = NULL;
hwif->channel = 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
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