Commit acb0c332 authored by Bartlomiej Zolnierkiewicz's avatar Bartlomiej Zolnierkiewicz Committed by Linus Torvalds

[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
parent 209297f1
...@@ -1812,7 +1812,7 @@ extern void init_umc8672(void); ...@@ -1812,7 +1812,7 @@ extern void init_umc8672(void);
#endif #endif
#ifdef CONFIG_BLK_DEV_DTC2278 #ifdef CONFIG_BLK_DEV_DTC2278
static int __initdata probe_dtc2278; static int __initdata probe_dtc2278;
extern void init_dtc2278(void); extern int dtc2278_init(void);
#endif #endif
#ifdef CONFIG_BLK_DEV_HT6560B #ifdef CONFIG_BLK_DEV_HT6560B
static int __initdata probe_ht6560b; static int __initdata probe_ht6560b;
...@@ -2609,7 +2609,7 @@ int __init ide_init (void) ...@@ -2609,7 +2609,7 @@ int __init ide_init (void)
#endif #endif
#ifdef CONFIG_BLK_DEV_DTC2278 #ifdef CONFIG_BLK_DEV_DTC2278
if (probe_dtc2278) if (probe_dtc2278)
init_dtc2278(); (void)dtc2278_init();
#endif #endif
#ifdef CONFIG_BLK_DEV_HT6560B #ifdef CONFIG_BLK_DEV_HT6560B
if (probe_ht6560b) if (probe_ht6560b)
......
...@@ -95,9 +95,16 @@ static void tune_dtc2278 (ide_drive_t *drive, u8 pio) ...@@ -95,9 +95,16 @@ static void tune_dtc2278 (ide_drive_t *drive, u8 pio)
HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1; HWIF(drive)->drives[!drive->select.b.unit].io_32bit = 1;
} }
void __init probe_dtc2278 (void) static int __init probe_dtc2278(void)
{ {
unsigned long flags; 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); local_irq_save(flags);
/* /*
...@@ -117,76 +124,60 @@ void __init probe_dtc2278 (void) ...@@ -117,76 +124,60 @@ void __init probe_dtc2278 (void)
#endif #endif
local_irq_restore(flags); local_irq_restore(flags);
ide_hwifs[0].serialized = 1; hwif->serialized = 1;
ide_hwifs[1].serialized = 1; hwif->chipset = ide_dtc2278;
ide_hwifs[0].chipset = ide_dtc2278; hwif->tuneproc = &tune_dtc2278;
ide_hwifs[1].chipset = ide_dtc2278; hwif->drives[0].no_unmask = 1;
ide_hwifs[0].tuneproc = &tune_dtc2278; hwif->drives[1].no_unmask = 1;
ide_hwifs[0].drives[0].no_unmask = 1; hwif->mate = mate;
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]);
}
static void dtc2278_release (void) mate->serialized = 1;
{ mate->chipset = ide_dtc2278;
if (ide_hwifs[0].chipset != ide_dtc2278 && mate->drives[0].no_unmask = 1;
ide_hwifs[1].chipset != ide_dtc2278) mate->drives[1].no_unmask = 1;
return; mate->mate = hwif;
mate->channel = 1;
ide_hwifs[0].serialized = 0; probe_hwif_init(hwif);
ide_hwifs[1].serialized = 0; probe_hwif_init(mate);
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;
}
#ifndef MODULE return 0;
/*
* init_dtc2278:
*
* called by ide.c when parsing command line
*/
void __init init_dtc2278 (void)
{
probe_dtc2278();
} }
#else /* Can be called directly from ide.c. */
int __init dtc2278_init(void)
MODULE_AUTHOR("See Local File");
MODULE_DESCRIPTION("support of DTC-2278 VLB IDE chipsets");
MODULE_LICENSE("GPL");
static int __init dtc2278_mod_init(void)
{ {
probe_dtc2278(); if (probe_dtc2278()) {
if (ide_hwifs[0].chipset != ide_dtc2278 && printk(KERN_ERR "dtc2278: ide interfaces already in use!\n");
ide_hwifs[1].chipset != ide_dtc2278) { return -EBUSY;
dtc2278_release();
return -ENODEV;
} }
return 0; 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 #endif
MODULE_AUTHOR("See Local File");
MODULE_DESCRIPTION("support of DTC-2278 VLB 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