linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
@ 2014-10-29  0:20 Heiko Stübner
  2014-10-30  4:44 ` Jingoo Han
  2014-11-03 17:17 ` Lee Jones
  0 siblings, 2 replies; 9+ messages in thread
From: Heiko Stübner @ 2014-10-29  0:20 UTC (permalink / raw)
  To: Jingoo Han, Bryan Wu, Lee Jones; +Cc: linux-kernel

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 <heiko@sntech.de>
---
 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



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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-10-29  0:20 [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled Heiko Stübner
@ 2014-10-30  4:44 ` Jingoo Han
  2014-11-03 17:17 ` Lee Jones
  1 sibling, 0 replies; 9+ messages in thread
From: Jingoo Han @ 2014-10-30  4:44 UTC (permalink / raw)
  To: 'Heiko Stübner'
  Cc: 'Bryan Wu', 'Lee Jones',
	linux-kernel, 'Jingoo Han'

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 <heiko@sntech.de>

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 <jg1.han@samsung.com>

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



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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-10-29  0:20 [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled Heiko Stübner
  2014-10-30  4:44 ` Jingoo Han
@ 2014-11-03 17:17 ` Lee Jones
  2014-11-04  9:07   ` Lee Jones
  1 sibling, 1 reply; 9+ messages in thread
From: Lee Jones @ 2014-11-03 17:17 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: Jingoo Han, Bryan Wu, linux-kernel

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 <heiko@sntech.de>
> ---
>  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

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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-03 17:17 ` Lee Jones
@ 2014-11-04  9:07   ` Lee Jones
  2014-11-04 10:18     ` Jingoo Han
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2014-11-04  9:07 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: Jingoo Han, Bryan Wu, linux-kernel

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 <heiko@sntech.de>
> > ---
> >  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

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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-04  9:07   ` Lee Jones
@ 2014-11-04 10:18     ` Jingoo Han
  2014-11-04 14:42       ` Lee Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Jingoo Han @ 2014-11-04 10:18 UTC (permalink / raw)
  To: 'Lee Jones', 'Heiko Stübner'
  Cc: 'Bryan Wu', linux-kernel, 'Jingoo Han'

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 <heiko@sntech.de>
> > > ---
> > >  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


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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-04 10:18     ` Jingoo Han
@ 2014-11-04 14:42       ` Lee Jones
  2014-11-04 15:02         ` Heiko Stübner
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2014-11-04 14:42 UTC (permalink / raw)
  To: Jingoo Han; +Cc: 'Heiko Stübner', 'Bryan Wu', linux-kernel

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 <heiko@sntech.de>
> > > > ---
> > > >  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

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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-04 14:42       ` Lee Jones
@ 2014-11-04 15:02         ` Heiko Stübner
  2014-11-04 17:15           ` Lee Jones
  0 siblings, 1 reply; 9+ messages in thread
From: Heiko Stübner @ 2014-11-04 15:02 UTC (permalink / raw)
  To: Lee Jones; +Cc: Jingoo Han, 'Bryan Wu', linux-kernel

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 <heiko@sntech.de>
> > > > > ---
> > > > > 
> > > > >  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

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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-04 15:02         ` Heiko Stübner
@ 2014-11-04 17:15           ` Lee Jones
  2014-11-10 23:41             ` Heiko Stübner
  0 siblings, 1 reply; 9+ messages in thread
From: Lee Jones @ 2014-11-04 17:15 UTC (permalink / raw)
  To: Heiko Stübner; +Cc: Jingoo Han, 'Bryan Wu', linux-kernel

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 <heiko@sntech.de>
> > > > > > ---
> > > > > > 
> > > > > >  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

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

* Re: [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled
  2014-11-04 17:15           ` Lee Jones
@ 2014-11-10 23:41             ` Heiko Stübner
  0 siblings, 0 replies; 9+ messages in thread
From: Heiko Stübner @ 2014-11-10 23:41 UTC (permalink / raw)
  To: Lee Jones; +Cc: Jingoo Han, 'Bryan Wu', linux-kernel

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

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

end of thread, other threads:[~2014-11-10 23:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-29  0:20 [PATCH] backlight: use of_find_backlight_by_node stub when backlight class disabled Heiko Stübner
2014-10-30  4:44 ` Jingoo Han
2014-11-03 17:17 ` Lee Jones
2014-11-04  9:07   ` Lee Jones
2014-11-04 10:18     ` Jingoo Han
2014-11-04 14:42       ` Lee Jones
2014-11-04 15:02         ` Heiko Stübner
2014-11-04 17:15           ` Lee Jones
2014-11-10 23:41             ` Heiko Stübner

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