2019-10-07 03:32:39

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 0/7] backlight: gpio: simplify the driver

From: Bartosz Golaszewski <[email protected]>

While working on my other series related to gpio-backlight[1] I noticed
that we could simplify the driver if we made the only user of platform
data use GPIO lookups and device properties. This series tries to do
that.

The first patch adds all necessary data structures to ecovec24. Patch
2/7 unifies much of the code for both pdata and non-pdata cases. Patches
3-4/7 remove unused platform data fields. Last three patches contain
additional improvements for the GPIO backlight driver while we're already
modifying it.

I don't have access to this HW but hopefully this works. Only compile
tested.

[1] https://lkml.org/lkml/2019/6/25/900

v1 -> v2:
- rebased on top of v5.3-rc1 and adjusted to the recent changes from Andy
- added additional two patches with minor improvements

v2 -> v3:
- in patch 7/7: used initializers to set values for pdata and dev local vars

v3 -> v4:
- rebased on top of v5.4-rc1
- removed changes that are no longer relevant after commit ec665b756e6f
("backlight: gpio-backlight: Correct initial power state handling")
- added patch 7/7

v4 ->V5:
- in patch 7/7: added a comment replacing the name of the function being
pulled into probe()

Bartosz Golaszewski (7):
backlight: gpio: remove unneeded include
sh: ecovec24: add additional properties to the backlight device
backlight: gpio: simplify the platform data handling
sh: ecovec24: don't set unused fields in platform data
backlight: gpio: remove unused fields from platform data
backlight: gpio: use a helper variable for &pdev->dev
backlight: gpio: pull gpio_backlight_initial_power_state() into probe

arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
drivers/video/backlight/gpio_backlight.c | 108 +++++--------------
include/linux/platform_data/gpio_backlight.h | 3 -
3 files changed, 53 insertions(+), 91 deletions(-)

--
2.23.0


2019-10-07 03:32:43

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 1/7] backlight: gpio: remove unneeded include

From: Bartosz Golaszewski <[email protected]>

We no longer use any symbols from of_gpio.h. Remove this include.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Daniel Thompson <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 18e053e4716c..7e1990199fae 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -12,7 +12,6 @@
#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>
--
2.23.0

2019-10-07 03:32:48

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 3/7] backlight: gpio: simplify the platform data handling

From: Bartosz Golaszewski <[email protected]>

Now that the last user of platform data (sh ecovec24) defines a proper
GPIO lookup and sets the 'default-on' device property, we can drop the
platform_data-specific GPIO handling and unify a big chunk of code.

