video/rockchip: rga2: retry 10 times when timeout
[firefly-linux-kernel-4.4.55.git] / drivers / parport / parport_pc.c
index 903e1285fda06ce30c84bf79b44078e733048c38..78530d1714dc7422a597314e098a88513208c169 100644 (file)
@@ -1702,6 +1702,46 @@ static int parport_ECP_supported(struct parport *pb)
 }
 #endif
 
+#ifdef CONFIG_X86_32
+static int intel_bug_present_check_epp(struct parport *pb)
+{
+       const struct parport_pc_private *priv = pb->private_data;
+       int bug_present = 0;
+
+       if (priv->ecr) {
+               /* store value of ECR */
+               unsigned char ecr = inb(ECONTROL(pb));
+               unsigned char i;
+               for (i = 0x00; i < 0x80; i += 0x20) {
+                       ECR_WRITE(pb, i);
+                       if (clear_epp_timeout(pb)) {
+                               /* Phony EPP in ECP. */
+                               bug_present = 1;
+                               break;
+                       }
+               }
+               /* return ECR into the inital state */
+               ECR_WRITE(pb, ecr);
+       }
+
+       return bug_present;
+}
+static int intel_bug_present(struct parport *pb)
+{
+/* Check whether the device is legacy, not PCI or PCMCIA. Only legacy is known to be affected. */
+       if (pb->dev != NULL) {
+               return 0;
+       }
+
+       return intel_bug_present_check_epp(pb);
+}
+#else
+static int intel_bug_present(struct parport *pb)
+{
+       return 0;
+}
+#endif /* CONFIG_X86_32 */
+
 static int parport_ECPPS2_supported(struct parport *pb)
 {
        const struct parport_pc_private *priv = pb->private_data;
@@ -1722,8 +1762,6 @@ static int parport_ECPPS2_supported(struct parport *pb)
 
 static int parport_EPP_supported(struct parport *pb)
 {
-       const struct parport_pc_private *priv = pb->private_data;
-
        /*
         * Theory:
         *      Bit 0 of STR is the EPP timeout bit, this bit is 0
@@ -1742,16 +1780,8 @@ static int parport_EPP_supported(struct parport *pb)
                return 0;  /* No way to clear timeout */
 
        /* Check for Intel bug. */
-       if (priv->ecr) {
-               unsigned char i;
-               for (i = 0x00; i < 0x80; i += 0x20) {
-                       ECR_WRITE(pb, i);
-                       if (clear_epp_timeout(pb)) {
-                               /* Phony EPP in ECP. */
-                               return 0;
-                       }
-               }
-       }
+       if (intel_bug_present(pb))
+               return 0;
 
        pb->modes |= PARPORT_MODE_EPP;
 
@@ -2004,6 +2034,7 @@ struct parport *parport_pc_probe_port(unsigned long int base,
        struct resource *ECR_res = NULL;
        struct resource *EPP_res = NULL;
        struct platform_device *pdev = NULL;
+       int ret;
 
        if (!dev) {
                /* We need a physical device to attach to, but none was
@@ -2014,8 +2045,11 @@ struct parport *parport_pc_probe_port(unsigned long int base,
                        return NULL;
                dev = &pdev->dev;
 
-               dev->coherent_dma_mask = DMA_BIT_MASK(24);
-               dev->dma_mask = &dev->coherent_dma_mask;
+               ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(24));
+               if (ret) {
+                       dev_err(dev, "Unable to set coherent dma mask: disabling DMA\n");
+                       dma = PARPORT_DMA_NONE;
+               }
        }
 
        ops = kmalloc(sizeof(struct parport_operations), GFP_KERNEL);
@@ -2221,7 +2255,7 @@ out5:
                release_region(base+0x3, 5);
        release_region(base, 3);
 out4:
-       parport_put_port(p);
+       parport_del_port(p);
 out3:
        kfree(priv);
 out2:
@@ -2260,7 +2294,7 @@ void parport_pc_unregister_port(struct parport *p)
                                    priv->dma_handle);
 #endif
        kfree(p->private_data);
-       parport_put_port(p);
+       parport_del_port(p);
        kfree(ops); /* hope no-one cached it */
 }
 EXPORT_SYMBOL(parport_pc_unregister_port);
@@ -2596,8 +2630,6 @@ enum parport_pc_pci_cards {
        syba_2p_epp,
        syba_1p_ecp,
        titan_010l,
-       titan_1284p1,
-       titan_1284p2,
        avlab_1p,
        avlab_2p,
        oxsemi_952,
@@ -2656,8 +2688,6 @@ static struct parport_pc_pci {
        /* syba_2p_epp AP138B */        { 2, { { 0, 0x078 }, { 0, 0x178 }, } },
        /* syba_1p_ecp W83787 */        { 1, { { 0, 0x078 }, } },
        /* titan_010l */                { 1, { { 3, -1 }, } },
-       /* titan_1284p1 */              { 1, { { 0, 1 }, } },
-       /* titan_1284p2 */              { 2, { { 0, 1 }, { 2, 3 }, } },
        /* avlab_1p             */      { 1, { { 0, 1}, } },
        /* avlab_2p             */      { 2, { { 0, 1}, { 2, 3 },} },
        /* The Oxford Semi cards are unusual: 954 doesn't support ECP,
@@ -2673,8 +2703,8 @@ static struct parport_pc_pci {
        /* netmos_9705 */               { 1, { { 0, -1 }, } },
        /* netmos_9715 */               { 2, { { 0, 1 }, { 2, 3 },} },
        /* netmos_9755 */               { 2, { { 0, 1 }, { 2, 3 },} },
-       /* netmos_9805 */               { 1, { { 0, -1 }, } },
-       /* netmos_9815 */               { 2, { { 0, -1 }, { 2, -1 }, } },
+       /* netmos_9805 */               { 1, { { 0, 1 }, } },
+       /* netmos_9815 */               { 2, { { 0, 1 }, { 2, 3 }, } },
        /* netmos_9901 */               { 1, { { 0, -1 }, } },
        /* netmos_9865 */               { 1, { { 0, -1 }, } },
        /* quatech_sppxp100 */          { 1, { { 0, 1 }, } },
@@ -2718,8 +2748,6 @@ static const struct pci_device_id parport_pc_pci_tbl[] = {
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, syba_1p_ecp },
        { PCI_VENDOR_ID_TITAN, PCI_DEVICE_ID_TITAN_010L,
          PCI_ANY_ID, PCI_ANY_ID, 0, 0, titan_010l },
-       { 0x9710, 0x9805, 0x1000, 0x0010, 0, 0, titan_1284p1 },
-       { 0x9710, 0x9815, 0x1000, 0x0020, 0, 0, titan_1284p2 },
        /* PCI_VENDOR_ID_AVLAB/Intek21 has another bunch of cards ...*/
        /* AFAVLAB_TK9902 */
        { 0x14db, 0x2120, PCI_ANY_ID, PCI_ANY_ID, 0, 0, avlab_1p},
@@ -2823,16 +2851,12 @@ static int parport_pc_pci_probe(struct pci_dev *dev,
                if (irq == IRQ_NONE) {
                        printk(KERN_DEBUG
        "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx)\n",
-                               parport_pc_pci_tbl[i + last_sio].vendor,
-                               parport_pc_pci_tbl[i + last_sio].device,
-                               io_lo, io_hi);
+                               id->vendor, id->device, io_lo, io_hi);
                        irq = PARPORT_IRQ_NONE;
                } else {
                        printk(KERN_DEBUG
        "PCI parallel port detected: %04x:%04x, I/O at %#lx(%#lx), IRQ %d\n",
-                               parport_pc_pci_tbl[i + last_sio].vendor,
-                               parport_pc_pci_tbl[i + last_sio].device,
-                               io_lo, io_hi, irq);
+                               id->vendor, id->device, io_lo, io_hi, irq);
                }
                data->ports[count] =
                        parport_pc_probe_port(io_lo, io_hi, irq,
@@ -2862,8 +2886,6 @@ static void parport_pc_pci_remove(struct pci_dev *dev)
        struct pci_parport_data *data = pci_get_drvdata(dev);
        int i;
 
-       pci_set_drvdata(dev, NULL);
-
        if (data) {
                for (i = data->num - 1; i >= 0; i--)
                        parport_pc_unregister_port(data->ports[i]);
@@ -2989,7 +3011,6 @@ static int parport_pc_platform_probe(struct platform_device *pdev)
 
 static struct platform_driver parport_pc_platform_driver = {
        .driver = {
-               .owner  = THIS_MODULE,
                .name   = "parport_pc",
        },
        .probe          = parport_pc_platform_probe,
@@ -3318,13 +3339,14 @@ static void __exit parport_pc_exit(void)
        while (!list_empty(&ports_list)) {
                struct parport_pc_private *priv;
                struct parport *port;
+               struct device *dev;
                priv = list_entry(ports_list.next,
                                  struct parport_pc_private, list);
                port = priv->port;
-               if (port->dev && port->dev->bus == &platform_bus_type)
-                       platform_device_unregister(
-                               to_platform_device(port->dev));
+               dev = port->dev;
                parport_pc_unregister_port(port);
+               if (dev && dev->bus == &platform_bus_type)
+                       platform_device_unregister(to_platform_device(dev));
        }
 }