Skip to contentSkip to conversation

backlight: use of_find_backlight_by_node stub when backlight class disabled

PATCH Applied Heiko Stübner 3 participants 9 messages Oct 29, 2014 – Nov 10, 2014 Backlight class/subsystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backlight: use of_find_backlight_by_node stub when backlight class disabled

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/backlight.h +1 -1
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *
Signature · 1 line
2.0.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Heiko Stübner

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

of_find_backlight_by_node()is defined at ./drivers/video/backlight/backlight.c file. Also, this file can be built when CONFIG_BACKLIGHT_CLASS_DEVICE=y. So, in order to prevent the possible build error, this patch looks good.

Best regards,
Jingoo Han

Quoted 19 lines
---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/backlight.h +1 -2
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *
--

2.0.1

Applied
#2 lore raw
In reply to Heiko Stübner
Quoted 10 lines · Heiko Stübner

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to Backlight -next with Jingoo's Ack.

Quoted 13 lines
include/linux/backlight.h +1 -1
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#3 lore raw
Quoted 6 lines · Lee Jones
Quoted 4 lines · Heiko Stübner

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Quoted 8 lines
Quoted 6 lines

Therefore use the stub function also when the backlight class is disabled.

---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to Backlight -next with Jingoo's Ack.

I've removed this patch, as it causes unexpected:

Redefinition of of_find_backlight_by_node()

... error.

Bear in mind that defined(CONFIG_BACKLIGHT_CLASS_DEVICE) is false if it's built in as a module. Change to nested #ifdefs instead.

Quoted 14 lines
Quoted 13 lines
include/linux/backlight.h +1 -1
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#4 lore raw
Quoted 15 lines · Heiko Stübner
Quoted 13 lines · Lee Jones
Quoted 10 lines · Heiko Stübner

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Applied to Backlight -next with Jingoo's Ack.

I've removed this patch, as it causes unexpected:

Redefinition of of_find_backlight_by_node()

I reproduced the same build error.

Then, how about folding the following two patches into
one single patch? These two patches were already sent by Heiko Stübner.

[PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled [PATCH] backlight: extend of_find_backlight_by_node stub-check to modules

Then, the one single patch will do as follows.

-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && (defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
+ defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))

In this case, I cannot find any build errors.
Thank you.

Best regards,
Jingoo Han

Quoted 26 lines

... error.

Bear in mind that defined(CONFIG_BACKLIGHT_CLASS_DEVICE) is false if it's built in as a module. Change to nested #ifdefs instead.

Quoted 8 lines
Quoted 8 lines
include/linux/backlight.h +0 -0
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
Quoted 6 lines

