aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-05-13 16:03:15 -0400
committerDavid Woodhouse <David.Woodhouse@intel.com>2010-05-13 16:23:06 -0400
commit2bfefa4c9632fb09bfe3277cf7b690818b147654 (patch)
tree9ddbd55e57e266dfea47e38fa007f47731fed8fb /drivers/mtd
parentecce2a6f9bdc7635838baeff8a09a76c9a70e7e0 (diff)
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>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/lpddr/qinfo_probe.c7
-rw-r--r--drivers/mtd/maps/ixp2000.c3
-rw-r--r--drivers/mtd/maps/ixp4xx.c3
-rw-r--r--drivers/mtd/maps/pxa2xx-flash.c3
-rw-r--r--drivers/mtd/tests/mtd_pagetest.c3
-rw-r--r--drivers/mtd/tests/mtd_readtest.c3
-rw-r--r--drivers/mtd/tests/mtd_speedtest.c3
-rw-r--r--drivers/mtd/tests/mtd_stresstest.c3
-rw-r--r--drivers/mtd/tests/mtd_subpagetest.c3
9 files changed, 10 insertions, 21 deletions
diff --git a/drivers/mtd/lpddr/qinfo_probe.c b/drivers/mtd/lpddr/qinfo_probe.c
index 79bf40f48b75..dbfe17baf046 100644
--- a/drivers/mtd/lpddr/qinfo_probe.c
+++ b/drivers/mtd/lpddr/qinfo_probe.c
@@ -134,13 +134,12 @@ out:
134static int lpddr_chip_setup(struct map_info *map, struct lpddr_private *lpddr) 134static 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 if (!lpddr->qinfo) { 138 if (!lpddr->qinfo) {
139 printk(KERN_WARNING "%s: no memory for LPDDR qinfo structure\n", 139 printk(KERN_WARNING "%s: no memory for LPDDR qinfo structure\n",
140 map->name); 140 map->name);
141 return 0; 141 return 0;
142 } 142 }
143 memset(lpddr->qinfo, 0, sizeof(struct qinfo_chip));
144 143
145 /* Get the ManuID */ 144 /* Get the ManuID */
146 lpddr->ManufactId = CMDVAL(map_read(map, map->pfow_base + PFOW_MANUFACTURER_ID)); 145 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)
185 lpddr.numchips = 1; 184 lpddr.numchips = 1;
186 185
187 numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum; 186 numvirtchips = lpddr.numchips * lpddr.qinfo->HWPartsNum;
188 retlpddr = kmalloc(sizeof(struct lpddr_private) + 187 retlpddr = kzalloc(sizeof(struct lpddr_private) +
189 numvirtchips * sizeof(struct flchip), GFP_KERNEL); 188 numvirtchips * sizeof(struct flchip), GFP_KERNEL);
190 if (!retlpddr) 189 if (!retlpddr)
191 return NULL; 190 return NULL;
192 191
193 memset(retlpddr, 0, sizeof(struct lpddr_private) +
194 numvirtchips * sizeof(struct flchip));
195 memcpy(retlpddr, &lpddr, sizeof(struct lpddr_private)); 192 memcpy(retlpddr, &lpddr, sizeof(struct lpddr_private));
196 193
197 retlpddr->numchips = numvirtchips; 194 retlpddr->numchips = numvirtchips;
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c
index 1bdf0ee6d0b6..9639d83a9d6c 100644
--- a/drivers/mtd/maps/ixp2000.c
+++ b/drivers/mtd/maps/ixp2000.c
@@ -165,12 +165,11 @@ static int ixp2000_flash_probe(struct platform_device *dev)
165 return -EIO; 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 if(!info) { 169 if(!info) {
170 err = -ENOMEM; 170 err = -ENOMEM;
171 goto Error; 171 goto Error;
172 } 172 }
173 memset(info, 0, sizeof(struct ixp2000_flash_info));
174 173
175 platform_set_drvdata(dev, info); 174 platform_set_drvdata(dev, info);
176 175
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c
index 7513d90fee6f..e0a5e0426ead 100644
--- a/drivers/mtd/maps/ixp4xx.c
+++ b/drivers/mtd/maps/ixp4xx.c
@@ -196,12 +196,11 @@ static int ixp4xx_flash_probe(struct platform_device *dev)
196 return err; 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 if(!info) { 200 if(!info) {
201 err = -ENOMEM; 201 err = -ENOMEM;
202 goto Error; 202 goto Error;
203 } 203 }
204 memset(info, 0, sizeof(struct ixp4xx_flash_info));
205 204
206 platform_set_drvdata(dev, info); 205 platform_set_drvdata(dev, info);
207 206
diff --git a/drivers/mtd/maps/pxa2xx-flash.c b/drivers/mtd/maps/pxa2xx-flash.c
index 91dc6331053f..dd90880048cf 100644
--- a/drivers/mtd/maps/pxa2xx-flash.c
+++ b/drivers/mtd/maps/pxa2xx-flash.c
@@ -63,11 +63,10 @@ static int __init pxa2xx_flash_probe(struct platform_device *pdev)
63 if (!res) 63 if (!res)
64 return -ENODEV; 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 if (!info) 67 if (!info)
68 return -ENOMEM; 68 return -ENOMEM;
69 69
70 memset(info, 0, sizeof(struct pxa2xx_flash_info));
71 info->map.name = (char *) flash->name; 70 info->map.name = (char *) flash->name;
72 info->map.bankwidth = flash->width; 71 info->map.bankwidth = flash->width;
73 info->map.phys = res->start; 72 info->map.phys = res->start;
diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c
index 921a85df9196..6bc1b8276c62 100644
--- a/drivers/mtd/tests/mtd_pagetest.c
+++ b/drivers/mtd/tests/mtd_pagetest.c
@@ -480,12 +480,11 @@ static int scan_for_bad_eraseblocks(void)
480{ 480{
481 int i, bad = 0; 481 int i, bad = 0;
482 482
483 bbt = kmalloc(ebcnt, GFP_KERNEL); 483 bbt = kzalloc(ebcnt, GFP_KERNEL);
484 if (!bbt) { 484 if (!bbt) {
485 printk(PRINT_PREF "error: cannot allocate memory\n"); 485 printk(PRINT_PREF "error: cannot allocate memory\n");
486 return -ENOMEM; 486 return -ENOMEM;
487 } 487 }
488 memset(bbt, 0 , ebcnt);
489 488
490 printk(PRINT_PREF "scanning for bad eraseblocks\n"); 489 printk(PRINT_PREF "scanning for bad eraseblocks\n");
491 for (i = 0; i < ebcnt; ++i) { 490 for (i = 0; i < ebcnt; ++i) {
diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c
index 7107fccbc7de..afe71aa15c4b 100644
--- a/drivers/mtd/tests/mtd_readtest.c
+++ b/drivers/mtd/tests/mtd_readtest.c
@@ -141,12 +141,11 @@ static int scan_for_bad_eraseblocks(void)
141{ 141{
142 int i, bad = 0; 142 int i, bad = 0;
143 143
144 bbt = kmalloc(ebcnt, GFP_KERNEL); 144 bbt = kzalloc(ebcnt, GFP_KERNEL);
145 if (!bbt) { 145 if (!bbt) {
146 printk(PRINT_PREF "error: cannot allocate memory\n"); 146 printk(PRINT_PREF "error: cannot allocate memory\n");
147 return -ENOMEM; 147 return -ENOMEM;
148 } 148 }
149 memset(bbt, 0 , ebcnt);
150 149
151 /* NOR flash does not implement block_isbad */ 150 /* NOR flash does not implement block_isbad */
152 if (mtd->block_isbad == NULL) 151 if (mtd->block_isbad == NULL)
diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c
index 56ca62bb96bf..161feeb7b8b9 100644
--- a/drivers/mtd/tests/mtd_speedtest.c
+++ b/drivers/mtd/tests/mtd_speedtest.c
@@ -295,12 +295,11 @@ static int scan_for_bad_eraseblocks(void)
295{ 295{
296 int i, bad = 0; 296 int i, bad = 0;
297 297
298 bbt = kmalloc(ebcnt, GFP_KERNEL); 298 bbt = kzalloc(ebcnt, GFP_KERNEL);
299 if (!bbt) { 299 if (!bbt) {
300 printk(PRINT_PREF "error: cannot allocate memory\n"); 300 printk(PRINT_PREF "error: cannot allocate memory\n");
301 return -ENOMEM; 301 return -ENOMEM;
302 } 302 }
303 memset(bbt, 0 , ebcnt);
304 303
305 /* NOR flash does not implement block_isbad */ 304 /* NOR flash does not implement block_isbad */
306 if (mtd->block_isbad == NULL) 305 if (mtd->block_isbad == NULL)
diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c
index 3854afec56d0..531625fc9259 100644
--- a/drivers/mtd/tests/mtd_stresstest.c
+++ b/drivers/mtd/tests/mtd_stresstest.c
@@ -221,12 +221,11 @@ static int scan_for_bad_eraseblocks(void)
221{ 221{
222 int i, bad = 0; 222 int i, bad = 0;
223 223
224 bbt = kmalloc(ebcnt, GFP_KERNEL); 224 bbt = kzalloc(ebcnt, GFP_KERNEL);
225 if (!bbt) { 225 if (!bbt) {
226 printk(PRINT_PREF "error: cannot allocate memory\n"); 226 printk(PRINT_PREF "error: cannot allocate memory\n");
227 return -ENOMEM; 227 return -ENOMEM;
228 } 228 }
229 memset(bbt, 0 , ebcnt);
230 229
231 /* NOR flash does not implement block_isbad */ 230 /* NOR flash does not implement block_isbad */
232 if (mtd->block_isbad == NULL) 231 if (mtd->block_isbad == NULL)
diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c
index 700237a3d120..11204e8aab5f 100644
--- a/drivers/mtd/tests/mtd_subpagetest.c
+++ b/drivers/mtd/tests/mtd_subpagetest.c
@@ -354,12 +354,11 @@ static int scan_for_bad_eraseblocks(void)
354{ 354{
355 int i, bad = 0; 355 int i, bad = 0;
356 356
357 bbt = kmalloc(ebcnt, GFP_KERNEL); 357 bbt = kzalloc(ebcnt, GFP_KERNEL);
358 if (!bbt) { 358 if (!bbt) {
359 printk(PRINT_PREF "error: cannot allocate memory\n"); 359 printk(PRINT_PREF "error: cannot allocate memory\n");
360 return -ENOMEM; 360 return -ENOMEM;
361 } 361 }
362 memset(bbt, 0 , ebcnt);
363 362
364 printk(PRINT_PREF "scanning for bad eraseblocks\n"); 363 printk(PRINT_PREF "scanning for bad eraseblocks\n");
365 for (i = 0; i < ebcnt; ++i) { 364 for (i = 0; i < ebcnt; ++i) {