aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/parport
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/parport')
-rw-r--r--drivers/parport/parport_cs.c2
-rw-r--r--drivers/parport/parport_mfc3.c1
-rw-r--r--drivers/parport/parport_pc.c70
-rw-r--r--drivers/parport/parport_serial.c10
-rw-r--r--drivers/parport/parport_sunbpp.c1
-rw-r--r--drivers/parport/share.c5
6 files changed, 72 insertions, 17 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..02c0d52c9f76 100644
--- a/drivers/parport/parport_pc.c
+++ b/drivers/parport/parport_pc.c
@@ -53,6 +53,7 @@
53#include <linux/slab.h> 53#include <linux/slab.h>
54#include <linux/pci.h> 54#include <linux/pci.h>
55#include <linux/pnp.h> 55#include <linux/pnp.h>
56#include <linux/platform_device.h>
56#include <linux/sysctl.h> 57#include <linux/sysctl.h>
57 58
58#include <asm/io.h> 59#include <asm/io.h>
@@ -620,6 +621,7 @@ static size_t parport_pc_fifo_write_block_dma (struct parport *port,
620 unsigned long dmaflag; 621 unsigned long dmaflag;
621 size_t left = length; 622 size_t left = length;
622 const struct parport_pc_private *priv = port->physport->private_data; 623 const struct parport_pc_private *priv = port->physport->private_data;
624 struct device *dev = port->physport->dev;
623 dma_addr_t dma_addr, dma_handle; 625 dma_addr_t dma_addr, dma_handle;
624 size_t maxlen = 0x10000; /* max 64k per DMA transfer */ 626 size_t maxlen = 0x10000; /* max 64k per DMA transfer */
625 unsigned long start = (unsigned long) buf; 627 unsigned long start = (unsigned long) buf;
@@ -631,8 +633,8 @@ dump_parport_state ("enter fifo_write_block_dma", port);
631 if ((start ^ end) & ~0xffffUL) 633 if ((start ^ end) & ~0xffffUL)
632 maxlen = 0x10000 - (start & 0xffff); 634 maxlen = 0x10000 - (start & 0xffff);
633 635
634 dma_addr = dma_handle = pci_map_single(priv->dev, (void *)buf, length, 636 dma_addr = dma_handle = dma_map_single(dev, (void *)buf, length,
635 PCI_DMA_TODEVICE); 637 DMA_TO_DEVICE);
636 } else { 638 } else {
637 /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */ 639 /* above 16 MB we use a bounce buffer as ISA-DMA is not possible */
638 maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */ 640 maxlen = PAGE_SIZE; /* sizeof(priv->dma_buf) */
@@ -728,9 +730,9 @@ dump_parport_state ("enter fifo_write_block_dma", port);
728 730
729 /* Turn off DMA mode */ 731 /* Turn off DMA mode */
730 frob_econtrol (port, 1<<3, 0); 732 frob_econtrol (port, 1<<3, 0);
731 733
732 if (dma_handle) 734 if (dma_handle)
733 pci_unmap_single(priv->dev, dma_handle, length, PCI_DMA_TODEVICE); 735 dma_unmap_single(dev, dma_handle, length, DMA_TO_DEVICE);
734 736
735dump_parport_state ("leave fifo_write_block_dma", port); 737dump_parport_state ("leave fifo_write_block_dma", port);
736 return length - left; 738 return length - left;
@@ -2146,7 +2148,7 @@ static DEFINE_SPINLOCK(ports_lock);
2146struct parport *parport_pc_probe_port (unsigned long int base, 2148struct parport *parport_pc_probe_port (unsigned long int base,
2147 unsigned long int base_hi, 2149 unsigned long int base_hi,
2148 int irq, int dma, 2150 int irq, int dma,
2149 struct pci_dev *dev) 2151 struct device *dev)
2150{ 2152{
2151 struct parport_pc_private *priv; 2153 struct parport_pc_private *priv;
2152 struct parport_operations *ops; 2154 struct parport_operations *ops;
@@ -2155,6 +2157,17 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2155 struct resource *base_res; 2157 struct resource *base_res;
2156 struct resource *ECR_res = NULL; 2158 struct resource *ECR_res = NULL;
2157 struct resource *EPP_res = NULL; 2159 struct resource *EPP_res = NULL;
2160 struct platform_device *pdev = NULL;
2161
2162 if (!dev) {
2163 /* We need a physical device to attach to, but none was
2164 * provided. Create our own. */
2165 pdev = platform_device_register_simple("parport_pc",
2166 base, NULL, 0);
2167 if (IS_ERR(pdev))
2168 return NULL;
2169 dev = &pdev->dev;
2170 }
2158 2171
2159 ops = kmalloc(sizeof (struct parport_operations), GFP_KERNEL); 2172 ops = kmalloc(sizeof (struct parport_operations), GFP_KERNEL);
2160 if (!ops) 2173 if (!ops)
@@ -2180,9 +2193,10 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2180 priv->fifo_depth = 0; 2193 priv->fifo_depth = 0;
2181 priv->dma_buf = NULL; 2194 priv->dma_buf = NULL;
2182 priv->dma_handle = 0; 2195 priv->dma_handle = 0;
2183 priv->dev = dev;
2184 INIT_LIST_HEAD(&priv->list); 2196 INIT_LIST_HEAD(&priv->list);
2185 priv->port = p; 2197 priv->port = p;
2198
2199 p->dev = dev;
2186 p->base_hi = base_hi; 2200 p->base_hi = base_hi;
2187 p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT; 2201 p->modes = PARPORT_MODE_PCSPP | PARPORT_MODE_SAFEININT;
2188 p->private_data = priv; 2202 p->private_data = priv;
@@ -2305,9 +2319,10 @@ struct parport *parport_pc_probe_port (unsigned long int base,
2305 p->dma = PARPORT_DMA_NONE; 2319 p->dma = PARPORT_DMA_NONE;
2306 } else { 2320 } else {
2307 priv->dma_buf = 2321 priv->dma_buf =
2308 pci_alloc_consistent(priv->dev, 2322 dma_alloc_coherent(dev,
2309 PAGE_SIZE, 2323 PAGE_SIZE,
2310 &priv->dma_handle); 2324 &priv->dma_handle,
2325 GFP_KERNEL);
2311 if (! priv->dma_buf) { 2326 if (! priv->dma_buf) {
2312 printk (KERN_WARNING "%s: " 2327 printk (KERN_WARNING "%s: "
2313 "cannot get buffer for DMA, " 2328 "cannot get buffer for DMA, "
@@ -2356,6 +2371,8 @@ out3:
2356out2: 2371out2:
2357 kfree (ops); 2372 kfree (ops);
2358out1: 2373out1:
2374 if (pdev)
2375 platform_device_unregister(pdev);
2359 return NULL; 2376 return NULL;
2360} 2377}
2361 2378
@@ -2383,7 +2400,7 @@ void parport_pc_unregister_port (struct parport *p)
2383 release_region(p->base_hi, 3); 2400 release_region(p->base_hi, 3);
2384#if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA) 2401#if defined(CONFIG_PARPORT_PC_FIFO) && defined(HAS_DMA)
2385 if (priv->dma_buf) 2402 if (priv->dma_buf)
2386 pci_free_consistent(priv->dev, PAGE_SIZE, 2403 dma_free_coherent(p->physport->dev, PAGE_SIZE,
2387 priv->dma_buf, 2404 priv->dma_buf,
2388 priv->dma_handle); 2405 priv->dma_handle);
2389#endif 2406#endif
@@ -2489,7 +2506,7 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
2489 */ 2506 */
2490 release_resource(base_res); 2507 release_resource(base_res);
2491 if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi, 2508 if (parport_pc_probe_port (ite8872_lpt, ite8872_lpthi,
2492 irq, PARPORT_DMA_NONE, NULL)) { 2509 irq, PARPORT_DMA_NONE, &pdev->dev)) {
2493 printk (KERN_INFO 2510 printk (KERN_INFO
2494 "parport_pc: ITE 8872 parallel port: io=0x%X", 2511 "parport_pc: ITE 8872 parallel port: io=0x%X",
2495 ite8872_lpt); 2512 ite8872_lpt);
@@ -2672,7 +2689,7 @@ static int __devinit sio_via_probe (struct pci_dev *pdev, int autoirq,
2672 } 2689 }
2673 2690
2674 /* finally, do the probe with values obtained */ 2691 /* finally, do the probe with values obtained */
2675 if (parport_pc_probe_port (port1, port2, irq, dma, NULL)) { 2692 if (parport_pc_probe_port (port1, port2, irq, dma, &pdev->dev)) {
2676 printk (KERN_INFO 2693 printk (KERN_INFO
2677 "parport_pc: VIA parallel port: io=0x%X", port1); 2694 "parport_pc: VIA parallel port: io=0x%X", port1);
2678 if (irq != PARPORT_IRQ_NONE) 2695 if (irq != PARPORT_IRQ_NONE)
@@ -2970,7 +2987,7 @@ static int parport_pc_pci_probe (struct pci_dev *dev,
2970 parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi); 2987 parport_pc_pci_tbl[i + last_sio].device, io_lo, io_hi);
2971 data->ports[count] = 2988 data->ports[count] =
2972 parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE, 2989 parport_pc_probe_port (io_lo, io_hi, PARPORT_IRQ_NONE,
2973 PARPORT_DMA_NONE, dev); 2990 PARPORT_DMA_NONE, &dev->dev);
2974 if (data->ports[count]) 2991 if (data->ports[count])
2975 count++; 2992 count++;
2976 } 2993 }
@@ -3077,8 +3094,8 @@ static int parport_pc_pnp_probe(struct pnp_dev *dev, const struct pnp_device_id
3077 } else 3094 } else
3078 dma = PARPORT_DMA_NONE; 3095 dma = PARPORT_DMA_NONE;
3079 3096
3080 printk(KERN_INFO "parport: PnPBIOS parport detected.\n"); 3097 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))) 3098 if (!(pdata = parport_pc_probe_port (io_lo, io_hi, irq, dma, &dev->dev)))
3082 return -ENODEV; 3099 return -ENODEV;
3083 3100
3084 pnp_set_drvdata(dev,pdata); 3101 pnp_set_drvdata(dev,pdata);
@@ -3103,6 +3120,21 @@ static struct pnp_driver parport_pc_pnp_driver = {
3103}; 3120};
3104 3121
3105 3122
3123static int __devinit parport_pc_platform_probe(struct platform_device *pdev)
3124{
3125 /* Always succeed, the actual probing is done in
3126 * parport_pc_probe_port(). */
3127 return 0;
3128}
3129
3130static struct platform_driver parport_pc_platform_driver = {
3131 .driver = {
3132 .owner = THIS_MODULE,
3133 .name = "parport_pc",
3134 },
3135 .probe = parport_pc_platform_probe,
3136};
3137
3106/* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */ 3138/* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */
3107static int __devinit __attribute__((unused)) 3139static int __devinit __attribute__((unused))
3108parport_pc_find_isa_ports (int autoirq, int autodma) 3140parport_pc_find_isa_ports (int autoirq, int autodma)
@@ -3378,9 +3410,15 @@ __setup("parport_init_mode=",parport_init_mode_setup);
3378 3410
3379static int __init parport_pc_init(void) 3411static int __init parport_pc_init(void)
3380{ 3412{
3413 int err;
3414
3381 if (parse_parport_params()) 3415 if (parse_parport_params())
3382 return -EINVAL; 3416 return -EINVAL;
3383 3417
3418 err = platform_driver_register(&parport_pc_platform_driver);
3419 if (err)
3420 return err;
3421
3384 if (io[0]) { 3422 if (io[0]) {
3385 int i; 3423 int i;
3386 /* Only probe the ports we were given. */ 3424 /* Only probe the ports we were given. */
@@ -3405,6 +3443,7 @@ static void __exit parport_pc_exit(void)
3405 pci_unregister_driver (&parport_pc_pci_driver); 3443 pci_unregister_driver (&parport_pc_pci_driver);
3406 if (pnp_registered_parport) 3444 if (pnp_registered_parport)
3407 pnp_unregister_driver (&parport_pc_pnp_driver); 3445 pnp_unregister_driver (&parport_pc_pnp_driver);
3446 platform_driver_unregister(&parport_pc_platform_driver);
3408 3447
3409 spin_lock(&ports_lock); 3448 spin_lock(&ports_lock);
3410 while (!list_empty(&ports_list)) { 3449 while (!list_empty(&ports_list)) {
@@ -3413,6 +3452,9 @@ static void __exit parport_pc_exit(void)
3413 priv = list_entry(ports_list.next, 3452 priv = list_entry(ports_list.next,
3414 struct parport_pc_private, list); 3453 struct parport_pc_private, list);
3415 port = priv->port; 3454 port = priv->port;
3455 if (port->dev && port->dev->bus == &platform_bus_type)
3456 platform_device_unregister(
3457 to_platform_device(port->dev));
3416 spin_unlock(&ports_lock); 3458 spin_unlock(&ports_lock);
3417 parport_pc_unregister_port(port); 3459 parport_pc_unregister_port(port);
3418 spin_lock(&ports_lock); 3460 spin_lock(&ports_lock);
diff --git a/drivers/parport/parport_serial.c b/drivers/parport/parport_serial.c
index 78c0a269a2ba..90ea3b8b99b0 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;
@@ -392,6 +392,7 @@ static int parport_serial_pci_suspend(struct pci_dev *dev, pm_message_t state)
392static int parport_serial_pci_resume(struct pci_dev *dev) 392static int parport_serial_pci_resume(struct pci_dev *dev)
393{ 393{
394 struct parport_serial_private *priv = pci_get_drvdata(dev); 394 struct parport_serial_private *priv = pci_get_drvdata(dev);
395 int err;
395 396
396 pci_set_power_state(dev, PCI_D0); 397 pci_set_power_state(dev, PCI_D0);
397 pci_restore_state(dev); 398 pci_restore_state(dev);
@@ -399,7 +400,12 @@ static int parport_serial_pci_resume(struct pci_dev *dev)
399 /* 400 /*
400 * The device may have been disabled. Re-enable it. 401 * The device may have been disabled. Re-enable it.
401 */ 402 */
402 pci_enable_device(dev); 403 err = pci_enable_device(dev);
404 if (err) {
405 printk(KERN_ERR "parport_serial: %s: error enabling "
406 "device for resume (%d)\n", pci_name(dev), err);
407 return err;
408 }
403 409
404 if (priv->serial) 410 if (priv->serial)
405 pciserial_resume_ports(priv->serial); 411 pciserial_resume_ports(priv->serial);
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(&registration_lock); 374 mutex_lock(&registration_lock);
370 spin_lock_irq(&parportlist_lock); 375 spin_lock_irq(&parportlist_lock);