[PATCH] Random fixes for the ixp4xx mapping driver

Alexey Zaytsev alexey.zaytsev at gmail.com
Wed Apr 19 15:04:25 EDT 2006


Hi all.

I've made a few fixes to the driver, including:

- Fix build with partitioning disabled.
- Change the error handling path in a cleaner way.
- Some coding style.


Hope gmail won't mess with it.

--- linux-2.6.16.1.orig/drivers/mtd/maps/ixp4xx.c       2006-04-19
21:03:06.000000000 +0400
+++ linux-2.6.16.1/drivers/mtd/maps/ixp4xx.c    2006-04-19
22:13:37.000000000 +0400
@@ -151,7 +151,9 @@
       struct resource *res;
 };

-static const char *probes[] = { "RedBoot", "cmdlinepart", NULL };
+#ifdef CONFIG_MTD_PARTITIONS
+static const char *probes[] __initdata = { "RedBoot", "cmdlinepart", NULL };
+#endif

  static int ixp4xx_flash_remove(struct platform_device *dev)
 {
@@ -164,7 +166,9 @@
               return 0;

       if (info->mtd) {
+#ifdef CONFIG_MTD_PARTITIONS
               del_mtd_partitions(info->mtd);
+#endif
               map_destroy(info->mtd);
       }
       if (info->map.virt)
@@ -187,7 +191,7 @@
 {
       struct flash_platform_data *plat = dev->dev.platform_data;
       struct ixp4xx_flash_info *info;
-       int err = -1;
+       int err = 0;

       if (!plat)
               return -ENODEV;
@@ -201,7 +205,7 @@
       info = kmalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
       if(!info) {
               err = -ENOMEM;
-               goto Error;
+               goto out;
       }
       memzero(info, sizeof(struct ixp4xx_flash_info));

@@ -221,9 +225,9 @@
        */
       info->map.bankwidth = 2;
       info->map.name = dev->dev.bus_id;
-       info->map.read = ixp4xx_read16,
-       info->map.write = ixp4xx_probe_write16,
-       info->map.copy_from = ixp4xx_copy_from,
+       info->map.read = ixp4xx_read16;
+       info->map.write = ixp4xx_probe_write16;
+       info->map.copy_from = ixp4xx_copy_from;

       info->res = request_mem_region(dev->resource->start,
                       dev->resource->end - dev->resource->start + 1,
@@ -231,7 +235,7 @@
       if (!info->res) {
               printk(KERN_ERR "IXP4XXFlash: Could not reserve memory
region\n");
               err = -ENOMEM;
-               goto Error;
+               goto out;
       }

       info->map.virt = ioremap(dev->resource->start,
@@ -239,35 +243,36 @@
       if (!info->map.virt) {
               printk(KERN_ERR "IXP4XXFlash: Failed to ioremap region\n");
               err = -EIO;
-               goto Error;
+               goto out;
       }

       info->mtd = do_map_probe(plat->map_name, &info->map);
       if (!info->mtd) {
               printk(KERN_ERR "IXP4XXFlash: map_probe failed\n");
               err = -ENXIO;
-               goto Error;
+               goto out;
       }
       info->mtd->owner = THIS_MODULE;

       /* Use the fast version */
-       info->map.write = ixp4xx_write16,
+       info->map.write = ixp4xx_write16;

+#ifdef CONFIG_MTD_PARTITIONS
       err = parse_mtd_partitions(info->mtd, probes, &info->partitions, 0);
       if (err > 0) {
               err = add_mtd_partitions(info->mtd, info->partitions, err);
-               if(err)
-                       printk(KERN_ERR "Could not parse partitions\n");
+
       }
+       if (err < 0)
+               printk(KERN_ERR "Could not parse partitions\n");
+#endif

+out:
       if (err)
-               goto Error;
-
+               ixp4xx_flash_remove(dev);
+
       return 0;

-Error:
-       ixp4xx_flash_remove(dev);
-       return err;
 }

  static struct platform_driver ixp4xx_flash_driver = {




More information about the linux-mtd mailing list