linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro
@ 2022-04-29 13:40 Michal Suchanek
  2022-04-29 15:48 ` Michal Suchánek
  2022-04-29 18:56 ` Dan Williams
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Suchanek @ 2022-04-29 13:40 UTC (permalink / raw)
  To: nvdimm
  Cc: Michal Suchanek, Dan Williams, Vishal Verma, Dave Jiang,
	Ira Weiny, Zou Wei, Bjorn Helgaas, linux-kernel

The ioremap passed as argument to __nfit_test_ioremap can be a macro so
it cannot be passed as function argument. Make __nfit_test_ioremap into
a macro so that ioremap can be passed as untyped macro argument.

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 tools/testing/nvdimm/test/iomap.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
index b752ce47ead3..ea956082e6a4 100644
--- a/tools/testing/nvdimm/test/iomap.c
+++ b/tools/testing/nvdimm/test/iomap.c
@@ -62,16 +62,14 @@ struct nfit_test_resource *get_nfit_res(resource_size_t resource)
 }
 EXPORT_SYMBOL(get_nfit_res);
 
-static void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size,
-		void __iomem *(*fallback_fn)(resource_size_t, unsigned long))
-{
-	struct nfit_test_resource *nfit_res = get_nfit_res(offset);
-
-	if (nfit_res)
-		return (void __iomem *) nfit_res->buf + offset
-			- nfit_res->res.start;
-	return fallback_fn(offset, size);
-}
+#define __nfit_test_ioremap(offset, size, fallback_fn) ({		\
+	struct nfit_test_resource *nfit_res = get_nfit_res(offset);	\
+	nfit_res ?							\
+		(void __iomem *) nfit_res->buf + (offset)		\
+			- nfit_res->res.start				\
+	:								\
+		fallback_fn((offset), (size)) ;				\
+})
 
 void __iomem *__wrap_devm_ioremap(struct device *dev,
 		resource_size_t offset, unsigned long size)
-- 
2.34.1


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

* Re: [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro
  2022-04-29 13:40 [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro Michal Suchanek
@ 2022-04-29 15:48 ` Michal Suchánek
  2022-04-29 18:56 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Suchánek @ 2022-04-29 15:48 UTC (permalink / raw)
  To: nvdimm
  Cc: Dan Williams, Vishal Verma, Dave Jiang, Ira Weiny, Zou Wei,
	Bjorn Helgaas, linux-kernel

On Fri, Apr 29, 2022 at 03:40:39PM +0200, Michal Suchanek wrote:
> The ioremap passed as argument to __nfit_test_ioremap can be a macro so
> it cannot be passed as function argument. Make __nfit_test_ioremap into
> a macro so that ioremap can be passed as untyped macro argument.

Fixes: 6bc756193ff6 ("tools/testing/nvdimm: libnvdimm unit test infrastructure")

The fallback_fn was passed around to start with, and ioremap was already
a define when this was merged.

> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  tools/testing/nvdimm/test/iomap.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
> index b752ce47ead3..ea956082e6a4 100644
> --- a/tools/testing/nvdimm/test/iomap.c
> +++ b/tools/testing/nvdimm/test/iomap.c
> @@ -62,16 +62,14 @@ struct nfit_test_resource *get_nfit_res(resource_size_t resource)
>  }
>  EXPORT_SYMBOL(get_nfit_res);
>  
> -static void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size,
> -		void __iomem *(*fallback_fn)(resource_size_t, unsigned long))
> -{
> -	struct nfit_test_resource *nfit_res = get_nfit_res(offset);
> -
> -	if (nfit_res)
> -		return (void __iomem *) nfit_res->buf + offset
> -			- nfit_res->res.start;
> -	return fallback_fn(offset, size);
> -}
> +#define __nfit_test_ioremap(offset, size, fallback_fn) ({		\
> +	struct nfit_test_resource *nfit_res = get_nfit_res(offset);	\
> +	nfit_res ?							\
> +		(void __iomem *) nfit_res->buf + (offset)		\
> +			- nfit_res->res.start				\
> +	:								\
> +		fallback_fn((offset), (size)) ;				\
> +})
>  
>  void __iomem *__wrap_devm_ioremap(struct device *dev,
>  		resource_size_t offset, unsigned long size)
> -- 
> 2.34.1
> 

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

* Re: [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro
  2022-04-29 13:40 [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro Michal Suchanek
  2022-04-29 15:48 ` Michal Suchánek
@ 2022-04-29 18:56 ` Dan Williams
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Williams @ 2022-04-29 18:56 UTC (permalink / raw)
  To: Michal Suchanek
  Cc: Linux NVDIMM, Vishal Verma, Dave Jiang, Ira Weiny, Zou Wei,
	Bjorn Helgaas, Linux Kernel Mailing List

On Fri, Apr 29, 2022 at 6:41 AM Michal Suchanek <msuchanek@suse.de> wrote:
>
> The ioremap passed as argument to __nfit_test_ioremap can be a macro so
> it cannot be passed as function argument. Make __nfit_test_ioremap into
> a macro so that ioremap can be passed as untyped macro argument.
>

Looks reasonable to me and passes tests, applied.

> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---
>  tools/testing/nvdimm/test/iomap.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
>
> diff --git a/tools/testing/nvdimm/test/iomap.c b/tools/testing/nvdimm/test/iomap.c
> index b752ce47ead3..ea956082e6a4 100644
> --- a/tools/testing/nvdimm/test/iomap.c
> +++ b/tools/testing/nvdimm/test/iomap.c
> @@ -62,16 +62,14 @@ struct nfit_test_resource *get_nfit_res(resource_size_t resource)
>  }
>  EXPORT_SYMBOL(get_nfit_res);
>
> -static void __iomem *__nfit_test_ioremap(resource_size_t offset, unsigned long size,
> -               void __iomem *(*fallback_fn)(resource_size_t, unsigned long))
> -{
> -       struct nfit_test_resource *nfit_res = get_nfit_res(offset);
> -
> -       if (nfit_res)
> -               return (void __iomem *) nfit_res->buf + offset
> -                       - nfit_res->res.start;
> -       return fallback_fn(offset, size);
> -}
> +#define __nfit_test_ioremap(offset, size, fallback_fn) ({              \
> +       struct nfit_test_resource *nfit_res = get_nfit_res(offset);     \
> +       nfit_res ?                                                      \
> +               (void __iomem *) nfit_res->buf + (offset)               \
> +                       - nfit_res->res.start                           \
> +       :                                                               \
> +               fallback_fn((offset), (size)) ;                         \
> +})
>
>  void __iomem *__wrap_devm_ioremap(struct device *dev,
>                 resource_size_t offset, unsigned long size)
> --
> 2.34.1
>

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

end of thread, other threads:[~2022-04-29 18:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-29 13:40 [PATCH] testing: nvdimm: iomap: make __nfit_test_ioremap a macro Michal Suchanek
2022-04-29 15:48 ` Michal Suchánek
2022-04-29 18:56 ` 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).