The only field used from the platform data is now the fbdev pointer.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Daniel Thompson <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 62 +++++-------------------
1 file changed, 11 insertions(+), 51 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 7e1990199fae..20c5311c7ed2 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -6,7 +6,6 @@
#include <linux/backlight.h>
#include <linux/err.h>
#include <linux/fb.h>
-#include <linux/gpio.h> /* Only for legacy support */
#include <linux/gpio/consumer.h>
#include <linux/init.h>
#include <linux/kernel.h>
@@ -54,28 +53,6 @@ static const struct backlight_ops gpio_backlight_ops = {
.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;
- int ret;
-
- gbl->def_value = device_property_read_bool(dev, "default-on");
-
- gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
- 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_initial_power_state(struct gpio_backlight *gbl)
{
struct device_node *node = gbl->dev->of_node;
@@ -107,35 +84,18 @@ static int gpio_backlight_probe(struct platform_device *pdev)

gbl->dev = &pdev->dev;

- if (pdev->dev.fwnode) {
- ret = gpio_backlight_probe_dt(pdev, gbl);
- if (ret)
- return ret;
- } else if (pdata) {
- /*
- * 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;
-
+ if (pdata)
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;
- } else {
- dev_err(&pdev->dev,
- "failed to find platform data or device tree node.\n");
- return -ENODEV;
+
+ gbl->def_value = device_property_read_bool(&pdev->dev, "default-on");
+
+ gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS);
+ if (IS_ERR(gbl->gpiod)) {
+ ret = PTR_ERR(gbl->gpiod);
+ if (ret != -EPROBE_DEFER)
+ dev_err(&pdev->dev,
+ "Error: The gpios parameter is missing or invalid.\n");
+ return ret;
}

memset(&props, 0, sizeof(props));
--
2.23.0

2019-10-07 03:32:55

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 5/7] backlight: gpio: remove unused fields from platform data

From: Bartosz Golaszewski <[email protected]>

Remove the platform data fields that nobody uses.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Daniel Thompson <[email protected]>
---
include/linux/platform_data/gpio_backlight.h | 3 ---
1 file changed, 3 deletions(-)

diff --git a/include/linux/platform_data/gpio_backlight.h b/include/linux/platform_data/gpio_backlight.h
index 34179d600360..1a8b5b1946fe 100644
--- a/include/linux/platform_data/gpio_backlight.h
+++ b/include/linux/platform_data/gpio_backlight.h
@@ -9,9 +9,6 @@ struct device;

struct gpio_backlight_platform_data {
struct device *fbdev;
- int gpio;
- int def_value;
- const char *name;
};

#endif
--
2.23.0

2019-10-07 03:33:03

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 7/7] backlight: gpio: pull gpio_backlight_initial_power_state() into probe

From: Bartosz Golaszewski <[email protected]>

The probe function in the gpio-backlight driver is quite short. If we
pull gpio_backlight_initial_power_state() into probe we can drop two
more fields from struct gpio_backlight and shrink the driver code.

Signed-off-by: Bartosz Golaszewski <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 37 +++++++++---------------
1 file changed, 13 insertions(+), 24 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 6247687b6330..407d4eaafc5c 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -17,11 +17,8 @@
#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)
@@ -53,41 +50,24 @@ static const struct backlight_ops gpio_backlight_ops = {
.check_fb = gpio_backlight_check_fb,
};

-static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)
-{
- struct device_node *node = gbl->dev->of_node;
-
- /* Not booted with device tree or no phandle link to the node */
- if (!node || !node->phandle)
- return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
-
- /* if the enable GPIO is disabled, do not enable the backlight */
- if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
- return FB_BLANK_POWERDOWN;
-
- return FB_BLANK_UNBLANK;
-}
-
-
static int gpio_backlight_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev);
+ struct device_node *of_node = dev->of_node;
struct backlight_properties props;
struct backlight_device *bl;
struct gpio_backlight *gbl;
- int ret;
+ int ret, def_value;

gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
if (gbl == NULL)
return -ENOMEM;

- gbl->dev = dev;
-
if (pdata)
gbl->fbdev = pdata->fbdev;

- gbl->def_value = device_property_read_bool(dev, "default-on");
+ def_value = device_property_read_bool(dev, "default-on");

gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
if (IS_ERR(gbl->gpiod)) {
@@ -109,7 +89,16 @@ static int gpio_backlight_probe(struct platform_device *pdev)
return PTR_ERR(bl);
}

- bl->props.power = gpio_backlight_initial_power_state(gbl);
+ /* Set the initial power state */
+ if (!of_node || !of_node->phandle)
+ /* Not booted with device tree or no phandle link to the node */
+ bl->props.power = def_value ? FB_BLANK_UNBLANK
+ : FB_BLANK_POWERDOWN;
+ else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
+ bl->props.power = FB_BLANK_POWERDOWN;
+ else
+ bl->props.power = FB_BLANK_UNBLANK;
+
bl->props.brightness = 1;

backlight_update_status(bl);
--
2.23.0

2019-10-07 03:33:54

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 6/7] backlight: gpio: use a helper variable for &pdev->dev

From: Bartosz Golaszewski <[email protected]>

Instead of dereferencing pdev each time, use a helper variable for
the associated device pointer.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
Reviewed-by: Daniel Thompson <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
---
drivers/video/backlight/gpio_backlight.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
index 20c5311c7ed2..6247687b6330 100644
--- a/drivers/video/backlight/gpio_backlight.c
+++ b/drivers/video/backlight/gpio_backlight.c
@@ -71,25 +71,25 @@ static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)

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 gpio_backlight_platform_data *pdata = dev_get_platdata(dev);
struct backlight_properties props;
struct backlight_device *bl;
struct gpio_backlight *gbl;
int ret;

