linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency
@ 2017-04-19 17:59 Arnd Bergmann
  2017-04-19 17:59 ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Arnd Bergmann
  2017-04-19 20:21 ` [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Laurent Pinchart
  0 siblings, 2 replies; 8+ messages in thread
From: Arnd Bergmann @ 2017-04-19 17:59 UTC (permalink / raw)
  To: Tomi Valkeinen, David Airlie
  Cc: Arnd Bergmann, Laurent Pinchart, dri-devel, linux-kernel

The panel driver gained support for backlight but fails to link now
when that is disabled:

drivers/gpu/drm/omapdrm/displays/panel-dpi.o: In function `panel_dpi_probe_of':
panel-dpi.c:(.text.panel_dpi_probe_of+0xe8): undefined reference to `of_find_backlight_by_node'

This adds a dependency like we have for the other panel drivers.

Fixes: 39135a305a0f ("drm/omap: displays: panel-dpi: Support for handling backlight devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/omapdrm/displays/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/omapdrm/displays/Kconfig b/drivers/gpu/drm/omapdrm/displays/Kconfig
index c226da145fb3..a349cb61961e 100644
--- a/drivers/gpu/drm/omapdrm/displays/Kconfig
+++ b/drivers/gpu/drm/omapdrm/displays/Kconfig
@@ -35,6 +35,7 @@ config DRM_OMAP_CONNECTOR_ANALOG_TV
 
 config DRM_OMAP_PANEL_DPI
 	tristate "Generic DPI panel"
+	depends on BACKLIGHT_CLASS_DEVICE
 	help
 	  Driver for generic DPI panels.
 
-- 
2.9.0

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

* [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code
  2017-04-19 17:59 [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Arnd Bergmann
@ 2017-04-19 17:59 ` Arnd Bergmann
  2017-04-19 18:03   ` [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v Arnd Bergmann
  2017-06-14 18:13   ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Thierry Reding
  2017-04-19 20:21 ` [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Laurent Pinchart
  1 sibling, 2 replies; 8+ messages in thread
From: Arnd Bergmann @ 2017-04-19 17:59 UTC (permalink / raw)
  To: Thierry Reding, David Airlie
  Cc: Arnd Bergmann, Vinay Simha BN, Laurent Pinchart, Hoegeun Kwon,
	dri-devel, linux-kernel

The new S6E3HA2 driver fails to link when backlight is disabled:

ERROR: "backlight_device_register" [drivers/gpu/drm/panel/panel-samsung-s6e3ha2.ko] undefined!
ERROR: "backlight_device_unregister" [drivers/gpu/drm/panel/panel-samsung-s6e3ha2.ko] undefined!

This adds a Kconfig dependency like we have it for some other panel drivers.

Fixes: ed29f9426d9b ("drm/panel: Add support for S6E3HA2 panel driver on TM2 board")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/panel/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 3e29a9903303..6eb9774284df 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -66,6 +66,7 @@ config DRM_PANEL_SAMSUNG_S6E3HA2
 	tristate "Samsung S6E3HA2 DSI video mode panel"
 	depends on OF
 	depends on DRM_MIPI_DSI
+	depends on BACKLIGHT_CLASS_DEVICE
 	select VIDEOMODE_HELPERS
 
 config DRM_PANEL_SAMSUNG_S6E8AA0
-- 
2.9.0

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

* [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v
  2017-04-19 17:59 ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Arnd Bergmann
@ 2017-04-19 18:03   ` Arnd Bergmann
  2017-06-14 18:13     ` Thierry Reding
  2017-06-14 18:13   ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Thierry Reding
  1 sibling, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2017-04-19 18:03 UTC (permalink / raw)
  To: Thierry Reding, David Airlie
  Cc: Arnd Bergmann, Donghwa Lee, Hoegeun Kwon, Laurent Pinchart,
	Maxime Ripard, dri-devel, linux-kernel

Without the dependency, we run into a link error:

drivers/gpu/drm/panel/panel-sitronix-st7789v.o: In function `st7789v_probe':
panel-sitronix-st7789v.c:(.text.st7789v_probe+0xc0): undefined reference to `of_find_backlight_by_node'

Fixes: 7142afb3a186 ("drm/panel: Add driver for sitronix ST7789V LCD controller")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/panel/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 6eb9774284df..04d068177e16 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -101,6 +101,7 @@ config DRM_PANEL_SHARP_LS043T1LE01
 config DRM_PANEL_SITRONIX_ST7789V
 	tristate "Sitronix ST7789V panel"
 	depends on OF && SPI
+	depends on BACKLIGHT_CLASS_DEVICE
 	help
 	  Say Y here if you want to enable support for the Sitronix
 	  ST7789V controller for 240x320 LCD panels
-- 
2.9.0

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

* Re: [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency
  2017-04-19 17:59 [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Arnd Bergmann
  2017-04-19 17:59 ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Arnd Bergmann
@ 2017-04-19 20:21 ` Laurent Pinchart
  2017-04-19 20:39   ` Arnd Bergmann
  1 sibling, 1 reply; 8+ messages in thread
From: Laurent Pinchart @ 2017-04-19 20:21 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Tomi Valkeinen, David Airlie, dri-devel, linux-kernel

Hi Arnd,

Thank you for the patch.

On Wednesday 19 Apr 2017 19:59:17 Arnd Bergmann wrote:
> The panel driver gained support for backlight but fails to link now
> when that is disabled:
> 
> drivers/gpu/drm/omapdrm/displays/panel-dpi.o: In function
> `panel_dpi_probe_of': panel-dpi.c:(.text.panel_dpi_probe_of+0xe8):
> undefined reference to `of_find_backlight_by_node'
> 
> This adds a dependency like we have for the other panel drivers.

I believe the dependency should be made optional. DPI panels that don't need 
backlight control should be supported by a kernel that has backlight support 
compiled out. How about something like

>From 07a98ab23b2080c79abbf8b5e7479123c50e6be7 Mon Sep 17 00:00:00 2001
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Date: Wed, 19 Apr 2017 23:13:43 +0300
Subject: [PATCH] backlight: Define API stub when backlight support is disabled

The of_find_backlight_by_node() function has a stubbed when CONFIG_OF is
disabled, but drivers that use backlights optionally will still fail to
link if backlight support is disabled. Fix it by defining the stub when
CONFIG_BACKLIGHT_CLASS_DEVICE is disabled.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 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 5f2fd61ef4fb..fae0b189f7b4 100644
--- a/include/linux/backlight.h
+++ b/include/linux/backlight.h
@@ -162,7 +162,7 @@ struct generic_bl_info {
 	void (*kick_battery)(void);
 };
 
-#ifdef CONFIG_OF
+#if IS_ENABLED(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 *


We might need to create stubs for backlight_force_update() and 
backlight_device_set_brightness() too.

> Fixes: 39135a305a0f ("drm/omap: displays: panel-dpi: Support for handling
> backlight devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/omapdrm/displays/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpu/drm/omapdrm/displays/Kconfig
> b/drivers/gpu/drm/omapdrm/displays/Kconfig index c226da145fb3..a349cb61961e
> 100644
> --- a/drivers/gpu/drm/omapdrm/displays/Kconfig
> +++ b/drivers/gpu/drm/omapdrm/displays/Kconfig
> @@ -35,6 +35,7 @@ config DRM_OMAP_CONNECTOR_ANALOG_TV
> 
>  config DRM_OMAP_PANEL_DPI
>  	tristate "Generic DPI panel"
> +	depends on BACKLIGHT_CLASS_DEVICE
>  	help
>  	  Driver for generic DPI panels.

-- 
Regards,

Laurent Pinchart

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

* Re: [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency
  2017-04-19 20:21 ` [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Laurent Pinchart
@ 2017-04-19 20:39   ` Arnd Bergmann
  2017-04-20  9:01     ` Jani Nikula
  0 siblings, 1 reply; 8+ messages in thread
From: Arnd Bergmann @ 2017-04-19 20:39 UTC (permalink / raw)
  To: Laurent Pinchart
  Cc: Tomi Valkeinen, David Airlie, dri-devel, Linux Kernel Mailing List

On Wed, Apr 19, 2017 at 10:21 PM, Laurent Pinchart
<laurent.pinchart@ideasonboard.com> wrote:
>>
>> This adds a dependency like we have for the other panel drivers.
>
> I believe the dependency should be made optional. DPI panels that don't need
> backlight control should be supported by a kernel that has backlight support
> compiled out.

That would be nice in principle, but I fear this would cause additional
problems.

> --- a/include/linux/backlight.h
> +++ b/include/linux/backlight.h
> @@ -162,7 +162,7 @@ struct generic_bl_info {
>         void (*kick_battery)(void);
>  };
>
> -#ifdef CONFIG_OF
> +#if IS_ENABLED(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 *
>
>
> We might need to create stubs for backlight_force_update() and
> backlight_device_set_brightness() too.
>

With BACKLIGHT_CLASS_DEVICE=m, you still get a link error when the user is
in a built-in driver. Using 'depends on' usually solves this (except for drivers
that cannot be modules).

There are three possible workarounds for this that I can think of:

- Use 'depends on BACKLIGHT_CLASS_DEVICE || BACKLIGHT_CLASS_DEVICE=n'
  in each driver that implements optional backlight support. We do
this elsewhere, but
  it's confusing and easy to get wrong.

- use IS_REACHABLE() instead of IS_ENABLED() when testing for
  backlight support. This will always result in a kernel that builds cleanly,
  but can be surprising for users when backlight support is a module that
  gets loaded at boot, but it is still not used.

- Make BACKLIGHT_CLASS_DEVICE a 'bool' symbol instead, and force the
  core API code to always be built-in or completely disabled. This makes
  it really easy to use, at the expense of a larger kernel image for those that
  currently use a loadable module.

       Arnd

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

* Re: [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency
  2017-04-19 20:39   ` Arnd Bergmann
@ 2017-04-20  9:01     ` Jani Nikula
  0 siblings, 0 replies; 8+ messages in thread
From: Jani Nikula @ 2017-04-20  9:01 UTC (permalink / raw)
  To: Arnd Bergmann, Laurent Pinchart
  Cc: Tomi Valkeinen, Linux Kernel Mailing List, dri-devel

On Wed, 19 Apr 2017, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wed, Apr 19, 2017 at 10:21 PM, Laurent Pinchart
> <laurent.pinchart@ideasonboard.com> wrote:
>>>
>>> This adds a dependency like we have for the other panel drivers.
>>
>> I believe the dependency should be made optional. DPI panels that don't need
>> backlight control should be supported by a kernel that has backlight support
>> compiled out.
>
> That would be nice in principle, but I fear this would cause additional
> problems.
>
>> --- a/include/linux/backlight.h
>> +++ b/include/linux/backlight.h
>> @@ -162,7 +162,7 @@ struct generic_bl_info {
>>         void (*kick_battery)(void);
>>  };
>>
>> -#ifdef CONFIG_OF
>> +#if IS_ENABLED(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 *
>>
>>
>> We might need to create stubs for backlight_force_update() and
>> backlight_device_set_brightness() too.
>>
>
> With BACKLIGHT_CLASS_DEVICE=m, you still get a link error when the user is
> in a built-in driver. Using 'depends on' usually solves this (except for drivers
> that cannot be modules).
>
> There are three possible workarounds for this that I can think of:
>
> - Use 'depends on BACKLIGHT_CLASS_DEVICE || BACKLIGHT_CLASS_DEVICE=n'
>   in each driver that implements optional backlight support. We do
> this elsewhere, but
>   it's confusing and easy to get wrong.

FWIW I think this is the fix, and not a workaround.

"depends on FOO || FOO=n" is an expression used throughout the kernel,
and it accurately describes the dependency here. Of course, all drivers
implementing this must still wrap backlight class usage around
IS_ENABLED().

BR,
Jani.

>
> - use IS_REACHABLE() instead of IS_ENABLED() when testing for
>   backlight support. This will always result in a kernel that builds cleanly,
>   but can be surprising for users when backlight support is a module that
>   gets loaded at boot, but it is still not used.
>
> - Make BACKLIGHT_CLASS_DEVICE a 'bool' symbol instead, and force the
>   core API code to always be built-in or completely disabled. This makes
>   it really easy to use, at the expense of a larger kernel image for those that
>   currently use a loadable module.
>
>        Arnd
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Jani Nikula, Intel Open Source Technology Center

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

* Re: [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code
  2017-04-19 17:59 ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Arnd Bergmann
  2017-04-19 18:03   ` [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v Arnd Bergmann
@ 2017-06-14 18:13   ` Thierry Reding
  1 sibling, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2017-06-14 18:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David Airlie, Vinay Simha BN, Laurent Pinchart, Hoegeun Kwon,
	dri-devel, linux-kernel

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

On Wed, Apr 19, 2017 at 07:59:18PM +0200, Arnd Bergmann wrote:
> The new S6E3HA2 driver fails to link when backlight is disabled:
> 
> ERROR: "backlight_device_register" [drivers/gpu/drm/panel/panel-samsung-s6e3ha2.ko] undefined!
> ERROR: "backlight_device_unregister" [drivers/gpu/drm/panel/panel-samsung-s6e3ha2.ko] undefined!
> 
> This adds a Kconfig dependency like we have it for some other panel drivers.
> 
> Fixes: ed29f9426d9b ("drm/panel: Add support for S6E3HA2 panel driver on TM2 board")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/panel/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Applied to drm-misc-next, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v
  2017-04-19 18:03   ` [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v Arnd Bergmann
@ 2017-06-14 18:13     ` Thierry Reding
  0 siblings, 0 replies; 8+ messages in thread
From: Thierry Reding @ 2017-06-14 18:13 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David Airlie, Donghwa Lee, Hoegeun Kwon, Laurent Pinchart,
	Maxime Ripard, dri-devel, linux-kernel

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

On Wed, Apr 19, 2017 at 08:03:08PM +0200, Arnd Bergmann wrote:
> Without the dependency, we run into a link error:
> 
> drivers/gpu/drm/panel/panel-sitronix-st7789v.o: In function `st7789v_probe':
> panel-sitronix-st7789v.c:(.text.st7789v_probe+0xc0): undefined reference to `of_find_backlight_by_node'
> 
> Fixes: 7142afb3a186 ("drm/panel: Add driver for sitronix ST7789V LCD controller")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/gpu/drm/panel/Kconfig | 1 +
>  1 file changed, 1 insertion(+)

Applied to drm-misc-next, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-06-14 18:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-19 17:59 [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Arnd Bergmann
2017-04-19 17:59 ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Arnd Bergmann
2017-04-19 18:03   ` [PATCH 3/3] drm/panel: add backlight dependency for sitronix-st7789v Arnd Bergmann
2017-06-14 18:13     ` Thierry Reding
2017-06-14 18:13   ` [PATCH 2/3] drm/panel: S6E3HA2 needs backlight code Thierry Reding
2017-04-19 20:21 ` [PATCH 1/3] drm/omap: displays: panel-dpi: add backlight dependency Laurent Pinchart
2017-04-19 20:39   ` Arnd Bergmann
2017-04-20  9:01     ` Jani Nikula

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