[MTD] replace kmalloc+memset with kzalloc
authorBurman Yan <yan_952@hotmail.com>
Wed, 15 Nov 2006 19:10:29 +0000 (21:10 +0200)
committerDavid Woodhouse <dwmw2@infradead.org>
Tue, 28 Nov 2006 23:47:21 +0000 (23:47 +0000)
Signed-off-by: Yan Burman <yan_952@hotmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
41 files changed:
arch/ppc/platforms/ev64360.c
drivers/mtd/afs.c
drivers/mtd/chips/amd_flash.c
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/chips/cfi_cmdset_0020.c
drivers/mtd/chips/gen_probe.c
drivers/mtd/chips/jedec.c
drivers/mtd/chips/map_absent.c
drivers/mtd/chips/map_ram.c
drivers/mtd/chips/map_rom.c
drivers/mtd/chips/sharp.c
drivers/mtd/cmdlinepart.c
drivers/mtd/devices/block2mtd.c
drivers/mtd/devices/ms02-nv.c
drivers/mtd/devices/phram.c
drivers/mtd/devices/slram.c
drivers/mtd/ftl.c
drivers/mtd/inftlcore.c
drivers/mtd/maps/ceiva.c
drivers/mtd/maps/integrator-flash.c
drivers/mtd/maps/omap_nor.c
drivers/mtd/maps/pcmciamtd.c
drivers/mtd/maps/physmap.c
drivers/mtd/maps/plat-ram.c
drivers/mtd/maps/sa1100-flash.c
drivers/mtd/maps/tqm834x.c
drivers/mtd/maps/tqm8xxl.c
drivers/mtd/mtd_blkdevs.c
drivers/mtd/mtdblock.c
drivers/mtd/mtdblock_ro.c
drivers/mtd/mtdchar.c
drivers/mtd/mtdconcat.c
drivers/mtd/mtdpart.c
drivers/mtd/nand/diskonchip.c
drivers/mtd/nand/nand_bbt.c
drivers/mtd/nand/nandsim.c
drivers/mtd/nftlcore.c
drivers/mtd/onenand/generic.c
drivers/mtd/onenand/onenand_bbt.c
drivers/mtd/redboot.c

index 90ed375c9b903771cecb6c5cebf946efcb0f94d6..f87e06f6bab99aabffbda6a6c104314400760637 100644 (file)
@@ -358,13 +358,12 @@ ev64360_setup_mtd(void)
 
        ptbl_entries = 3;
 
-       if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
+       if ((ptbl = kzalloc(ptbl_entries * sizeof(struct mtd_partition),
                GFP_KERNEL)) == NULL) {
 
                printk(KERN_WARNING "Can't alloc MTD partition table\n");
                return -ENOMEM;
        }
-       memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
 
        ptbl[0].name = "reserved";
        ptbl[0].offset = 0;
