Skip to content

Commit e93d12a

Browse files
arndbaxboe
authored andcommitted
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 <[email protected]> Cc: Matias Bjorling <[email protected]> Fixes: b2b7e00 ("null_blk: register as a LightNVM device") Signed-off-by: Jens Axboe <[email protected]>
1 parent 038a75a commit e93d12a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/block/null_blk.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -510,17 +510,17 @@ static int null_lnvm_id(struct request_queue *q, struct nvm_id *id)
510510
id->ppaf.ch_offset = 56;
511511
id->ppaf.ch_len = 8;
512512

513-
do_div(size, bs); /* convert size to pages */
514-
do_div(size, 256); /* concert size to pgs pr blk */
513+
sector_div(size, bs); /* convert size to pages */
514+
size >>= 8; /* concert size to pgs pr blk */
515515
grp = &id->groups[0];
516516
grp->mtype = 0;
517517
grp->fmtype = 0;
518518
grp->num_ch = 1;
519519
grp->num_pg = 256;
520520
blksize = size;
521-
do_div(size, (1 << 16));
521+
size >>= 16;
522522
grp->num_lun = size + 1;
523-
do_div(blksize, grp->num_lun);
523+
sector_div(blksize, grp->num_lun);
524524
grp->num_blk = blksize;
525525
grp->num_pln = 1;
526526

0 commit comments

Comments
 (0)