fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / drivers / mtd / maps / uclinux.c
index baff49b..389fea2 100644 (file)
@@ -5,12 +5,11 @@
  *
  *     (C) Copyright 2002, Greg Ungerer (gerg@snapgear.com)
  *
- *     $Id: uclinux.c,v 1.7 2004/07/12 21:59:45 dwmw2 Exp $
+ *     $Id: uclinux.c,v 1.12 2005/11/07 11:14:29 gleixner Exp $
  */
 
 /****************************************************************************/
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -23,9 +22,6 @@
 #include <linux/mtd/partitions.h>
 #include <asm/io.h>
 
-/****************************************************************************/
-
-
 /****************************************************************************/
 
 struct map_info uclinux_ram_map = {
@@ -40,14 +36,14 @@ struct mtd_partition uclinux_romfs[] = {
        { .name = "ROMfs" }
 };
 
-#define        NUM_PARTITIONS  (sizeof(uclinux_romfs) / sizeof(uclinux_romfs[0]))
+#define        NUM_PARTITIONS  ARRAY_SIZE(uclinux_romfs)
 
 /****************************************************************************/
 
 int uclinux_point(struct mtd_info *mtd, loff_t from, size_t len,
        size_t *retlen, u_char **mtdbuf)
 {
-       struct map_info *map = (struct map_info *) mtd->priv;
+       struct map_info *map = mtd->priv;
        *mtdbuf = (u_char *) (map->virt + ((int) from));
        *retlen = len;
        return(0);
@@ -60,18 +56,19 @@ int __init uclinux_mtd_init(void)
        struct mtd_info *mtd;
        struct map_info *mapp;
        extern char _ebss;
+       unsigned long addr = (unsigned long) &_ebss;
 
        mapp = &uclinux_ram_map;
-       mapp->phys = (unsigned long) &_ebss;
-       mapp->size = PAGE_ALIGN(*((unsigned long *)((&_ebss) + 8)));
+       mapp->phys = addr;
+       mapp->size = PAGE_ALIGN(ntohl(*((unsigned long *)(addr + 8))));
        mapp->bankwidth = 4;
 
        printk("uclinux[mtd]: RAM probe address=0x%x size=0x%x\n",
-               (int) mapp->map_priv_2, (int) mapp->size);
+               (int) mapp->phys, (int) mapp->size);
 
        mapp->virt = ioremap_nocache(mapp->phys, mapp->size);
 
-       if (!mapp->virt) {
+       if (mapp->virt == 0) {
                printk("uclinux[mtd]: ioremap_nocache() failed\n");
                return(-EIO);
        }
@@ -84,7 +81,7 @@ int __init uclinux_mtd_init(void)
                iounmap(mapp->virt);
                return(-ENXIO);
        }
-               
+
        mtd->owner = THIS_MODULE;
        mtd->point = uclinux_point;
        mtd->priv = mapp;
@@ -95,7 +92,6 @@ int __init uclinux_mtd_init(void)
        printk("uclinux[mtd]: set %s to be root filesystem\n",
                uclinux_romfs[0].name);
        ROOT_DEV = MKDEV(MTD_BLOCK_MAJOR, 0);
-       put_mtd_device(mtd);
 
        return(0);
 }
@@ -109,7 +105,7 @@ void __exit uclinux_mtd_cleanup(void)
                map_destroy(uclinux_ram_mtdinfo);
                uclinux_ram_mtdinfo = NULL;
        }
-       if (uclinux_ram_map.map_priv_1) {
+       if (uclinux_ram_map.virt) {
                iounmap((void *) uclinux_ram_map.virt);
                uclinux_ram_map.virt = 0;
        }