mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media, platform, LLVMLinux: Remove nested function from ti-vpe
@ 2014-09-27  1:11 Behan Webster
  2014-10-30 13:04 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 2+ messages in thread
From: Behan Webster @ 2014-09-27  1:11 UTC (permalink / raw)
  To: archit, b.zolnierkie, m.chehab
  Cc: behanw, hans.verkuil, k.debski, linux-kernel, linux-media, Arnd Bergmann

Replace the use of nested functions where a normal function will suffice.

Nested functions are not liked by upstream kernel developers in general. Their
use breaks the use of clang as a compiler, and doesn't make the code any
better.

This code now works for both gcc and clang.

Signed-off-by: Behan Webster <behanw@converseincode.com>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
---
 drivers/media/platform/ti-vpe/csc.c | 8 ++------
 drivers/media/platform/ti-vpe/sc.c  | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti-vpe/csc.c
index 940df40..44fbf41 100644
--- a/drivers/media/platform/ti-vpe/csc.c
+++ b/drivers/media/platform/ti-vpe/csc.c
@@ -93,12 +93,8 @@ void csc_dump_regs(struct csc_data *csc)
 {
 	struct device *dev = &csc->pdev->dev;
 
-	u32 read_reg(struct csc_data *csc, int offset)
-	{
-		return ioread32(csc->base + offset);
-	}
-
-#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(csc, CSC_##r))
+#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
+	ioread32(csc->base + CSC_##r))
 
 	DUMPREG(CSC00);
 	DUMPREG(CSC01);
diff --git a/drivers/media/platform/ti-vpe/sc.c b/drivers/media/platform/ti-vpe/sc.c
index 6314171..1088381 100644
--- a/drivers/media/platform/ti-vpe/sc.c
+++ b/drivers/media/platform/ti-vpe/sc.c
@@ -24,12 +24,8 @@ void sc_dump_regs(struct sc_data *sc)
 {
 	struct device *dev = &sc->pdev->dev;
 
-	u32 read_reg(struct sc_data *sc, int offset)
-	{
-		return ioread32(sc->base + offset);
-	}
-
-#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(sc, CFG_##r))
+#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
+	ioread32(sc->base + CFG_##r))
 
 	DUMPREG(SC0);
 	DUMPREG(SC1);
-- 
1.9.1


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

* Re: [PATCH] media, platform, LLVMLinux: Remove nested function from ti-vpe
  2014-09-27  1:11 [PATCH] media, platform, LLVMLinux: Remove nested function from ti-vpe Behan Webster
@ 2014-10-30 13:04 ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 2+ messages in thread
From: Mauro Carvalho Chehab @ 2014-10-30 13:04 UTC (permalink / raw)
  To: Behan Webster
  Cc: archit, b.zolnierkie, hans.verkuil, k.debski, linux-kernel,
	linux-media, Arnd Bergmann

Em Fri, 26 Sep 2014 18:11:45 -0700
Behan Webster <behanw@converseincode.com> escreveu:

> Replace the use of nested functions where a normal function will suffice.
> 
> Nested functions are not liked by upstream kernel developers in general. Their
> use breaks the use of clang as a compiler, and doesn't make the code any
> better.
> 
> This code now works for both gcc and clang.

I'm ok with this patch, as it makes the code cleaner, but in a few
cases, such functions could be useful, for example for doing things
like typecasting or when we need to use multiple versions of the same
code, one to be used internally and another to be used externally
with a different set of arguments inside the function call
(none of this applies here, it seems).

So, I think clang should be fixed anyway to support it.

Anyway, I'll be applying this patch.

Regards,
Mauro

> 
> Signed-off-by: Behan Webster <behanw@converseincode.com>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/media/platform/ti-vpe/csc.c | 8 ++------
>  drivers/media/platform/ti-vpe/sc.c  | 8 ++------
>  2 files changed, 4 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/media/platform/ti-vpe/csc.c b/drivers/media/platform/ti-vpe/csc.c
> index 940df40..44fbf41 100644
> --- a/drivers/media/platform/ti-vpe/csc.c
> +++ b/drivers/media/platform/ti-vpe/csc.c
> @@ -93,12 +93,8 @@ void csc_dump_regs(struct csc_data *csc)
>  {
>  	struct device *dev = &csc->pdev->dev;
>  
> -	u32 read_reg(struct csc_data *csc, int offset)
> -	{
> -		return ioread32(csc->base + offset);
> -	}
> -
> -#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(csc, CSC_##r))
> +#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
> +	ioread32(csc->base + CSC_##r))
>  
>  	DUMPREG(CSC00);
>  	DUMPREG(CSC01);
> diff --git a/drivers/media/platform/ti-vpe/sc.c b/drivers/media/platform/ti-vpe/sc.c
> index 6314171..1088381 100644
> --- a/drivers/media/platform/ti-vpe/sc.c
> +++ b/drivers/media/platform/ti-vpe/sc.c
> @@ -24,12 +24,8 @@ void sc_dump_regs(struct sc_data *sc)
>  {
>  	struct device *dev = &sc->pdev->dev;
>  
> -	u32 read_reg(struct sc_data *sc, int offset)
> -	{
> -		return ioread32(sc->base + offset);
> -	}
> -
> -#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, read_reg(sc, CFG_##r))
> +#define DUMPREG(r) dev_dbg(dev, "%-35s %08x\n", #r, \
> +	ioread32(sc->base + CFG_##r))
>  
>  	DUMPREG(SC0);
>  	DUMPREG(SC1);

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

end of thread, other threads:[~2014-10-30 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-27  1:11 [PATCH] media, platform, LLVMLinux: Remove nested function from ti-vpe Behan Webster
2014-10-30 13:04 ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®