index 6a45be04564b7cd6b92b4b7afab76696d50feb23..52d51eb91c16f7c1a7a5ec7c3cbbcd5936cb5a39 100644 (file)
@@ -207,11 +207,10 @@ static int parse_afs_partitions(struct mtd_info *mtd,
        if (!sz)
                return ret;
 
-       parts = kmalloc(sz, GFP_KERNEL);
+       parts = kzalloc(sz, GFP_KERNEL);
        if (!parts)
                return -ENOMEM;
 
-       memset(parts, 0, sz);
        str = (char *)(parts + idx);
 
        /*
index 16eaca69fb5aff52137560149b4409217463f47b..e7999f15d85a51881f54a2d49d79506c3a3623d0 100644 (file)
@@ -643,13 +643,12 @@ static struct mtd_info *amd_flash_probe(struct map_info *map)
        int reg_idx;
        int offset;
 
-       mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd) {
                printk(KERN_WARNING
                       "%s: kmalloc failed for info structure\n", map->name);
                return NULL;
        }
-       memset(mtd, 0, sizeof(*mtd));
        mtd->priv = map;
 
        memset(&temp, 0, sizeof(temp));
index e24973636e61bbf0123aeb8a82ad8550e63c3aa6..11de545355266d9a0fff04248e6dbd23d7b30ec0 100644 (file)
@@ -337,12 +337,11 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary)
        struct mtd_info *mtd;
        int i;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd) {
                printk(KERN_ERR "Failed to allocate memory for MTD device\n");
                return NULL;
        }
-       memset(mtd, 0, sizeof(*mtd));
        mtd->priv = map;
        mtd->type = MTD_NORFLASH;
 
index ca0882b5819f4dbcd6fd929770c088e3363f62c0..e3acd398fb37910c539dfb22fb0a8921748522ff 100644 (file)
@@ -257,12 +257,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
        struct mtd_info *mtd;
        int i;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd) {
                printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
                return NULL;
        }
-       memset(mtd, 0, sizeof(*mtd));
        mtd->priv = map;
        mtd->type = MTD_NORFLASH;
 
index fae70a5db5409f65307a6f851edfaafda6bb039e..d56849f5f107bbb119569ef42c27f3cdbc5e60ab 100644 (file)
@@ -172,7 +172,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
        int i,j;
        unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips);
 
        if (!mtd) {
@@ -181,7 +181,6 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
                return NULL;
        }
 
-       memset(mtd, 0, sizeof(*mtd));
        mtd->priv = map;
        mtd->type = MTD_NORFLASH;
        mtd->size = devsize * cfi->numchips;
index cdb0f590b40c117ba246f23e2351528608476df2..77843d560ae481eb2131acad573beb5a4a40ec18 100644 (file)
@@ -113,13 +113,12 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi
        }
 
        mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG;
-       chip_map = kmalloc(mapsize, GFP_KERNEL);
+       chip_map = kzalloc(mapsize, GFP_KERNEL);
        if (!chip_map) {
                printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name);
                kfree(cfi.cfiq);
                return NULL;
        }
-       memset (chip_map, 0, mapsize);
 
        set_bit(0, chip_map); /* Mark first chip valid */
 
index 2c3f019197c116463b74b04645dd6baf54e0dd65..14e57b2bf8424ccc287a184bdd9e08a26f7925c4 100644 (file)
@@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(struct map_info *map)
    char Part[200];
    memset(&priv,0,sizeof(priv));
 
-   MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
+   MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
    if (!MTD)
           return NULL;
 
-   memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private));
    priv = (struct jedec_private *)&MTD[1];
 
    my_bank_size = map->size;
index ac01a949b687a4513e7217c0c59ac1f492d06a45..fc478c0f93f55bdcce74f7f82393a5c36a39b605 100644 (file)
@@ -47,13 +47,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map)
 {
        struct mtd_info *mtd;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd) {
                return NULL;
        }
 
-       memset(mtd, 0, sizeof(*mtd));
-
        map->fldrv      = &map_absent_chipdrv;
        mtd->priv       = map;
        mtd->name       = map->name;
index 3a66680abfd06cc3b3c6b60e129e957d84e912a9..5cb6d5263661a63f862d458a6b3a2dfdc31686ae 100644 (file)
@@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(struct map_info *map)
 #endif
        /* OK. It seems to be RAM. */
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd)
                return NULL;
 
-       memset(mtd, 0, sizeof(*mtd));
-
        map->fldrv = &mapram_chipdrv;
        mtd->priv = map;
        mtd->name = map->name;
index 1b328b1378fda2d9d288d535434a7113a7262d74..cb27f855074c279a65ce23a53cc2615ff9417d55 100644 (file)
@@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(struct map_info *map)
 {
        struct mtd_info *mtd;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd)
                return NULL;
 
-       memset(mtd, 0, sizeof(*mtd));
-
        map->fldrv = &maprom_chipdrv;
        mtd->priv = map;
        mtd->name = map->name;
index 967abbecdff9bb450aab9852e28c5ee84d39dcc7..c9cd3d21ccfaa98c64d976e29cabc0fef28ee7d0 100644 (file)
@@ -112,18 +112,16 @@ static struct mtd_info *sharp_probe(struct map_info *map)
        struct sharp_info *sharp = NULL;
        int width;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if(!mtd)
                return NULL;
 
-       sharp = kmalloc(sizeof(*sharp), GFP_KERNEL);
+       sharp = kzalloc(sizeof(*sharp), GFP_KERNEL);
        if(!sharp) {
                kfree(mtd);
                return NULL;
        }
 
