Skip to content

Commit c8fdcc8

Browse files
linuswLee Jones
authored andcommitted
backlight: bd6107: Convert to use GPIO descriptor
The Rohm BD6107 driver can pass a fixed GPIO line using the old GPIO API using platform data. As there are no in-tree users of this platform data since 2013, we can convert this to use a GPIO descriptor and require any out-of-tree consumers to pass the GPIO using a machine descriptor table instead. Signed-off-by: Linus Walleij <[email protected]> Reviewed-by: Laurent Pinchart <[email protected]> Reviewed-by: Daniel Thompson <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent edeec4f commit c8fdcc8

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

drivers/video/backlight/bd6107.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <linux/delay.h>
1212
#include <linux/err.h>
1313
#include <linux/fb.h>
14-
#include <linux/gpio.h>
14+
#include <linux/gpio/consumer.h>
1515
#include <linux/i2c.h>
1616
#include <linux/module.h>
1717
#include <linux/platform_data/bd6107.h>
@@ -71,6 +71,7 @@ struct bd6107 {
7171
struct i2c_client *client;
7272
struct backlight_device *backlight;
7373
struct bd6107_platform_data *pdata;
74+
struct gpio_desc *reset;
7475
};
7576

7677
static int bd6107_write(struct bd6107 *bd, u8 reg, u8 data)
@@ -94,9 +95,10 @@ static int bd6107_backlight_update_status(struct backlight_device *backlight)
9495
bd6107_write(bd, BD6107_MAINCNT1, brightness);
9596
bd6107_write(bd, BD6107_LEDCNT1, BD6107_LEDCNT1_LEDONOFF1);
9697
} else {
97-
gpio_set_value(bd->pdata->reset, 0);
98+
/* Assert the reset line (gpiolib will handle active low) */
99+
gpiod_set_value(bd->reset, 1);
98100
msleep(24);
99-
gpio_set_value(bd->pdata->reset, 1);
101+
gpiod_set_value(bd->reset, 0);
100102
}
101103

102104
return 0;
@@ -125,8 +127,8 @@ static int bd6107_probe(struct i2c_client *client,
125127
struct bd6107 *bd;
126128
int ret;
127129

128-
if (pdata == NULL || !pdata->reset) {
129-
dev_err(&client->dev, "No reset GPIO in platform data\n");
130+
if (pdata == NULL) {
131+
dev_err(&client->dev, "No platform data\n");
130132
return -EINVAL;
131133
}
132134

@@ -144,10 +146,16 @@ static int bd6107_probe(struct i2c_client *client,
144146
bd->client = client;
145147
bd->pdata = pdata;
146148

147-
ret = devm_gpio_request_one(&client->dev, pdata->reset,
148-
GPIOF_DIR_OUT | GPIOF_INIT_LOW, "reset");
149-
if (ret < 0) {
149+
/*
150+
* Request the reset GPIO line with GPIOD_OUT_HIGH meaning asserted,
151+
* so in the machine descriptor table (or other hardware description),
152+
* the line should be flagged as active low so this will assert
153+
* the reset.
154+
*/
155+
bd->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_HIGH);
156+
if (IS_ERR(bd->reset)) {
150157
dev_err(&client->dev, "unable to request reset GPIO\n");
158+
ret = PTR_ERR(bd->reset);
151159
return ret;
152160
}
153161

include/linux/platform_data/bd6107.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ struct device;
99

1010
struct bd6107_platform_data {
1111
struct device *fbdev;
12-
int reset; /* Reset GPIO */
1312
unsigned int def_value;
1413
};
1514

0 commit comments

Comments
 (0)