]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mtd/maps/omap_nor.c
[MTD] [MAPS] fix platform driver hotplug/coldplug
[linux-2.6-omap-h63xx.git] / drivers / mtd / maps / omap_nor.c
index 7f370bb794fefae45e192df190d657e7bcd13110..676248ff4a75ae8e11d3d35fb0acf7b4227c3a24 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (C) 2001-2002 MontaVista Software Inc.
  * Copyright (C) 2003-2004 Texas Instruments
- * Copyright (C) 2004 Nokia Corporation 
+ * Copyright (C) 2004 Nokia Corporation
  *
  *     Assembled using driver code copyright the companies above
  *     and written by David Brownell, Jian Zhang <jzhang@ti.com>,
@@ -70,21 +70,18 @@ static void omap_set_vpp(struct map_info *map, int enable)
        }
 }
 
-static int __devinit omapflash_probe(struct device *dev)
+static int __devinit omapflash_probe(struct platform_device *pdev)
 {
        int err;
        struct omapflash_info *info;
-       struct platform_device *pdev = to_platform_device(dev);
        struct flash_platform_data *pdata = pdev->dev.platform_data;
        struct resource *res = pdev->resource;
        unsigned long size = res->end - res->start + 1;
 
-       info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       memset(info, 0, sizeof(struct omapflash_info));
-
        if (!request_mem_region(res->start, size, "flash")) {
                err = -EBUSY;
                goto out_free_info;
@@ -119,7 +116,7 @@ static int __devinit omapflash_probe(struct device *dev)
 #endif
                add_mtd_device(info->mtd);
 
-       dev_set_drvdata(&pdev->dev, info);
+       platform_set_drvdata(pdev, info);
 
        return 0;
 
@@ -133,12 +130,11 @@ out_free_info:
        return err;
 }
 
-static int __devexit omapflash_remove(struct device *dev)
+static int __devexit omapflash_remove(struct platform_device *pdev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct omapflash_info *info = dev_get_drvdata(&pdev->dev);
+       struct omapflash_info *info = platform_get_drvdata(pdev);
 
-       dev_set_drvdata(&pdev->dev, NULL);
+       platform_set_drvdata(pdev, NULL);
 
        if (info) {
                if (info->parts) {
@@ -155,21 +151,23 @@ static int __devexit omapflash_remove(struct device *dev)
        return 0;
 }
 
-static struct device_driver omapflash_driver = {
-       .name   = "omapflash",
-       .bus    = &platform_bus_type,
+static struct platform_driver omapflash_driver = {
        .probe  = omapflash_probe,
        .remove = __devexit_p(omapflash_remove),
+       .driver = {
+               .name   = "omapflash",
+               .owner  = THIS_MODULE,
+       },
 };
 
 static int __init omapflash_init(void)
 {
-       return driver_register(&omapflash_driver);
+       return platform_driver_register(&omapflash_driver);
 }
 
 static void __exit omapflash_exit(void)
 {
-       driver_unregister(&omapflash_driver);
+       platform_driver_unregister(&omapflash_driver);
 }
 
 module_init(omapflash_init);
@@ -177,4 +175,4 @@ module_exit(omapflash_exit);
 
 MODULE_LICENSE("GPL");
 MODULE_DESCRIPTION("MTD NOR map driver for TI OMAP boards");
-
+MODULE_ALIAS("platform:omapflash");