Commit 95b93a0cd46682c6d9e8eea803fda510cb6b863a

Authored by Burman Yan
Committed by David Woodhouse
1 parent 998a43e72d

[MTD] replace kmalloc+memset with kzalloc

Signed-off-by: Yan Burman <yan_952@hotmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

Showing 41 changed files with 53 additions and 125 deletions Side-by-side Diff

arch/ppc/platforms/ev64360.c
... ... @@ -358,13 +358,12 @@
358 358  
359 359 ptbl_entries = 3;
360 360  
361   - if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition),
  361 + if ((ptbl = kzalloc(ptbl_entries * sizeof(struct mtd_partition),
362 362 GFP_KERNEL)) == NULL) {
363 363  
364 364 printk(KERN_WARNING "Can't alloc MTD partition table\n");
365 365 return -ENOMEM;
366 366 }
367   - memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition));
368 367  
369 368 ptbl[0].name = "reserved";
370 369 ptbl[0].offset = 0;
... ... @@ -207,11 +207,10 @@
207 207 if (!sz)
208 208 return ret;
209 209  
210   - parts = kmalloc(sz, GFP_KERNEL);
  210 + parts = kzalloc(sz, GFP_KERNEL);
211 211 if (!parts)
212 212 return -ENOMEM;
213 213  
214   - memset(parts, 0, sz);
215 214 str = (char *)(parts + idx);
216 215  
217 216 /*
drivers/mtd/chips/amd_flash.c
... ... @@ -643,13 +643,12 @@
643 643 int reg_idx;
644 644 int offset;
645 645  
646   - mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL);
  646 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
647 647 if (!mtd) {
648 648 printk(KERN_WARNING
649 649 "%s: kmalloc failed for info structure\n", map->name);
650 650 return NULL;
651 651 }
652   - memset(mtd, 0, sizeof(*mtd));
653 652 mtd->priv = map;
654 653  
655 654 memset(&temp, 0, sizeof(temp));
drivers/mtd/chips/cfi_cmdset_0001.c
... ... @@ -337,12 +337,11 @@
337 337 struct mtd_info *mtd;
338 338 int i;
339 339  
340   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  340 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
341 341 if (!mtd) {
342 342 printk(KERN_ERR "Failed to allocate memory for MTD device\n");
343 343 return NULL;
344 344 }
345   - memset(mtd, 0, sizeof(*mtd));
346 345 mtd->priv = map;
347 346 mtd->type = MTD_NORFLASH;
348 347  
drivers/mtd/chips/cfi_cmdset_0002.c
... ... @@ -257,12 +257,11 @@
257 257 struct mtd_info *mtd;
258 258 int i;
259 259  
260   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  260 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
261 261 if (!mtd) {
262 262 printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
263 263 return NULL;
264 264 }
265   - memset(mtd, 0, sizeof(*mtd));
266 265 mtd->priv = map;
267 266 mtd->type = MTD_NORFLASH;
268 267  
drivers/mtd/chips/cfi_cmdset_0020.c
... ... @@ -172,7 +172,7 @@
172 172 int i,j;
173 173 unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave;
174 174  
175   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  175 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
176 176 //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips);
177 177  
178 178 if (!mtd) {
... ... @@ -181,7 +181,6 @@
181 181 return NULL;
182 182 }
183 183  
184   - memset(mtd, 0, sizeof(*mtd));
185 184 mtd->priv = map;
186 185 mtd->type = MTD_NORFLASH;
187 186 mtd->size = devsize * cfi->numchips;
drivers/mtd/chips/gen_probe.c
... ... @@ -113,13 +113,12 @@
113 113 }
114 114  
115 115 mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG;
116   - chip_map = kmalloc(mapsize, GFP_KERNEL);
  116 + chip_map = kzalloc(mapsize, GFP_KERNEL);
117 117 if (!chip_map) {
118 118 printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name);
119 119 kfree(cfi.cfiq);
120 120 return NULL;
121 121 }
122   - memset (chip_map, 0, mapsize);
123 122  
124 123 set_bit(0, chip_map); /* Mark first chip valid */
125 124  
drivers/mtd/chips/jedec.c
... ... @@ -116,11 +116,10 @@
116 116 char Part[200];
117 117 memset(&priv,0,sizeof(priv));
118 118  
119   - MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
  119 + MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL);
