diff options
author | Joe Perches <joe@perches.com> | 2010-11-04 23:07:40 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-12-03 11:27:29 -0500 |
commit | 309b5e4e4154721f8079bc250d2233fd4b3aa039 (patch) | |
tree | b004e9ff14c82a247e34e6050d1477ac750f7c54 /drivers/mtd | |
parent | 08b3af3092bb2c284796e4e823c5309c2d0a9bca (diff) |
mtd: use vzalloc
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/nand/nandsim.c | 3 | ||||
-rw-r--r-- | drivers/mtd/ubi/vtbl.c | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index c45e06fba154..a5aa99f014ba 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
@@ -470,7 +470,7 @@ static int alloc_device(struct nandsim *ns) | |||
470 | err = -EINVAL; | 470 | err = -EINVAL; |
471 | goto err_close; | 471 | goto err_close; |
472 | } | 472 | } |
473 | ns->pages_written = vmalloc(ns->geom.pgnum); | 473 | ns->pages_written = vzalloc(ns->geom.pgnum); |
474 | if (!ns->pages_written) { | 474 | if (!ns->pages_written) { |
475 | NS_ERR("alloc_device: unable to allocate pages written array\n"); | 475 | NS_ERR("alloc_device: unable to allocate pages written array\n"); |
476 | err = -ENOMEM; | 476 | err = -ENOMEM; |
@@ -483,7 +483,6 @@ static int alloc_device(struct nandsim *ns) | |||
483 | goto err_free; | 483 | goto err_free; |
484 | } | 484 | } |
485 | ns->cfile = cfile; | 485 | ns->cfile = cfile; |
486 | memset(ns->pages_written, 0, ns->geom.pgnum); | ||
487 | return 0; | 486 | return 0; |
488 | } | 487 | } |
489 | 488 | ||
diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index fcdb7f65fe0b..0b8141fc5c26 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c | |||
@@ -425,12 +425,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, | |||
425 | 425 | ||
426 | /* Read both LEB 0 and LEB 1 into memory */ | 426 | /* Read both LEB 0 and LEB 1 into memory */ |
427 | ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { | 427 | ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { |
428 | leb[seb->lnum] = vmalloc(ubi->vtbl_size); | 428 | leb[seb->lnum] = vzalloc(ubi->vtbl_size); |
429 | if (!leb[seb->lnum]) { | 429 | if (!leb[seb->lnum]) { |
430 | err = -ENOMEM; | 430 | err = -ENOMEM; |
431 | goto out_free; | 431 | goto out_free; |
432 | } | 432 | } |
433 | memset(leb[seb->lnum], 0, ubi->vtbl_size); | ||
434 | 433 | ||
435 | err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, | 434 | err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, |
436 | ubi->vtbl_size); | 435 | ubi->vtbl_size); |
@@ -516,10 +515,9 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, | |||
516 | int i; | 515 | int i; |
517 | struct ubi_vtbl_record *vtbl; | 516 | struct ubi_vtbl_record *vtbl; |
518 | 517 | ||
519 | vtbl = vmalloc(ubi->vtbl_size); | 518 | vtbl = vzalloc(ubi->vtbl_size); |
520 | if (!vtbl) | 519 | if (!vtbl) |
521 | return ERR_PTR(-ENOMEM); | 520 | return ERR_PTR(-ENOMEM); |
522 | memset(vtbl, 0, ubi->vtbl_size); | ||
523 | 521 | ||
524 | for (i = 0; i < ubi->vtbl_slots; i++) | 522 | for (i = 0; i < ubi->vtbl_slots; i++) |
525 | memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE); | 523 | memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE); |