Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / mtd / devices / pmc551.c
index 80d4287..666cce1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: pmc551.c,v 1.26 2004/07/14 17:25:07 dwmw2 Exp $
+ * $Id: pmc551.c,v 1.32 2005/11/07 11:14:25 gleixner Exp $
  *
  * PMC551 PCI Mezzanine Ram Device
  *
@@ -27,7 +27,7 @@
  *      it as high speed swap or for a high speed disk device of some
  *      sort.  Which becomes very useful on diskless systems in the
  *      embedded market I might add.
- *      
+ *
  * Notes:
  *      Due to what I assume is more buggy SROM, the 64M PMC551 I
  *      have available claims that all 4 of it's DRAM banks have 64M
  *       Minyard set up the card to utilize a 1M sliding apature.
  *
  *      Corey Minyard <minyard@nortelnetworks.com>
- *       * Modified driver to utilize a sliding aperture instead of 
+ *       * Modified driver to utilize a sliding aperture instead of
  *         mapping all memory into kernel space which turned out to
  *         be very wasteful.
- *       * Located a bug in the SROM's initialization sequence that 
+ *       * Located a bug in the SROM's initialization sequence that
  *         made the memory unusable, added a fix to code to touch up
  *         the DRAM some.
  *
@@ -82,7 +82,6 @@
  *       * Comb the init routine.  It's still a bit cludgy on a few things.
  */
 
-#include <linux/version.h>
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/mtd/pmc551.h>
 #include <linux/mtd/compatmac.h>
 
