2014-10-29 00:16:56

by Heiko Stuebner

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Heiko Stuebner <[email protected]>
---
include/linux/backlight.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/backlight.h b/include/linux/backlight.h
index adb14a8..d9cb644 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -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


2014-10-30 04:43:56

by Jingoo Han

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Wednesday, October 29, 2014 9:20 AM, Heiko St?bner wrote:
>
> 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.
>
> Signed-off-by: Heiko Stuebner <[email protected]>

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.

Acked-by: Jingoo Han <[email protected]>

Best regards,
Jingoo Han

> ---
> include/linux/backlight.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index adb14a8..d9cb644 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -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

2014-11-03 17:17:39

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Wed, 29 Oct 2014, Heiko Stübner wrote:

> 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.
>
> Signed-off-by: Heiko Stuebner <[email protected]>
> ---
> include/linux/backlight.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to Backlight -next with Jingoo's Ack.

> diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> index adb14a8..d9cb644 100644
> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -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 *

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2014-11-04 09:08:05

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Mon, 03 Nov 2014, Lee Jones wrote:

> On Wed, 29 Oct 2014, Heiko Stübner wrote:
>
> > 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.
> >
> > Signed-off-by: Heiko Stuebner <[email protected]>
> > ---
> > 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.

> > diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> > index adb14a8..d9cb644 100644
> > --- a/include/linux/backlight.h
> > +++ b/include/linux/backlight.h
> > @@ -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 *
>

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2014-11-04 10:18:35

by Jingoo Han

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Tuesday, November 04, 2014 6:08 PM, Heiko Stübner wrote:
> On Mon, 03 Nov 2014, Lee Jones wrote:
>
> > On Wed, 29 Oct 2014, Heiko Stübner wrote:
> >
> > > 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.
> > >
> > > Signed-off-by: Heiko Stuebner <[email protected]>
> > > ---
> > > 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.

-#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

>
> ... 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.
>
> > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> > > index adb14a8..d9cb644 100644
> > > --- a/include/linux/backlight.h
> > > +++ b/include/linux/backlight.h
> > > @@ -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 *
> >
>
> --
> Lee Jones
> Linaro STMicroelectronics Landing Team Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

2014-11-04 14:42:30

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Tue, 04 Nov 2014, Jingoo Han wrote:

> On Tuesday, November 04, 2014 6:08 PM, Heiko Stübner wrote:
> > On Mon, 03 Nov 2014, Lee Jones wrote:
> >
> > > On Wed, 29 Oct 2014, Heiko Stübner wrote:
> > >
> > > > 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.
> > > >
> > > > Signed-off-by: Heiko Stuebner <[email protected]>
> > > > ---
> > > > 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.
>
> -#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.

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.

> > ... 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.
> >
> > > > diff --git a/include/linux/backlight.h b/include/linux/backlight.h
> > > > index adb14a8..d9cb644 100644
> > > > --- a/include/linux/backlight.h
> > > > +++ b/include/linux/backlight.h
> > > > @@ -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 *
> > >
> >
>

--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2014-11-04 14:59:14

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

Am Dienstag, 4. November 2014, 14:42:20 schrieb Lee Jones:
> On Tue, 04 Nov 2014, Jingoo Han wrote:
> > On Tuesday, November 04, 2014 6:08 PM, Heiko St?bner wrote:
> > > On Mon, 03 Nov 2014, Lee Jones wrote:
> > > > On Wed, 29 Oct 2014, Heiko St?bner wrote:
> > > > > 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.
> > > > >
> > > > > Signed-off-by: Heiko Stuebner <[email protected]>
> > > > > ---
> > > > >
> > > > > 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.
> >
> > -#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.
>
> 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

2014-11-04 17:15:49

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

On Tue, 04 Nov 2014, Heiko Stübner wrote:

> Am Dienstag, 4. November 2014, 14:42:20 schrieb Lee Jones:
> > On Tue, 04 Nov 2014, Jingoo Han wrote:
> > > On Tuesday, November 04, 2014 6:08 PM, Heiko Stübner wrote:
> > > > On Mon, 03 Nov 2014, Lee Jones wrote:
> > > > > On Wed, 29 Oct 2014, Heiko Stübner wrote:
> > > > > > 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.
> > > > > >
> > > > > > Signed-off-by: Heiko Stuebner <[email protected]>
> > > > > > ---
> > > > > >
> > > > > > 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.
> > >
> > > -#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.
> >
> > 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?

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


--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2014-11-10 23:37:44

by Heiko Stuebner

[permalink] [raw]
Subject: Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled

Hi,

Am Dienstag, 4. November 2014, 17:15:32 schrieb Lee Jones:
> 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