All of lore.kernel.org
 help / color / mirror / Atom feed
From: jacopo mondi <jacopo@jmondi.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Lee Jones <lee.jones@linaro.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sh@vger.kernel.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device
Date: Fri, 16 Mar 2018 10:07:48 +0000	[thread overview]
Message-ID: <20180316100748.GH16424@w540> (raw)
In-Reply-To: <20180315224202.96668-3-dmitry.torokhov@gmail.com>

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

Hello Dmitry

FYI I am brushing the ecovec board these days as well
https://www.spinics.net/lists/linux-sh/msg52536.html

And I have a board to test with but without any display panel, I'm
afraid.

On Thu, Mar 15, 2018 at 03:42:00PM -0700, Dmitry Torokhov wrote:
> Commit fe79f919f47e ("sh: ecovec24: Use gpio-backlight") removed custom
> backlight support and switched over to generic gpio-backlight driver. The
> comment when we run with DVI states "no backlight", but setting
> gpio_backlight_data.fbdev to NULL actually makes gpio-backlight to react to
> events from any framebuffer device, not ignore them.
>
> We want to get rid of platform data in favor of generic device properties
> in gpio_backlight driver, so we can not have kernel pointers passed around
> to tie the framebuffer device to backlight. Assuming that the intent of the
> above referenced commit was to indeed not export backlight when using DVI,
> let's switch to conditionally registering backlight device so it is not
> present at all in DVI case.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
> index 6f929abe0b50f..67633d2d42390 100644
> --- a/arch/sh/boards/mach-ecovec24/setup.c
> +++ b/arch/sh/boards/mach-ecovec24/setup.c
> @@ -368,7 +368,6 @@ static struct platform_device lcdc_device = {
>  };
>
>  static struct gpio_backlight_platform_data gpio_backlight_data = {
> -	.fbdev = &lcdc_device.dev,
>  	.gpio = GPIO_PTR1,
>  	.def_value = 1,
>  	.name = "backlight",
> @@ -987,7 +986,6 @@ static struct platform_device *ecovec_devices[] __initdata = {
>  	&usb1_common_device,
>  	&usbhs_device,
>  	&lcdc_device,
> -	&gpio_backlight_device,
>  	&ceu0_device,
>  	&ceu1_device,
>  	&keysc_device,
> @@ -1077,6 +1075,8 @@ static int __init arch_setup(void)
>  {
>  	struct clk *clk;
>  	bool cn12_enabled = false;
> +	bool use_backlight = false;
> +	int error;
>
>  	/* register board specific self-refresh code */
>  	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
> @@ -1193,9 +1193,6 @@ static int __init arch_setup(void)
>  		lcdc_info.ch[0].lcd_modes		= ecovec_dvi_modes;
>  		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_dvi_modes);
>
> -		/* No backlight */
> -		gpio_backlight_data.fbdev = NULL;
> -
>  		gpio_set_value(GPIO_PTA2, 1);
>  		gpio_set_value(GPIO_PTU1, 1);
>  	} else {
> @@ -1217,6 +1214,8 @@ static int __init arch_setup(void)
>  		/* enable TouchScreen */
>  		i2c_register_board_info(0, &ts_i2c_clients, 1);
>  		irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
> +
> +		use_backlight = true;
>  	}
>
>  	/* enable CEU0 */
> @@ -1431,8 +1430,19 @@ static int __init arch_setup(void)
>  	gpio_set_value(GPIO_PTG4, 1);
>  #endif
>
> -	return platform_add_devices(ecovec_devices,
> -				    ARRAY_SIZE(ecovec_devices));
> +	error = platform_add_devices(ecovec_devices,
> +				      ARRAY_SIZE(ecovec_devices));

I would invert this.
Register the backlight first, then all other devices.


> +	if (error)
> +		return error;
> +
> +	if (use_backlight) {
> +		error = platform_device_add(&gpio_backlight_device);
> +		if (error)
> +			pr_warn("%s: failed to register backlight: %d\n",
> +				error);

Could you use dev_warn here? Also the format is wrong, I assume you
are missing a '__func__' as second function argument.

Also, you may want to return error.

Thanks
   j

> +	}
> +
> +	return 0;
>  }
>  arch_initcall(arch_setup);
>
> --
> 2.16.2.804.g6dcf76e118-goog
>

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