-       memset(mtd, 0, sizeof(*mtd));
-
        width = sharp_probe_map(map,mtd);
        if(!width){
                kfree(mtd);
@@ -143,7 +141,6 @@ static struct mtd_info *sharp_probe(struct map_info *map)
        mtd->writesize = 1;
        mtd->name = map->name;
 
-       memset(sharp, 0, sizeof(*sharp));
        sharp->chipshift = 23;
        sharp->numchips = 1;
        sharp->chips[0].start = 0;
index 3402ce448702bfa897bd9f9e4468c1e5e16b9324..23fab14f1637cab5fb4ee175ff5eaea6db141915 100644 (file)
@@ -163,13 +163,12 @@ static struct mtd_partition * newpart(char *s,
                *num_parts = this_part + 1;
                alloc_size = *num_parts * sizeof(struct mtd_partition) +
                             extra_mem_size;
-               parts = kmalloc(alloc_size, GFP_KERNEL);
+               parts = kzalloc(alloc_size, GFP_KERNEL);
                if (!parts)
                {
                        printk(KERN_ERR ERRP "out of memory\n");
                        return NULL;
                }
-               memset(parts, 0, alloc_size);
                extra_mem = (unsigned char *)(parts + *num_parts);
        }
        /* enter this partition (offset will be calculated later if it is zero at this point) */
index 401c6a294baaebc7951dbca2a213dc2312a05072..6d917a4daa9db24b4d9e7cb23281e1842cef9283 100644 (file)
@@ -295,10 +295,9 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size)
        if (!devname)
                return NULL;
 
-       dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
        if (!dev)
                return NULL;
-       memset(dev, 0, sizeof(*dev));
 
        /* Get a handle on the device */
        bdev = open_bdev_excl(devname, O_RDWR, NULL);
index 08dfb899b27204ef036e693826643bd6452d8f38..9cff119a202483cd9cea74438c190b5a4fbb7171 100644 (file)
@@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong addr)
        int ret = -ENODEV;
 
        /* The module decodes 8MiB of address space. */
-       mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL);
+       mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL);
        if (!mod_res)
                return -ENOMEM;
 
-       memset(mod_res, 0, sizeof(*mod_res));
        mod_res->name = ms02nv_name;
        mod_res->start = addr;
        mod_res->end = addr + MS02NV_SLOT_SIZE - 1;
@@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong addr)
        }
 
        ret = -ENOMEM;
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd)
                goto err_out_mod_res_rel;
-       memset(mtd, 0, sizeof(*mtd));
-       mp = kmalloc(sizeof(*mp), GFP_KERNEL);
+       mp = kzalloc(sizeof(*mp), GFP_KERNEL);
        if (!mp)
                goto err_out_mtd;
-       memset(mp, 0, sizeof(*mp));
 
        mtd->priv = mp;
        mp->resource.module = mod_res;
 
        /* Firmware's diagnostic NVRAM area. */
-       diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL);
+       diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL);
        if (!diag_res)
                goto err_out_mp;
 
-       memset(diag_res, 0, sizeof(*diag_res));
        diag_res->name = ms02nv_res_diag_ram;
        diag_res->start = addr;
        diag_res->end = addr + MS02NV_RAM - 1;
@@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong addr)
        mp->resource.diag_ram = diag_res;
 
        /* User-available general-purpose NVRAM area. */
-       user_res = kmalloc(sizeof(*user_res), GFP_KERNEL);
+       user_res = kzalloc(sizeof(*user_res), GFP_KERNEL);
        if (!user_res)
                goto err_out_diag_res;
 
-       memset(user_res, 0, sizeof(*user_res));
        user_res->name = ms02nv_res_user_ram;
        user_res->start = addr + MS02NV_RAM;
        user_res->end = addr + size - 1;
@@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong addr)
        mp->resource.user_ram = user_res;
 
        /* Control and status register. */
-       csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL);
+       csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL);
        if (!csr_res)
                goto err_out_user_res;
 
-       memset(csr_res, 0, sizeof(*csr_res));
        csr_res->name = ms02nv_res_csr;
        csr_res->start = addr + MS02NV_CSR;
        csr_res->end = addr + MS02NV_CSR + 3;
index 6c7337f9ebbbfce6edc1f204f1d1b58d6bff2be5..56cc1ca7ffd5e7d8c552c47d3d0089fe4014c2e6 100644 (file)
@@ -126,12 +126,10 @@ static int register_device(char *name, unsigned long start, unsigned long len)
        struct phram_mtd_list *new;
        int ret = -ENOMEM;
 