120 120 if (!MTD)
121 121 return NULL;
122 122  
123   - memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private));
124 123 priv = (struct jedec_private *)&MTD[1];
125 124  
126 125 my_bank_size = map->size;
drivers/mtd/chips/map_absent.c
... ... @@ -47,12 +47,10 @@
47 47 {
48 48 struct mtd_info *mtd;
49 49  
50   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  50 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
51 51 if (!mtd) {
52 52 return NULL;
53 53 }
54   -
55   - memset(mtd, 0, sizeof(*mtd));
56 54  
57 55 map->fldrv = &map_absent_chipdrv;
58 56 mtd->priv = map;
drivers/mtd/chips/map_ram.c
... ... @@ -55,11 +55,9 @@
55 55 #endif
56 56 /* OK. It seems to be RAM. */
57 57  
58   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  58 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
59 59 if (!mtd)
60 60 return NULL;
61   -
62   - memset(mtd, 0, sizeof(*mtd));
63 61  
64 62 map->fldrv = &mapram_chipdrv;
65 63 mtd->priv = map;
drivers/mtd/chips/map_rom.c
... ... @@ -31,11 +31,9 @@
31 31 {
32 32 struct mtd_info *mtd;
33 33  
34   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  34 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
35 35 if (!mtd)
36 36 return NULL;
37   -
38   - memset(mtd, 0, sizeof(*mtd));
39 37  
40 38 map->fldrv = &maprom_chipdrv;
41 39 mtd->priv = map;
drivers/mtd/chips/sharp.c
... ... @@ -112,18 +112,16 @@
112 112 struct sharp_info *sharp = NULL;
113 113 int width;
114 114  
115   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  115 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
116 116 if(!mtd)
117 117 return NULL;
118 118  
119   - sharp = kmalloc(sizeof(*sharp), GFP_KERNEL);
  119 + sharp = kzalloc(sizeof(*sharp), GFP_KERNEL);
120 120 if(!sharp) {
121 121 kfree(mtd);
122 122 return NULL;
123 123 }
124 124  
125   - memset(mtd, 0, sizeof(*mtd));
126   -
127 125 width = sharp_probe_map(map,mtd);
128 126 if(!width){
129 127 kfree(mtd);
... ... @@ -143,7 +141,6 @@
143 141 mtd->writesize = 1;
144 142 mtd->name = map->name;
145 143  
146   - memset(sharp, 0, sizeof(*sharp));
147 144 sharp->chipshift = 23;
148 145 sharp->numchips = 1;
149 146 sharp->chips[0].start = 0;
drivers/mtd/cmdlinepart.c
... ... @@ -163,13 +163,12 @@
163 163 *num_parts = this_part + 1;
164 164 alloc_size = *num_parts * sizeof(struct mtd_partition) +
165 165 extra_mem_size;
166   - parts = kmalloc(alloc_size, GFP_KERNEL);
  166 + parts = kzalloc(alloc_size, GFP_KERNEL);
167 167 if (!parts)
168 168 {
169 169 printk(KERN_ERR ERRP "out of memory\n");
170 170 return NULL;
171 171 }
172   - memset(parts, 0, alloc_size);
173 172 extra_mem = (unsigned char *)(parts + *num_parts);
174 173 }
175 174 /* enter this partition (offset will be calculated later if it is zero at this point) */
drivers/mtd/devices/block2mtd.c
... ... @@ -295,10 +295,9 @@
295 295 if (!devname)
296 296 return NULL;
297 297  
298   - dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
  298 + dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL);
299 299 if (!dev)
300 300 return NULL;
301   - memset(dev, 0, sizeof(*dev));
302 301  
303 302 /* Get a handle on the device */
304 303 bdev = open_bdev_excl(devname, O_RDWR, NULL);
drivers/mtd/devices/ms02-nv.c
... ... @@ -131,11 +131,10 @@
131 131 int ret = -ENODEV;
132 132  
133 133 /* The module decodes 8MiB of address space. */
134   - mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL);
  134 + mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL);