- gbl = devm_kzalloc(&pdev->dev, sizeof(*gbl), GFP_KERNEL);
+ gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
if (gbl == NULL)
return -ENOMEM;

- gbl->dev = &pdev->dev;
+ gbl->dev = dev;

if (pdata)
gbl->fbdev = pdata->fbdev;

- gbl->def_value = device_property_read_bool(&pdev->dev, "default-on");
+ gbl->def_value = device_property_read_bool(dev, "default-on");

- gbl->gpiod = devm_gpiod_get(&pdev->dev, NULL, GPIOD_ASIS);
+ gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
if (IS_ERR(gbl->gpiod)) {
ret = PTR_ERR(gbl->gpiod);
if (ret != -EPROBE_DEFER)
@@ -101,11 +101,11 @@ static int gpio_backlight_probe(struct platform_device *pdev)
memset(&props, 0, sizeof(props));
props.type = BACKLIGHT_RAW;
props.max_brightness = 1;
- bl = devm_backlight_device_register(&pdev->dev, dev_name(&pdev->dev),
- &pdev->dev, gbl, &gpio_backlight_ops,
+ bl = devm_backlight_device_register(dev, dev_name(dev),
+ dev, gbl, &gpio_backlight_ops,
&props);
if (IS_ERR(bl)) {
- dev_err(&pdev->dev, "failed to register backlight\n");
+ dev_err(dev, "failed to register backlight\n");
return PTR_ERR(bl);
}

--
2.23.0

2019-10-07 03:34:22

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 2/7] sh: ecovec24: add additional properties to the backlight device

From: Bartosz Golaszewski <[email protected]>

Add a GPIO lookup entry and a device property for GPIO backlight to the
board file. Tie them to the platform device which is now registered using
platform_device_register_full() because of the properties. These changes
are inactive now but will be used once the gpio backlight driver is
modified.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
---
arch/sh/boards/mach-ecovec24/setup.c | 30 +++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index acaa97459531..aaa8ea62636f 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -371,6 +371,19 @@ static struct platform_device lcdc_device = {
},
};

