linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / drivers / parport / parport_pc.c
index fe800dc..9302b8f 100644 (file)
@@ -3,7 +3,7 @@
  * Authors: Phil Blundell <philb@gnu.org>
  *          Tim Waugh <tim@cyberelk.demon.co.uk>
  *         Jose Renau <renau@acm.org>
- *          David Campbell
+ *          David Campbell <campbell@torque.net>
  *          Andrea Arcangeli
  *
  * based on work by Grant Guenther <grant@torque.net> and Phil Blundell.
@@ -42,6 +42,7 @@
  * but rather will start at port->base_hi.
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -96,7 +97,7 @@ static struct superio_struct {        /* For Super-IO chips autodetection */
        int io;
        int irq;
        int dma;
-} superios[NR_SUPERIOS] = { {0,},};
+} superios[NR_SUPERIOS] __devinitdata = { {0,},};
 
 static int user_specified;
 #if defined(CONFIG_PARPORT_PC_SUPERIO) || \
@@ -1556,7 +1557,7 @@ static int __devinit get_superio_dma (struct parport *p)
        return PARPORT_DMA_NONE;
 }
 
-static int get_superio_irq (struct parport *p)
+static int __devinit get_superio_irq (struct parport *p)
 {
        int i=0;
         while( (superios[i].io != p->base) && (i<NR_SUPERIOS))
@@ -1578,7 +1579,7 @@ static int get_superio_irq (struct parport *p)
  *                         this shall always be the case!)
  *
  */
-static int parport_SPP_supported(struct parport *pb)
+static int __devinit parport_SPP_supported(struct parport *pb)
 {
        unsigned char r, w;
 
@@ -1659,7 +1660,7 @@ static int parport_SPP_supported(struct parport *pb)
  * two bits of ECR aren't writable, so we check by writing ECR and
  * reading it back to see if it's what we expect.
  */
-static int parport_ECR_present(struct parport *pb)
+static int __devinit parport_ECR_present(struct parport *pb)
 {
        struct parport_pc_private *priv = pb->private_data;
        unsigned char r = 0xc;
@@ -1711,7 +1712,7 @@ static int parport_ECR_present(struct parport *pb)
  * be misdetected here is rather academic. 
  */
 
-static int parport_PS2_supported(struct parport *pb)
+static int __devinit parport_PS2_supported(struct parport *pb)
 {
        int ok = 0;
   
@@ -1867,7 +1868,7 @@ static int __devinit parport_ECP_supported(struct parport *pb)
 }
 #endif
 
-static int parport_ECPPS2_supported(struct parport *pb)
+static int __devinit parport_ECPPS2_supported(struct parport *pb)
 {
        const struct parport_pc_private *priv = pb->private_data;
        int result;
@@ -1885,7 +1886,7 @@ static int parport_ECPPS2_supported(struct parport *pb)
 
 /* EPP mode detection  */
 
-static int parport_EPP_supported(struct parport *pb)
+static int __devinit parport_EPP_supported(struct parport *pb)
 {
        const struct parport_pc_private *priv = pb->private_data;
 
@@ -1930,7 +1931,7 @@ static int parport_EPP_supported(struct parport *pb)
        return 1;
 }
 
-static int parport_ECPEPP_supported(struct parport *pb)
+static int __devinit parport_ECPEPP_supported(struct parport *pb)
 {
        struct parport_pc_private *priv = pb->private_data;
        int result;
@@ -2072,7 +2073,7 @@ static int __devinit irq_probe_SPP(struct parport *pb)
  * When ECP is available we can autoprobe for IRQs.
  * NOTE: If we can autoprobe it, we can register the IRQ.
  */
-static int parport_irq_probe(struct parport *pb)
+static int __devinit parport_irq_probe(struct parport *pb)
 {
        struct parport_pc_private *priv = pb->private_data;
 
@@ -2778,7 +2779,7 @@ static struct parport_pc_pci {
        /* If set, this is called after probing for ports.  If 'failed'
         * is non-zero we couldn't use any of the ports. */
        void (*postinit_hook) (struct pci_dev *pdev, int failed);
-} cards[] = {
+} cards[] __devinitdata = {
        /* siig_1p_10x */               { 1, { { 2, 3 }, } },
        /* siig_2p_10x */               { 2, { { 2, 3 }, { 4, 5 }, } },
        /* siig_1p_20x */               { 1, { { 0, 1 }, } },
@@ -3125,9 +3126,9 @@ parport_pc_find_isa_ports (int autoirq, int autodma)
  * autoirq is PARPORT_IRQ_NONE, PARPORT_IRQ_AUTO, or PARPORT_IRQ_PROBEONLY
  * autodma is PARPORT_DMA_NONE or PARPORT_DMA_AUTO
  */
-static void __init parport_pc_find_ports (int autoirq, int autodma)
+static int __init parport_pc_find_ports (int autoirq, int autodma)
 {
-       int count = 0, err;
+       int count = 0, r;
 
 #ifdef CONFIG_PARPORT_PC_SUPERIO
        detect_and_report_winbond ();
@@ -3139,17 +3140,23 @@ static void __init parport_pc_find_ports (int autoirq, int autodma)
 
        /* PnP ports, skip detection if SuperIO already found them */
        if (!count) {
-               err = pnp_register_driver (&parport_pc_pnp_driver);
-               if (!err)
+               r = pnp_register_driver (&parport_pc_pnp_driver);
+               if (r >= 0) {
                        pnp_registered_parport = 1;
+                       count += r;
+               }
        }
 
        /* ISA ports and whatever (see asm/parport.h). */
-       parport_pc_find_nonpci_ports (autoirq, autodma);
+       count += parport_pc_find_nonpci_ports (autoirq, autodma);
+
+       r = pci_register_driver (&parport_pc_pci_driver);
+       if (r)
+               return r;
+       pci_registered_parport = 1;
+       count += 1;
 
-       err = pci_register_driver (&parport_pc_pci_driver);
-       if (!err)
-               pci_registered_parport = 1;
+       return count;
 }
 
 /*
@@ -3374,6 +3381,8 @@ __setup("parport_init_mode=",parport_init_mode_setup);
 
 static int __init parport_pc_init(void)
 {
+       int count = 0;
+
        if (parse_parport_params())
                return -EINVAL;
 
@@ -3386,11 +3395,12 @@ static int __init parport_pc_init(void)
                                break;
                        if ((io_hi[i]) == PARPORT_IOHI_AUTO)
                               io_hi[i] = 0x400 + io[i];
-                       parport_pc_probe_port(io[i], io_hi[i],
-                                                 irqval[i], dmaval[i], NULL);
+                       if (parport_pc_probe_port(io[i], io_hi[i],
+                                                 irqval[i], dmaval[i], NULL))
+                               count++;
                }
        } else
-               parport_pc_find_ports (irqval[0], dmaval[0]);
+               count += parport_pc_find_ports (irqval[0], dmaval[0]);
 
        return 0;
 }