135 135 if (!mod_res)
136 136 return -ENOMEM;
137 137  
138   - memset(mod_res, 0, sizeof(*mod_res));
139 138 mod_res->name = ms02nv_name;
140 139 mod_res->start = addr;
141 140 mod_res->end = addr + MS02NV_SLOT_SIZE - 1;
142 141  
143 142  
144 143  
145 144  
... ... @@ -153,24 +152,21 @@
153 152 }
154 153  
155 154 ret = -ENOMEM;
156   - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
  155 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
157 156 if (!mtd)
158 157 goto err_out_mod_res_rel;
159   - memset(mtd, 0, sizeof(*mtd));
160   - mp = kmalloc(sizeof(*mp), GFP_KERNEL);
  158 + mp = kzalloc(sizeof(*mp), GFP_KERNEL);
161 159 if (!mp)
162 160 goto err_out_mtd;
163   - memset(mp, 0, sizeof(*mp));
164 161  
165 162 mtd->priv = mp;
166 163 mp->resource.module = mod_res;
167 164  
168 165 /* Firmware's diagnostic NVRAM area. */
169   - diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL);
  166 + diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL);
170 167 if (!diag_res)
171 168 goto err_out_mp;
172 169  
173   - memset(diag_res, 0, sizeof(*diag_res));
174 170 diag_res->name = ms02nv_res_diag_ram;
175 171 diag_res->start = addr;
176 172 diag_res->end = addr + MS02NV_RAM - 1;
177 173  
... ... @@ -180,11 +176,10 @@
180 176 mp->resource.diag_ram = diag_res;
181 177  
182 178 /* User-available general-purpose NVRAM area. */
183   - user_res = kmalloc(sizeof(*user_res), GFP_KERNEL);
  179 + user_res = kzalloc(sizeof(*user_res), GFP_KERNEL);
184 180 if (!user_res)
185 181 goto err_out_diag_res;
186 182  
187   - memset(user_res, 0, sizeof(*user_res));
188 183 user_res->name = ms02nv_res_user_ram;
189 184 user_res->start = addr + MS02NV_RAM;
190 185 user_res->end = addr + size - 1;
191 186  
... ... @@ -194,11 +189,10 @@
194 189 mp->resource.user_ram = user_res;
195 190  
196 191 /* Control and status register. */
197   - csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL);
  192 + csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL);
198 193 if (!csr_res)
199 194 goto err_out_user_res;
200 195  
201   - memset(csr_res, 0, sizeof(*csr_res));
202 196 csr_res->name = ms02nv_res_csr;
203 197 csr_res->start = addr + MS02NV_CSR;
204 198 csr_res->end = addr + MS02NV_CSR + 3;
drivers/mtd/devices/phram.c
... ... @@ -126,11 +126,9 @@
126 126 struct phram_mtd_list *new;
127 127 int ret = -ENOMEM;
128 128  
129   - new = kmalloc(sizeof(*new), GFP_KERNEL);
  129 + new = kzalloc(sizeof(*new), GFP_KERNEL);
130 130 if (!new)
131 131 goto out0;
132   -
133   - memset(new, 0, sizeof(*new));
134 132  
135 133 ret = -EIO;
136 134 new->mtd.priv = ioremap(start, len);
drivers/mtd/devices/slram.c
... ... @@ -168,19 +168,16 @@
168 168 E("slram: Cannot allocate new MTD device.\n");
169 169 return(-ENOMEM);
170 170 }
171   - (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL);
  171 + (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL);
172 172 (*curmtd)->next = NULL;
173 173  
174 174 if ((*curmtd)->mtdinfo) {
175   - memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info));
176 175 (*curmtd)->mtdinfo->priv =
177   - kmalloc(sizeof(slram_priv_t), GFP_KERNEL);
  176 + kzalloc(sizeof(slram_priv_t), GFP_KERNEL);
