diff options
author | Arnd Bergmann <arnd@arndb.de> | 2016-01-14 01:04:08 +0300 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-01-14 01:10:34 +0300 |
commit | e93d12ae3be91d18b2a46deebb90a3f516db3d3c (patch) | |
tree | 11f16543a9c469cf562bbd93fb7000c3fd548c93 /drivers/block/null_blk.c | |
parent | 038a75afc54d4b4dc9794213bb16e88c1a31a752 (diff) | |
download | linux-e93d12ae3be91d18b2a46deebb90a3f516db3d3c.tar.xz |
null_blk: use sector_div instead of do_div
Dividing a sector_t number should be done using sector_div rather than do_div
to optimize the 32-bit sector_t case, and with the latest do_div optimizations,
we now get a compile-time warning for this:
arch/arm/include/asm/div64.h:32:95: note: expected 'uint64_t * {aka long long unsigned int *}' but argument is of type 'sector_t * {aka long unsigned int *}'
drivers/block/null_blk.c:521:81: warning: comparison of distinct pointer types lacks a cast
This changes the newly added code to use sector_div. It is a simplified version
of the original patch, as Linus Torvalds pointed out that we should not be using
an expensive division function in the first place.
This version was suggested by Matias Bjorling.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Matias Bjorling <m@bjorling.me>
Fixes: b2b7e00148a2 ("null_blk: register as a LightNVM device")
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/block/null_blk.c')
-rw-r--r-- | drivers/block/null_blk.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 5c8ba5484d86..a96ce7ec1ca5 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c @@ -510,17 +510,17 @@ static int null_lnvm_id(struct request_queue *q, struct nvm_id *id) id->ppaf.ch_offset = 56; id->ppaf.ch_len = 8; - do_div(size, bs); /* convert size to pages */ - do_div(size, 256); /* concert size to pgs pr blk */ + sector_div(size, bs); /* convert size to pages */ + size >>= 8; /* concert size to pgs pr blk */ grp = &id->groups[0]; grp->mtype = 0; grp->fmtype = 0; grp->num_ch = 1; grp->num_pg = 256; blksize = size; - do_div(size, (1 << 16)); + size >>= 16; grp->num_lun = size + 1; - do_div(blksize, grp->num_lun); + sector_div(blksize, grp->num_lun); grp->num_blk = blksize; grp->num_pln = 1; |