Commit d27d703a authored by Adam Belay's avatar Adam Belay

IDE PnP Update

Updates the IDE PnP driver to the new PnP API.
parent 05140d26
...@@ -239,14 +239,13 @@ config BLK_DEV_CMD640_ENHANCED ...@@ -239,14 +239,13 @@ config BLK_DEV_CMD640_ENHANCED
and your BIOS does not already do this for you, then say Y here. and your BIOS does not already do this for you, then say Y here.
Otherwise say N. Otherwise say N.
config BLK_DEV_ISAPNP config BLK_DEV_IDEPNP
bool "ISA-PNP EIDE support" bool "PNP EIDE support"
depends on BLK_DEV_IDE && ISAPNP depends on BLK_DEV_IDE && PNP
help help
If you have an ISA EIDE card that is PnP (Plug and Play) and If you have a PnP (Plug and Play) compatible EIDE card and
requires setup first before scanning for devices, say Y here. would like the kernel to automatically detect and activate
it, say Y here.
If unsure, say N.
config BLK_DEV_IDEPCI config BLK_DEV_IDEPCI
bool "PCI IDE chipset support" if PCI bool "PCI IDE chipset support" if PCI
......
...@@ -21,7 +21,7 @@ obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o ...@@ -21,7 +21,7 @@ obj-$(CONFIG_BLK_DEV_IDEFLOPPY) += ide-floppy.o
obj-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o obj-$(CONFIG_BLK_DEV_IDEPCI) += setup-pci.o
obj-$(CONFIG_BLK_DEV_IDEDMA_PCI) += ide-dma.o obj-$(CONFIG_BLK_DEV_IDEDMA_PCI) += ide-dma.o
obj-$(CONFIG_BLK_DEV_IDE_TCQ) += ide-tcq.o obj-$(CONFIG_BLK_DEV_IDE_TCQ) += ide-tcq.o
obj-$(CONFIG_BLK_DEV_ISAPNP) += ide-pnp.o obj-$(CONFIG_BLK_DEV_IDEPNP) += ide-pnp.o
ifeq ($(CONFIG_BLK_DEV_IDE),y) ifeq ($(CONFIG_BLK_DEV_IDE),y)
obj-$(CONFIG_PROC_FS) += ide-proc.o obj-$(CONFIG_PROC_FS) += ide-proc.o
......
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
#include <linux/ide.h> #include <linux/ide.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/isapnp.h> #include <linux/pnp.h>
#define DEV_NAME(dev) (dev->name)
#define GENERIC_HD_DATA 0 #define GENERIC_HD_DATA 0
#define GENERIC_HD_ERROR 1 #define GENERIC_HD_ERROR 1
...@@ -32,31 +30,27 @@ ...@@ -32,31 +30,27 @@
#define GENERIC_HD_SELECT 6 #define GENERIC_HD_SELECT 6
#define GENERIC_HD_STATUS 7 #define GENERIC_HD_STATUS 7
static int generic_ide_offsets[IDE_NR_PORTS] __initdata = { static int generic_ide_offsets[IDE_NR_PORTS] = {
GENERIC_HD_DATA, GENERIC_HD_ERROR, GENERIC_HD_NSECTOR, GENERIC_HD_DATA, GENERIC_HD_ERROR, GENERIC_HD_NSECTOR,
GENERIC_HD_SECTOR, GENERIC_HD_LCYL, GENERIC_HD_HCYL, GENERIC_HD_SECTOR, GENERIC_HD_LCYL, GENERIC_HD_HCYL,
GENERIC_HD_SELECT, GENERIC_HD_STATUS, -1, -1 GENERIC_HD_SELECT, GENERIC_HD_STATUS, -1, -1
}; };
/* ISA PnP device table entry */ /* Add your devices here :)) */
struct pnp_dev_t { struct pnp_device_id idepnp_devices[] = {
unsigned short card_vendor, card_device, vendor, device; /* Generic ESDI/IDE/ATA compatible hard disk controller */
int (*init_fn)(struct pnp_dev *dev, int enable); {.id = "PNP0600", .driver_data = 0},
{.id = ""}
}; };
/* Generic initialisation function for ISA PnP IDE interface */ static int idepnp_probe(struct pnp_dev * dev, const struct pnp_device_id *dev_id)
static int __init pnpide_generic_init(struct pnp_dev *dev, int enable)
{ {
hw_regs_t hw; hw_regs_t hw;
ide_hwif_t *hwif; ide_hwif_t *hwif;
int index; int index;
if (!enable)
return 0;
if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0))) if (!(pnp_port_valid(dev, 0) && pnp_port_valid(dev, 1) && pnp_irq_valid(dev, 0)))
return 1; return -1;
ide_setup_ports(&hw, (unsigned long) pnp_port_start(dev, 0), ide_setup_ports(&hw, (unsigned long) pnp_port_start(dev, 0),
generic_ide_offsets, generic_ide_offsets,
...@@ -68,82 +62,36 @@ static int __init pnpide_generic_init(struct pnp_dev *dev, int enable) ...@@ -68,82 +62,36 @@ static int __init pnpide_generic_init(struct pnp_dev *dev, int enable)
index = ide_register_hw(&hw, &hwif); index = ide_register_hw(&hw, &hwif);
if (index != -1) { if (index != -1) {
printk(KERN_INFO "ide%d: %s IDE interface\n", index, DEV_NAME(dev)); printk(KERN_INFO "ide%d: generic PnP IDE interface\n", index);
pnp_set_drvdata(dev,hwif);
hwif->pnp_dev = dev; hwif->pnp_dev = dev;
return 0; return 0;
} }
return 1; return -1;
} }
/* Add your devices here :)) */ static void idepnp_remove(struct pnp_dev * dev)
struct pnp_dev_t idepnp_devices[] __initdata = { {
/* Generic ESDI/IDE/ATA compatible hard disk controller */ ide_hwif_t *hwif = pnp_get_drvdata(dev);
{ ISAPNP_ANY_ID, ISAPNP_ANY_ID, if (hwif) {
ISAPNP_VENDOR('P', 'N', 'P'), ISAPNP_DEVICE(0x0600), ide_unregister(hwif->index);
pnpide_generic_init }, } else
{ 0 } printk(KERN_ERR "idepnp: Unable to remove device, please report.\n");
}; }
#define NR_PNP_DEVICES 8 static struct pnp_driver idepnp_driver = {
struct pnp_dev_inst { .name = "ide",
struct pnp_dev *dev; .id_table = idepnp_devices,
struct pnp_dev_t *dev_type; .probe = idepnp_probe,
.remove = idepnp_remove,
}; };
static struct pnp_dev_inst devices[NR_PNP_DEVICES];
static int pnp_ide_dev_idx = 0;
/*
* Probe for ISA PnP IDE interfaces.
*/
void __init pnpide_init(int enable) void pnpide_init(int enable)
{ {
struct pnp_dev *dev = NULL; if(enable)
struct pnp_dev_t *dev_type; pnp_register_driver(&idepnp_driver);
else
if (!isapnp_present()) pnp_unregister_driver(&idepnp_driver);
return;
/* Module unload, deactivate all registered devices. */
if (!enable) {
int i;
for (i = 0; i < pnp_ide_dev_idx; i++) {
dev = devices[i].dev;
devices[i].dev_type->init_fn(dev, 0);
pnp_device_detach(dev);
}
return;
}
for (dev_type = idepnp_devices; dev_type->vendor; dev_type++) {
while ((dev = pnp_find_dev(NULL, dev_type->vendor,
dev_type->device, dev))) {
if (pnp_device_attach(dev) < 0)
continue;
if (pnp_activate_dev(dev, NULL) < 0) {
printk(KERN_ERR"ide: %s activate failed\n", DEV_NAME(dev));
continue;
}
/* Call device initialization function */
if (dev_type->init_fn(dev, 1)) {
pnp_device_detach(dev);
} else {
#ifdef MODULE
/*
* Register device in the array to
* deactivate it on a module unload.
*/
if (pnp_ide_dev_idx >= NR_PNP_DEVICES)
return;
devices[pnp_ide_dev_idx].dev = dev;
devices[pnp_ide_dev_idx].dev_type = dev_type;
pnp_ide_dev_idx++;
#endif
}
}
}
} }
...@@ -818,6 +818,7 @@ void ide_unregister (unsigned int index) ...@@ -818,6 +818,7 @@ void ide_unregister (unsigned int index)
EXPORT_SYMBOL(ide_unregister); EXPORT_SYMBOL(ide_unregister);
/** /**
* ide_setup_ports - set up IDE interface ports * ide_setup_ports - set up IDE interface ports
* @hw: register descriptions * @hw: register descriptions
...@@ -2145,12 +2146,12 @@ static void __init probe_for_hwifs (void) ...@@ -2145,12 +2146,12 @@ static void __init probe_for_hwifs (void)
buddha_init(); buddha_init();
} }
#endif /* CONFIG_BLK_DEV_BUDDHA */ #endif /* CONFIG_BLK_DEV_BUDDHA */
#if defined(CONFIG_BLK_DEV_ISAPNP) && defined(CONFIG_ISAPNP) #if defined(CONFIG_BLK_DEV_IDEPNP) && defined(CONFIG_PNP)
{ {
extern void pnpide_init(int enable); extern void pnpide_init(int enable);
pnpide_init(1); pnpide_init(1);
} }
#endif /* CONFIG_BLK_DEV_ISAPNP */ #endif /* CONFIG_BLK_DEV_IDEPNP */
} }
void __init ide_init_builtin_drivers (void) void __init ide_init_builtin_drivers (void)
...@@ -2321,9 +2322,9 @@ int ide_unregister_subdriver (ide_drive_t *drive) ...@@ -2321,9 +2322,9 @@ int ide_unregister_subdriver (ide_drive_t *drive)
spin_unlock_irqrestore(&ide_lock, flags); spin_unlock_irqrestore(&ide_lock, flags);
return 1; return 1;
} }
#if defined(CONFIG_BLK_DEV_ISAPNP) && defined(CONFIG_ISAPNP) && defined(MODULE) #if defined(CONFIG_BLK_DEV_IDEPNP) && defined(CONFIG_PNP) && defined(MODULE)
pnpide_init(0); pnpide_init(0);
#endif /* CONFIG_BLK_DEV_ISAPNP */ #endif /* CONFIG_BLK_DEV_IDEPNP */
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
ide_remove_proc_entries(drive->proc, DRIVER(drive)->proc); ide_remove_proc_entries(drive->proc, DRIVER(drive)->proc);
ide_remove_proc_entries(drive->proc, generic_subdriver_entries); ide_remove_proc_entries(drive->proc, generic_subdriver_entries);
......
...@@ -1705,6 +1705,7 @@ static inline void ide_release_dma(ide_hwif_t *drive) {;} ...@@ -1705,6 +1705,7 @@ static inline void ide_release_dma(ide_hwif_t *drive) {;}
#endif #endif
extern void hwif_unregister(ide_hwif_t *); extern void hwif_unregister(ide_hwif_t *);
extern void ide_unregister (unsigned int index);
extern void export_ide_init_queue(ide_drive_t *); extern void export_ide_init_queue(ide_drive_t *);
extern u8 export_probe_for_drive(ide_drive_t *); extern u8 export_probe_for_drive(ide_drive_t *);
......
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