All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] null_blk: use sector_div instead of do_div
@ 2016-01-13 22:04 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-01-13 22:04 UTC (permalink / raw)
  To: axboe
  Cc: Matias Bjorling, Linux Kernel Mailing List, linux-arm-kernel, torvalds

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")
---
[resent to Jens' correct address, sorry about the duplicates]

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 95dff91135ad..6f9587156569 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,17 +495,17 @@ static int null_lnvm_id(struct nvm_dev *dev, 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;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] null_blk: use sector_div instead of do_div
@ 2016-01-13 22:04 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-01-13 22:04 UTC (permalink / raw)
  To: linux-arm-kernel

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")
---
[resent to Jens' correct address, sorry about the duplicates]

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 95dff91135ad..6f9587156569 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,17 +495,17 @@ static int null_lnvm_id(struct nvm_dev *dev, 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;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] null_blk: use sector_div instead of do_div
  2016-01-13 22:04 ` Arnd Bergmann
@ 2016-01-13 22:11   ` Jens Axboe
  -1 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2016-01-13 22:11 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Matias Bjorling, Linux Kernel Mailing List, linux-arm-kernel, torvalds

On 01/13/2016 03:04 PM, Arnd Bergmann wrote:
> 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")
> ---
> [resent to Jens' correct address, sorry about the duplicates]

Thanks Arnd, added.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] null_blk: use sector_div instead of do_div
@ 2016-01-13 22:11   ` Jens Axboe
  0 siblings, 0 replies; 6+ messages in thread
From: Jens Axboe @ 2016-01-13 22:11 UTC (permalink / raw)
  To: linux-arm-kernel

On 01/13/2016 03:04 PM, Arnd Bergmann wrote:
> 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")
> ---
> [resent to Jens' correct address, sorry about the duplicates]

Thanks Arnd, added.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] null_blk: use sector_div instead of do_div
@ 2016-01-13 21:49 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-01-13 21:49 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Matias Bjorling, Linux Kernel Mailing List, linux-arm-kernel, torvalds

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")

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 95dff91135ad..6f9587156569 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,17 +495,17 @@ static int null_lnvm_id(struct nvm_dev *dev, 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;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2] null_blk: use sector_div instead of do_div
@ 2016-01-13 21:49 ` Arnd Bergmann
  0 siblings, 0 replies; 6+ messages in thread
From: Arnd Bergmann @ 2016-01-13 21:49 UTC (permalink / raw)
  To: linux-arm-kernel

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")

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index 95dff91135ad..6f9587156569 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -495,17 +495,17 @@ static int null_lnvm_id(struct nvm_dev *dev, 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;
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-01-13 22:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-13 22:04 [PATCH v2] null_blk: use sector_div instead of do_div Arnd Bergmann
2016-01-13 22:04 ` Arnd Bergmann
2016-01-13 22:11 ` Jens Axboe
2016-01-13 22:11   ` Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2016-01-13 21:49 Arnd Bergmann
2016-01-13 21:49 ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.