diff options
author | David Brownell <david-b@pacbell.net> | 2007-05-08 03:27:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:05 -0400 |
commit | c15a3837d2aa30e3ea41aed49d80abed355ab6bd (patch) | |
tree | 23da1c16c1e73ac5679f81c3264fc0faeb92fcf2 /drivers | |
parent | d2d9433a4c84c9e7ed78d633fdbffb35d5afda17 (diff) |
parport->dev driver model support
Currently a parport_driver can't get a handle on the device node for the
underlying parport (PNPACPI, PCI, etc). That prevents correct placement of
sysfs child nodes, which can affect things like power management.
This patch adds a field to "struct parport" pointing to that device node, and
updates non-legacy port drivers to initialize that device pointer. That field
replaces the analagous PCI-only support in parport_pc.
[akpm@linux-foundation.org: fix powerpc build]
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/parport/parport_cs.c | 2 | ||||
-rw-r--r-- | drivers/parport/parport_mfc3.c | 1 | ||||
-rw-r--r-- | drivers/parport/parport_pc.c | 31 | ||||
-rw-r--r-- | drivers/parport/parport_serial.c | 2 | ||||
-rw-r--r-- | drivers/parport/parport_sunbpp.c | 1 | ||||
-rw-r--r-- | drivers/parport/share.c | 5 |
6 files changed, 26 insertions, 16 deletions
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c index 316c06f4423c..8b7d84eca05d 100644 --- a/drivers/parport/parport_cs.c +++ b/drivers/parport/parport_cs.c | |||
@@ -201,7 +201,7 @@ static int parport_config(struct pcmcia_device *link) | |||
201 | 201 | ||
202 | p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2, | 202 | p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2, |
203 | link->irq.AssignedIRQ, PARPORT_DMA_NONE, | 203 | link->irq.AssignedIRQ, PARPORT_DMA_NONE, |
204 | NULL); | 204 | &link->dev); |
205 | if (p == NULL) { | 205 | if (p == NULL) { |
206 | printk(KERN_NOTICE "parport_cs: parport_pc_probe_port() at " | 206 | printk(KERN_NOTICE "parport_cs: parport_pc_probe_port() at " |
207 | "0x%3x, irq %u failed\n", link->io.BasePort1, | 207 | "0x%3x, irq %u failed\n", link->io.BasePort1, |
diff --git a/drivers/parport/parport_mfc3.c b/drivers/parport/parport_mfc3.c index e5b0a544de40..77726fc49766 100644 --- a/drivers/parport/parport_mfc3.c +++ b/drivers/parport/parport_mfc3.c | |||
@@ -356,6 +356,7 @@ static int __init parport_mfc3_init(void) | |||
356 | if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, IRQF_SHARED, p->name, &pp_mfc3_ops)) | 356 | if (request_irq(IRQ_AMIGA_PORTS, mfc3_interrupt, IRQF_SHARED, p->name, &pp_mfc3_ops)) |
357 | goto out_irq; | 357 | goto out_irq; |
358 | } | 358 | } |
359 | p->dev = &z->dev; | ||
359 | 360 | ||
360 | this_port[pias++] = p; | 361 | this_port[pias++] = p; |
361 | printk(KERN_INFO "%s: Multiface III port using irq\n", p->name); | 362 | printk(KERN_INFO "%s: Multiface III port using irq\n", p->name); |
diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c index 3de2623afa13..c3240a67ef85 100644 --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c | |||
@@ -620,6 +620,7 @@ static size_t parport_pc_fifo_write_block_dma (struct parport *port, | |||
620 | unsigned long dmaflag; | 620 | unsigned long dmaflag; |
621 | size_t left = length; | 621 | size_t left = length; |
622 | const struct parport_pc_private *priv = port->physport->private_data; | 622 | const struct parport_pc_private *priv = port->physport->private_data; |
623 | struct device *dev = port->physport->dev; | ||
623 | dma_addr_t dma_addr, dma_handle; | 624 | dma_addr_t dma_addr, dma_handle; |
624 | size_t maxlen = 0x10000; /* max 64k per DMA transfer */ | 625 | size_t maxlen = 0x10000; /* max 64k per DMA transfer */ |
625 | unsigned long start = (unsigned long) buf; | 626 | unsigned long start = (unsigned long) buf; |
@@ -631,8 +632,8 @@ dump_parport_state ("enter fifo_write_block_dma", port); | |||
631 | if ((start ^ end) & ~0xffffUL) | 632 | if ((start ^ end) & ~0xffffUL) |
632 | maxlen = 0x10000 - (start & 0xffff); | 633 | maxlen = 0x10000 - (start & 0xffff); |
633 | 634 | ||
634 | dma_addr = dma_handle = pci_map_single(priv->dev, (void *)buf, length, | 635 | dma_addr = dma_handle = dma_map_single(dev, (void *)buf, length, |
635 | PCI_DMA_TODEVICE); | 636 | DMA_TO_DEVICE); |
636 | } else { | 637 | } else { |
637 | /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */ | 638 | /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */ |
638 | maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */ | 639 | maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */ |
@@ -728,9 +729,9 @@ dump_parport_state ("enter fifo_write_block_dma", port); | |||
728 | 729 | ||
729 | /* Turn off DMA mode */ | 730 | /* Turn off DMA mode */ |
730 | frob_econtrol (port, 1<<3, 0); | 731 | frob_econtrol (port, 1<<3, 0); |
731 | 732 | ||
732 | if (dma_handle) | 733 | if (dma_handle) |
733 | pci_unmap_single(priv->dev, dma_handle, length, PCI_DMA_TODEVICE); | 734 | dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE); |
734 | 735 | ||
735 | dump_parport_state ("leave fifo_write_block_dma", port); | 736 | dump_parport_state ("leave fifo_write_block_dma", port); |
736 | return length - left; | 737 | return length - left; |
@@ -2146,7 +2147,7 @@ static DEFINE_SPINLOCK(ports_lock); | |||
2146 | struct parport *parport_pc_probe_port (unsigned long int base, | 2147 | struct parport *parport_pc_probe_port (unsigned long int base, |
2147 | unsigned long int base_hi, | 2148 | unsigned long int base_hi, |
2148 | int irq, int dma, | 2149 | int irq, int dma, |
2149 | struct pci_dev *dev) | 2150 | struct device *dev) |
2150 | { | 2151 | { |
2151 | struct parport_pc_private *priv; | 2152 | struct parport_pc_private *priv; |
2152 | struct parport_operations *ops; | 2153 | struct parport_operations *ops; |
@@ -2180,9 +2181,10 @@ struct parport *parport_pc_probe_port (unsigned long int base, | |||
2180 | priv->fifo_depth = 0; | 2181 | priv->fifo_depth = 0; |
2181 | priv->dma_buf = NULL; | 2182 | priv->dma_buf = NULL; |
2182 | priv->dma_handle = 0; | 2183 | priv->dma_handle = 0; |
2183 | priv->dev = dev; | ||
2184 | INIT_LIST_HEAD(&priv->list); | 2184 | INIT_LIST_HEAD(&priv->list); |
2185 | priv->port = p; | 2185 | priv->port = p; |
2186 | |||
2187 | p->dev = dev; | ||
2186 | p->base_hi = base_hi; | 2188 | p->base_hi = base_hi; |
2187 | p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT; | 2189 | p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT; |
2188 | p->private_data = priv; | 2190 | p->private_data = priv; |
@@ -2305,9 +2307,10 @@ struct parport *parport_pc_probe_port (unsigned long int base, | |||
2305 | p->dma = PARPORT_DMA_NONE; | 2307 | p->dma = PARPORT_DMA_NONE; |
2306 | } else { | 2308 | } else { |
2307 | priv->dma_buf = | 2309 | priv->dma_buf = |
2308 | pci_alloc_consistent(priv->dev, | 2310 | dma_alloc_coherent(dev, |
2309 | PAGE_SIZE, | 2311 | PAGE_SIZE, |
2310 | &priv->dma_handle); | 2312 | &priv->dma_handle, |
2313 | GFP_KERNEL); | ||
2311 | if (! priv->dma_buf) { | 2314 | if (! priv->dma_buf) { |
2312 | printk (KERN_WARNING "%s: " | 2315 | printk (KERN_WARNING "%s: " |
2313 | "cannot get buffer for DMA, " | 2316 | "cannot get buffer for DMA, " |
@@ -2383,7 +2386,7 @@ void parport_pc_unregister_port (struct parport *p) | |||
2383 | release_region(p->base_hi, 3); | 2386 | release_region(p->base_hi, 3); |
2384 | #if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA) | 2387 | #if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA) |
2385 | if (priv->dma_buf) | 2388 | if (priv->dma_buf) |
2386 | pci_free_consistent(priv->dev, PAGE_SIZE, | 2389 | dma_free_coherent(p->physport->dev, PAGE_SIZE, |
2387 | priv->dma_buf, | 2390 | priv->dma_buf, |
2388 | priv->dma_handle); | 2391 | priv->dma_handle); |
2389 | #endif | 2392 | #endif |
@@ -2489,7 +2492,7 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq, | |||
2489 | */ | 2492 | */ |
2490 | release_resource(base_res); | 2493 | release_resource(base_res); |
2491 | if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, | 2494 | if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, |
2492 | irq, PARPORT_DMA_NONE, NULL)) { | 2495 | irq, PARPORT_DMA_NONE, &pdev->dev)) { |
2493 | printk (KERN_INFO | 2496 | printk (KERN_INFO |
2494 | "parport_pc: ITE 8872 parallel port: io=0x%X", | 2497 | "parport_pc: ITE 8872 parallel port: io=0x%X", |
2495 | ite8872_lpt); | 2498 | ite8872_lpt); |
@@ -2672,7 +2675,7 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq, | |||
2672 | } | 2675 | } |
2673 | 2676 | ||
2674 | /* finally, do the probe with values obtained */ | 2677 | /* finally, do the probe with values obtained */ |
2675 | if (parport_pc_probe_port (port1, port2, irq, dma, NULL)) { | 2678 | if (parport_pc_probe_port (port1, port2, irq, dma, &pdev->dev)) { |
2676 | printk (KERN_INFO | 2679 | printk (KERN_INFO |
2677 | "parport_pc: VIA parallel port: io=0x%X", port1); | 2680 | "parport_pc: VIA parallel port: io=0x%X", port1); |
2678 | if (irq != PARPORT_IRQ_NONE) | 2681 | if (irq != PARPORT_IRQ_NONE) |
@@ -2970,7 +2973,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev, | |||
2970 | parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi); | 2973 | parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi); |
2971 | data->ports[count] = | 2974 | data->ports[count] = |
2972 | parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, | 2975 | parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, |
2973 | PARPORT_DMA_NONE, dev); | 2976 | PARPORT_DMA_NONE, &dev->dev); |
2974 | if (data->ports[count]) | 2977 | if (data->ports[count]) |
2975 | count++; | 2978 | count++; |
2976 | } | 2979 | } |
@@ -3077,8 +3080,8 @@ static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id | |||
3077 | } else | 3080 | } else |
3078 | dma = PARPORT_DMA_NONE; | 3081 | dma = PARPORT_DMA_NONE; |
3079 | 3082 | ||
3080 | printk(KERN_INFO "parport: PnPBIOS parport detected.\n"); | 3083 | dev_info(&dev->dev, "reported by %s\n", dev->protocol->name); |
3081 | if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, NULL))) | 3084 | if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, &dev->dev))) |
3082 | return -ENODEV; | 3085 | return -ENODEV; |
3083 | 3086 | ||
3084 | pnp_set_drvdata(dev,pdata); | 3087 | pnp_set_drvdata(dev,pdata); |
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c index 78c0a269a2ba..e06223cf6c26 100644 --- a/drivers/parport/parport_serial.c +++ b/drivers/parport/parport_serial.c | |||
@@ -305,7 +305,7 @@ static int __devinit parport_register (struct pci_dev *dev, | |||
305 | dev_dbg(&dev->dev, "PCI parallel port detected: I/O at " | 305 | dev_dbg(&dev->dev, "PCI parallel port detected: I/O at " |
306 | "%#lx(%#lx)\n", io_lo, io_hi); | 306 | "%#lx(%#lx)\n", io_lo, io_hi); |
307 | port = parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, | 307 | port = parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, |
308 | PARPORT_DMA_NONE, dev); | 308 | PARPORT_DMA_NONE, &dev->dev); |
309 | if (port) { | 309 | if (port) { |
310 | priv->port[priv->num_par++] = port; | 310 | priv->port[priv->num_par++] = port; |
311 | success = 1; | 311 | success = 1; |
diff --git a/drivers/parport/parport_sunbpp.c b/drivers/parport/parport_sunbpp.c index 400bb90084cf..d27019c2f860 100644 --- a/drivers/parport/parport_sunbpp.c +++ b/drivers/parport/parport_sunbpp.c | |||
@@ -322,6 +322,7 @@ static int __devinit init_one_port(struct sbus_dev *sdev) | |||
322 | goto out_free_ops; | 322 | goto out_free_ops; |
323 | 323 | ||
324 | p->size = size; | 324 | p->size = size; |
325 | p->dev = &sdev->ofdev.dev; | ||
325 | 326 | ||
326 | if ((err = request_irq(p->irq, parport_sunbpp_interrupt, | 327 | if ((err = request_irq(p->irq, parport_sunbpp_interrupt, |
327 | IRQF_SHARED, p->name, p)) != 0) { | 328 | IRQF_SHARED, p->name, p)) != 0) { |
diff --git a/drivers/parport/share.c b/drivers/parport/share.c index fd9129e424f9..cd66442acfee 100644 --- a/drivers/parport/share.c +++ b/drivers/parport/share.c | |||
@@ -365,6 +365,11 @@ void parport_announce_port (struct parport *port) | |||
365 | parport_daisy_init(port); | 365 | parport_daisy_init(port); |
366 | #endif | 366 | #endif |
367 | 367 | ||
368 | if (!port->dev) | ||
369 | printk(KERN_WARNING "%s: fix this legacy " | ||
370 | "no-device port driver!\n", | ||
371 | port->name); | ||
372 | |||
368 | parport_proc_register(port); | 373 | parport_proc_register(port); |
369 | mutex_lock(®istration_lock); | 374 | mutex_lock(®istration_lock); |
370 | spin_lock_irq(&parportlist_lock); | 375 | spin_lock_irq(&parportlist_lock); |