178 177  
179 178 if (!(*curmtd)->mtdinfo->priv) {
180 179 kfree((*curmtd)->mtdinfo);
181 180 (*curmtd)->mtdinfo = NULL;
182   - } else {
183   - memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t));
184 181 }
185 182 }
186 183  
... ... @@ -1033,15 +1033,13 @@
1033 1033 {
1034 1034 partition_t *partition;
1035 1035  
1036   - partition = kmalloc(sizeof(partition_t), GFP_KERNEL);
  1036 + partition = kzalloc(sizeof(partition_t), GFP_KERNEL);
1037 1037  
1038 1038 if (!partition) {
1039 1039 printk(KERN_WARNING "No memory to scan for FTL on %s\n",
1040 1040 mtd->name);
1041 1041 return;
1042 1042 }
1043   -
1044   - memset(partition, 0, sizeof(partition_t));
1045 1043  
1046 1044 partition->mbd.mtd = mtd;
1047 1045  
drivers/mtd/inftlcore.c
... ... @@ -67,13 +67,12 @@
67 67  
68 68 DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name);
69 69  
70   - inftl = kmalloc(sizeof(*inftl), GFP_KERNEL);
  70 + inftl = kzalloc(sizeof(*inftl), GFP_KERNEL);
71 71  
72 72 if (!inftl) {
73 73 printk(KERN_WARNING "INFTL: Out of memory for data structures\n");
74 74 return;
75 75 }
76   - memset(inftl, 0, sizeof(*inftl));
77 76  
78 77 inftl->mbd.mtd = mtd;
79 78 inftl->mbd.devnum = -1;
drivers/mtd/maps/ceiva.c
... ... @@ -122,10 +122,9 @@
122 122 /*
123 123 * Allocate the map_info structs in one go.
124 124 */
125   - maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
  125 + maps = kzalloc(sizeof(struct map_info) * nr, GFP_KERNEL);
126 126 if (!maps)
127 127 return -ENOMEM;
128   - memset(maps, 0, sizeof(struct map_info) * nr);
129 128 /*
130 129 * Claim and then map the memory regions.
131 130 */
drivers/mtd/maps/integrator-flash.c
... ... @@ -75,13 +75,11 @@
75 75 int err;
76 76 void __iomem *base;
77 77  
78   - info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL);
  78 + info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL);
79 79 if (!info) {
80 80 err = -ENOMEM;
81 81 goto out;
82 82 }
83   -
84   - memset(info, 0, sizeof(struct armflash_info));
85 83  
86 84 info->plat = plat;
87 85 if (plat && plat->init) {
drivers/mtd/maps/omap_nor.c
... ... @@ -78,11 +78,9 @@
78 78 struct resource *res = pdev->resource;
79 79 unsigned long size = res->end - res->start + 1;
80 80  
81   - info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL);
  81 + info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL);
82 82 if (!info)
83 83 return -ENOMEM;
84   -
85   - memset(info, 0, sizeof(struct omapflash_info));
86 84  
87 85 if (!request_mem_region(res->start, size, "flash")) {
88 86 err = -EBUSY;
drivers/mtd/maps/pcmciamtd.c
... ... @@ -735,11 +735,10 @@
735 735 struct pcmciamtd_dev *dev;
736 736  
737 737 /* Create new memory card device */
738   - dev = kmalloc(sizeof(*dev), GFP_KERNEL);
  738 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
739 739 if (!dev) return -ENOMEM;
740 740 DEBUG(1, "dev=0x%p", dev);
741 741  
742   - memset(dev, 0, sizeof(*dev));
743 742 dev->p_dev = link;
744 743 link->priv = dev;
745 744  
drivers/mtd/maps/physmap.c
... ... @@ -92,12 +92,11 @@
92 92 (unsigned long long)(dev->resource->end - dev->resource->start + 1),
93 93 (unsigned long long)dev->resource->start);
94 94  
95   - info = kmalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);
  95 + info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL);
