Skip to contentSkip to conversation

gpio-backlight: remove platform data support

RFC In review Dmitry Torokhov 7 participants 22 messages Mar 15, 2018 – Mar 27, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover gpio-backlight: remove platform data support

Hi,

This series attempts to remove platform data support from gpio_blackllist driver and switch it over to generic device properties/GPIO tables. The only user of platform data was SuperH Ecovec24 board; please take a look at patch #2 that tries to only register backlight when the board is using LDC and not DVI.

Please note that I do not have the hardware (do we even care about ecovec24? I'd like to rip out platform data support from tsc2007 as well, but ecovec24 is using custom pendown handler and GPIOs have to be switched off from interrupt mode to GPIO and back in that pendown handler, which is all quite messy. If we do not care about this board I'd much rather removed that custom pendown).

Thanks!

Dmitry Torokhov (4):
backlight: gpio_backlight: use generic device properties
sh: ecovec24: conditionally register backlight device
sh: ecovec24: convert backlight to use device properties
backlight: gpio_backlight: remove platform data support

 arch/sh/boards/mach-ecovec24/setup.c         | 47 ++++++----
 drivers/video/backlight/gpio_backlight.c     | 93 +++-----------------
 include/linux/platform_data/gpio_backlight.h | 20 -----
 3 files changed, 46 insertions(+), 114 deletions(-)
 delete mode 100644 include/linux/platform_data/gpio_backlight.h
Signature · 1 line
Dmitry
#1 lore raw

RFC 1/4 backlight: gpio_backlight: use generic device properties

Instead of using of_property_read_bool() switch to using device_property_read_bool() This will allow switching from platform data to device properties everywhere.

---
 drivers/video/backlight/gpio_backlight.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)
drivers/video/backlight/gpio_backlight.c +2 -10
index e470da95d806f..173fc4aafb89b 100644
@@ -61,11 +61,10 @@ static int gpio_backlight_probe_dt(struct platform_device *pdev,
 				   struct gpio_backlight *gbl)
 {
 	struct device *dev = &pdev->dev;
-	struct device_node *np = dev->of_node;
 	enum gpiod_flags flags;
 	int ret;
 
-	gbl->def_value = of_property_read_bool(np, "default-on");
+	gbl->def_value = device_property_read_bool(dev, "default-on");
 	flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
 
 	gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
@@ -89,22 +88,15 @@ static int gpio_backlight_probe(struct platform_device *pdev)
 	struct backlight_properties props;
 	struct backlight_device *bl;
 	struct gpio_backlight *gbl;
-	struct device_node *np = pdev->dev.of_node;
 	int ret;
 
-	if (!pdata && !np) {
-		dev_err(&pdev->dev,
-			"failed to find platform data or device tree node.\n");
-		return -ENODEV;
-	}
-
 	gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
 	if (gbl = NULL)
 		return -ENOMEM;
 
 	gbl->dev = &pdev->dev;
 
-	if (np) {
+	if (!pdata) {
 		ret = gpio_backlight_probe_dt(pdev, gbl);
 		if (ret)
 			return ret;
Signature · 1 line
2.16.2.804.g6dcf76e118-goog
Reviewed-by on v1 1/4
#2 lore raw

Re: [RFC 1/4] backlight: gpio_backlight: use generic device properties

Quoted 5 lines · Dmitry Torokhov

Instead of using of_property_read_bool() switch to using device_property_read_bool() This will allow switching from platform data to device properties everywhere.

Looks good to me.

Yours,
Linus Walleij

#3 lore raw

RFC 2/4 sh: ecovec24: conditionally register backlight device

In reply to Dmitry Torokhov

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.

---
 arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +17 -7
index 6f929abe0b50f..67633d2d42390 100644
@@ -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));
+	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);
+	}
+
+	return 0;
 }
 arch_initcall(arch_setup);
 
Signature · 1 line
2.16.2.804.g6dcf76e118-goog
#4 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

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.

Quoted 67 lines · Dmitry Torokhov

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.

---
 arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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 */

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 7 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
@@ -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.

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1442

Quoted 8 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+	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

Quoted 9 lines
arch/sh/boards/mach-ecovec24/setup.c +3 -1
+	}
+
+	return 0;
 }
 arch_initcall(arch_setup);
 
--

2.16.2.804.g6dcf76e118-goog

#5 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

Hi Jacopo,

Quoted 5 lines · jacopo mondi

Hello Dmitry

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

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Quoted 74 lines

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

Quoted 70 lines · Dmitry Torokhov

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.

