Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1295003 > unrolled thread

Re: [PATCH] null_blk: use sector_div instead of do_div

Started byArnd Bergmann <arnd@arndb.de>
First post2015-12-18 17:20 +0100
Last post2015-12-18 17:20 +0100
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] null_blk: use sector_div instead of do_div Arnd Bergmann <arnd@arndb.de> - 2015-12-18 17:20 +0100

#1295003 — Re: [PATCH] null_blk: use sector_div instead of do_div

FromArnd Bergmann <arnd@arndb.de>
Date2015-12-18 17:20 +0100
SubjectRe: [PATCH] null_blk: use sector_div instead of do_div
Message-ID<qH5V9-7UF-29@gated-at.bofh.it>
On Saturday 28 November 2015 09:05:56 Matias Bjørling wrote:
> 
> I had my head around the original code and kept references to the device 
> layout I had in mind. 256 being number of pages in a block, and the 2^16 
> being number of blocks in a lun and wanted to communicate that part.. 
> which led to producing silly code in the mean time.
> 
> Similarly, the bs is always fixed to 4k for lightnvm, until other bs 
> sizes are supported. We could optimize it out, I left it in for the same 
> reasons.

I still see the build warning in linux-next, can you merge your patch?

	Arnd

> diff --git i/drivers/block/null_blk.c w/drivers/block/null_blk.c
> index 5c8ba54..97c02fe 100644
> --- i/drivers/block/null_blk.c
> +++ w/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; /* convert 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; /* convert size to num luns */
>         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;
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web