mtd: pmcmsp-flash: Allocating too much in init_msp_flash()
[pandora-kernel.git] / drivers / mtd / maps / pmcmsp-flash.c
index 64aea6a..f9fa3fa 100644 (file)
@@ -75,15 +75,15 @@ static int __init init_msp_flash(void)
 
        printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt);
 
-       msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
+       msp_flash = kcalloc(fcnt, sizeof(*msp_flash), GFP_KERNEL);
        if (!msp_flash)
                return -ENOMEM;
 
-       msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
+       msp_parts = kcalloc(fcnt, sizeof(*msp_parts), GFP_KERNEL);
        if (!msp_parts)
                goto free_msp_flash;
 
-       msp_maps = kcalloc(fcnt, sizeof(struct mtd_info), GFP_KERNEL);
+       msp_maps = kcalloc(fcnt, sizeof(*msp_maps), GFP_KERNEL);
        if (!msp_maps)
                goto free_msp_parts;
 
@@ -173,7 +173,7 @@ static int __init init_msp_flash(void)
                msp_flash[i] = do_map_probe("cfi_probe", &msp_maps[i]);
                if (msp_flash[i]) {
                        msp_flash[i]->owner = THIS_MODULE;
-                       add_mtd_partitions(msp_flash[i], msp_parts[i], pcnt);
+                       mtd_device_register(msp_flash[i], msp_parts[i], pcnt);
                } else {
                        printk(KERN_ERR "map probe failed for flash\n");
                        ret = -ENXIO;
@@ -188,7 +188,7 @@ static int __init init_msp_flash(void)
 
 cleanup_loop:
        while (i--) {
-               del_mtd_partitions(msp_flash[i]);
+               mtd_device_unregister(msp_flash[i]);
                map_destroy(msp_flash[i]);
                kfree(msp_maps[i].name);
                iounmap(msp_maps[i].virt);
@@ -207,7 +207,7 @@ static void __exit cleanup_msp_flash(void)
        int i;
 
        for (i = 0; i < fcnt; i++) {
-               del_mtd_partitions(msp_flash[i]);
+               mtd_device_unregister(msp_flash[i]);
                map_destroy(msp_flash[i]);
                iounmap((void *)msp_maps[i].virt);