-#if LINUX_VERSION_CODE > 0x20300
-#define PCI_BASE_ADDRESS(dev) (dev->resource[0].start)
-#else
-#define PCI_BASE_ADDRESS(dev) (dev->base_address[0])
-#endif
-
 static struct mtd_info *pmc551list;
 
 static int pmc551_erase (struct mtd_info *mtd, struct erase_info *instr)
 {
-        struct mypriv *priv = (struct mypriv *)mtd->priv;
+        struct mypriv *priv = mtd->priv;
         u32 soff_hi, soff_lo; /* start address offset hi/lo */
         u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
         unsigned long end;
@@ -175,16 +168,14 @@ out:
        printk(KERN_DEBUG "pmc551_erase() done\n");
 #endif
 
-        if (instr->callback) {
-                (*(instr->callback))(instr);
-       }
+        mtd_erase_callback(instr);
         return 0;
 }
 
 
 static int pmc551_point (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char **mtdbuf)
 {
-        struct mypriv *priv = (struct mypriv *)mtd->priv;
+        struct mypriv *priv = mtd->priv;
         u32 soff_hi;
         u32 soff_lo;
 
@@ -225,7 +216,7 @@ static void pmc551_unpoint (struct mtd_info *mtd, u_char *addr, loff_t from, siz
 
 static int pmc551_read (struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen, u_char *buf)
 {
-        struct mypriv *priv = (struct mypriv *)mtd->priv;
+        struct mypriv *priv = mtd->priv;
         u32 soff_hi, soff_lo; /* start address offset hi/lo */
         u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
         unsigned long end;
@@ -287,7 +278,7 @@ out:
 
 static int pmc551_write (struct mtd_info *mtd, loff_t to, size_t len, size_t *retlen, const u_char *buf)
 {
-        struct mypriv *priv = (struct mypriv *)mtd->priv;
+        struct mypriv *priv = mtd->priv;
         u32 soff_hi, soff_lo; /* start address offset hi/lo */
         u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
         unsigned long end;
@@ -398,7 +389,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
        bcmd |= (0x40|0x20);
        pci_write_config_byte(dev, PMC551_SYS_CTRL_REG, bcmd);
 
-        /* 
+        /*
         * Take care and turn off the memory on the device while we
         * tweak the configurations
         */
@@ -416,7 +407,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
         * Grab old BAR0 config so that we can figure out memory size
         * This is another bit of kludge going on.  The reason for the
         * redundancy is I am hoping to retain the original configuration
-        * previously assigned to the card by the BIOS or some previous 
+        * previously assigned to the card by the BIOS or some previous
         * fixup routine in the kernel.  So we read the old config into cfg,
         * then write all 1's to the memory space, read back the result into
         * "size", and then write back all the old config.
@@ -488,7 +479,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
         } while ( (PCI_COMMAND_IO) & cmd );
 
         /*
-        * Turn on auto refresh 
+        * Turn on auto refresh
         * The loop is taken directly from Ramix's example code.  I assume that
         * this must be held high for some duration of time, but I can find no
         * documentation refrencing the reasons why.
@@ -564,7 +555,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
               (size<1024)?size:(size<1048576)?size>>10:size>>20,
                (size<1024)?'B':(size<1048576)?'K':'M',
               size, ((dcmd&(0x1<<3)) == 0)?"non-":"",
-               PCI_BASE_ADDRESS(dev)&PCI_BASE_ADDRESS_MEM_MASK );
+               (dev->resource[0].start)&PCI_BASE_ADDRESS_MEM_MASK );
 
         /*
          * Check to see the state of the memory
@@ -623,7 +614,7 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
        pci_read_config_byte(dev, PMC551_SYS_CTRL_REG, &bcmd );
        printk( KERN_DEBUG "pmc551: EEPROM is under %s control\n"
                           "pmc551: System Control Register is %slocked to PCI access\n"
-                          "pmc551: System Control Register is %slocked to EEPROM access\n", 
+                          "pmc551: System Control Register is %slocked to EEPROM access\n",
                (bcmd&0x1)?"software":"hardware",
                (bcmd&0x20)?"":"un", (bcmd&0x40)?"":"un");
 #endif
@@ -638,10 +629,6 @@ static u32 fixup_pmc551 (struct pci_dev *dev)
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Mark Ferrell <mferrell@mvista.com>");
 MODULE_DESCRIPTION(PMC551_VERSION);
-MODULE_PARM(msize, "i");
-MODULE_PARM_DESC(msize, "memory size in Megabytes [1 - 1024]");
-MODULE_PARM(asize, "i");
-MODULE_PARM_DESC(asize, "aperture size, must be <= memsize [1-1024]");
 
 /*
  * Stuff these outside the ifdef so as to not bust compiled in driver support
@@ -653,10 +640,15 @@ static int asize=CONFIG_MTD_PMC551_APERTURE_SIZE
 static int asize=0;
 #endif
 
+module_param(msize, int, 0);
+MODULE_PARM_DESC(msize, "memory size in Megabytes [1 - 1024]");
+module_param(asize, int, 0);
+MODULE_PARM_DESC(asize, "aperture size, must be <= memsize [1-1024]");
+
 /*
  * PMC551 Card Initialization
  */
-int __init init_pmc551(void)
+static int __init init_pmc551(void)
 {
         struct pci_dev *PCI_Device = NULL;
         struct mypriv *priv;
@@ -694,7 +686,7 @@ int __init init_pmc551(void)
                 }
 
                 printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%lX\n",
-                                   PCI_BASE_ADDRESS(PCI_Device));
+                                   PCI_Device->resource[0].start);
 
                 /*
                  * The PMC551 device acts VERY weird if you don't init it
@@ -748,10 +740,10 @@ int __init init_pmc551(void)
                        printk(KERN_NOTICE "pmc551: Using specified aperture size %dM\n", asize>>20);
                        priv->asize = asize;
                }
-                priv->start = ioremap((PCI_BASE_ADDRESS(PCI_Device)
+                priv->start = ioremap(((PCI_Device->resource[0].start)
                                        & PCI_BASE_ADDRESS_MEM_MASK),
                                       priv->asize);
-               
+
                if (!priv->start) {
                        printk(KERN_NOTICE "pmc551: Unable to map IO space\n");
                         kfree(mtd->priv);
@@ -772,7 +764,7 @@ int __init init_pmc551(void)
                                          priv->curr_map0 );
 
 #ifdef CONFIG_MTD_PMC551_DEBUG
-               printk( KERN_DEBUG "pmc551: aperture set to %d\n", 
+               printk( KERN_DEBUG "pmc551: aperture set to %d\n",
                        (priv->base_map0 & 0xF0)>>4 );
 #endif
 
@@ -828,15 +820,15 @@ static void __exit cleanup_pmc551(void)
        struct mypriv *priv;
 
        while((mtd=pmc551list)) {
-               priv = (struct mypriv *)mtd->priv;
+               priv = mtd->priv;
                pmc551list = priv->nextpmc551;
-               
+
                if(priv->start) {
                        printk (KERN_DEBUG "pmc551: unmapping %dM starting at 0x%p\n",
                                priv->asize>>20, priv->start);
                        iounmap (priv->start);
                }
-               
+
                kfree (mtd->priv);
                del_mtd_device (mtd);
                kfree (mtd);