]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
drivers/mtd: Use kzalloc
authorJulia Lawall <julia@diku.dk>
Thu, 13 May 2010 20:03:15 +0000 (22:03 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Thu, 13 May 2010 20:23:06 +0000 (21:23 +0100)
Use kzalloc rather than the combination of kmalloc and memset.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression x,size,flags;
statement S;
@@

-x = kmalloc(size,flags);
+x = kzalloc(size,flags);
 if (x == NULL) S
-memset(x, 0, size);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/lpddr/qinfo_probe.c
drivers/mtd/maps/ixp2000.c
drivers/mtd/maps/ixp4xx.c
drivers/mtd/maps/pxa2xx-flash.c
drivers/mtd/tests/mtd_pagetest.c
drivers/mtd/tests/mtd_readtest.c
drivers/mtd/tests/mtd_speedtest.c
drivers/mtd/tests/mtd_stresstest.c
drivers/mtd/tests/mtd_subpagetest.c

index 79bf40f48b753aaed5634e8240e8b38687f9b1e5..dbfe17baf0463a7e47325f2b228487e29e28391c 100644 (file)
@@ -134,13 +134,12 @@ out:
 static int lpddr_chip_setup(struct map_info *map, struct lpddr_private *lpddr)
 {
 
-       lpddr->qinfo = kmalloc(sizeof(struct qinfo_chip), GFP_KERNEL);
+       lpddr->qinfo = kzalloc(sizeof(struct qinfo_chip), GFP_KERNEL);
        if (!lpddr->qinfo) {
                printk(KERN_WARNING "%s: no memory for LPDDR qinfo structure\n",
                                map->name);
                return 0;
        }
-       memset(lpddr->qinfo, 0, sizeof(struct qinfo_chip));
 
        /* Get the ManuID */
        lpddr->ManufactId = CMDVAL(map_read(map, map->pfow_base + PFOW_MANUFACTURER_ID));
@@ -185,13 +184,11 @@ static struct lpddr_private *lpddr_probe_chip(struct map_info *map)
        lpddr.numchips = 1;
 
        numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum;
-       retlpddr = kmalloc(sizeof(struct lpddr_private) +
+       retlpddr = kzalloc(sizeof(struct lpddr_private) +
                        numvirtchips * sizeof(struct flchip), GFP_KERNEL);
        if (!retlpddr)
                return NULL;
 
-       memset(retlpddr, 0, sizeof(struct lpddr_private) +
-                               numvirtchips * sizeof(struct flchip));
        memcpy(retlpddr, &lpddr, sizeof(struct lpddr_private));
 
        retlpddr->numchips = numvirtchips;
index 1bdf0ee6d0b63cb4d4d8e7b396ac01cfb4ba22d9..9639d83a9d6c9303b123ba39a399f3c9594154c5 100644 (file)
@@ -165,12 +165,11 @@ static int ixp2000_flash_probe(struct platform_device *dev)
                return -EIO;
        }
 
-       info = kmalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL);
        if(!info) {
                err = -ENOMEM;
                goto Error;
        }
-       memset(info, 0, sizeof(struct ixp2000_flash_info));
 
        platform_set_drvdata(dev, info);
 
index 7513d90fee6fcd33dfbd49dc35feb7461fce45e9..e0a5e0426ead49be256a455df91026427c950e97 100644 (file)
@@ -196,12 +196,11 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
                        return err;
        }
 
-       info = kmalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL);
        if(!info) {
                err = -ENOMEM;
                goto Error;
        }
-       memset(info, 0, sizeof(struct ixp4xx_flash_info));
 
        platform_set_drvdata(dev, info);
 
index 91dc6331053f512fc881ee6b28376da93616c294..dd90880048cf3fe2f8d209ad654159565a5987e4 100644 (file)
@@ -63,11 +63,10 @@ static int __init pxa2xx_flash_probe(struct platform_device *pdev)
        if (!res)
                return -ENODEV;
 
-       info = kmalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       memset(info, 0, sizeof(struct pxa2xx_flash_info));
        info->map.name = (char *) flash->name;
        info->map.bankwidth = flash->width;
        info->map.phys = res->start;
index 921a85df9196fafa08393da12ffb46407e8fb5d7..6bc1b8276c6270353a97a726ec3b999cfe9d7cbf 100644 (file)
@@ -480,12 +480,11 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {
index 7107fccbc7dec049b72585e1ab38a4f330145ea9..afe71aa15c4b4493c5e2c5d50946d71122c35b98 100644 (file)
@@ -141,12 +141,11 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        /* NOR flash does not implement block_isbad */
        if (mtd->block_isbad == NULL)
index 56ca62bb96bf5e14e0a2a60a624717900b0033d7..161feeb7b8b9dc299c2adfcc0f1bd13c8134e273 100644 (file)
@@ -295,12 +295,11 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        /* NOR flash does not implement block_isbad */
        if (mtd->block_isbad == NULL)
index 3854afec56d0575b65d00c824d898c2347d69529..531625fc9259cdd167f0ade4755cf1f71cdefaa2 100644 (file)
@@ -221,12 +221,11 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        /* NOR flash does not implement block_isbad */
        if (mtd->block_isbad == NULL)
index 700237a3d120ecc2169a0329eedc42c8cf2cec0d..11204e8aab5f33bb4bcb51c150ab30e63139f8f2 100644 (file)
@@ -354,12 +354,11 @@ static int scan_for_bad_eraseblocks(void)
 {
        int i, bad = 0;
 
-       bbt = kmalloc(ebcnt, GFP_KERNEL);
+       bbt = kzalloc(ebcnt, GFP_KERNEL);
        if (!bbt) {
                printk(PRINT_PREF "error: cannot allocate memory\n");
                return -ENOMEM;
        }
-       memset(bbt, 0 , ebcnt);
 
        printk(PRINT_PREF "scanning for bad eraseblocks\n");
        for (i = 0; i < ebcnt; ++i) {