Commit ad1aa714 authored by Russell King's avatar Russell King Committed by Linus Torvalds

[PATCH] Hotplug parallel ports

The Mobility docking station provides a PCI-based parallel port.  Since the
docking station connects via Cardbus, such devices are removable. 
Therefore, track which parallel ports are registered to each PCI device,
and remove them when the PCI device is removed.
Signed-off-by: default avatarRussell King <rmk@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f6480aaa
...@@ -2907,10 +2907,16 @@ static struct pci_device_id parport_pc_pci_tbl[] = { ...@@ -2907,10 +2907,16 @@ static struct pci_device_id parport_pc_pci_tbl[] = {
}; };
MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl); MODULE_DEVICE_TABLE(pci,parport_pc_pci_tbl);
struct pci_parport_data {
int num;
struct parport *ports[2];
};
static int parport_pc_pci_probe (struct pci_dev *dev, static int parport_pc_pci_probe (struct pci_dev *dev,
const struct pci_device_id *id) const struct pci_device_id *id)
{ {
int err, count, n, i = id->driver_data; int err, count, n, i = id->driver_data;
struct pci_parport_data *data;
if (i < last_sio) if (i < last_sio)
/* This is an onboard Super-IO and has already been probed */ /* This is an onboard Super-IO and has already been probed */
...@@ -2922,9 +2928,15 @@ static int parport_pc_pci_probe (struct pci_dev *dev, ...@@ -2922,9 +2928,15 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
if ((err = pci_enable_device (dev)) != 0) if ((err = pci_enable_device (dev)) != 0)
return err; return err;
data = kmalloc(sizeof(struct pci_parport_data), GFP_KERNEL);
if (!data)
return -ENOMEM;
if (cards[i].preinit_hook && if (cards[i].preinit_hook &&
cards[i].preinit_hook (dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) cards[i].preinit_hook (dev, PARPORT_IRQ_NONE, PARPORT_DMA_NONE)) {
kfree(data);
return -ENODEV; return -ENODEV;
}
for (n = 0; n < cards[i].numports; n++) { for (n = 0; n < cards[i].numports; n++) {
int lo = cards[i].addr[n].lo; int lo = cards[i].addr[n].lo;
...@@ -2943,21 +2955,46 @@ static int parport_pc_pci_probe (struct pci_dev *dev, ...@@ -2943,21 +2955,46 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
"I/O at %#lx(%#lx)\n", "I/O at %#lx(%#lx)\n",
parport_pc_pci_tbl[i + last_sio].vendor, parport_pc_pci_tbl[i + last_sio].vendor,
parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi); parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi);
if (parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, data->ports[count] =
PARPORT_DMA_NONE, dev)) parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE,
PARPORT_DMA_NONE, dev);
if (data->ports[count])
count++; count++;
} }
data->num = count;
if (cards[i].postinit_hook) if (cards[i].postinit_hook)
cards[i].postinit_hook (dev, count == 0); cards[i].postinit_hook (dev, count == 0);
return count == 0 ? -ENODEV : 0; if (count) {
pci_set_drvdata(dev, data);
return 0;
}
kfree(data);
return -ENODEV;
}
static void __devexit parport_pc_pci_remove(struct pci_dev *dev)
{
struct pci_parport_data *data = pci_get_drvdata(dev);
int i;
pci_set_drvdata(dev, NULL);
for (i = data->num - 1; i >= 0; i--)
parport_pc_unregister_port(data->ports[i]);
kfree(data);
} }
static struct pci_driver parport_pc_pci_driver = { static struct pci_driver parport_pc_pci_driver = {
.name = "parport_pc", .name = "parport_pc",
.id_table = parport_pc_pci_tbl, .id_table = parport_pc_pci_tbl,
.probe = parport_pc_pci_probe, .probe = parport_pc_pci_probe,
.remove = __devexit_p(parport_pc_pci_remove),
}; };
static int __init parport_pc_init_superio (int autoirq, int autodma) static int __init parport_pc_init_superio (int autoirq, int autodma)
......
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