Skip to content

Commit 023a600

Browse files
committed
Merge tag 'gpio-v4.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio
Pull GPIO fixes from Linus Walleij: "Two GPIO fixes: - Fix a translation problem in of_get_named_gpiod_flags() - Fix a long standing container_of() mistake in the TPS65912 driver" * tag 'gpio-v4.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio: gpio: tps65912: fix wrong container_of arguments gpiolib: of: allow of_gpiochip_find_and_xlate to find more than one chip per node
2 parents 10d6dfc + 2f97c20 commit 023a600

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

drivers/gpio/gpio-tps65912.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ struct tps65912_gpio_data {
2626
struct gpio_chip gpio_chip;
2727
};
2828

29+
#define to_tgd(gc) container_of(gc, struct tps65912_gpio_data, gpio_chip)
30+
2931
static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
3032
{
31-
struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
33+
struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
34+
struct tps65912 *tps65912 = tps65912_gpio->tps65912;
3235
int val;
3336

3437
val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset);
@@ -42,7 +45,8 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset)
4245
static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
4346
int value)
4447
{
45-
struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
48+
struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
49+
struct tps65912 *tps65912 = tps65912_gpio->tps65912;
4650

4751
if (value)
4852
tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset,
@@ -55,7 +59,8 @@ static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset,
5559
static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
5660
int value)
5761
{
58-
struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
62+
struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
63+
struct tps65912 *tps65912 = tps65912_gpio->tps65912;
5964

6065
/* Set the initial value */
6166
tps65912_gpio_set(gc, offset, value);
@@ -66,7 +71,8 @@ static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset,
6671

6772
static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset)
6873
{
69-
struct tps65912 *tps65912 = container_of(gc, struct tps65912, gpio);
74+
struct tps65912_gpio_data *tps65912_gpio = to_tgd(gc);
75+
struct tps65912 *tps65912 = tps65912_gpio->tps65912;
7076

7177
return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset,
7278
GPIO_CFG_MASK);

drivers/gpio/gpiolib-of.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,13 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data)
4646

4747
ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags);
4848
if (ret < 0) {
49-
/* We've found the gpio chip, but the translation failed.
50-
* Return true to stop looking and return the translation
51-
* error via out_gpio
49+
/* We've found a gpio chip, but the translation failed.
50+
* Store translation error in out_gpio.
51+
* Return false to keep looking, as more than one gpio chip
52+
* could be registered per of-node.
5253
*/
5354
gg_data->out_gpio = ERR_PTR(ret);
54-
return true;
55+
return false;
5556
}
5657

5758
gg_data->out_gpio = gpiochip_get_desc(gc, ret);

0 commit comments

Comments
 (0)