aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand/nandsim.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand/nandsim.c')
-rw-r--r--drivers/mtd/nand/nandsim.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index 6cc8fbfabb8e..cf0cd3146817 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -28,7 +28,7 @@
28#include <linux/module.h> 28#include <linux/module.h>
29#include <linux/moduleparam.h> 29#include <linux/moduleparam.h>
30#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
31#include <asm/div64.h> 31#include <linux/math64.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33#include <linux/errno.h> 33#include <linux/errno.h>
34#include <linux/string.h> 34#include <linux/string.h>
@@ -546,12 +546,6 @@ static char *get_partition_name(int i)
546 return kstrdup(buf, GFP_KERNEL); 546 return kstrdup(buf, GFP_KERNEL);
547} 547}
548 548
549static uint64_t divide(uint64_t n, uint32_t d)
550{
551 do_div(n, d);
552 return n;
553}
554
555/* 549/*
556 * Initialize the nandsim structure. 550 * Initialize the nandsim structure.
557 * 551 *
@@ -580,7 +574,7 @@ static int init_nandsim(struct mtd_info *mtd)
580 ns->geom.oobsz = mtd->oobsize; 574 ns->geom.oobsz = mtd->oobsize;
581 ns->geom.secsz = mtd->erasesize; 575 ns->geom.secsz = mtd->erasesize;
582 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz; 576 ns->geom.pgszoob = ns->geom.pgsz + ns->geom.oobsz;
583 ns->geom.pgnum = divide(ns->geom.totsz, ns->geom.pgsz); 577 ns->geom.pgnum = div_u64(ns->geom.totsz, ns->geom.pgsz);
584 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz; 578 ns->geom.totszoob = ns->geom.totsz + (uint64_t)ns->geom.pgnum * ns->geom.oobsz;
585 ns->geom.secshift = ffs(ns->geom.secsz) - 1; 579 ns->geom.secshift = ffs(ns->geom.secsz) - 1;
586 ns->geom.pgshift = chip->page_shift; 580 ns->geom.pgshift = chip->page_shift;
@@ -921,7 +915,7 @@ static int setup_wear_reporting(struct mtd_info *mtd)
921 915
922 if (!rptwear) 916 if (!rptwear)
923 return 0; 917 return 0;
924 wear_eb_count = divide(mtd->size, mtd->erasesize); 918 wear_eb_count = div_u64(mtd->size, mtd->erasesize);
925 mem = wear_eb_count * sizeof(unsigned long); 919 mem = wear_eb_count * sizeof(unsigned long);
926 if (mem / sizeof(unsigned long) != wear_eb_count) { 920 if (mem / sizeof(unsigned long) != wear_eb_count) {
927 NS_ERR("Too many erase blocks for wear reporting\n"); 921 NS_ERR("Too many erase blocks for wear reporting\n");