+static struct gpiod_lookup_table gpio_backlight_lookup = {
+ .dev_id = "gpio-backlight.0",
+ .table = {
+ GPIO_LOOKUP("sh7724_pfc", GPIO_PTR1, NULL, GPIO_ACTIVE_HIGH),
+ { }
+ },
+};
+
+static struct property_entry gpio_backlight_props[] = {
+ PROPERTY_ENTRY_BOOL("default-on"),
+ { }
+};
+
static struct gpio_backlight_platform_data gpio_backlight_data = {
.fbdev = &lcdc_device.dev,
.gpio = GPIO_PTR1,
@@ -378,13 +391,15 @@ static struct gpio_backlight_platform_data gpio_backlight_data = {
.name = "backlight",
};

-static struct platform_device gpio_backlight_device = {
+static const struct platform_device_info gpio_backlight_device_info = {
.name = "gpio-backlight",
- .dev = {
- .platform_data = &gpio_backlight_data,
- },
+ .data = &gpio_backlight_data,
+ .size_data = sizeof(gpio_backlight_data),
+ .properties = gpio_backlight_props,
};

+static struct platform_device *gpio_backlight_device;
+
/* CEU0 */
static struct ceu_platform_data ceu0_pdata = {
.num_subdevs = 2,
@@ -1006,7 +1021,6 @@ static struct platform_device *ecovec_devices[] __initdata = {
&usb1_common_device,
&usbhs_device,
&lcdc_device,
- &gpio_backlight_device,
&keysc_device,
&cn12_power,
#if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE)
@@ -1462,6 +1476,12 @@ static int __init arch_setup(void)
#endif
#endif

+ gpiod_add_lookup_table(&gpio_backlight_lookup);
+ gpio_backlight_device = platform_device_register_full(
+ &gpio_backlight_device_info);
+ if (IS_ERR(gpio_backlight_device))
+ return PTR_ERR(gpio_backlight_device);
+
return platform_add_devices(ecovec_devices,
ARRAY_SIZE(ecovec_devices));
}
--
2.23.0

2019-10-07 03:35:13

by Bartosz Golaszewski

[permalink] [raw]
Subject: [PATCH v5 4/7] sh: ecovec24: don't set unused fields in platform data

From: Bartosz Golaszewski <[email protected]>

Platform data fields other than fbdev are no longer used by the
backlight driver. Remove them.

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Linus Walleij <[email protected]>
---
arch/sh/boards/mach-ecovec24/setup.c | 3 ---
1 file changed, 3 deletions(-)

diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index aaa8ea62636f..dd427bac5cde 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -386,9 +386,6 @@ static struct property_entry gpio_backlight_props[] = {

static struct gpio_backlight_platform_data gpio_backlight_data = {
.fbdev = &lcdc_device.dev,
- .gpio = GPIO_PTR1,
- .def_value = 1,
- .name = "backlight",
};

static const struct platform_device_info gpio_backlight_device_info = {
--
2.23.0

2019-10-07 12:57:35

by Daniel Thompson

[permalink] [raw]
Subject: Re: [PATCH v5 7/7] backlight: gpio: pull gpio_backlight_initial_power_state() into probe

On Mon, Oct 07, 2019 at 05:32:00AM +0200, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <[email protected]>
>
> The probe function in the gpio-backlight driver is quite short. If we
> pull gpio_backlight_initial_power_state() into probe we can drop two
> more fields from struct gpio_backlight and shrink the driver code.
>
> Signed-off-by: Bartosz Golaszewski <[email protected]>

Acked-by: Daniel Thompson <[email protected]>

> ---
> drivers/video/backlight/gpio_backlight.c | 37 +++++++++---------------
> 1 file changed, 13 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/video/backlight/gpio_backlight.c b/drivers/video/backlight/gpio_backlight.c
> index 6247687b6330..407d4eaafc5c 100644
> --- a/drivers/video/backlight/gpio_backlight.c
> +++ b/drivers/video/backlight/gpio_backlight.c
> @@ -17,11 +17,8 @@
> #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)
> @@ -53,41 +50,24 @@ static const struct backlight_ops gpio_backlight_ops = {
> .check_fb = gpio_backlight_check_fb,
> };
>
> -static int gpio_backlight_initial_power_state(struct gpio_backlight *gbl)
> -{
> - struct device_node *node = gbl->dev->of_node;
> -
> - /* Not booted with device tree or no phandle link to the node */
> - if (!node || !node->phandle)
> - return gbl->def_value ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
> -
> - /* if the enable GPIO is disabled, do not enable the backlight */
> - if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
> - return FB_BLANK_POWERDOWN;
> -
> - return FB_BLANK_UNBLANK;
> -}
> -
> -
> static int gpio_backlight_probe(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> struct gpio_backlight_platform_data *pdata = dev_get_platdata(dev);
> + struct device_node *of_node = dev->of_node;
> struct backlight_properties props;
> struct backlight_device *bl;
> struct gpio_backlight *gbl;
> - int ret;
> + int ret, def_value;
>
> gbl = devm_kzalloc(dev, sizeof(*gbl), GFP_KERNEL);
> if (gbl == NULL)
> return -ENOMEM;
>
> - gbl->dev = dev;
> -
> if (pdata)
> gbl->fbdev = pdata->fbdev;
>
> - gbl->def_value = device_property_read_bool(dev, "default-on");
> + def_value = device_property_read_bool(dev, "default-on");
>
> gbl->gpiod = devm_gpiod_get(dev, NULL, GPIOD_ASIS);
> if (IS_ERR(gbl->gpiod)) {
> @@ -109,7 +89,16 @@ static int gpio_backlight_probe(struct platform_device *pdev)
> return PTR_ERR(bl);
> }
>
> - bl->props.power = gpio_backlight_initial_power_state(gbl);
> + /* Set the initial power state */
> + if (!of_node || !of_node->phandle)
> + /* Not booted with device tree or no phandle link to the node */
> + bl->props.power = def_value ? FB_BLANK_UNBLANK
> + : FB_BLANK_POWERDOWN;
> + else if (gpiod_get_value_cansleep(gbl->gpiod) == 0)
> + bl->props.power = FB_BLANK_POWERDOWN;
> + else
> + bl->props.power = FB_BLANK_UNBLANK;
> +
> bl->props.brightness = 1;
>
> backlight_update_status(bl);
> --
> 2.23.0
>

2019-10-14 08:15:30

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

On Mon, 07 Oct 2019, Bartosz Golaszewski wrote:

> From: Bartosz Golaszewski <[email protected]>
>
> While working on my other series related to gpio-backlight[1] I noticed
> that we could simplify the driver if we made the only user of platform
> data use GPIO lookups and device properties. This series tries to do
> that.
>
> The first patch adds all necessary data structures to ecovec24. Patch
> 2/7 unifies much of the code for both pdata and non-pdata cases. Patches
> 3-4/7 remove unused platform data fields. Last three patches contain
> additional improvements for the GPIO backlight driver while we're already
> modifying it.
>
> I don't have access to this HW but hopefully this works. Only compile
> tested.
>
> [1] https://lkml.org/lkml/2019/6/25/900
>
> v1 -> v2:
> - rebased on top of v5.3-rc1 and adjusted to the recent changes from Andy
> - added additional two patches with minor improvements
>
> v2 -> v3:
> - in patch 7/7: used initializers to set values for pdata and dev local vars
>
> v3 -> v4:
> - rebased on top of v5.4-rc1
> - removed changes that are no longer relevant after commit ec665b756e6f
> ("backlight: gpio-backlight: Correct initial power state handling")
> - added patch 7/7
>
> v4 ->V5:
> - in patch 7/7: added a comment replacing the name of the function being
> pulled into probe()
>
> Bartosz Golaszewski (7):
> backlight: gpio: remove unneeded include
> sh: ecovec24: add additional properties to the backlight device
> backlight: gpio: simplify the platform data handling
> sh: ecovec24: don't set unused fields in platform data
> backlight: gpio: remove unused fields from platform data
> backlight: gpio: use a helper variable for &pdev->dev
> backlight: gpio: pull gpio_backlight_initial_power_state() into probe
>
> arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--

I guess we're just waiting for the SH Acks now?

> drivers/video/backlight/gpio_backlight.c | 108 +++++--------------
> include/linux/platform_data/gpio_backlight.h | 3 -
> 3 files changed, 53 insertions(+), 91 deletions(-)
>

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-10-14 08:17:12

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

pon., 14 paź 2019 o 10:12 Lee Jones <[email protected]> napisał(a):
>
> On Mon, 07 Oct 2019, Bartosz Golaszewski wrote:
>
> > From: Bartosz Golaszewski <[email protected]>
> >
> > While working on my other series related to gpio-backlight[1] I noticed
> > that we could simplify the driver if we made the only user of platform
> > data use GPIO lookups and device properties. This series tries to do
> > that.
> >
> > The first patch adds all necessary data structures to ecovec24. Patch
> > 2/7 unifies much of the code for both pdata and non-pdata cases. Patches
> > 3-4/7 remove unused platform data fields. Last three patches contain
> > additional improvements for the GPIO backlight driver while we're already
> > modifying it.
> >
> > I don't have access to this HW but hopefully this works. Only compile
> > tested.
> >
> > [1] https://lkml.org/lkml/2019/6/25/900
> >
> > v1 -> v2:
> > - rebased on top of v5.3-rc1 and adjusted to the recent changes from Andy
> > - added additional two patches with minor improvements
> >
> > v2 -> v3:
> > - in patch 7/7: used initializers to set values for pdata and dev local vars
> >
> > v3 -> v4:
> > - rebased on top of v5.4-rc1
> > - removed changes that are no longer relevant after commit ec665b756e6f
> > ("backlight: gpio-backlight: Correct initial power state handling")
> > - added patch 7/7
> >
> > v4 ->V5:
> > - in patch 7/7: added a comment replacing the name of the function being
> > pulled into probe()
> >
> > Bartosz Golaszewski (7):
> > backlight: gpio: remove unneeded include
> > sh: ecovec24: add additional properties to the backlight device
> > backlight: gpio: simplify the platform data handling
> > sh: ecovec24: don't set unused fields in platform data
> > backlight: gpio: remove unused fields from platform data
> > backlight: gpio: use a helper variable for &pdev->dev
> > backlight: gpio: pull gpio_backlight_initial_power_state() into probe
> >
> > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
>
> I guess we're just waiting for the SH Acks now?
>

We've been waiting for them for a couple months now - the sh patches
haven't changed since v1...

Rich, Yoshinori - could you ack this so that it can go in for v5.5?

Thanks,
Bartosz

> > drivers/video/backlight/gpio_backlight.c | 108 +++++--------------
> > include/linux/platform_data/gpio_backlight.h | 3 -
> > 3 files changed, 53 insertions(+), 91 deletions(-)
> >
>
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog

2019-10-16 16:01:16

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

On Mon, Oct 14, 2019 at 10:12 AM Lee Jones <[email protected]> wrote:

> > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
>
> I guess we're just waiting for the SH Acks now?

The one maintainer with this board is probably overloaded.

I would say just apply it, it can't hold back the entire series.

Yours,
Linus Walleij

2019-10-16 16:01:48

by jacopo mondi

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

Hi, sorry for not having replied earlier

On Wed, Oct 16, 2019 at 02:56:57PM +0200, Linus Walleij wrote:
> On Mon, Oct 14, 2019 at 10:12 AM Lee Jones <[email protected]> wrote:
>
> > > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
> >
> > I guess we're just waiting for the SH Acks now?
>
> The one maintainer with this board is probably overloaded.
>
> I would say just apply it, it can't hold back the entire series.

I've been able to resurect the Ecovec, and I've also been given a copy
of its schematics file a few weeks ago.

It's in my TODO list to test this series but I didn't manage to find
time. If I pinky promise I get back to you before end of the week,
could you wait for me ? :)

Thanks and sorry again!

>
> Yours,
> Linus Walleij


Attachments:
(No filename) (789.00 B)
signature.asc (849.00 B)
Download all attachments

2019-10-18 10:10:23

by Lee Jones

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

On Wed, 16 Oct 2019, Jacopo Mondi wrote:

> Hi, sorry for not having replied earlier
>
> On Wed, Oct 16, 2019 at 02:56:57PM +0200, Linus Walleij wrote:
> > On Mon, Oct 14, 2019 at 10:12 AM Lee Jones <[email protected]> wrote:
> >
> > > > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
> > >
> > > I guess we're just waiting for the SH Acks now?
> >
> > The one maintainer with this board is probably overloaded.
> >
> > I would say just apply it, it can't hold back the entire series.
>
> I've been able to resurect the Ecovec, and I've also been given a copy
> of its schematics file a few weeks ago.
>
> It's in my TODO list to test this series but I didn't manage to find
> time. If I pinky promise I get back to you before end of the week,
> could you wait for me ? :)

Yes, no problem.

--
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

2019-10-19 08:33:23

by jacopo mondi

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

Hi,

On Thu, Oct 17, 2019 at 08:25:50AM +0100, Lee Jones wrote:
> On Wed, 16 Oct 2019, Jacopo Mondi wrote:
>
> > Hi, sorry for not having replied earlier
> >
> > On Wed, Oct 16, 2019 at 02:56:57PM +0200, Linus Walleij wrote:
> > > On Mon, Oct 14, 2019 at 10:12 AM Lee Jones <[email protected]> wrote:
> > >
> > > > > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
> > > >
> > > > I guess we're just waiting for the SH Acks now?
> > >
> > > The one maintainer with this board is probably overloaded.
> > >
> > > I would say just apply it, it can't hold back the entire series.
> >
> > I've been able to resurect the Ecovec, and I've also been given a copy
> > of its schematics file a few weeks ago.
> >
> > It's in my TODO list to test this series but I didn't manage to find
> > time. If I pinky promise I get back to you before end of the week,
> > could you wait for me ? :)

Finally had some time to spend on this.

As I've reported to Bartosz, this version does not work on Ecovec out
of the box, as the GPIO line connected to the backlight needs to be
configured to work in output mode before registering the backlight
device.

With this simple change:

$ git diff
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
index dd427bac5cde..eec6e805c3ed 100644
--- a/arch/sh/boards/mach-ecovec24/setup.c
+++ b/arch/sh/boards/mach-ecovec24/setup.c
@@ -1473,6 +1473,7 @@ static int __init arch_setup(void)
#endif
#endif

+ gpio_direction_output(GPIO_PTR1, 1);
gpiod_add_lookup_table(&gpio_backlight_lookup);
gpio_backlight_device = platform_device_register_full(
&gpio_backlight_device_info);

I can now control the gpio through the backlight interface.

So please add this bit on top of next iteration and add my:
Tested-by: Jacopo Mondi <[email protected]>

Thanks and sorry for the long time it took!

>
> Yes, no problem.
>
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog


Attachments:
(No filename) (2.12 kB)
signature.asc (849.00 B)
Download all attachments

2019-10-19 08:42:47

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH v5 0/7] backlight: gpio: simplify the driver

pt., 18 paź 2019 o 17:02 Jacopo Mondi <[email protected]> napisał(a):
>
> Hi,
>
> On Thu, Oct 17, 2019 at 08:25:50AM +0100, Lee Jones wrote:
> > On Wed, 16 Oct 2019, Jacopo Mondi wrote:
> >
> > > Hi, sorry for not having replied earlier
> > >
> > > On Wed, Oct 16, 2019 at 02:56:57PM +0200, Linus Walleij wrote:
> > > > On Mon, Oct 14, 2019 at 10:12 AM Lee Jones <[email protected]> wrote:
> > > >
> > > > > > arch/sh/boards/mach-ecovec24/setup.c | 33 ++++--
> > > > >
> > > > > I guess we're just waiting for the SH Acks now?
> > > >
> > > > The one maintainer with this board is probably overloaded.
> > > >
> > > > I would say just apply it, it can't hold back the entire series.
> > >
> > > I've been able to resurect the Ecovec, and I've also been given a copy
> > > of its schematics file a few weeks ago.
> > >
> > > It's in my TODO list to test this series but I didn't manage to find
> > > time. If I pinky promise I get back to you before end of the week,
> > > could you wait for me ? :)
>
> Finally had some time to spend on this.
>
> As I've reported to Bartosz, this version does not work on Ecovec out
> of the box, as the GPIO line connected to the backlight needs to be
> configured to work in output mode before registering the backlight
> device.
>
> With this simple change:
>
> $ git diff
> diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c
> index dd427bac5cde..eec6e805c3ed 100644
> --- a/arch/sh/boards/mach-ecovec24/setup.c
> +++ b/arch/sh/boards/mach-ecovec24/setup.c
> @@ -1473,6 +1473,7 @@ static int __init arch_setup(void)
> #endif
> #endif
>
> + gpio_direction_output(GPIO_PTR1, 1);

This is a hack actually. The problem lies with the gpio backlight
driver - it should really set the mode to output, not leave it as is.
If there's no good reason to keep it as it is now, I'll add another
patch to the series that moves the call to devm_gpiod_get() to where
we've already determined the initial value in probe() and pass an
appropriate GPIOD_OUT_HIGH/LOW flag.

Bart

> gpiod_add_lookup_table(&gpio_backlight_lookup);
> gpio_backlight_device = platform_device_register_full(
> &gpio_backlight_device_info);
>
> I can now control the gpio through the backlight interface.
>
> So please add this bit on top of next iteration and add my:
> Tested-by: Jacopo Mondi <[email protected]>
>
> Thanks and sorry for the long time it took!
>
> >
> > Yes, no problem.
> >
> > --
> > Lee Jones [李琼斯]
> > Linaro Services Technical Lead
> > Linaro.org │ Open source software for ARM SoCs
> > Follow Linaro: Facebook | Twitter | Blog