Merge to Fedora kernel-2.6.18-1.2239_FC5 patched with stable patch-2.6.18.2-vs2.0...
[linux-2.6.git] / drivers / mtd / maps / elan-104nc.c
index 326e9cc..e9465f5 100644 (file)
@@ -16,7 +16,7 @@
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
 
-   $Id: elan-104nc.c,v 1.18 2003/06/23 07:37:02 dwmw2 Exp $
+   $Id: elan-104nc.c,v 1.25 2004/11/28 09:40:39 dwmw2 Exp $
 
 The ELAN-104NC has up to 8 Mibyte of Intel StrataFlash (28F320/28F640) in x16
 mode.  This drivers uses the CFI probe and Intel Extended Command Set drivers.
@@ -53,8 +53,8 @@ always fail.  So we don't do it.  I just hope it doesn't break anything.
 #define PAGE_IO_SIZE 2
 
 static volatile int page_in_window = -1; // Current page in window.
-static unsigned long iomapadr;
-static spinlock_t elan_104nc_spin = SPIN_LOCK_UNLOCKED;
+static void __iomem *iomapadr;
+static DEFINE_SPINLOCK(elan_104nc_spin);
 
 /* partition_info gives details on the logical partitions that the split the 
  * single flash device into. If the size if zero we use up to the end of the
@@ -107,39 +107,19 @@ static inline void elan_104nc_page(struct map_info *map, unsigned long ofs)
 }
 
 
-static __u8 elan_104nc_read8(struct map_info *map, unsigned long ofs)
+static map_word elan_104nc_read16(struct map_info *map, unsigned long ofs)
 {
-       __u8 ret;
+       map_word ret;
        spin_lock(&elan_104nc_spin);
        elan_104nc_page(map, ofs);
-       ret = readb(iomapadr + (ofs & WINDOW_MASK));
-       spin_unlock(&elan_104nc_spin);
-       return ret;
-}
-
-static __u16 elan_104nc_read16(struct map_info *map, unsigned long ofs)
-{
-       __u16 ret;
-       spin_lock(&elan_104nc_spin);
-       elan_104nc_page(map, ofs);
-       ret = readw(iomapadr + (ofs & WINDOW_MASK));
-       spin_unlock(&elan_104nc_spin);
-       return ret;
-}
-
-static __u32 elan_104nc_read32(struct map_info *map, unsigned long ofs)
-{
-       __u32 ret;
-       spin_lock(&elan_104nc_spin);
-       elan_104nc_page(map, ofs);
-       ret = readl(iomapadr + (ofs & WINDOW_MASK));
+       ret.x[0] = readw(iomapadr + (ofs & WINDOW_MASK));
        spin_unlock(&elan_104nc_spin);
        return ret;
 }
 
 static void elan_104nc_copy_from(struct map_info *map, void *to, unsigned long from, ssize_t len)
 {
-       while(len) {
+       while (len) {
                unsigned long thislen = len;
                if (len > (WINDOW_LENGTH - (from & WINDOW_MASK)))
                        thislen = WINDOW_LENGTH-(from & WINDOW_MASK);
@@ -154,27 +134,11 @@ static void elan_104nc_copy_from(struct map_info *map, void *to, unsigned long f
        }
 }
 
-static void elan_104nc_write8(struct map_info *map, __u8 d, unsigned long adr)
-{
-       spin_lock(&elan_104nc_spin);
-       elan_104nc_page(map, adr);
-       writeb(d, iomapadr + (adr & WINDOW_MASK));
-       spin_unlock(&elan_104nc_spin);
-}
-
-static void elan_104nc_write16(struct map_info *map, __u16 d, unsigned long adr)
-{
-       spin_lock(&elan_104nc_spin);
-       elan_104nc_page(map, adr);
-       writew(d, iomapadr + (adr & WINDOW_MASK));
-       spin_unlock(&elan_104nc_spin);
-}
-
-static void elan_104nc_write32(struct map_info *map, __u32 d, unsigned long adr)
+static void elan_104nc_write16(struct map_info *map, map_word d, unsigned long adr)
 {
        spin_lock(&elan_104nc_spin);
        elan_104nc_page(map, adr);
-       writel(d, iomapadr + (adr & WINDOW_MASK));
+       writew(d.x[0], iomapadr + (adr & WINDOW_MASK));
        spin_unlock(&elan_104nc_spin);
 }
 
@@ -201,14 +165,10 @@ static struct map_info elan_104nc_map = {
        .size = 8*1024*1024, /* this must be set to a maximum possible amount
                        of flash so the cfi probe routines find all
                        the chips */
-       .buswidth = 2,
-       .read8 = elan_104nc_read8,
-       .read16 = elan_104nc_read16,
-       .read32 = elan_104nc_read32,
+       .bankwidth = 2,
+       .read = elan_104nc_read16,
        .copy_from = elan_104nc_copy_from,
-       .write8 = elan_104nc_write8,
-       .write16 = elan_104nc_write16,
-       .write32 = elan_104nc_write32,
+       .write = elan_104nc_write16,
        .copy_to = elan_104nc_copy_to
 };
 
@@ -222,15 +182,15 @@ static void cleanup_elan_104nc(void)
                map_destroy( all_mtd );
        }
 
-       iounmap((void *)iomapadr);
+       iounmap(iomapadr);
 }
 
-int __init init_elan_104nc(void)
+static int __init init_elan_104nc(void)
 {
        /* Urg! We use I/O port 0x22 without request_region()ing it,
           because it's already allocated to the PIC. */
 
-       iomapadr = (unsigned long)ioremap(WINDOW_START, WINDOW_LENGTH);
+       iomapadr = ioremap(WINDOW_START, WINDOW_LENGTH);
        if (!iomapadr) {
                printk( KERN_ERR"%s: failed to ioremap memory region\n",
                        elan_104nc_map.name );