96 96 if (info == NULL) {
97 97 err = -ENOMEM;
98 98 goto err_out;
99 99 }
100   - memset(info, 0, sizeof(*info));
101 100  
102 101 platform_set_drvdata(dev, info);
103 102  
drivers/mtd/maps/plat-ram.c
... ... @@ -147,14 +147,13 @@
147 147  
148 148 pdata = pdev->dev.platform_data;
149 149  
150   - info = kmalloc(sizeof(*info), GFP_KERNEL);
  150 + info = kzalloc(sizeof(*info), GFP_KERNEL);
151 151 if (info == NULL) {
152 152 dev_err(&pdev->dev, "no memory for flash info\n");
153 153 err = -ENOMEM;
154 154 goto exit_error;
155 155 }
156 156  
157   - memset(info, 0, sizeof(*info));
158 157 platform_set_drvdata(pdev, info);
159 158  
160 159 info->dev = &pdev->dev;
drivers/mtd/maps/sa1100-flash.c
... ... @@ -273,13 +273,11 @@
273 273 /*
274 274 * Allocate the map_info structs in one go.
275 275 */
276   - info = kmalloc(size, GFP_KERNEL);
  276 + info = kzalloc(size, GFP_KERNEL);
277 277 if (!info) {
278 278 ret = -ENOMEM;
279 279 goto out;
280 280 }
281   -
282   - memset(info, 0, size);
283 281  
284 282 if (plat->init) {
285 283 ret = plat->init();
drivers/mtd/maps/tqm834x.c
... ... @@ -132,20 +132,16 @@
132 132  
133 133 pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx);
134 134  
135   - map_banks[idx] =
136   - (struct map_info *)kmalloc(sizeof(struct map_info),
137   - GFP_KERNEL);
  135 + map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
138 136 if (map_banks[idx] == NULL) {
139 137 ret = -ENOMEM;
140 138 goto error_mem;
141 139 }
142   - memset((void *)map_banks[idx], 0, sizeof(struct map_info));
143   - map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
  140 + map_banks[idx]->name = kzalloc(16, GFP_KERNEL);
144 141 if (map_banks[idx]->name == NULL) {
145 142 ret = -ENOMEM;
146 143 goto error_mem;
147 144 }
148   - memset((void *)map_banks[idx]->name, 0, 16);
149 145  
150 146 sprintf(map_banks[idx]->name, "TQM834x-%d", idx);
151 147 map_banks[idx]->size = flash_size;
drivers/mtd/maps/tqm8xxl.c
... ... @@ -134,14 +134,13 @@
134 134  
135 135 printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx);
136 136  
137   - map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL);
  137 + map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL);
138 138 if(map_banks[idx] == NULL) {
139 139 ret = -ENOMEM;
140 140 /* FIXME: What if some MTD devices were probed already? */
141 141 goto error_mem;
142 142 }
143 143  
144   - memset((void *)map_banks[idx], 0, sizeof(struct map_info));
145 144 map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
146 145  
147 146 if (!map_banks[idx]->name) {
drivers/mtd/mtd_blkdevs.c
... ... @@ -373,11 +373,9 @@
373 373 if (!blktrans_notifier.list.next)
374 374 register_mtd_user(&blktrans_notifier);
375 375  
376   - tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
  376 + tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL);
377 377 if (!tr->blkcore_priv)
378 378 return -ENOMEM;
379   -
380   - memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv));
381 379  
382 380 mutex_lock(&mtd_table_mutex);
383 381  
drivers/mtd/mtdblock.c
... ... @@ -278,11 +278,10 @@
278 278 }
279 279  
280 280 /* OK, it's not open. Create cache info for it */
281   - mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
  281 + mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL);