---
 arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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
 
Quoted 7 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 4 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
-	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.

We could do that, but why would that be better?

Quoted 12 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1442

Quoted 10 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+	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

I would rather not, as the backlight device would be in unknown state here, and using dev_warn with device that has not been fully registered does not give any benefits. There is also no ambiguity as there is only one backlight.

Quoted 1 line

are missing a '__func__' as second function argument.

I'll fix this.

Quoted 2 lines

Also, you may want to return error.

How would caller handle this error? Should we kill all successfully registered devices on error adding backlight?

Thanks.

Signature · 1 line
Dmitry
#6 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

Hi Dmitry,

Quoted 11 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 5 lines · jacopo mondi

Hello Dmitry

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

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Quoted 82 lines
Quoted 74 lines

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

Quoted 70 lines · Dmitry Torokhov

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.

---
 arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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
 
Quoted 7 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 4 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
-	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.

Quoted 2 lines

We could do that, but why would that be better?

That if backlight device registration fails we do not register all other devices. But yes that may be a bit too harsh, isn't it?

Quoted 13 lines
Quoted 12 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1442

Quoted 10 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+	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

Quoted 4 lines

I would rather not, as the backlight device would be in unknown state here, and using dev_warn with device that has not been fully registered does not give any benefits. There is also no ambiguity as there is only one backlight.

You are very correct, sorry for the fuss.

Quoted 10 lines
Quoted 2 lines

are missing a '__func__' as second function argument.

I'll fix this.

Quoted 2 lines

Also, you may want to return error.

How would caller handle this error? Should we kill all successfully registered devices on error adding backlight?

As the function returned an error code for 'platform_add_devices()' I thought we may want to return one as well. That's why I proposed to invert the registration order :)

All minor nits btw, sorry for jumping up, I understand this is an RFC and ecovec board file is not the real juice of this series ;)

Ping me if I can help with testing as I've the board.

Thanks
j

Quoted 5 lines

Thanks.

Signature · 1 line
Dmitry
#7 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

Quoted 16 lines · jacopo mondi

Hi Dmitry,

Quoted 10 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 6 lines · jacopo mondi

Hello Dmitry

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

Quoted 6 lines
Quoted 2 lines

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Umh, but I’m still using the SH7724 Evovec board. Please don’t remove support for that.

The SuperH port of the Linux kernel is still maintained.

Adrian

Quoted 141 lines
Quoted 83 lines
Quoted 75 lines

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

Quoted 71 lines · Dmitry Torokhov

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.

---
arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------

1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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
 
Quoted 7 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 4 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
-    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.

Quoted 2 lines

We could do that, but why would that be better?

That if backlight device registration fails we do not register all other devices. But yes that may be a bit too harsh, isn't it?

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+    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);
Quoted 6 lines
Quoted 1 line

Could you use dev_warn here? Also the format is wrong, I assume you

I would rather not, as the backlight device would be in unknown state here, and using dev_warn with device that has not been fully registered does not give any benefits. There is also no ambiguity as there is only one backlight.

You are very correct, sorry for the fuss.

Quoted 10 lines
Quoted 2 lines

are missing a '__func__' as second function argument.

I'll fix this.

Quoted 2 lines

Also, you may want to return error.

How would caller handle this error? Should we kill all successfully registered devices on error adding backlight?

As the function returned an error code for 'platform_add_devices()' I thought we may want to return one as well. That's why I proposed to invert the registration order :)

All minor nits btw, sorry for jumping up, I understand this is an RFC and ecovec board file is not the real juice of this series ;)

Ping me if I can help with testing as I've the board.

Thanks
j

Quoted 5 lines

Thanks.

Signature · 1 line
Dmitry

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

Quoted 19 lines · John Paul Adrian Glaubitz
Quoted 19 lines · jacopo mondi

Hi Dmitry,

Quoted 12 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 6 lines · jacopo mondi

Hello Dmitry

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

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Quoted 8 lines
Quoted 3 lines

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Umh, but I’m still using the SH7724 Evovec board. Please don’t remove support for that.

The SuperH port of the Linux kernel is still maintained.

Thanks. At some point it would be nice to remove the board file, but only once the conversion to device tree happens. If anyone has a list of boards that people are still using or have access to and who can do testing, it would be nice to compile that somewhere so we can figure out what needs to be tested and who can test it.

Rich

#9 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

Quoted 27 lines · Rich Felker
Quoted 26 lines · John Paul Adrian Glaubitz
Quoted 16 lines · jacopo mondi

