# \[PATCH 0/2\] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

- Subsystems: FRAMEBUFFER LAYER, OMAP DISPLAY SUBSYSTEM and FRAMEBUFFER SUPPORT (DSS2), THE REST
- Maintainers: Helge Deller, Linus Torvalds
- Series: 2 patches touching 3 files, +21/-18
- List: linux-fbdev
- 7 messages, 3 authors
- Page: https://ratatoskr.run/linux-fbdev/2014/09/4342664/t

## \[PATCH 0/2\] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

- From: Behan Webster \<hidden\>
- Date: 2014-09-27 01:11:12 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342664.md

```text
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

```

## \[PATCH 1/2\] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss

- From: Behan Webster \<hidden\>
- Date: 2014-09-27 01:11:15 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342665.md

```text
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 <redacted>
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

```

## \[PATCH 2/2\] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb

- From: Behan Webster \<hidden\>
- Date: 2014-09-27 01:11:33 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342666.md

```text
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 <redacted>
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

```

## Re: \[PATCH 1/2\] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss

- From: Felipe Balbi \<hidden\>
- Date: 2014-09-27 16:46:47 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342771.md

```text
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 <redacted>
> 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 <redacted>

-- 
balbi
```

## Re: \[PATCH 2/2\] arm, fbdev, omap2, LLVMLinux: Remove nested function from omapfb

- From: Felipe Balbi \<hidden\>
- Date: 2014-09-27 16:47:10 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342772.md

```text
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 <redacted>
> Suggested-by: Arnd Bergmann <arnd@arndb.de>
> Cc: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Felipe Balbi <redacted>

-- 
balbi
```

## Re: \[PATCH 1/2\] arm, fbdev, omap2, LLVMLinux: Remove nested function from omap2 dss

- From: Behan Webster \<hidden\>
- Date: 2014-09-27 22:54:03 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4342797.md

```text
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 <redacted>
>> 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

```

## Re: \[PATCH 0/2\] LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

- From: Tomi Valkeinen \<hidden\>
- Date: 2014-09-30 10:15:52 
- Message: https://ratatoskr.run/linux-fbdev/2014/09/4344036.md

```text
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


```
