linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM
@ 2014-09-27  1:10 Behan Webster
  2014-09-27  1:10 ` [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss Behan Webster
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Behan Webster @ 2014-09-27  1:10 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen
  Cc: behanw, archit, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark

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.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and
clang (the C front end for the LLVM compiler infrastructure project). 

Behan Webster (2):
  arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
  arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb

 drivers/video/fbdev/omap2/dss/dispc-compat.c   |  9 +++++----
 drivers/video/fbdev/omap2/dss/manager-sysfs.c  | 16 +++++++++-------
 drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++-------
 3 files changed, 21 insertions(+), 18 deletions(-)

-- 
1.9.1


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

* [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
  2014-09-27  1:10 [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Behan Webster
@ 2014-09-27  1:10 ` Behan Webster
  2014-09-27 16:46   ` Felipe Balbi
  2014-09-27  1:10 ` [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb Behan Webster
  2014-09-30 10:15 ` [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Tomi Valkeinen
  2 siblings, 1 reply; 7+ messages in thread
From: Behan Webster @ 2014-09-27  1:10 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen
  Cc: behanw, archit, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark, 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/video/fbdev/omap2/dss/dispc-compat.c  |  9 +++++----
 drivers/video/fbdev/omap2/dss/manager-sysfs.c | 16 +++++++++-------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/video/fbdev/omap2/dss/dispc-compat.c b/drivers/video/fbdev/omap2/dss/dispc-compat.c
index 83779c2..633c461 100644
--- a/drivers/video/fbdev/omap2/dss/dispc-compat.c
+++ b/drivers/video/fbdev/omap2/dss/dispc-compat.c
@@ -634,13 +634,14 @@ void dispc_mgr_disable_sync(enum omap_channel channel)
 		WARN_ON(1);
 }
 
+static inline void dispc_irq_wait_handler(void *data, u32 mask)
+{
+	complete((struct completion *)data);
+}
+
 int omap_dispc_wait_for_irq_interruptible_timeout(u32 irqmask,
 		unsigned long timeout)
 {
-	void dispc_irq_wait_handler(void *data, u32 mask)
-	{
-		complete((struct completion *)data);
-	}
 
 	int r;
 	DECLARE_COMPLETION_ONSTACK(completion);
diff --git a/drivers/video/fbdev/omap2/dss/manager-sysfs.c b/drivers/video/fbdev/omap2/dss/manager-sysfs.c
index 37b59fe..a7414fb 100644
--- a/drivers/video/fbdev/omap2/dss/manager-sysfs.c
+++ b/drivers/video/fbdev/omap2/dss/manager-sysfs.c
@@ -44,6 +44,13 @@ static ssize_t manager_display_show(struct omap_overlay_manager *mgr, char *buf)
 			dssdev->name : "<none>");
 }
 
+static int manager_display_match(struct omap_dss_device *dssdev, void *data)
+{
+	const char *str = data;
+
+	return sysfs_streq(dssdev->name, str);
+}
+
 static ssize_t manager_display_store(struct omap_overlay_manager *mgr,
 		const char *buf, size_t size)
 {
@@ -52,17 +59,12 @@ static ssize_t manager_display_store(struct omap_overlay_manager *mgr,
 	struct omap_dss_device *dssdev = NULL;
 	struct omap_dss_device *old_dssdev;
 
-	int match(struct omap_dss_device *dssdev, void *data)
-	{
-		const char *str = data;
-		return sysfs_streq(dssdev->name, str);
-	}
-
 	if (buf[size-1] = '\n')
 		--len;
 
 	if (len > 0)
-		dssdev = omap_dss_find_device((void *)buf, match);
+		dssdev = omap_dss_find_device((void *)buf,
+			manager_display_match);
 
 	if (len > 0 && dssdev = NULL)
 		return -EINVAL;
-- 
1.9.1


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

* [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
  2014-09-27  1:10 [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Behan Webster
  2014-09-27  1:10 ` [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss Behan Webster
@ 2014-09-27  1:10 ` Behan Webster
  2014-09-27 16:46   ` Felipe Balbi
  2014-09-30 10:15 ` [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Tomi Valkeinen
  2 siblings, 1 reply; 7+ messages in thread
From: Behan Webster @ 2014-09-27  1:10 UTC (permalink / raw)
  To: plagnioj, tomi.valkeinen
  Cc: behanw, archit, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark, 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/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
index ec2d132..1587243 100644
--- a/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/fbdev/omap2/omapfb/omapfb-main.c
@@ -273,16 +273,16 @@ static struct omapfb_colormode omapfb_colormodes[] = {
 	},
 };
 
+static bool cmp_component(struct fb_bitfield *f1, struct fb_bitfield *f2)
+{
+	return f1->length = f2->length &&
+		f1->offset = f2->offset &&
+		f1->msb_right = f2->msb_right;
+}
+
 static bool cmp_var_to_colormode(struct fb_var_screeninfo *var,
 		struct omapfb_colormode *color)
 {
-	bool cmp_component(struct fb_bitfield *f1, struct fb_bitfield *f2)
-	{
-		return f1->length = f2->length &&
-			f1->offset = f2->offset &&
-			f1->msb_right = f2->msb_right;
-	}
-
 	if (var->bits_per_pixel = 0 ||
 			var->red.length = 0 ||
 			var->blue.length = 0 ||
-- 
1.9.1


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

* Re: [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
  2014-09-27  1:10 ` [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss Behan Webster
@ 2014-09-27 16:46   ` Felipe Balbi
  2014-09-27 22:53     ` Behan Webster
  0 siblings, 1 reply; 7+ messages in thread
From: Felipe Balbi @ 2014-09-27 16:46 UTC (permalink / raw)
  To: Behan Webster
  Cc: plagnioj, tomi.valkeinen, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark, Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

On Fri, Sep 26, 2014 at 06:10:52PM -0700, Behan Webster wrote:
> 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>

another one that make sense :-) And probably also deserves
checkpatch/coccinelle/sparse.

Reviewed-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
  2014-09-27  1:10 ` [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb Behan Webster
@ 2014-09-27 16:46   ` Felipe Balbi
  0 siblings, 0 replies; 7+ messages in thread
From: Felipe Balbi @ 2014-09-27 16:46 UTC (permalink / raw)
  To: Behan Webster
  Cc: plagnioj, tomi.valkeinen, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark, Arnd Bergmann

[-- Attachment #1: Type: text/plain, Size: 571 bytes --]

On Fri, Sep 26, 2014 at 06:10:53PM -0700, Behan Webster wrote:
> 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>

Reviewed-by: Felipe Balbi <balbi@ti.com>

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
  2014-09-27 16:46   ` Felipe Balbi
@ 2014-09-27 22:53     ` Behan Webster
  0 siblings, 0 replies; 7+ messages in thread
From: Behan Webster @ 2014-09-27 22:53 UTC (permalink / raw)
  To: balbi
  Cc: plagnioj, tomi.valkeinen, daniel.vetter, geert, laurent.pinchart,
	linux-fbdev, linux-kernel, linux-omap, robdclark, Arnd Bergmann

On 09/27/14 09:46, Felipe Balbi wrote:
> On Fri, Sep 26, 2014 at 06:10:52PM -0700, Behan Webster wrote:
>> 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>
> another one that make sense :-) And probably also deserves
> checkpatch/coccinelle/sparse.
Indeed! That would be very appreciated.

The clang static analyzer already points this one out. :)

Behan

-- 
Behan Webster
behanw@converseincode.com


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

* Re: [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM
  2014-09-27  1:10 [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Behan Webster
  2014-09-27  1:10 ` [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss Behan Webster
  2014-09-27  1:10 ` [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb Behan Webster
@ 2014-09-30 10:15 ` Tomi Valkeinen
  2 siblings, 0 replies; 7+ messages in thread
From: Tomi Valkeinen @ 2014-09-30 10:15 UTC (permalink / raw)
  To: Behan Webster, plagnioj
  Cc: daniel.vetter, geert, laurent.pinchart, linux-fbdev, linux-kernel,
	linux-omap, robdclark

[-- Attachment #1: Type: text/plain, Size: 1174 bytes --]

On 27/09/14 04:10, Behan Webster wrote:
> 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.
> 
> The LLVMLinux project aims to fully build the Linux kernel using both gcc and
> clang (the C front end for the LLVM compiler infrastructure project). 
> 
> Behan Webster (2):
>   arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss
>   arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb
> 
>  drivers/video/fbdev/omap2/dss/dispc-compat.c   |  9 +++++----
>  drivers/video/fbdev/omap2/dss/manager-sysfs.c  | 16 +++++++++-------
>  drivers/video/fbdev/omap2/omapfb/omapfb-main.c | 14 +++++++-------
>  3 files changed, 21 insertions(+), 18 deletions(-)
> 

I have to say I do like small helper funcs as nested functions, as they
are restricted inside the parent function's scope. But, of course,
nested funcs have their issues.

So looks fine to me, queuing for 3.18.

 Tomi



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

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

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-27  1:10 [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Behan Webster
2014-09-27  1:10 ` [PATCH 1/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss Behan Webster
2014-09-27 16:46   ` Felipe Balbi
2014-09-27 22:53     ` Behan Webster
2014-09-27  1:10 ` [PATCH 2/2] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb Behan Webster
2014-09-27 16:46   ` Felipe Balbi
2014-09-30 10:15 ` [PATCH 0/2] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM Tomi Valkeinen

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