Hi Dmitry,

Quoted 10 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 6 lines · jacopo mondi

Hello Dmitry

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

Quoted 6 lines
Quoted 2 lines

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Umh, but I’m still using the SH7724 Evovec board. Please don’t remove support for that.

Quoted 7 lines
Quoted 1 line

The SuperH port of the Linux kernel is still maintained.

Thanks. At some point it would be nice to remove the board file, but only once the conversion to device tree happens. If anyone has a list of boards that people are still using or have access to and who can do testing, it would be nice to compile that somewhere so we can figure out what needs to be tested and who can test it.

For me I simply want to remove the custom "pen down" handler for tsc2007 from ecovec24. Unfortunately it seems with the current code you have to switch from interrupt delivery to GPIO access on the board and it is not really compatible with common handler and ecovec24 is the only board that needs this custom handler support. If we can remove it then we can switch the driver to use generic device properties only.

Note that the driver is still functional without the pendown handler, it uses alternative methods for detecting lifting the pen, but they are less reliable. I wonder how many people use ecovec24 with the touchscreen.

Thanks.

Signature · 1 line
Dmitry
#10 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

In reply to Rich Felker
Quoted 10 lines · Rich Felker
Quoted 4 lines

Umh, but I’m still using the SH7724 Evovec board. Please don’t remove support for that.

The SuperH port of the Linux kernel is still maintained.

Thanks. At some point it would be nice to remove the board file, but only once the conversion to device tree happens. If anyone has a list of boards that people are still using or have access to and who can do testing, it would be nice to compile that somewhere so we can figure out what needs to be tested and who can test it.

We should maybe create a wiki page somewhere. Either in the kernel wiki (I don't have an account for that) or the Debian Wiki.

Here's what I still use:

- Renesas SH7724 Evovec
- Renesas SH7786LCR Evaluation Board
- LANDISK SH7751
- Sega Dreamcast (although I currently don't use that)
- NextVoD (currently not in the kernel)

Adrian

Signature · 4 lines
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913
#11 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

In reply to John Paul Adrian Glaubitz

Hi Andrian,

Quoted 19 lines · John Paul Adrian Glaubitz
Quoted 19 lines · jacopo mondi

Hi Dmitry,

Quoted 12 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 6 lines · jacopo mondi

Hello Dmitry

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

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Quoted 7 lines
Quoted 3 lines

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Umh, but I’m still using the SH7724 Evovec board. Please don’t remove support for that.

The SuperH port of the Linux kernel is still maintained.

Sorry if I was not clear here, it is not anyone's intention to remove any support for any SH board. The media subsystem is working to replace some components (the legacy camera drivers) a few SH boards (ecovec included) are the only remaining user of. Nobody is working to remove support for those boards.

I have access to a few SH boards, if you're planning to collect that informations in some wiki, I'll list myself there.

Thanks
j

Quoted 145 lines

Adrian

Quoted 141 lines
Quoted 83 lines
Quoted 75 lines

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

Quoted 71 lines · Dmitry Torokhov

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.

---
arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------

1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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
 
Quoted 7 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 4 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
-    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.

Quoted 2 lines

We could do that, but why would that be better?

That if backlight device registration fails we do not register all other devices. But yes that may be a bit too harsh, isn't it?

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+    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);
Quoted 6 lines
Quoted 1 line

Could you use dev_warn here? Also the format is wrong, I assume you

I would rather not, as the backlight device would be in unknown state here, and using dev_warn with device that has not been fully registered does not give any benefits. There is also no ambiguity as there is only one backlight.

You are very correct, sorry for the fuss.

Quoted 10 lines
Quoted 2 lines

are missing a '__func__' as second function argument.

I'll fix this.

Quoted 2 lines

Also, you may want to return error.

How would caller handle this error? Should we kill all successfully registered devices on error adding backlight?

As the function returned an error code for 'platform_add_devices()' I thought we may want to return one as well. That's why I proposed to invert the registration order :)

All minor nits btw, sorry for jumping up, I understand this is an RFC and ecovec board file is not the real juice of this series ;)

Ping me if I can help with testing as I've the board.

Thanks
j

Quoted 5 lines

Thanks.

--
Dmitry

--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#12 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Hi Jacopo!

Quoted 3 lines · jacopo mondi

Sorry if I was not clear here, it is not anyone's intention to remove any support for any SH board. The media subsystem is working to replace some components (the legacy camera drivers) a few SH boards (ecovec included) are the only remaining user of. Nobody is working to remove support for those boards.