282 282 if (!mtdblk)
283 283 return -ENOMEM;
284 284  
285   - memset(mtdblk, 0, sizeof(*mtdblk));
286 285 mtdblk->count = 1;
287 286 mtdblk->mtd = mtd;
288 287  
289 288  
... ... @@ -339,12 +338,10 @@
339 338  
340 339 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
341 340 {
342   - struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
  341 + struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
343 342  
344 343 if (!dev)
345 344 return;
346   -
347   - memset(dev, 0, sizeof(*dev));
348 345  
349 346 dev->mtd = mtd;
350 347 dev->devnum = mtd->index;
drivers/mtd/mtdblock_ro.c
... ... @@ -33,12 +33,10 @@
33 33  
34 34 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
35 35 {
36   - struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL);
  36 + struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL);
37 37  
38 38 if (!dev)
39 39 return;
40   -
41   - memset(dev, 0, sizeof(*dev));
42 40  
43 41 dev->mtd = mtd;
44 42 dev->devnum = mtd->index;
drivers/mtd/mtdchar.c
... ... @@ -431,7 +431,7 @@
431 431 if(!(file->f_mode & 2))
432 432 return -EPERM;
433 433  
434   - erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL);
  434 + erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL);
435 435 if (!erase)
436 436 ret = -ENOMEM;
437 437 else {
... ... @@ -440,7 +440,6 @@
440 440  
441 441 init_waitqueue_head(&waitq);
442 442  
443   - memset (erase,0,sizeof(struct erase_info));
444 443 if (copy_from_user(&erase->addr, argp,
445 444 sizeof(struct erase_info_user))) {
446 445 kfree(erase);
drivers/mtd/mtdconcat.c
... ... @@ -708,14 +708,13 @@
708 708  
709 709 /* allocate the device structure */
710 710 size = SIZEOF_STRUCT_MTD_CONCAT(num_devs);
711   - concat = kmalloc(size, GFP_KERNEL);
  711 + concat = kzalloc(size, GFP_KERNEL);
712 712 if (!concat) {
713 713 printk
714 714 ("memory allocation error while creating concatenated device \"%s\"\n",
715 715 name);
716 716 return NULL;
717 717 }
718   - memset(concat, 0, size);
719 718 concat->subdev = (struct mtd_info **) (concat + 1);
720 719  
721 720 /*
drivers/mtd/mtdpart.c
... ... @@ -323,14 +323,13 @@
323 323 for (i = 0; i < nbparts; i++) {
324 324  
325 325 /* allocate the partition structure */
326   - slave = kmalloc (sizeof(*slave), GFP_KERNEL);
  326 + slave = kzalloc (sizeof(*slave), GFP_KERNEL);
327 327 if (!slave) {
328 328 printk ("memory allocation error while creating partitions for \"%s\"\n",
329 329 master->name);
330 330 del_mtd_partitions(master);
331 331 return -ENOMEM;
332 332 }
333   - memset(slave, 0, sizeof(*slave));
334 333 list_add(&slave->list, &mtd_partitions);
335 334  
336 335 /* set up the MTD object for this partition */
drivers/mtd/nand/diskonchip.c
... ... @@ -1635,13 +1635,12 @@
1635 1635  
1636 1636 len = sizeof(struct mtd_info) +
1637 1637 sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr));
1638   - mtd = kmalloc(len, GFP_KERNEL);
  1638 + mtd = kzalloc(len, GFP_KERNEL);
1639 1639 if (!mtd) {
1640 1640 printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len);
1641 1641 ret = -ENOMEM;
1642 1642 goto fail;
1643 1643 }
1644   - memset(mtd, 0, len);
1645 1644  
1646 1645 nand = (struct nand_chip *) (mtd + 1);
1647 1646 doc = (struct doc_priv *) (nand + 1);
drivers/mtd/nand/nand_bbt.c
... ... @@ -960,14 +960,12 @@
960 960 struct nand_bbt_descr *md = this->bbt_md;
961 961  
962 962 len = mtd->size >> (this->bbt_erase_shift + 2);
963   - /* Allocate memory (2bit per block) */
964   - this->bbt = kmalloc(len, GFP_KERNEL);
  963 + /* Allocate memory (2bit per block) and clear the memory bad block table */
  964 + this->bbt = kzalloc(len, GFP_KERNEL);