WARNING: multiple messages have this Message-ID (diff)
From: jacopo mondi <jacopo@jmondi.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>,
	Lee Jones <lee.jones@linaro.org>,
	Daniel Thompson <daniel.thompson@linaro.org>,
	Jingoo Han <jingoohan1@gmail.com>,
	linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-sh@vger.kernel.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Rich Felker <dalias@libc.org>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device
Date: Fri, 16 Mar 2018 11:07:48 +0100	[thread overview]
Message-ID: <20180316100748.GH16424@w540> (raw)
In-Reply-To: <20180315224202.96668-3-dmitry.torokhov@gmail.com>

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

Hello Dmitry

FYI I am brushing the ecovec board these days as well
https://www.spinics.net/lists/linux-sh/msg52536.html

And I have a board to test with but without any display panel, I'm
afraid.

On Thu, Mar 15, 2018 at 03:42:00PM -0700, Dmitry Torokhov wrote:
> Commit fe79f919f47e ("sh: ecovec24: Use gpio-backlight") removed custom
> backlight support and switched over to generic gpio-backlight driver. The
> comment when we run with DVI states "no backlight", but setting
> gpio_backlight_data.fbdev to NULL actually makes gpio-backlight to react to
> events from any framebuffer device, not ignore them.
>
> We want to get rid of platform data in favor of generic device properties
> in gpio_backlight driver, so we can not have kernel pointers passed around
> to tie the framebuffer device to backlight. Assuming that the intent of the
> above referenced commit was to indeed not export backlight when using DVI,
> let's switch to conditionally registering backlight device so it is not
> present at all in DVI case.
>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
> index 6f929abe0b50f..67633d2d42390 100644
> --- a/arch/sh/boards/mach-ecovec24/setup.c
> +++ b/arch/sh/boards/mach-ecovec24/setup.c
> @@ -368,7 +368,6 @@ static struct platform_device lcdc_device = {
>  };
>
>  static struct gpio_backlight_platform_data gpio_backlight_data = {
> -	.fbdev = &lcdc_device.dev,
>  	.gpio = GPIO_PTR1,
>  	.def_value = 1,
>  	.name = "backlight",
> @@ -987,7 +986,6 @@ static struct platform_device *ecovec_devices[] __initdata = {
>  	&usb1_common_device,
>  	&usbhs_device,
>  	&lcdc_device,
> -	&gpio_backlight_device,
>  	&ceu0_device,
>  	&ceu1_device,
>  	&keysc_device,
> @@ -1077,6 +1075,8 @@ static int __init arch_setup(void)
>  {
>  	struct clk *clk;
>  	bool cn12_enabled = false;
> +	bool use_backlight = false;
> +	int error;
>
>  	/* register board specific self-refresh code */
>  	sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF |
> @@ -1193,9 +1193,6 @@ static int __init arch_setup(void)
>  		lcdc_info.ch[0].lcd_modes		= ecovec_dvi_modes;
>  		lcdc_info.ch[0].num_modes		= ARRAY_SIZE(ecovec_dvi_modes);
>
> -		/* No backlight */
> -		gpio_backlight_data.fbdev = NULL;
> -
>  		gpio_set_value(GPIO_PTA2, 1);
>  		gpio_set_value(GPIO_PTU1, 1);
>  	} else {
> @@ -1217,6 +1214,8 @@ static int __init arch_setup(void)
>  		/* enable TouchScreen */
>  		i2c_register_board_info(0, &ts_i2c_clients, 1);
>  		irq_set_irq_type(IRQ0, IRQ_TYPE_LEVEL_LOW);
> +
> +		use_backlight = true;
>  	}
>
>  	/* enable CEU0 */
> @@ -1431,8 +1430,19 @@ static int __init arch_setup(void)
>  	gpio_set_value(GPIO_PTG4, 1);
>  #endif
>
> -	return platform_add_devices(ecovec_devices,
> -				    ARRAY_SIZE(ecovec_devices));
> +	error = platform_add_devices(ecovec_devices,
> +				      ARRAY_SIZE(ecovec_devices));

I would invert this.
Register the backlight first, then all other devices.


> +	if (error)
> +		return error;
> +
> +	if (use_backlight) {
> +		error = platform_device_add(&gpio_backlight_device);
> +		if (error)
> +			pr_warn("%s: failed to register backlight: %d\n",
> +				error);

Could you use dev_warn here? Also the format is wrong, I assume you
are missing a '__func__' as second function argument.

Also, you may want to return error.

Thanks
   j

> +	}
> +
> +	return 0;
>  }
>  arch_initcall(arch_setup);
>
> --
> 2.16.2.804.g6dcf76e118-goog
>

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

  reply	other threads:[~2018-03-16 10:07 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-15 22:41 [RFC 0/4] gpio-backlight: remove platform data support Dmitry Torokhov
2018-03-15 22:41 ` Dmitry Torokhov
2018-03-15 22:41 ` [RFC 1/4] backlight: gpio_backlight: use generic device properties Dmitry Torokhov
2018-03-15 22:41   ` Dmitry Torokhov
2018-03-27 11:53   ` Linus Walleij
2018-03-27 11:53     ` Linus Walleij
2018-03-15 22:42 ` [RFC 2/4] sh: ecovec24: conditionally register backlight device Dmitry Torokhov
2018-03-15 22:42   ` Dmitry Torokhov
2018-03-16 10:07   ` jacopo mondi [this message]
2018-03-16 10:07     ` jacopo mondi
2018-03-16 23:38     ` Dmitry Torokhov
2018-03-16 23:38       ` Dmitry Torokhov
2018-03-17  9:25       ` jacopo mondi
2018-03-17  9:25         ` jacopo mondi
2018-03-17 10:21         ` John Paul Adrian Glaubitz
2018-03-17 10:21           ` John Paul Adrian Glaubitz
2018-03-17 17:16           ` Rich Felker
2018-03-17 17:16             ` Rich Felker
2018-03-17 17:33             ` Dmitry Torokhov
2018-03-17 17:33               ` Dmitry Torokhov
2018-03-17 17:55             ` John Paul Adrian Glaubitz
2018-03-17 17:55               ` John Paul Adrian Glaubitz
2018-03-18 10:54           ` jacopo mondi
2018-03-18 10:54             ` jacopo mondi
2018-03-18 11:12             ` John Paul Adrian Glaubitz
2018-03-18 11:12               ` John Paul Adrian Glaubitz
2018-03-17 17:37         ` Dmitry Torokhov
2018-03-17 17:37           ` Dmitry Torokhov
2018-03-15 22:42 ` [RFC 3/4] sh: ecovec24: convert backlight to use device properties Dmitry Torokhov
2018-03-15 22:42   ` Dmitry Torokhov
2018-03-16  8:50   ` Geert Uytterhoeven
2018-03-16  8:50     ` Geert Uytterhoeven
2018-03-16 23:40     ` Dmitry Torokhov
2018-03-16 23:40       ` Dmitry Torokhov
2018-03-16 10:08   ` jacopo mondi
2018-03-16 10:08     ` jacopo mondi
2018-03-15 22:42 ` [RFC 4/4] backlight: gpio_backlight: remove platform data support Dmitry Torokhov
2018-03-15 22:42   ` Dmitry Torokhov
2018-03-27 11:55   ` Linus Walleij
2018-03-27 11:55     ` Linus Walleij
2018-03-16 11:11 ` [RFC 0/4] gpio-backlight: " Daniel Thompson
2018-03-27 11:59 ` Linus Walleij
2018-03-27 11:59   ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180316100748.GH16424@w540 \
    --to=jacopo@jmondi.org \
    --cc=dalias@libc.org \
    --cc=daniel.thompson@linaro.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jingoohan1@gmail.com \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=lee.jones@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=ysato@users.sourceforge.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.