Ok, I am very relieved to hear that. I have invested a lot of work and effort into Debian's SuperH port and I therefore hope we can still keep it for a while.

FWIW, I will send out free ST-40 SuperH development boxes to anyone who is is willing to work on the SH kernel :-).

Quoted 1 line

I have access to a few SH boards, if you're planning to collect that informations in some wiki, I'll list myself there.

I'll find the proper wiki to post this information. I need to figure out what I need to get an account for the kernel.org wiki.

Adrian

- --

 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer - [email protected]
`. `'   Freie Universitaet Berlin - [email protected]
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEYv+KdYTgKVaVRgAGdCY7N/W1+RMFAlquSYcACgkQdCY7N/W1 +RPkZBAAt2dXvx99JoE/X2O3Gsg+v5w682u/bglBBN+IBtFtlE4ARMBrJnyd9I7L x/a0pDsEBuU1AIy2I6gcLc84ekd1A42qfsh4pISXKhMfDFFVBsxhbk0wbH7tyAqk EWI7aQsBUVrrDl4pn0CRy0tirRBBabG6U+AiVYVdrxbNBKVMrQlfwf+Y1Ez7fAsP 3gEet5qNYJsQ0ofzQIXIr6i/sXYPL+rovPIRIBsvuvmmaGGvKmbe8PgFehcX1dbj uPij8bgvfrEcT85hOi3MoCnBd5o1vEbtvfh5aBK4DIIZaAKMXmhDS0fhgQEYerv2 EaxzPkdMmhbd8N5T/DcIbaCoVPPDDDn/PFK1hSwN/lpL4n7ouQPjjA87qwPLbX7o vfyoAsohtp1qKtepbp+x5CfjCwqeWu7qzaxjUF3tzAorH+wUUDsOKn2dKGHv7Vlr LtE+IdO2eJPzZpcmZ0e86bn0YNk7ZtVmDMhdyUfbkI4ZkrO3ANJz4Ed+9vJPzAo7 YKZXI1DHJSd33bpAUtNE1Os9DMLqpuMIYxxGPENhEwcvVo5Ftix8NkviHbQxwLbY GH36VySCqzkYSt6HUavv5W+N9v4T24pvHx9r+D4f6ACiMT17OtVwS5PMjPcARM5/ Ftp3D9JX8ZRMpktGMuUx18Hhm9wnAwhXK28vFoq6u5TLvVkmnu8=2O6i -----END PGP SIGNATURE-----

#13 lore raw

Re: [RFC 2/4] sh: ecovec24: conditionally register backlight device

In reply to jacopo mondi
Quoted 101 lines · jacopo mondi

Hi Dmitry,

Quoted 11 lines · Dmitry Torokhov

Hi Jacopo,

Quoted 5 lines · jacopo mondi

Hello Dmitry

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

What is the ecovec board BTW? Is it some devkit or what? It seems quite old to me.

Yes, it is a SuperH 4 based development board. It is old for sure. I'm also working on removing some stuff the ecovec board file is the only user of...

Quoted 82 lines
Quoted 81 lines

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

Quoted 67 lines · Dmitry Torokhov

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.

---
 arch/sh/boards/mach-ecovec24/setup.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +4 -5
index 6f929abe0b50f..67633d2d42390 100644
@@ -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 */

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1434

Quoted 7 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -2
@@ -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.

Quoted 5 lines
Quoted 2 lines

We could do that, but why would that be better?

That if backlight device registration fails we do not register all other devices. But yes that may be a bit too harsh, isn't it?

Yes, that was my reasoning. With platform_add_devices() that unwinds all the devices it created successfully we do not really have any option but return error (which is either ignored or fatal). Here we can simply warn and still let the device boot so users have easier way to see what went wrong.

Quoted 32 lines
Quoted 14 lines
Quoted 13 lines

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1442

Quoted 11 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+	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

Quoted 4 lines

I would rather not, as the backlight device would be in unknown state here, and using dev_warn with device that has not been fully registered does not give any benefits. There is also no ambiguity as there is only one backlight.

You are very correct, sorry for the fuss.

Quoted 10 lines
Quoted 2 lines

are missing a '__func__' as second function argument.

I'll fix this.

Quoted 2 lines

Also, you may want to return error.

How would caller handle this error? Should we kill all successfully registered devices on error adding backlight?

Quoted 8 lines

As the function returned an error code for 'platform_add_devices()' I thought we may want to return one as well. That's why I proposed to invert the registration order :)