965 965 if (!this->bbt) {
966 966 printk(KERN_ERR "nand_scan_bbt: Out of memory\n");
967 967 return -ENOMEM;
968 968 }
969   - /* Clear the memory bad block table */
970   - memset(this->bbt, 0x00, len);
971 969  
972 970 /* If no primary table decriptor is given, scan the device
973 971 * to build a memory based bad block table
drivers/mtd/nand/nandsim.c
... ... @@ -1511,14 +1511,12 @@
1511 1511 }
1512 1512  
1513 1513 /* Allocate and initialize mtd_info, nand_chip and nandsim structures */
1514   - nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)
  1514 + nsmtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip)
1515 1515 + sizeof(struct nandsim), GFP_KERNEL);
1516 1516 if (!nsmtd) {
1517 1517 NS_ERR("unable to allocate core structures.\n");
1518 1518 return -ENOMEM;
1519 1519 }
1520   - memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) +
1521   - sizeof(struct nandsim));
1522 1520 chip = (struct nand_chip *)(nsmtd + 1);
1523 1521 nsmtd->priv = (void *)chip;
1524 1522 nand = (struct nandsim *)(chip + 1);
drivers/mtd/nftlcore.c
... ... @@ -57,13 +57,12 @@
57 57  
58 58 DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name);
59 59  
60   - nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
  60 + nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL);
61 61  
62 62 if (!nftl) {
63 63 printk(KERN_WARNING "NFTL: out of memory for data structures\n");
64 64 return;
65 65 }
66   - memset(nftl, 0, sizeof(*nftl));
67 66  
68 67 nftl->mbd.mtd = mtd;
69 68 nftl->mbd.devnum = -1;
drivers/mtd/onenand/generic.c
... ... @@ -45,11 +45,9 @@
45 45 unsigned long size = res->end - res->start + 1;
46 46 int err;
47 47  
48   - info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL);
  48 + info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL);
49 49 if (!info)
50 50 return -ENOMEM;
51   -
52   - memset(info, 0, sizeof(struct onenand_info));
53 51  
54 52 if (!request_mem_region(res->start, size, dev->driver->name)) {
55 53 err = -EBUSY;
drivers/mtd/onenand/onenand_bbt.c
... ... @@ -177,14 +177,12 @@
177 177 int len, ret = 0;
178 178  
179 179 len = mtd->size >> (this->erase_shift + 2);
180   - /* Allocate memory (2bit per block) */
181   - bbm->bbt = kmalloc(len, GFP_KERNEL);
  180 + /* Allocate memory (2bit per block) and clear the memory bad block table */
  181 + bbm->bbt = kzalloc(len, GFP_KERNEL);
182 182 if (!bbm->bbt) {
183 183 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n");
184 184 return -ENOMEM;
185 185 }
186   - /* Clear the memory bad block table */
187   - memset(bbm->bbt, 0x00, len);
188 186  
189 187 /* Set the bad block position */
190 188 bbm->badblockpos = ONENAND_BADBLOCK_POS;
191 189  
... ... @@ -230,13 +228,11 @@
230 228 struct onenand_chip *this = mtd->priv;
231 229 struct bbm_info *bbm;
232 230  
233   - this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL);
  231 + this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL);
234 232 if (!this->bbm)
235 233 return -ENOMEM;
236 234  
237 235 bbm = this->bbm;
238   -
239   - memset(bbm, 0, sizeof(struct bbm_info));
240 236  
241 237 /* 1KB page has same configuration as 2KB page */
242 238 if (!bbm->badblock_pattern)
drivers/mtd/redboot.c
... ... @@ -165,14 +165,12 @@
165 165 }
166 166 }
167 167 #endif
168   - parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
  168 + parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL);
169 169  
170 170 if (!parts) {
171 171 ret = -ENOMEM;
172 172 goto out;
173 173 }
174   -
175   - memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen);
176 174  
177 175 nullname = (char *)&parts[nrparts];
178 176 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED