mtd: maps/sa1100: fix section mismatch
[safe/jmp/linux-2.6] / drivers / mtd / maps / sa1100-flash.c
index c38c2c3..f3af87e 100644 (file)
@@ -1,11 +1,8 @@
 /*
  * Flash memory access on SA11x0 based devices
- * 
- * (C) 2000 Nicolas Pitre <nico@cam.org>
- * 
- * $Id: sa1100-flash.c,v 1.47 2004/11/01 13:44:36 rmk Exp $
+ *
+ * (C) 2000 Nicolas Pitre <nico@fluxnic.net>
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
 #include <linux/init.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/err.h>
+#include <linux/io.h>
 
 #include <linux/mtd/mtd.h>
 #include <linux/mtd/map.h>
 #include <linux/mtd/partitions.h>
 #include <linux/mtd/concat.h>
 
-#include <asm/hardware.h>
-#include <asm/io.h>
+#include <mach/hardware.h>
 #include <asm/sizes.h>
 #include <asm/mach/flash.h>
 
@@ -212,8 +209,8 @@ static int sa1100_probe_subdev(struct sa_subdev_info *subdev, struct resource *r
        }
        subdev->mtd->owner = THIS_MODULE;
 
-       printk(KERN_INFO "SA1100 flash: CFI device at 0x%08lx, %dMiB, "
-               "%d-bit\n", phys, subdev->mtd->size >> 20,
+       printk(KERN_INFO "SA1100 flash: CFI device at 0x%08lx, %uMiB, %d-bit\n",
+               phys, (unsigned)(subdev->mtd->size >> 20),
                subdev->map.bankwidth * 8);
 
        return 0;
@@ -241,8 +238,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
 #endif
        }
 
-       if (info->parts)
-               kfree(info->parts);
+       kfree(info->parts);
 
        for (i = info->num_subdev - 1; i >= 0; i--)
                sa1100_destroy_subdev(&info->subdev[i]);
@@ -252,7 +248,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
                plat->exit();
 }
 
-static struct sa_info *__init
+static struct sa_info *__devinit
 sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
 {
        struct sa_info *info;
@@ -275,14 +271,12 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
        /*
         * Allocate the map_info structs in one go.
         */
-       info = kmalloc(size, GFP_KERNEL);
+       info = kzalloc(size, GFP_KERNEL);
        if (!info) {
                ret = -ENOMEM;
                goto out;
        }
 
-       memset(info, 0, size);
-
        if (plat->init) {
                ret = plat->init();
                if (ret)
@@ -301,7 +295,7 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
                        break;
 
                subdev->map.name = subdev->name;
-               sprintf(subdev->name, "sa1100-%d", i);
+               sprintf(subdev->name, "%s-%d", plat->name, i);
                subdev->plat = plat;
 
                ret = sa1100_probe_subdev(subdev, res);
@@ -323,7 +317,7 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
         * otherwise fail.  Either way, it'll be called "sa1100".
         */
        if (info->num_subdev == 1) {
-               strcpy(info->subdev[0].name, "sa1100");
+               strcpy(info->subdev[0].name, plat->name);
                info->mtd = info->subdev[0].mtd;
                ret = 0;
        } else if (info->num_subdev > 1) {
@@ -336,7 +330,7 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
                        cdev[i] = info->subdev[i].mtd;
 
                info->mtd = mtd_concat_create(cdev, info->num_subdev,
-                                             "sa1100");
+                                             plat->name);
                if (info->mtd == NULL)
                        ret = -ENXIO;
 #else
@@ -357,9 +351,8 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
 
 static const char *part_probes[] = { "cmdlinepart", "RedBoot", NULL };
 
-static int __init sa1100_mtd_probe(struct device *dev)
+static int __devinit sa1100_mtd_probe(struct platform_device *pdev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
        struct flash_platform_data *plat = pdev->dev.platform_data;
        struct mtd_partition *parts;
        const char *part_type = NULL;
@@ -403,65 +396,53 @@ static int __init sa1100_mtd_probe(struct device *dev)
 
        info->nr_parts = nr_parts;
 
-       dev_set_drvdata(dev, info);
+       platform_set_drvdata(pdev, info);
        err = 0;
 
  out:
        return err;
 }
 
-static int __exit sa1100_mtd_remove(struct device *dev)
+static int __exit sa1100_mtd_remove(struct platform_device *pdev)
 {
-       struct sa_info *info = dev_get_drvdata(dev);
-       struct flash_platform_data *plat = dev->platform_data;
+       struct sa_info *info = platform_get_drvdata(pdev);
+       struct flash_platform_data *plat = pdev->dev.platform_data;
 
-       dev_set_drvdata(dev, NULL);
+       platform_set_drvdata(pdev, NULL);
        sa1100_destroy(info, plat);
 
        return 0;
 }
 
 #ifdef CONFIG_PM
-static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
+static void sa1100_mtd_shutdown(struct platform_device *dev)
 {
-       struct sa_info *info = dev_get_drvdata(dev);
-       int ret = 0;
-
-       if (info)
-               ret = info->mtd->suspend(info->mtd);
-
-       return ret;
-}
-
-static int sa1100_mtd_resume(struct device *dev)
-{
-       struct sa_info *info = dev_get_drvdata(dev);
-       if (info)
+       struct sa_info *info = platform_get_drvdata(dev);
+       if (info && info->mtd->suspend(info->mtd) == 0)
                info->mtd->resume(info->mtd);
-       return 0;
 }
 #else
-#define sa1100_mtd_suspend NULL
-#define sa1100_mtd_resume  NULL
+#define sa1100_mtd_shutdown NULL
 #endif
 
-static struct device_driver sa1100_mtd_driver = {
-       .name           = "flash",
-       .bus            = &platform_bus_type,
+static struct platform_driver sa1100_mtd_driver = {
        .probe          = sa1100_mtd_probe,
        .remove         = __exit_p(sa1100_mtd_remove),
-       .suspend        = sa1100_mtd_suspend,
-       .resume         = sa1100_mtd_resume,
+       .shutdown       = sa1100_mtd_shutdown,
+       .driver         = {
+               .name   = "sa1100-mtd",
+               .owner  = THIS_MODULE,
+       },
 };
 
 static int __init sa1100_mtd_init(void)
 {
-       return driver_register(&sa1100_mtd_driver);
+       return platform_driver_register(&sa1100_mtd_driver);
 }
 
 static void __exit sa1100_mtd_exit(void)
 {
-       driver_unregister(&sa1100_mtd_driver);
+       platform_driver_unregister(&sa1100_mtd_driver);
 }
 
 module_init(sa1100_mtd_init);
@@ -470,3 +451,4 @@ module_exit(sa1100_mtd_exit);
 MODULE_AUTHOR("Nicolas Pitre");
 MODULE_DESCRIPTION("SA1100 CFI map driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:sa1100-mtd");