linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] libnvdimm/region: Fix build error
@ 2020-03-30 14:19 YueHaibing
  2020-03-31  9:46 ` Dan Williams
  2020-03-31 11:50 ` [PATCH v2 " YueHaibing
  0 siblings, 2 replies; 4+ messages in thread
From: YueHaibing @ 2020-03-30 14:19 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny,
	aneesh.kumar, jmoyer
  Cc: linux-nvdimm, linux-kernel, YueHaibing

On CONFIG_PPC32=y build fails:

drivers/nvdimm/region_devs.c:1034:14: note: in expansion of macro ‘do_div’
  remainder = do_div(per_mapping, mappings);
              ^~~~~~
In file included from ./arch/powerpc/include/generated/asm/div64.h:1:0,
                 from ./include/linux/kernel.h:18,
                 from ./include/asm-generic/bug.h:19,
                 from ./arch/powerpc/include/asm/bug.h:109,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/scatterlist.h:7,
                 from drivers/nvdimm/region_devs.c:5:
./include/asm-generic/div64.h:243:22: error: passing argument 1 of ‘__div64_32’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   __rem = __div64_32(&(n), __base); \

Use div_u64 instead of do_div to fix this.

Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/nvdimm/region_devs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index bf239e783940..2291f0649d27 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -564,7 +564,7 @@ static ssize_t align_store(struct device *dev,
 	 * space for the namespace.
 	 */
 	dpa = val;
-	remainder = do_div(dpa, nd_region->ndr_mappings);
+	remainder = div_u64(dpa, nd_region->ndr_mappings);
 	if (!is_power_of_2(dpa) || dpa < PAGE_SIZE
 			|| val > region_size(nd_region) || remainder)
 		return -EINVAL;
@@ -1031,7 +1031,7 @@ static unsigned long default_align(struct nd_region *nd_region)
 
 	mappings = max_t(u16, 1, nd_region->ndr_mappings);
 	per_mapping = align;
-	remainder = do_div(per_mapping, mappings);
+	remainder = div_u64(per_mapping, mappings);
 	if (remainder)
 		align *= mappings;
 
-- 
2.17.1



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

* Re: [PATCH -next] libnvdimm/region: Fix build error
  2020-03-30 14:19 [PATCH -next] libnvdimm/region: Fix build error YueHaibing
@ 2020-03-31  9:46 ` Dan Williams
  2020-03-31 11:50 ` [PATCH v2 " YueHaibing
  1 sibling, 0 replies; 4+ messages in thread
From: Dan Williams @ 2020-03-31  9:46 UTC (permalink / raw)
  To: YueHaibing
  Cc: Vishal L Verma, Dave Jiang, Weiny, Ira, Aneesh Kumar K.V, jmoyer,
	linux-nvdimm, Linux Kernel Mailing List

On Mon, Mar 30, 2020 at 7:23 AM YueHaibing <yuehaibing@huawei.com> wrote:
>
> On CONFIG_PPC32=y build fails:
>
> drivers/nvdimm/region_devs.c:1034:14: note: in expansion of macro ‘do_div’
>   remainder = do_div(per_mapping, mappings);
>               ^~~~~~
> In file included from ./arch/powerpc/include/generated/asm/div64.h:1:0,
>                  from ./include/linux/kernel.h:18,
>                  from ./include/asm-generic/bug.h:19,
>                  from ./arch/powerpc/include/asm/bug.h:109,
>                  from ./include/linux/bug.h:5,
>                  from ./include/linux/scatterlist.h:7,
>                  from drivers/nvdimm/region_devs.c:5:
> ./include/asm-generic/div64.h:243:22: error: passing argument 1 of ‘__div64_32’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>    __rem = __div64_32(&(n), __base); \
>
> Use div_u64 instead of do_div to fix this.
>
> Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
>  drivers/nvdimm/region_devs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
> index bf239e783940..2291f0649d27 100644
> --- a/drivers/nvdimm/region_devs.c
> +++ b/drivers/nvdimm/region_devs.c
> @@ -564,7 +564,7 @@ static ssize_t align_store(struct device *dev,
>          * space for the namespace.
>          */
>         dpa = val;
> -       remainder = do_div(dpa, nd_region->ndr_mappings);
> +       remainder = div_u64(dpa, nd_region->ndr_mappings);

This is not an equivalent conversion.

    dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder);

>         if (!is_power_of_2(dpa) || dpa < PAGE_SIZE
>                         || val > region_size(nd_region) || remainder)
>                 return -EINVAL;
> @@ -1031,7 +1031,7 @@ static unsigned long default_align(struct nd_region *nd_region)
>
>         mappings = max_t(u16, 1, nd_region->ndr_mappings);
>         per_mapping = align;
> -       remainder = do_div(per_mapping, mappings);
> +       remainder = div_u64(per_mapping, mappings);

Same problem here.

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

* [PATCH v2 -next] libnvdimm/region: Fix build error
  2020-03-30 14:19 [PATCH -next] libnvdimm/region: Fix build error YueHaibing
  2020-03-31  9:46 ` Dan Williams
@ 2020-03-31 11:50 ` YueHaibing
  2020-03-31 19:42   ` Dan Williams
  1 sibling, 1 reply; 4+ messages in thread
From: YueHaibing @ 2020-03-31 11:50 UTC (permalink / raw)
  To: dan.j.williams, vishal.l.verma, dave.jiang, ira.weiny,
	aneesh.kumar, jmoyer
  Cc: linux-nvdimm, linux-kernel, YueHaibing

On CONFIG_PPC32=y build fails:

drivers/nvdimm/region_devs.c:1034:14: note: in expansion of macro ‘do_div’
  remainder = do_div(per_mapping, mappings);
              ^~~~~~
In file included from ./arch/powerpc/include/generated/asm/div64.h:1:0,
                 from ./include/linux/kernel.h:18,
                 from ./include/asm-generic/bug.h:19,
                 from ./arch/powerpc/include/asm/bug.h:109,
                 from ./include/linux/bug.h:5,
                 from ./include/linux/scatterlist.h:7,
                 from drivers/nvdimm/region_devs.c:5:
./include/asm-generic/div64.h:243:22: error: passing argument 1 of ‘__div64_32’ from incompatible pointer type [-Werror=incompatible-pointer-types]
   __rem = __div64_32(&(n), __base); \

Use div_u64 instead of do_div to fix this.

Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
v2: use div_u64_rem and code cleanup
---
 drivers/nvdimm/region_devs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/nvdimm/region_devs.c b/drivers/nvdimm/region_devs.c
index bf239e783940..ccbb5b43b8b2 100644
--- a/drivers/nvdimm/region_devs.c
+++ b/drivers/nvdimm/region_devs.c
@@ -563,8 +563,7 @@ static ssize_t align_store(struct device *dev,
 	 * contribute to the tail capacity in system-physical-address
 	 * space for the namespace.
 	 */
-	dpa = val;
-	remainder = do_div(dpa, nd_region->ndr_mappings);
+	dpa = div_u64_rem(val, nd_region->ndr_mappings, &remainder);
 	if (!is_power_of_2(dpa) || dpa < PAGE_SIZE
 			|| val > region_size(nd_region) || remainder)
 		return -EINVAL;
@@ -1010,7 +1009,7 @@ EXPORT_SYMBOL(nd_region_release_lane);
 
 static unsigned long default_align(struct nd_region *nd_region)
 {
-	unsigned long align, per_mapping;
+	unsigned long align;
 	int i, mappings;
 	u32 remainder;
 
@@ -1030,8 +1029,7 @@ static unsigned long default_align(struct nd_region *nd_region)
 	}
 
 	mappings = max_t(u16, 1, nd_region->ndr_mappings);
-	per_mapping = align;
-	remainder = do_div(per_mapping, mappings);
+	div_u64_rem(align, mappings, &remainder);
 	if (remainder)
 		align *= mappings;
 
-- 
2.17.1



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

* Re: [PATCH v2 -next] libnvdimm/region: Fix build error
  2020-03-31 11:50 ` [PATCH v2 " YueHaibing
@ 2020-03-31 19:42   ` Dan Williams
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Williams @ 2020-03-31 19:42 UTC (permalink / raw)
  To: YueHaibing
  Cc: Vishal L Verma, Dave Jiang, Weiny, Ira, Aneesh Kumar K.V, jmoyer,
	linux-nvdimm, Linux Kernel Mailing List

On Tue, Mar 31, 2020 at 4:52 AM YueHaibing <yuehaibing@huawei.com> wrote:
>
> On CONFIG_PPC32=y build fails:
>
> drivers/nvdimm/region_devs.c:1034:14: note: in expansion of macro ‘do_div’
>   remainder = do_div(per_mapping, mappings);
>               ^~~~~~
> In file included from ./arch/powerpc/include/generated/asm/div64.h:1:0,
>                  from ./include/linux/kernel.h:18,
>                  from ./include/asm-generic/bug.h:19,
>                  from ./arch/powerpc/include/asm/bug.h:109,
>                  from ./include/linux/bug.h:5,
>                  from ./include/linux/scatterlist.h:7,
>                  from drivers/nvdimm/region_devs.c:5:
> ./include/asm-generic/div64.h:243:22: error: passing argument 1 of ‘__div64_32’ from incompatible pointer type [-Werror=incompatible-pointer-types]
>    __rem = __div64_32(&(n), __base); \
>
> Use div_u64 instead of do_div to fix this.
>
> Fixes: 2522afb86a8c ("libnvdimm/region: Introduce an 'align' attribute")
> Signed-off-by: YueHaibing <yuehaibing@huawei.com>
> ---
> v2: use div_u64_rem and code cleanup

Looks good now, thanks, applied.

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

end of thread, other threads:[~2020-03-31 19:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-30 14:19 [PATCH -next] libnvdimm/region: Fix build error YueHaibing
2020-03-31  9:46 ` Dan Williams
2020-03-31 11:50 ` [PATCH v2 " YueHaibing
2020-03-31 19:42   ` Dan Williams

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).