include/linux/backlight.h struct generic_bl_info { · line 163

Quoted 5 lines
include/linux/backlight.h +1 -1
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead

Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw
Quoted 36 lines · Jingoo Han
Quoted 15 lines · Heiko Stübner
Quoted 13 lines · Lee Jones
Quoted 10 lines · Heiko Stübner

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 5 lines
Quoted 1 line

Applied to Backlight -next with Jingoo's Ack.

I've removed this patch, as it causes unexpected:

Redefinition of of_find_backlight_by_node()

I reproduced the same build error.

Then, how about folding the following two patches into
one single patch? These two patches were already sent by Heiko Stübner.

[PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled [PATCH] backlight: extend of_find_backlight_by_node stub-check to modules

Then, the one single patch will do as follows.

(quoted diff) +2 -1
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && (defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
+			   defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
Quoted 1 line

In this case, I cannot find any build errors.

That's a neat trick. I didn't know you could do that.

However, it's bit messy consider different formatting, or a nested #ifdef instead please.

Quoted 21 lines
Quoted 20 lines

... error.

Bear in mind that defined(CONFIG_BACKLIGHT_CLASS_DEVICE) is false if it's built in as a module. Change to nested #ifdefs instead.

Quoted 14 lines
Quoted 13 lines
include/linux/backlight.h +1 -1
index adb14a8..d9cb644 100644
@@ -157,7 +157,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && defined(CONFIG_BACKLIGHT_CLASS_DEVICE)
 struct backlight_device *of_find_backlight_by_node(struct device_node *node);
 #else
 static inline struct backlight_device *
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#6 lore raw

Am Dienstag, 4. November 2014, 14:42:20 schrieb Lee Jones:

Quoted 36 lines · Jingoo Han
Quoted 35 lines · Heiko Stübner
Quoted 12 lines · Lee Jones
Quoted 11 lines · Heiko Stübner
Quoted 10 lines

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to Backlight -next with Jingoo's Ack.

I've removed this patch, as it causes unexpected:
Redefinition of of_find_backlight_by_node()

I reproduced the same build error.

Then, how about folding the following two patches into
one single patch? These two patches were already sent by Heiko Stübner.

[PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled [PATCH] backlight: extend of_find_backlight_by_node stub-check to modules>
Then, the one single patch will do as follows.

(quoted diff) +2 -1
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && (defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
+			   defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
Quoted 6 lines
Quoted 1 line

In this case, I cannot find any build errors.

That's a neat trick. I didn't know you could do that.

However, it's bit messy consider different formatting, or a nested #ifdef instead please.

I guess it is a matter of me "not seeing the forrest for the trees", but how would a nested ifdef look like, as this would result in 3 possible results when for CONFIG_OF first and then for one of the BACKLIGHT_CLASS defines?

Formatting wise, when applied both defined(CONFIG_BACKLIGHT_foo) parts are exactly below each other, making it (hopefully) clear where the "or" is part of. What would look better?

Thanks
Heiko

#7 lore raw
Quoted 44 lines · Heiko Stübner

Am Dienstag, 4. November 2014, 14:42:20 schrieb Lee Jones:

Quoted 36 lines · Jingoo Han
Quoted 35 lines · Heiko Stübner
Quoted 12 lines · Lee Jones
Quoted 11 lines · Heiko Stübner
Quoted 10 lines

Drivers may want to search for an optional backlight even when the backlight class is disabled. In this case the linker would miss the function referenced in the backlight header.

Therefore use the stub function also when the backlight class is disabled.

---

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
 include/linux/backlight.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to Backlight -next with Jingoo's Ack.

I've removed this patch, as it causes unexpected:
Redefinition of of_find_backlight_by_node()

I reproduced the same build error.

Then, how about folding the following two patches into
one single patch? These two patches were already sent by Heiko Stübner.

[PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled [PATCH] backlight: extend of_find_backlight_by_node stub-check to modules>
Then, the one single patch will do as follows.

(quoted diff) +2 -1
-#ifdef CONFIG_OF
+#if defined(CONFIG_OF) && (defined(CONFIG_BACKLIGHT_CLASS_DEVICE) || \
+			   defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE))
Quoted 6 lines
Quoted 1 line

In this case, I cannot find any build errors.

That's a neat trick. I didn't know you could do that.

However, it's bit messy consider different formatting, or a nested #ifdef instead please.

Quoted 7 lines

I guess it is a matter of me "not seeing the forrest for the trees", but how would a nested ifdef look like, as this would result in 3 possible results when for CONFIG_OF first and then for one of the BACKLIGHT_CLASS defines?

Formatting wise, when applied both defined(CONFIG_BACKLIGHT_foo) parts are exactly below each other, making it (hopefully) clear where the "or" is part of. What would look better?

Actually there is a better way still:

#ifdef CONFIG_OF && IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) struct backlight_device *of_find_backlight_by_node(struct device_node *node); #else
static inline struct backlight_device * of_find_backlight_by_node(struct device_node *node)

{
      return NULL;
}

#endif

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#8 lore raw

Hi,

Am Dienstag, 4. November 2014, 17:15:32 schrieb Lee Jones:

Quoted 11 lines

Actually there is a better way still:

#ifdef CONFIG_OF && IS_ENABLED(CONFIG_BACKLIGHT_CLASS_DEVICE) struct backlight_device *of_find_backlight_by_node(struct device_node *node); #else
static inline struct backlight_device * of_find_backlight_by_node(struct device_node *node)

{
      return NULL;
}

#endif

After further looking at the problem, I'm actually not even sure, if my approach is the best one at all.

The problem I was trying to fix was panel-simple (drivers/gpu/drm/panel/panel- simple.c) checking for an optional backlight, while not depending on the backlight-class itself.

As both components do not have a relationship, there exist the possibility of panel-simply being build into the kernel while the backlight_class is build as module. So while the IS_ENABLED check would define the prototype, panel-generic would still miss the function when linking.

Should panel-generic simply depend in the backlight_class instead?

Thanks
Heiko