Commit 2bfefa4c9632fb09bfe3277cf7b690818b147654
Committed by
David Woodhouse
1 parent
ecce2a6f9b
Exists in
master
and in
7 other branches
drivers/mtd: Use kzalloc
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>
Showing 9 changed files with 10 additions and 21 deletions Side-by-side Diff
drivers/mtd/lpddr/qinfo_probe.c
... | ... | @@ -134,13 +134,12 @@ |
134 | 134 | static int lpddr_chip_setup(struct map_info *map, struct lpddr_private *lpddr) |
135 | 135 | { |
136 | 136 | |
137 | - lpddr->qinfo = kmalloc(sizeof(struct qinfo_chip), GFP_KERNEL); | |
137 | + lpddr->qinfo = kzalloc(sizeof(struct qinfo_chip), GFP_KERNEL); | |
138 | 138 | if (!lpddr->qinfo) { |
139 | 139 | printk(KERN_WARNING "%s: no memory for LPDDR qinfo structure\n", |
140 | 140 | map->name); |
141 | 141 | return 0; |
142 | 142 | } |
143 | - memset(lpddr->qinfo, 0, sizeof(struct qinfo_chip)); | |
144 | 143 | |
145 | 144 | /* Get the ManuID */ |
146 | 145 | lpddr->ManufactId = CMDVAL(map_read(map, map->pfow_base + PFOW_MANUFACTURER_ID)); |
147 | 146 | |
... | ... | @@ -185,13 +184,11 @@ |
185 | 184 | lpddr.numchips = 1; |
186 | 185 | |
187 | 186 | numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum; |
188 | - retlpddr = kmalloc(sizeof(struct lpddr_private) + | |
187 | + retlpddr = kzalloc(sizeof(struct lpddr_private) + | |
189 | 188 | numvirtchips * sizeof(struct flchip), GFP_KERNEL); |
190 | 189 | if (!retlpddr) |
191 | 190 | return NULL; |
192 | 191 | |
193 | - memset(retlpddr, 0, sizeof(struct lpddr_private) + | |
194 | - numvirtchips * sizeof(struct flchip)); | |
195 | 192 | memcpy(retlpddr, &lpddr, sizeof(struct lpddr_private)); |
196 | 193 | |
197 | 194 | retlpddr->numchips = numvirtchips; |
drivers/mtd/maps/ixp2000.c
... | ... | @@ -165,12 +165,11 @@ |
165 | 165 | return -EIO; |
166 | 166 | } |
167 | 167 | |
168 | - info = kmalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL); | |
168 | + info = kzalloc(sizeof(struct ixp2000_flash_info), GFP_KERNEL); | |
169 | 169 | if(!info) { |
170 | 170 | err = -ENOMEM; |
171 | 171 | goto Error; |
172 | 172 | } |
173 | - memset(info, 0, sizeof(struct ixp2000_flash_info)); | |
174 | 173 | |
175 | 174 | platform_set_drvdata(dev, info); |
176 | 175 |
drivers/mtd/maps/ixp4xx.c
... | ... | @@ -196,12 +196,11 @@ |
196 | 196 | return err; |
197 | 197 | } |
198 | 198 | |
199 | - info = kmalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL); | |
199 | + info = kzalloc(sizeof(struct ixp4xx_flash_info), GFP_KERNEL); | |
200 | 200 | if(!info) { |
201 | 201 | err = -ENOMEM; |
202 | 202 | goto Error; |
203 | 203 | } |
204 | - memset(info, 0, sizeof(struct ixp4xx_flash_info)); | |
205 | 204 | |
206 | 205 | platform_set_drvdata(dev, info); |
207 | 206 |
drivers/mtd/maps/pxa2xx-flash.c
... | ... | @@ -63,11 +63,10 @@ |
63 | 63 | if (!res) |
64 | 64 | return -ENODEV; |
65 | 65 | |
66 | - info = kmalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL); | |
66 | + info = kzalloc(sizeof(struct pxa2xx_flash_info), GFP_KERNEL); | |
67 | 67 | if (!info) |
68 | 68 | return -ENOMEM; |
69 | 69 | |
70 | - memset(info, 0, sizeof(struct pxa2xx_flash_info)); | |
71 | 70 | info->map.name = (char *) flash->name; |
72 | 71 | info->map.bankwidth = flash->width; |
73 | 72 | info->map.phys = res->start; |
drivers/mtd/tests/mtd_pagetest.c
... | ... | @@ -480,12 +480,11 @@ |
480 | 480 | { |
481 | 481 | int i, bad = 0; |
482 | 482 | |
483 | - bbt = kmalloc(ebcnt, GFP_KERNEL); | |
483 | + bbt = kzalloc(ebcnt, GFP_KERNEL); | |
484 | 484 | if (!bbt) { |
485 | 485 | printk(PRINT_PREF "error: cannot allocate memory\n"); |
486 | 486 | return -ENOMEM; |
487 | 487 | } |
488 | - memset(bbt, 0 , ebcnt); | |
489 | 488 | |
490 | 489 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); |
491 | 490 | for (i = 0; i < ebcnt; ++i) { |
drivers/mtd/tests/mtd_readtest.c
... | ... | @@ -141,12 +141,11 @@ |
141 | 141 | { |
142 | 142 | int i, bad = 0; |
143 | 143 | |
144 | - bbt = kmalloc(ebcnt, GFP_KERNEL); | |
144 | + bbt = kzalloc(ebcnt, GFP_KERNEL); | |
145 | 145 | if (!bbt) { |
146 | 146 | printk(PRINT_PREF "error: cannot allocate memory\n"); |
147 | 147 | return -ENOMEM; |
148 | 148 | } |
149 | - memset(bbt, 0 , ebcnt); | |
150 | 149 | |
151 | 150 | /* NOR flash does not implement block_isbad */ |
152 | 151 | if (mtd->block_isbad == NULL) |
drivers/mtd/tests/mtd_speedtest.c
... | ... | @@ -295,12 +295,11 @@ |
295 | 295 | { |
296 | 296 | int i, bad = 0; |
297 | 297 | |
298 | - bbt = kmalloc(ebcnt, GFP_KERNEL); | |
298 | + bbt = kzalloc(ebcnt, GFP_KERNEL); | |
299 | 299 | if (!bbt) { |
300 | 300 | printk(PRINT_PREF "error: cannot allocate memory\n"); |
301 | 301 | return -ENOMEM; |
302 | 302 | } |
303 | - memset(bbt, 0 , ebcnt); | |
304 | 303 | |
305 | 304 | /* NOR flash does not implement block_isbad */ |
306 | 305 | if (mtd->block_isbad == NULL) |
drivers/mtd/tests/mtd_stresstest.c
... | ... | @@ -221,12 +221,11 @@ |
221 | 221 | { |
222 | 222 | int i, bad = 0; |
223 | 223 | |
224 | - bbt = kmalloc(ebcnt, GFP_KERNEL); | |
224 | + bbt = kzalloc(ebcnt, GFP_KERNEL); | |
225 | 225 | if (!bbt) { |
226 | 226 | printk(PRINT_PREF "error: cannot allocate memory\n"); |
227 | 227 | return -ENOMEM; |
228 | 228 | } |
229 | - memset(bbt, 0 , ebcnt); | |
230 | 229 | |
231 | 230 | /* NOR flash does not implement block_isbad */ |
232 | 231 | if (mtd->block_isbad == NULL) |
drivers/mtd/tests/mtd_subpagetest.c
... | ... | @@ -354,12 +354,11 @@ |
354 | 354 | { |
355 | 355 | int i, bad = 0; |
356 | 356 | |
357 | - bbt = kmalloc(ebcnt, GFP_KERNEL); | |
357 | + bbt = kzalloc(ebcnt, GFP_KERNEL); | |
358 | 358 | if (!bbt) { |
359 | 359 | printk(PRINT_PREF "error: cannot allocate memory\n"); |
360 | 360 | return -ENOMEM; |
361 | 361 | } |
362 | - memset(bbt, 0 , ebcnt); | |
363 | 362 | |
364 | 363 | printk(PRINT_PREF "scanning for bad eraseblocks\n"); |
365 | 364 | for (i = 0; i < ebcnt; ++i) { |