]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/maps/sa1100-flash.c
[MTD] [MAPS] fix platform driver hotplug/coldplug
[linux-2.6-omap-h63xx.git] / drivers / mtd / maps / sa1100-flash.c
index 9e8bb1782be00318ab3eb58264ccf087e3761c8d..c7d5a52a2d559e997c62ba629bdf38f28f72e2c1 100644 (file)
@@ -5,7 +5,6 @@
  *
  * $Id: sa1100-flash.c,v 1.51 2005/11/07 11:14:28 gleixner Exp $
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/ioport.h>
@@ -274,14 +273,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)
@@ -356,9 +353,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 __init 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;
@@ -402,28 +398,28 @@ 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 int sa1100_mtd_suspend(struct platform_device *dev, pm_message_t state)
 {
-       struct sa_info *info = dev_get_drvdata(dev);
+       struct sa_info *info = platform_get_drvdata(dev);
        int ret = 0;
 
        if (info)
@@ -432,17 +428,17 @@ static int sa1100_mtd_suspend(struct device *dev, pm_message_t state)
        return ret;
 }
 
-static int sa1100_mtd_resume(struct device *dev)
+static int sa1100_mtd_resume(struct platform_device *dev)
 {
-       struct sa_info *info = dev_get_drvdata(dev);
+       struct sa_info *info = platform_get_drvdata(dev);
        if (info)
                info->mtd->resume(info->mtd);
        return 0;
 }
 
-static void sa1100_mtd_shutdown(struct device *dev)
+static void sa1100_mtd_shutdown(struct platform_device *dev)
 {
-       struct sa_info *info = dev_get_drvdata(dev);
+       struct sa_info *info = platform_get_drvdata(dev);
        if (info && info->mtd->suspend(info->mtd) == 0)
                info->mtd->resume(info->mtd);
 }
@@ -452,24 +448,26 @@ static void sa1100_mtd_shutdown(struct device *dev)
 #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   = "flash",
+               .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);
@@ -478,3 +476,4 @@ module_exit(sa1100_mtd_exit);
 MODULE_AUTHOR("Nicolas Pitre");
 MODULE_DESCRIPTION("SA1100 CFI map driver");
 MODULE_LICENSE("GPL");
+MODULE_ALIAS("platform:flash");