-       new = kmalloc(sizeof(*new), GFP_KERNEL);
+       new = kzalloc(sizeof(*new), GFP_KERNEL);
        if (!new)
                goto out0;
 
-       memset(new, 0, sizeof(*new));
-
        ret = -EIO;
        new->mtd.priv = ioremap(start, len);
        if (!new->mtd.priv) {
index 542a0c009006d4b682d30c03fa437a4f0b62a2aa..5f49248a48564398a82239c569bf860b5d431da0 100644 (file)
@@ -168,19 +168,16 @@ static int register_device(char *name, unsigned long start, unsigned long length
                E("slram: Cannot allocate new MTD device.\n");
                return(-ENOMEM);
        }
-       (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
+       (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
        (*curmtd)->next = NULL;
 
        if ((*curmtd)->mtdinfo) {
-               memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info));
                (*curmtd)->mtdinfo->priv =
-                       kmalloc(sizeof(slram_priv_t), GFP_KERNEL);
+                       kzalloc(sizeof(slram_priv_t), GFP_KERNEL);
 
                if (!(*curmtd)->mtdinfo->priv) {
                        kfree((*curmtd)->mtdinfo);
                        (*curmtd)->mtdinfo = NULL;
-               } else {
-                       memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t));
                }
        }
 
index da39355132d84caff599356f238c883b689f9b93..24235d4f1d23219255da945d14afe2493a742ef6 100644 (file)
@@ -1033,7 +1033,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 {
        partition_t *partition;
 
-       partition = kmalloc(sizeof(partition_t), GFP_KERNEL);
+       partition = kzalloc(sizeof(partition_t), GFP_KERNEL);
 
        if (!partition) {
                printk(KERN_WARNING "No memory to scan for FTL on %s\n",
@@ -1041,8 +1041,6 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
                return;
        }
 
-       memset(partition, 0, sizeof(partition_t));
-
        partition->mbd.mtd = mtd;
 
        if ((scan_header(partition) == 0) &&
index d2f54c037e0f8622e4c8d8e4bcbdefce8f103bad..b0e396504e67cf98d2469afc881594706c706bd9 100644 (file)
@@ -67,13 +67,12 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 
        DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name);
 
-       inftl = kmalloc(sizeof(*inftl), GFP_KERNEL);
+       inftl = kzalloc(sizeof(*inftl), GFP_KERNEL);
 
        if (!inftl) {
                printk(KERN_WARNING "INFTL: Out of memory for data structures\n");
                return;
        }
-       memset(inftl, 0, sizeof(*inftl));
 
        inftl->mbd.mtd = mtd;
        inftl->mbd.devnum = -1;
index 0402c21e291d40c750bd9a047dcf7f13bc811d7e..629e6e2641a84c7ca5e2d0ecd53b56566008362b 100644 (file)
@@ -122,10 +122,9 @@ static int __init clps_setup_mtd(struct clps_info *clps, int nr, struct mtd_info
        /*
         * Allocate the map_info structs in one go.
         */
-       maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
+       maps = kzalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
        if (!maps)
                return -ENOMEM;
-       memset(maps, 0, sizeof(struct map_info) * nr);
        /*
         * Claim and then map the memory regions.
         */
index c8db01b3e45f2d68f4a6612f47d67cd5c9153e6b..6946d802e6f67e1c03a577e01fa345d2b794715b 100644 (file)
@@ -75,14 +75,12 @@ static int armflash_probe(struct platform_device *dev)
        int err;
        void __iomem *base;
 
-       info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL);
        if (!info) {
                err = -ENOMEM;
                goto out;
        }
 
-       memset(info, 0, sizeof(struct armflash_info));
-
        info->plat = plat;
        if (plat && plat->init) {
                err = plat->init();
index 418afffb2d8026bd85fea3270895f067a7fca4b0..e8d9ae535673d68d04b547f029dbdadefd6b3e58 100644 (file)
@@ -78,12 +78,10 @@ static int __devinit omapflash_probe(struct platform_device *pdev)
        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;
index 995347b1beba5c1a90cfc4144b274da652164223..eaeb56a4070acadbe9633fddad14bc8b69a0f829 100644 (file)
@@ -735,11 +735,10 @@ static int pcmciamtd_probe(struct pcmcia_device *link)
        struct pcmciamtd_dev *dev;
 
        /* Create new memory card device */
-       dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev) return -ENOMEM;
        DEBUG(1, "dev=0x%p", dev);
 
-       memset(dev, 0, sizeof(*dev));
        dev->p_dev = link;
        link->priv = dev;
 
index bb67c505b1a5b7875431949904a965abf82a743d..28c5ffd75233a27fd8dd40ba23cf739fe5710f69 100644 (file)
@@ -92,12 +92,11 @@ static int physmap_flash_probe(struct platform_device *dev)
            (unsigned long long)(dev->resource->end - dev->resource->start + 1),
            (unsigned long long)dev->resource->start);
 
-       info = kmalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);
        if (info == NULL) {
                err = -ENOMEM;
                goto err_out;
        }
