Commit 8a5f10d9 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] parport: keep track of parport_pc ports

	parport_pc switched to keeping track of the ports it had
created; in module_exit it uses the private list instead of messing
with parport_enumerate().
	Added compile fix for configs that have CONFIG_PARPORT_PC_FIFO turned
off (from -mm).
parent e63fd952
...@@ -2107,6 +2107,9 @@ static int __devinit parport_dma_probe (struct parport *p) ...@@ -2107,6 +2107,9 @@ static int __devinit parport_dma_probe (struct parport *p)
/* --- Initialisation code -------------------------------- */ /* --- Initialisation code -------------------------------- */
static LIST_HEAD(ports_list);
static spinlock_t ports_lock = SPIN_LOCK_UNLOCKED;
struct parport *parport_pc_probe_port (unsigned long int base, struct parport *parport_pc_probe_port (unsigned long int base,
unsigned long int base_hi, unsigned long int base_hi,
int irq, int dma, int irq, int dma,
...@@ -2145,6 +2148,8 @@ struct parport *parport_pc_probe_port (unsigned long int base, ...@@ -2145,6 +2148,8 @@ struct parport *parport_pc_probe_port (unsigned long int base,
priv->dma_buf = 0; priv->dma_buf = 0;
priv->dma_handle = 0; priv->dma_handle = 0;
priv->dev = dev; priv->dev = dev;
INIT_LIST_HEAD(&priv->list);
priv->port = p;
p->base_hi = base_hi; p->base_hi = base_hi;
p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT; p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
p->private_data = priv; p->private_data = priv;
...@@ -2296,6 +2301,9 @@ struct parport *parport_pc_probe_port (unsigned long int base, ...@@ -2296,6 +2301,9 @@ struct parport *parport_pc_probe_port (unsigned long int base,
/* Now that we've told the sharing engine about the port, and /* Now that we've told the sharing engine about the port, and
found out its characteristics, let the high-level drivers found out its characteristics, let the high-level drivers
know about it. */ know about it. */
spin_lock(&ports_lock);
list_add(&priv->list, &ports_list);
spin_unlock(&ports_lock);
parport_announce_port (p); parport_announce_port (p);
return p; return p;
...@@ -2320,11 +2328,13 @@ EXPORT_SYMBOL (parport_pc_probe_port); ...@@ -2320,11 +2328,13 @@ EXPORT_SYMBOL (parport_pc_probe_port);
void parport_pc_unregister_port (struct parport *p) void parport_pc_unregister_port (struct parport *p)
{ {
#ifdef CONFIG_PARPORT_PC_FIFO
struct parport_pc_private *priv = p->private_data; struct parport_pc_private *priv = p->private_data;
#endif /* CONFIG_PARPORT_PC_FIFO */
struct parport_operations *ops = p->ops; struct parport_operations *ops = p->ops;
parport_remove_port(p); parport_remove_port(p);
spin_lock(&ports_lock);
list_del_init(&priv->list);
spin_unlock(&ports_lock);
if (p->dma != PARPORT_DMA_NONE) if (p->dma != PARPORT_DMA_NONE)
free_dma(p->dma); free_dma(p->dma);
if (p->irq != PARPORT_IRQ_NONE) if (p->irq != PARPORT_IRQ_NONE)
...@@ -3126,19 +3136,21 @@ static int __init parport_pc_init(void) ...@@ -3126,19 +3136,21 @@ static int __init parport_pc_init(void)
static void __exit parport_pc_exit(void) static void __exit parport_pc_exit(void)
{ {
/* We ought to keep track of which ports are actually ours. */
struct parport *p = parport_enumerate(), *tmp;
if (registered_parport) if (registered_parport)
pci_unregister_driver (&parport_pc_pci_driver); pci_unregister_driver (&parport_pc_pci_driver);
while (p) { spin_lock(&ports_lock);
tmp = p->next; while (!list_empty(&ports_list)) {
if (p->modes & PARPORT_MODE_PCSPP) struct parport_pc_private *priv;
parport_pc_unregister_port (p); struct parport *port;
priv = list_entry(ports_list.next,
p = tmp; struct parport_pc_private, list);
} port = priv->port;
spin_unlock(&ports_lock);
parport_pc_unregister_port(port);
spin_lock(&ports_lock);
}
spin_unlock(&ports_lock);
pnp_unregister_driver (&parport_pc_pnp_driver); pnp_unregister_driver (&parport_pc_pnp_driver);
} }
......
...@@ -39,6 +39,8 @@ struct parport_pc_private { ...@@ -39,6 +39,8 @@ struct parport_pc_private {
char *dma_buf; char *dma_buf;
dma_addr_t dma_handle; dma_addr_t dma_handle;
struct pci_dev *dev; struct pci_dev *dev;
struct list_head list;
struct parport *port;
}; };
static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d) static __inline__ void parport_pc_write_data(struct parport *p, unsigned char d)
......
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