All minor nits btw, sorry for jumping up, I understand this is an RFC and ecovec board file is not the real juice of this series ;)

Ping me if I can help with testing as I've the board.

Yes, I'll fix up the other mess ups and I'll post a v2.

Thanks!

Signature · 1 line
Dmitry
#14 lore raw

RFC 3/4 sh: ecovec24: convert backlight to use device properties

In reply to Dmitry Torokhov

Instead of backlight legacy platform data, let's switch to using device properties and GPIO lookup tables.

---
 arch/sh/boards/mach-ecovec24/setup.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +15 -8
index 67633d2d42390..ad3d48b3ead19 100644
@@ -11,11 +11,13 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/sh_mmcif.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mfd/tmio.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -30,7 +32,6 @@
 #include <linux/spi/mmc_spi.h>
 #include <linux/input.h>
 #include <linux/input/sh_keysc.h>
-#include <linux/platform_data/gpio_backlight.h>
 #include <linux/sh_eth.h>
 #include <linux/sh_intc.h>
 #include <linux/videodev2.h>
@@ -367,17 +368,21 @@ static struct platform_device lcdc_device = {
 	},
 };
 
-static struct gpio_backlight_platform_data gpio_backlight_data = {
-	.gpio = GPIO_PTR1,
-	.def_value = 1,
-	.name = "backlight",
+static struct gpiod_lookup_table gpio_backlight_gpios_table = {
+	.dev_id = "gpio-backlight.0",
+	.table = {
+		GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTR1, NULL, 0, GPIO_ACTIVE_HIGH);
+		{ }
+	},
+};
+
+static struct property_entry gpio_backlight_properties[] = {
+	PROPERTY_ENTRY_BOOL("default-on"),
+	{ }
 };
 
 static struct platform_device gpio_backlight_device = {
 	.name = "gpio-backlight",
-	.dev = {
-		.platform_data = &gpio_backlight_data,
-	},
 };
 
 /* CEU0 */