-       memset(info, 0, sizeof(*info));
 
        platform_set_drvdata(dev, info);
 
index 5d3c75451ca292afb002d6f817f5c7e6bc3c4569..2b6504ecbbd16a362331000f501ee5371f5ed862 100644 (file)
@@ -147,14 +147,13 @@ static int platram_probe(struct platform_device *pdev)
 
        pdata = pdev->dev.platform_data;
 
-       info = kmalloc(sizeof(*info), GFP_KERNEL);
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (info == NULL) {
                dev_err(&pdev->dev, "no memory for flash info\n");
                err = -ENOMEM;
                goto exit_error;
        }
 
-       memset(info, 0, sizeof(*info));
        platform_set_drvdata(pdev, info);
 
        info->dev = &pdev->dev;
index 950bf1c578417f0d2ba3d5b035fd0adb8e5b99ac..f904e6bd02e05856f220bea1fe89afb0566b60c6 100644 (file)
@@ -273,14 +273,12 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat)
        /*
         * Allocate the map_info structs in one go.
         */
-       info = kmalloc(size, GFP_KERNEL);
+       info = kzalloc(size, GFP_KERNEL);
        if (!info) {
                ret = -ENOMEM;
                goto out;
        }
 
-       memset(info, 0, size);
-
        if (plat->init) {
                ret = plat->init();
                if (ret)
index 58e5912bd381463ea971cbb53c9b7d0f0719ace8..9adc970e55e6a871f225bcb2827024fda5bb1609 100644 (file)
@@ -132,20 +132,16 @@ static int __init init_tqm834x_mtd(void)
 
                pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx);
 
-               map_banks[idx] =
-                       (struct map_info *)kmalloc(sizeof(struct map_info),
-                                                  GFP_KERNEL);
+               map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
                if (map_banks[idx] == NULL) {
                        ret = -ENOMEM;
                        goto error_mem;
                }
-               memset((void *)map_banks[idx], 0, sizeof(struct map_info));
-               map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
+               map_banks[idx]->name = kzalloc(16, GFP_KERNEL);
                if (map_banks[idx]->name == NULL) {
                        ret = -ENOMEM;
                        goto error_mem;
                }
-               memset((void *)map_banks[idx]->name, 0, 16);
 
                sprintf(map_banks[idx]->name, "TQM834x-%d", idx);
                map_banks[idx]->size = flash_size;
index 19578ba84ee8d934e0354fdb0adf80f61beaa8c0..37e4ded9b60033c2b8dce6005953d77687c3d41c 100644 (file)
@@ -134,14 +134,13 @@ int __init init_tqm_mtd(void)
 
                printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx);
 
-               map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL);
+               map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
                if(map_banks[idx] == NULL) {
                        ret = -ENOMEM;
                        /* FIXME: What if some MTD devices were probed already? */
                        goto error_mem;
                }
 
-               memset((void *)map_banks[idx], 0, sizeof(struct map_info));
                map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
 
                if (!map_banks[idx]->name) {
index b5d62cb357da3a2398851ed2dfb8a8dce76fa288..b879a66daa9e037964ff858f362e8b7cb062b207 100644 (file)
@@ -373,12 +373,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr)
        if (!blktrans_notifier.list.next)
                register_mtd_user(&blktrans_notifier);
 
-       tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
+       tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
        if (!tr->blkcore_priv)
                return -ENOMEM;
 
-       memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv));
-
        mutex_lock(&mtd_table_mutex);
 
        ret = register_blkdev(tr->major, tr->name);
