]> Pileus Git - ~andy/linux/blobdiff - drivers/parport/parport_pc.c
r8169: prevent bit sign expansion error in mdio_write
[~andy/linux] / drivers / parport / parport_pc.c
index c3240a67ef8511ec69b308f0a6751fa957732752..e9743d3efaf682a8a5db6b07d6f841cf7dc2c05d 100644 (file)
 #include <linux/ioport.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
+#include <linux/dma-mapping.h>
 #include <linux/pci.h>
 #include <linux/pnp.h>
+#include <linux/platform_device.h>
 #include <linux/sysctl.h>
 
 #include <asm/io.h>
@@ -270,13 +272,6 @@ static int clear_epp_timeout(struct parport *pb)
  * of these are in parport_pc.h.
  */
 
-static irqreturn_t parport_pc_interrupt(int irq, void *dev_id)
-{
-       parport_generic_irq(irq, (struct parport *) dev_id);
-       /* FIXME! Was it really ours? */
-       return IRQ_HANDLED;
-}
-
 static void parport_pc_init_state(struct pardevice *dev, struct parport_state *s)
 {
        s->u.pc.ctr = 0xc;
@@ -2156,6 +2151,17 @@ struct parport *parport_pc_probe_port (unsigned long int base,
        struct resource *base_res;
        struct resource *ECR_res = NULL;
        struct resource *EPP_res = NULL;
+       struct platform_device *pdev = NULL;
+
+       if (!dev) {
+               /* We need a physical device to attach to, but none was
+                * provided. Create our own. */
+               pdev = platform_device_register_simple("parport_pc",
+                                                      base, NULL, 0);
+               if (IS_ERR(pdev))
+                       return NULL;
+               dev = &pdev->dev;
+       }
 
        ops = kmalloc(sizeof (struct parport_operations), GFP_KERNEL);
        if (!ops)
@@ -2288,7 +2294,7 @@ struct parport *parport_pc_probe_port (unsigned long int base,
                EPP_res = NULL;
        }
        if (p->irq != PARPORT_IRQ_NONE) {
-               if (request_irq (p->irq, parport_pc_interrupt,
+               if (request_irq (p->irq, parport_irq_handler,
                                 0, p->name, p)) {
                        printk (KERN_WARNING "%s: irq %d in use, "
                                "resorting to polled operation\n",
@@ -2359,6 +2365,8 @@ out3:
 out2:
        kfree (ops);
 out1:
+       if (pdev)
+               platform_device_unregister(pdev);
        return NULL;
 }
 
@@ -2409,7 +2417,6 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
        u32 ite8872set;
        u32 ite8872_lpt, ite8872_lpthi;
        u8 ite8872_irq, type;
-       char *fake_name = "parport probe";
        int irq;
        int i;
 
@@ -2417,11 +2424,11 @@ static int __devinit sio_ite_8872_probe (struct pci_dev *pdev, int autoirq,
        
        // make sure which one chip
        for(i = 0; i < 5; i++) {
-               base_res = request_region(inta_addr[i], 0x8, fake_name);
+               base_res = request_region(inta_addr[i], 32, "it887x");
                if (base_res) {
                        int test;
                        pci_write_config_dword (pdev, 0x60,
-                                               0xe7000000 | inta_addr[i]);
+                                               0xe5000000 | inta_addr[i]);
                        pci_write_config_dword (pdev, 0x78,
                                                0x00000000 | inta_addr[i]);
                        test = inb (inta_addr[i]);
@@ -3106,6 +3113,21 @@ static struct pnp_driver parport_pc_pnp_driver = {
 };
 
 
+static int __devinit parport_pc_platform_probe(struct platform_device *pdev)
+{
+       /* Always succeed, the actual probing is done in
+        * parport_pc_probe_port(). */
+       return 0;
+}
+
+static struct platform_driver parport_pc_platform_driver = {
+       .driver = {
+               .owner  = THIS_MODULE,
+               .name   = "parport_pc",
+       },
+       .probe          = parport_pc_platform_probe,
+};
+
 /* This is called by parport_pc_find_nonpci_ports (in asm/parport.h) */
 static int __devinit __attribute__((unused))
 parport_pc_find_isa_ports (int autoirq, int autodma)
@@ -3381,9 +3403,15 @@ __setup("parport_init_mode=",parport_init_mode_setup);
 
 static int __init parport_pc_init(void)
 {
+       int err;
+
        if (parse_parport_params())
                return -EINVAL;
 
+       err = platform_driver_register(&parport_pc_platform_driver);
+       if (err)
+               return err;
+
        if (io[0]) {
                int i;
                /* Only probe the ports we were given. */
@@ -3408,19 +3436,19 @@ static void __exit parport_pc_exit(void)
                pci_unregister_driver (&parport_pc_pci_driver);
        if (pnp_registered_parport)
                pnp_unregister_driver (&parport_pc_pnp_driver);
+       platform_driver_unregister(&parport_pc_platform_driver);
 
-       spin_lock(&ports_lock);
        while (!list_empty(&ports_list)) {
                struct parport_pc_private *priv;
                struct parport *port;
                priv = list_entry(ports_list.next,
                                  struct parport_pc_private, list);
                port = priv->port;
-               spin_unlock(&ports_lock);
+               if (port->dev && port->dev->bus == &platform_bus_type)
+                       platform_device_unregister(
+                               to_platform_device(port->dev));
                parport_pc_unregister_port(port);
-               spin_lock(&ports_lock);
        }
-       spin_unlock(&ports_lock);
 }
 
 MODULE_AUTHOR("Phil Blundell, Tim Waugh, others");