aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport/parport_pc.c
diff options
context:
space:
mode:
authorDavid Brownell <david-b@pacbell.net>2007-05-08 03:27:35 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:05 -0400
commitc15a3837d2aa30e3ea41aed49d80abed355ab6bd (patch)
tree23da1c16c1e73ac5679f81c3264fc0faeb92fcf2 /drivers/parport/parport_pc.c
parentd2d9433a4c84c9e7ed78d633fdbffb35d5afda17 (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/parport/parport_pc.c')
-rw-r--r--drivers/parport/parport_pc.c31
1 files changed, 17 insertions, 14 deletions
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
735dump_parport_state ("leave fifo_write_block_dma", port); 736dump_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);
2146struct parport *parport_pc_probe_port (unsigned long int base, 2147struct 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);