index a052648f6e319c4f58e6d2fb6ffff7bbcaad17f6..952da30b17452d829bc97b669b626a38d1836ab5 100644 (file)
@@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd)
        }
 
        /* OK, it's not open. Create cache info for it */
-       mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
+       mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
        if (!mtdblk)
                return -ENOMEM;
 
-       memset(mtdblk, 0, sizeof(*mtdblk));
        mtdblk->count = 1;
        mtdblk->mtd = mtd;
 
@@ -339,13 +338,11 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev)
 
 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 {
-       struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 
        if (!dev)
                return;
 
-       memset(dev, 0, sizeof(*dev));
-
        dev->mtd = mtd;
        dev->devnum = mtd->index;
 
index 642ccc66f2838d46c76576af30e7afe1d139c18d..f79dbb49b1a2601ae596283d75ca83564121d0d5 100644 (file)
@@ -33,13 +33,11 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev,
 
 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 {
-       struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+       struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 
        if (!dev)
                return;
 
-       memset(dev, 0, sizeof(*dev));
-
        dev->mtd = mtd;
        dev->devnum = mtd->index;
 
index 07618f51d969e7e4d4555330ff532ca04cfe7adf..7c4adc6413281a855cf4a9888eca798d49f463bc 100644 (file)
@@ -431,7 +431,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
                if(!(file->f_mode & 2))
                        return -EPERM;
 
-               erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
+               erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);
                if (!erase)
                        ret = -ENOMEM;
                else {
@@ -440,7 +440,6 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
 
                        init_waitqueue_head(&waitq);
 
-                       memset (erase,0,sizeof(struct erase_info));
                        if (copy_from_user(&erase->addr, argp,
                                    sizeof(struct erase_info_user))) {
                                kfree(erase);
index cf927a8803e711e008624809e55e6301d913aa0a..ec51483b1c51b27a7fc1e8a3edf1c15af7e4fbc2 100644 (file)
@@ -708,14 +708,13 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],     /* subdevices to c
 
        /* allocate the device structure */
        size = SIZEOF_STRUCT_MTD_CONCAT(num_devs);
-       concat = kmalloc(size, GFP_KERNEL);
+       concat = kzalloc(size, GFP_KERNEL);
        if (!concat) {
                printk
                    ("memory allocation error while creating concatenated device \"%s\"\n",
                     name);
                return NULL;
        }
-       memset(concat, 0, size);
        concat->subdev = (struct mtd_info **) (concat + 1);
 
        /*
index a20f75fd8d61a1ba0faf4bcecfca81112175d646..89692f898ef4ad78a77dced4b9d0a04cc44288a7 100644 (file)
@@ -323,14 +323,13 @@ int add_mtd_partitions(struct mtd_info *master,
        for (i = 0; i < nbparts; i++) {
 
                /* allocate the partition structure */
-               slave = kmalloc (sizeof(*slave), GFP_KERNEL);
+               slave = kzalloc (sizeof(*slave), GFP_KERNEL);
                if (!slave) {
                        printk ("memory allocation error while creating partitions for \"%s\"\n",
                                master->name);
                        del_mtd_partitions(master);
                        return -ENOMEM;
                }
-               memset(slave, 0, sizeof(*slave));
                list_add(&slave->list, &mtd_partitions);
 
                /* set up the MTD object for this partition */
index 6107f532855b8d4dbb901ff83c721e76a0b59af2..12608c13cce5b2365c3aaf5e77f2481ec9bef241 100644 (file)
@@ -1635,13 +1635,12 @@ static int __init doc_probe(unsigned long physadr)
 
        len = sizeof(struct mtd_info) +
            sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr));
-       mtd = kmalloc(len, GFP_KERNEL);
+       mtd = kzalloc(len, GFP_KERNEL);
        if (!mtd) {
                printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
                ret = -ENOMEM;
                goto fail;
        }
-       memset(mtd, 0, len);
 
        nand                    = (struct nand_chip *) (mtd + 1);
        doc                     = (struct doc_priv *) (nand + 1);
index 4e74fe9af29ef02cb0a0f2a0134651abbc3757b2..5e121ceaa59899ea94d964aab94df39845c18520 100644 (file)
@@ -960,14 +960,12 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
        struct nand_bbt_descr *md = this->bbt_md;
 
        len = mtd->size >> (this->bbt_erase_shift + 2);