@@ -1436,6 +1441,8 @@ static int __init arch_setup(void)
 		return error;
 
 	if (use_backlight) {
+		device_add_properties(&gpio_backlight_device.dev,
+				      gpio_backlight_properties);
 		error = platform_device_add(&gpio_backlight_device);
 		if (error)
 			pr_warn("%s: failed to register backlight: %d\n",
Signature · 1 line
2.16.2.804.g6dcf76e118-goog
#15 lore raw

Re: [RFC 3/4] sh: ecovec24: convert backlight to use device properties

Hi Dmitry,

Quoted 4 lines · Dmitry Torokhov

Instead of backlight legacy platform data, let's switch to using device properties and GPIO lookup tables.

Thanks for your patch!

arch/sh/boards/mach-ecovec24/setup.c static struct platform_device lcdc_device = { · line 371

Quoted 12 lines
arch/sh/boards/mach-ecovec24/setup.c +1 -4
@@ -367,17 +368,21 @@ static struct platform_device lcdc_device = {
        },
 };
 
-static struct gpio_backlight_platform_data gpio_backlight_data = {
-       .gpio = GPIO_PTR1,
-       .def_value = 1,
-       .name = "backlight",
+static struct gpiod_lookup_table gpio_backlight_gpios_table = {

gpio_backlight_gpios_table is unused?

arch/sh/boards/mach-ecovec24/setup.c static struct platform_device lcdc_device = { · line 379

Quoted 8 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+       .dev_id = "gpio-backlight.0",
+       .table = {
+               GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTR1, NULL, 0, GPIO_ACTIVE_HIGH);
+               { }
+       },
+};
+
+static struct property_entry gpio_backlight_properties[] = {

const

Quoted 13 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -3
+       PROPERTY_ENTRY_BOOL("default-on"),
+       { }
 };
 
 static struct platform_device gpio_backlight_device = {
        .name = "gpio-backlight",
-       .dev = {
-               .platform_data = &gpio_backlight_data,
-       },
 };
 
 /* CEU0 */

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1448

Quoted 8 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -0
@@ -1436,6 +1441,8 @@ static int __init arch_setup(void)
                return error;
 
        if (use_backlight) {
+               device_add_properties(&gpio_backlight_device.dev,
+                                     gpio_backlight_properties);
                error = platform_device_add(&gpio_backlight_device);
                if (error)
                        pr_warn("%s: failed to register backlight: %d\n",

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#16 lore raw

Re: [RFC 3/4] sh: ecovec24: convert backlight to use device properties

Quoted 18 lines · Geert Uytterhoeven

Hi Dmitry,

Quoted 4 lines · Dmitry Torokhov

Instead of backlight legacy platform data, let's switch to using device properties and GPIO lookup tables.

Thanks for your patch!

Quoted 7 lines
arch/sh/boards/mach-ecovec24/setup.c +0 -0
@@ -367,17 +368,21 @@ static struct platform_device lcdc_device = {
        },
 };
 
Quoted 7 lines

arch/sh/boards/mach-ecovec24/setup.c static struct platform_device lcdc_device = { · line 371

Quoted 5 lines
arch/sh/boards/mach-ecovec24/setup.c +1 -4
-static struct gpio_backlight_platform_data gpio_backlight_data = {
-       .gpio = GPIO_PTR1,
-       .def_value = 1,
-       .name = "backlight",
+static struct gpiod_lookup_table gpio_backlight_gpios_table = {

gpio_backlight_gpios_table is unused?

There was supposed to be gpiod_add_lookup_table() that I lost as I was reshuffling and reshuffling the patches.

Quoted 11 lines

arch/sh/boards/mach-ecovec24/setup.c static struct platform_device lcdc_device = { · line 379

Quoted 9 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -0
+       .dev_id = "gpio-backlight.0",
+       .table = {
+               GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTR1, NULL, 0, GPIO_ACTIVE_HIGH);
+               { }
+       },
+};
+
+static struct property_entry gpio_backlight_properties[] = {

const

OK.

Quoted 33 lines
Quoted 14 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -3
+       PROPERTY_ENTRY_BOOL("default-on"),
+       { }
 };
 
 static struct platform_device gpio_backlight_device = {
        .name = "gpio-backlight",
-       .dev = {
-               .platform_data = &gpio_backlight_data,
-       },
 };
 
 /* CEU0 */

arch/sh/boards/mach-ecovec24/setup.c static int __init arch_setup(void) · line 1448

Quoted 8 lines
arch/sh/boards/mach-ecovec24/setup.c +2 -0
@@ -1436,6 +1441,8 @@ static int __init arch_setup(void)
                return error;
 
        if (use_backlight) {
+               device_add_properties(&gpio_backlight_device.dev,
+                                     gpio_backlight_properties);
                error = platform_device_add(&gpio_backlight_device);
                if (error)
                        pr_warn("%s: failed to register backlight: %d\n",

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Signature · 1 line
Dmitry
#17 lore raw

Re: [RFC 3/4] sh: ecovec24: convert backlight to use device properties

In reply to Dmitry Torokhov

Hi Dmitry,

Quoted 37 lines · Dmitry Torokhov

Instead of backlight legacy platform data, let's switch to using device properties and GPIO lookup tables.

---
 arch/sh/boards/mach-ecovec24/setup.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
arch/sh/boards/mach-ecovec24/setup.c +2 -1
index 67633d2d42390..ad3d48b3ead19 100644
@@ -11,11 +11,13 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/mmc/host.h>
 #include <linux/mmc/sh_mmcif.h>
 #include <linux/mtd/physmap.h>
 #include <linux/mfd/tmio.h>
 #include <linux/gpio.h>
+#include <linux/gpio/machine.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -30,7 +32,6 @@
 #include <linux/spi/mmc_spi.h>
 #include <linux/input.h>
 #include <linux/input/sh_keysc.h>
-#include <linux/platform_data/gpio_backlight.h>
 #include <linux/sh_eth.h>
 #include <linux/sh_intc.h>
 #include <linux/videodev2.h>
@@ -367,17 +368,21 @@ static struct platform_device lcdc_device = {
 	},
 };

arch/sh/boards/mach-ecovec24/setup.c static struct platform_device lcdc_device = { · line 375

Quoted 10 lines
arch/sh/boards/mach-ecovec24/setup.c +5 -4
 
-static struct gpio_backlight_platform_data gpio_backlight_data = {
-	.gpio = GPIO_PTR1,
-	.def_value = 1,
-	.name = "backlight",
+static struct gpiod_lookup_table gpio_backlight_gpios_table = {
+	.dev_id = "gpio-backlight.0",
+	.table = {
+		GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTR1, NULL, 0, GPIO_ACTIVE_HIGH);
+		{ }

I understand this is an RFC, but this bit does not even compile.

../arch/sh/boards/mach-ecovec24/setup.c:374:70: error: expected '}' before ';' token

Thanks
j

Quoted 28 lines
arch/sh/boards/mach-ecovec24/setup.c +8 -4
+	},
+};
+
+static struct property_entry gpio_backlight_properties[] = {
+	PROPERTY_ENTRY_BOOL("default-on"),
+	{ }
 };
 
 static struct platform_device gpio_backlight_device = {
 	.name = "gpio-backlight",
-	.dev = {
-		.platform_data = &gpio_backlight_data,
-	},
 };
 
 /* CEU0 */
@@ -1436,6 +1441,8 @@ static int __init arch_setup(void)
 		return error;
 
 	if (use_backlight) {
+		device_add_properties(&gpio_backlight_device.dev,
+				      gpio_backlight_properties);
 		error = platform_device_add(&gpio_backlight_device);
 		if (error)
 			pr_warn("%s: failed to register backlight: %d\n",
--

2.16.2.804.g6dcf76e118-goog

#18 lore raw

RFC 4/4 backlight: gpio_backlight: remove platform data support

In reply to Dmitry Torokhov

Legacy boards can use static property sets/GPIO lookup tables to describe backlight connections, there is no need to maintain legacy platform data.

---
 drivers/video/backlight/gpio_backlight.c     | 85 ++++----------------
 include/linux/platform_data/gpio_backlight.h | 20 -----
 2 files changed, 14 insertions(+), 91 deletions(-)
 delete mode 100644 include/linux/platform_data/gpio_backlight.h
drivers/video/backlight/gpio_backlight.c +14 -70
index 173fc4aafb89b..795359deeb700 100644
@@ -15,17 +15,12 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
-#include <linux/platform_data/gpio_backlight.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 
 struct gpio_backlight {
-	struct device *dev;
-	struct device *fbdev;
-
 	struct gpio_desc *gpiod;
-	int def_value;
 };
 
 static int gpio_backlight_update_status(struct backlight_device *bl)
@@ -43,84 +38,32 @@ static int gpio_backlight_update_status(struct backlight_device *bl)
 	return 0;
 }
 
-static int gpio_backlight_check_fb(struct backlight_device *bl,
-				   struct fb_info *info)
-{
-	struct gpio_backlight *gbl = bl_get_data(bl);
-
-	return gbl->fbdev = NULL || gbl->fbdev = info->dev;
-}
-
 static const struct backlight_ops gpio_backlight_ops = {
 	.options	= BL_CORE_SUSPENDRESUME,
 	.update_status	= gpio_backlight_update_status,
-	.check_fb	= gpio_backlight_check_fb,
 };
 
-static int gpio_backlight_probe_dt(struct platform_device *pdev,
-				   struct gpio_backlight *gbl)
-{
-	struct device *dev = &pdev->dev;
-	enum gpiod_flags flags;
-	int ret;
-
-	gbl->def_value = device_property_read_bool(dev, "default-on");
-	flags = gbl->def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW;
-
-	gbl->gpiod = devm_gpiod_get(dev, NULL, flags);
-	if (IS_ERR(gbl->gpiod)) {
-		ret = PTR_ERR(gbl->gpiod);
-
-		if (ret != -EPROBE_DEFER) {
-			dev_err(dev,
-				"Error: The gpios parameter is missing or invalid.\n");
-		}
-		return ret;
-	}
-
-	return 0;
-}
-
 static int gpio_backlight_probe(struct platform_device *pdev)
 {
-	struct gpio_backlight_platform_data *pdata -		dev_get_platdata(&pdev->dev);
+	struct device *dev = &pdev->dev;
 	struct backlight_properties props;
 	struct backlight_device *bl;
 	struct gpio_backlight *gbl;
+	int def_value;
 	int ret;
 
-	gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
-	if (gbl = NULL)
+	gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
+	if (!gbl)
 		return -ENOMEM;
 
-	gbl->dev = &pdev->dev;
-
-	if (!pdata) {
-		ret = gpio_backlight_probe_dt(pdev, gbl);
-		if (ret)
-			return ret;
-	} else {
-		/*
-		 * Legacy platform data GPIO retrieveal. Do not expand
-		 * the use of this code path, currently only used by one
-		 * SH board.
-		 */
-		unsigned long flags = GPIOF_DIR_OUT;
-
-		gbl->fbdev = pdata->fbdev;
-		gbl->def_value = pdata->def_value;
-		flags |= gbl->def_value ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW;
-
-		ret = devm_gpio_request_one(gbl->dev, pdata->gpio, flags,
-					    pdata ? pdata->name : "backlight");
-		if (ret < 0) {
-			dev_err(&pdev->dev, "unable to request GPIO\n");
-			return ret;
-		}
-		gbl->gpiod = gpio_to_desc(pdata->gpio);
-		if (!gbl->gpiod)
-			return -EINVAL;
+	def_value = device_property_read_bool(dev, "default-on");
+	gbl->gpiod = devm_gpiod_get(dev, NULL,
+				    def_value ? GPIOD_OUT_HIGH : GPIOD_OUT_LOW);
+	if (IS_ERR(gbl->gpiod)) {
+		ret = PTR_ERR(gbl->gpiod);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev, "unable to request GPIO: %d\n", ret);
+		return ret;
 	}
 
 	memset(&props, 0, sizeof(props));
@@ -134,7 +77,7 @@ static int gpio_backlight_probe(struct platform_device *pdev)
 		return PTR_ERR(bl);
 	}
 
-	bl->props.brightness = gbl->def_value;
+	bl->props.brightness = def_value;
 	backlight_update_status(bl);
 
 	platform_set_drvdata(pdev, bl);
include/linux/platform_data/gpio_backlight.h deleted +0 -20
deleted file mode 100644
index 683d90453c419..0000000000000
@@ -1,20 +0,0 @@
-/*
- * gpio_backlight.h - Simple GPIO-controlled backlight
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-#ifndef __GPIO_BACKLIGHT_H__
-#define __GPIO_BACKLIGHT_H__
-
-struct device;
-
-struct gpio_backlight_platform_data {
-	struct device *fbdev;
-	int gpio;
-	int def_value;
-	const char *name;
-};
-
-#endif
Signature · 1 line
2.16.2.804.g6dcf76e118-goog
Reviewed-by on v1 4/4
#19 lore raw

Re: [RFC 4/4] backlight: gpio_backlight: remove platform data support

Quoted 4 lines · Dmitry Torokhov

Legacy boards can use static property sets/GPIO lookup tables to describe backlight connections, there is no need to maintain legacy platform data.

Good riddance, this is how all drivers should eventually end up after full device property conversion I guess.

Yours,
Linus Walleij

#20 lore raw
In reply to Dmitry Torokhov
Quoted 7 lines · Dmitry Torokhov

Hi,

This series attempts to remove platform data support from gpio_blackllist driver and switch it over to generic device properties/GPIO tables. The only user of platform data was SuperH Ecovec24 board; please take a look at patch #2 that tries to only register backlight when the board is using LDC and not DVI.

Can't comment on patch #2 but, from the backlight side of things I have no objections.

Daniel.

Quoted 25 lines

Please note that I do not have the hardware (do we even care about ecovec24? I'd like to rip out platform data support from tsc2007 as well, but ecovec24 is using custom pendown handler and GPIOs have to be switched off from interrupt mode to GPIO and back in that pendown handler, which is all quite messy. If we do not care about this board I'd much rather removed that custom pendown).

Thanks!

Dmitry Torokhov (4):
backlight: gpio_backlight: use generic device properties
sh: ecovec24: conditionally register backlight device
sh: ecovec24: convert backlight to use device properties
backlight: gpio_backlight: remove platform data support

 arch/sh/boards/mach-ecovec24/setup.c         | 47 ++++++----
 drivers/video/backlight/gpio_backlight.c     | 93 +++-----------------
 include/linux/platform_data/gpio_backlight.h | 20 -----
 3 files changed, 46 insertions(+), 114 deletions(-)
 delete mode 100644 include/linux/platform_data/gpio_backlight.h
Signature · 1 line
Dmitry
Reviewed-by on the v1 series
#21 lore raw
In reply to Dmitry Torokhov
Quoted 2 lines · Dmitry Torokhov

This series attempts to remove platform data support from gpio_blackllist driver

We really need a GPIO blacklist driver in the kernel, but for not let's fix backlight :D :D

Quoted 1 line

and switch it over to generic device properties/GPIO tables.

This series:

Quoted 6 lines

Please note that I do not have the hardware (do we even care about ecovec24? I'd like to rip out platform data support from tsc2007 as well, but ecovec24 is using custom pendown handler and GPIOs have to be switched off from interrupt mode to GPIO and back in that pendown handler, which is all quite messy. If we do not care about this board I'd much rather removed that custom pendown).

I am also struggling with refactoring of board files, all over the place. At least Arnd deleted the Blackfin stuff now, but the misc ARM board and MIPS stuff still give me the creeps sometimes.

I guess if maintainers of the boards are not there to even ACK patches we can propose patches to simply delete them.

Yours,
Linus Walleij