Merge branch 'linux-next' of git://git.infradead.org/~dedekind/ubi-2.6
[safe/jmp/linux-2.6] / drivers / mtd / maps / ixp2000.c
index aa29a4a..c226479 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: ixp2000.c,v 1.9 2005/11/07 11:14:27 gleixner Exp $
- *
  * drivers/mtd/maps/ixp2000.c
  *
  * Mapping for the Intel XScale IXP2000 based systems
@@ -42,7 +40,6 @@ struct ixp2000_flash_info {
        struct          map_info map;
        struct          mtd_partition *partitions;
        struct          resource *res;
-       int             nr_banks;
 };
 
 static inline unsigned long flash_bank_setup(struct map_info *map, unsigned long ofs)
@@ -111,13 +108,12 @@ static void ixp2000_flash_copy_to(struct map_info *map, unsigned long to,
 }
 
 
-static int ixp2000_flash_remove(struct device *_dev)
+static int ixp2000_flash_remove(struct platform_device *dev)
 {
-       struct platform_device *dev = to_platform_device(_dev);
        struct flash_platform_data *plat = dev->dev.platform_data;
-       struct ixp2000_flash_info *info = dev_get_drvdata(&dev->dev);
+       struct ixp2000_flash_info *info = platform_get_drvdata(dev);
 
-       dev_set_drvdata(&dev->dev, NULL);
+       platform_set_drvdata(dev, NULL);
 
        if(!info)
                return 0;
@@ -129,8 +125,7 @@ static int ixp2000_flash_remove(struct device *_dev)
        if (info->map.map_priv_1)
                iounmap((void *) info->map.map_priv_1);
 
-       if (info->partitions) {
-               kfree(info->partitions); }
+       kfree(info->partitions);
 
        if (info->res) {
                release_resource(info->res);
@@ -144,10 +139,9 @@ static int ixp2000_flash_remove(struct device *_dev)
 }
 
 
-static int ixp2000_flash_probe(struct device *_dev)
+static int ixp2000_flash_probe(struct platform_device *dev)
 {
        static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
-       struct platform_device *dev = to_platform_device(_dev);
        struct ixp2000_flash_data *ixp_data = dev->dev.platform_data;
        struct flash_platform_data *plat;
        struct ixp2000_flash_info *info;
@@ -162,12 +156,12 @@ static int ixp2000_flash_probe(struct device *_dev)
                return -ENODEV;
 
        window_size = dev->resource->end - dev->resource->start + 1;
-       dev_info(_dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n",
-                       ixp_data->nr_banks, ((u32)window_size >> 20));
+       dev_info(&dev->dev, "Probe of IXP2000 flash(%d banks x %dMiB)\n",
+                ixp_data->nr_banks, ((u32)window_size >> 20));
 
        if (plat->width != 1) {
-               dev_err(_dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n",
-                               plat->width * 8);
+               dev_err(&dev->dev, "IXP2000 MTD map only supports 8-bit mode, asking for %d\n",
+                       plat->width * 8);
                return -EIO;
        }
 
@@ -178,7 +172,7 @@ static int ixp2000_flash_probe(struct device *_dev)
        }
        memzero(info, sizeof(struct ixp2000_flash_info));
 
-       dev_set_drvdata(&dev->dev, info);
+       platform_set_drvdata(dev, info);
 
        /*
         * Tell the MTD layer we're not 1:1 mapped so that it does
@@ -186,7 +180,6 @@ static int ixp2000_flash_probe(struct device *_dev)
         */
        info->map.phys = NO_XIP;
 
-       info->nr_banks = ixp_data->nr_banks;
        info->map.size = ixp_data->nr_banks * window_size;
        info->map.bankwidth = 1;
 
@@ -205,7 +198,7 @@ static int ixp2000_flash_probe(struct device *_dev)
                        dev->resource->end - dev->resource->start + 1,
                        dev->dev.bus_id);
        if (!info->res) {
-               dev_err(_dev, "Could not reserve memory region\n");
+               dev_err(&dev->dev, "Could not reserve memory region\n");
                err = -ENOMEM;
                goto Error;
        }
@@ -213,7 +206,7 @@ static int ixp2000_flash_probe(struct device *_dev)
        info->map.map_priv_1 = (unsigned long) ioremap(dev->resource->start,
                                dev->resource->end - dev->resource->start + 1);
        if (!info->map.map_priv_1) {
-               dev_err(_dev, "Failed to ioremap flash region\n");
+               dev_err(&dev->dev, "Failed to ioremap flash region\n");
                err = -EIO;
                goto Error;
        }
@@ -224,13 +217,13 @@ static int ixp2000_flash_probe(struct device *_dev)
         */
 
        erratum44_workaround = ixp2000_has_broken_slowport();
-       dev_info(_dev, "Erratum 44 workaround %s\n",
+       dev_info(&dev->dev, "Erratum 44 workaround %s\n",
               erratum44_workaround ? "enabled" : "disabled");
 #endif
 
        info->mtd = do_map_probe(plat->map_name, &info->map);
        if (!info->mtd) {
-               dev_err(_dev, "map_probe failed\n");
+               dev_err(&dev->dev, "map_probe failed\n");
                err = -ENXIO;
                goto Error;
        }
@@ -240,7 +233,7 @@ static int ixp2000_flash_probe(struct device *_dev)
        if (err > 0) {
                err = add_mtd_partitions(info->mtd, info->partitions, err);
                if(err)
-                       dev_err(_dev, "Could not parse partitions\n");
+                       dev_err(&dev->dev, "Could not parse partitions\n");
        }
 
        if (err)
@@ -249,29 +242,31 @@ static int ixp2000_flash_probe(struct device *_dev)
        return 0;
 
 Error:
-       ixp2000_flash_remove(_dev);
+       ixp2000_flash_remove(dev);
        return err;
 }
 
-static struct device_driver ixp2000_flash_driver = {
-       .name           = "IXP2000-Flash",
-       .bus            = &platform_bus_type,
-       .probe          = &ixp2000_flash_probe,
-       .remove         = &ixp2000_flash_remove
+static struct platform_driver ixp2000_flash_driver = {
+       .probe          = ixp2000_flash_probe,
+       .remove         = ixp2000_flash_remove,
+       .driver         = {
+               .name   = "IXP2000-Flash",
+               .owner  = THIS_MODULE,
+       },
 };
 
 static int __init ixp2000_flash_init(void)
 {
-       return driver_register(&ixp2000_flash_driver);
+       return platform_driver_register(&ixp2000_flash_driver);
 }
 
 static void __exit ixp2000_flash_exit(void)
 {
-       driver_unregister(&ixp2000_flash_driver);
+       platform_driver_unregister(&ixp2000_flash_driver);
 }
 
 module_init(ixp2000_flash_init);
 module_exit(ixp2000_flash_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net>");
-
+MODULE_ALIAS("platform:IXP2000-Flash");