-       /* Allocate memory (2bit per block) */
-       this->bbt = kmalloc(len, GFP_KERNEL);
+       /* Allocate memory (2bit per block) and clear the memory bad block table */
+       this->bbt = kzalloc(len, GFP_KERNEL);
        if (!this->bbt) {
                printk(KERN_ERR "nand_scan_bbt: Out of memory\n");
                return -ENOMEM;
        }
-       /* Clear the memory bad block table */
-       memset(this->bbt, 0x00, len);
 
        /* If no primary table decriptor is given, scan the device
         * to build a memory based bad block table
index abebcab47631d456341ff3594d26e330b90ac04e..3d39451ae8f5c113fa7ed4954f7c1789da601b33 100644 (file)
@@ -1511,14 +1511,12 @@ static int __init ns_init_module(void)
        }
 
        /* Allocate and initialize mtd_info, nand_chip and nandsim structures */
-       nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)
+       nsmtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)
                                + sizeof(struct nandsim), GFP_KERNEL);
        if (!nsmtd) {
                NS_ERR("unable to allocate core structures.\n");
                return -ENOMEM;
        }
-       memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) +
-                       sizeof(struct nandsim));
        chip        = (struct nand_chip *)(nsmtd + 1);
         nsmtd->priv = (void *)chip;
        nand        = (struct nandsim *)(chip + 1);
index f4d38546068ff6f3fc2bf9bbcc00f70ce686caa3..4b1ba4fcfcd3235ad231259aa1ddae23b11b8599 100644 (file)
@@ -57,13 +57,12 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 
        DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name);
 
-       nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
+       nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
 
        if (!nftl) {
                printk(KERN_WARNING "NFTL: out of memory for data structures\n");
                return;
        }
-       memset(nftl, 0, sizeof(*nftl));
 
        nftl->mbd.mtd = mtd;
        nftl->mbd.devnum = -1;
index af06a80f44de2278011cae50f9cff905a6fd2436..53eb5632bdbbf655ce305c28fee2ca3e6886f83b 100644 (file)
@@ -45,12 +45,10 @@ static int __devinit generic_onenand_probe(struct device *dev)
        unsigned long size = res->end - res->start + 1;
        int err;
 
-       info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL);
+       info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
-       memset(info, 0, sizeof(struct onenand_info));
-
        if (!request_mem_region(res->start, size, dev->driver->name)) {
                err = -EBUSY;
                goto out_free_info;
index 1b00dac3d7d601dc6305e52ed9067a94e7a78aaf..e3822c1cdb8d99ed15b412a5f8bc63617ef2ac9a 100644 (file)
@@ -177,14 +177,12 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd)
        int len, ret = 0;
 
        len = mtd->size >> (this->erase_shift + 2);
-       /* Allocate memory (2bit per block) */
-       bbm->bbt = kmalloc(len, GFP_KERNEL);
+       /* Allocate memory (2bit per block) and clear the memory bad block table */
+       bbm->bbt = kzalloc(len, GFP_KERNEL);
        if (!bbm->bbt) {
                printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
                return -ENOMEM;
        }
-       /* Clear the memory bad block table */
-       memset(bbm->bbt, 0x00, len);
 
        /* Set the bad block position */
        bbm->badblockpos = ONENAND_BADBLOCK_POS;
@@ -230,14 +228,12 @@ int onenand_default_bbt(struct mtd_info *mtd)
        struct onenand_chip *this = mtd->priv;
        struct bbm_info *bbm;
 
-       this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL);
+       this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL);
        if (!this->bbm)
                return -ENOMEM;
 
        bbm = this->bbm;
 
-       memset(bbm, 0, sizeof(struct bbm_info));
-
        /* 1KB page has same configuration as 2KB page */
        if (!bbm->badblock_pattern)
                bbm->badblock_pattern = &largepage_memorybased;
index 5b58523e4d4ecd597c8d72e63ae702a7b5d02389..4b277211e27ba48755670cb4d07d2124039145c5 100644 (file)
@@ -165,15 +165,13 @@ static int parse_redboot_partitions(struct mtd_info *master,
                }
        }
 #endif
-       parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
+       parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
 
        if (!parts) {
                ret = -ENOMEM;
                goto out;
        }
 
-       memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);
-
        nullname = (char *)&parts[nrparts];
 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
        if (nulllen > 0) {