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>
This commit is contained in:
committed by
David Woodhouse
parent
ecce2a6f9b
commit
2bfefa4c96
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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) {
|
||||
|
Reference in New Issue
Block a user