Commit 023a6007a08d342b64895a7342e426d12d9627dd
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
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
Showing 2 changed files Side-by-side Diff
drivers/gpio/gpio-tps65912.c
... | ... | @@ -26,9 +26,12 @@ |
26 | 26 | struct gpio_chip gpio_chip; |
27 | 27 | }; |
28 | 28 | |
29 | +#define to_tgd(gc) container_of(gc, struct tps65912_gpio_data, gpio_chip) | |
30 | + | |
29 | 31 | static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) |
30 | 32 | { |
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; | |
32 | 35 | int val; |
33 | 36 | |
34 | 37 | val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset); |
... | ... | @@ -42,7 +45,8 @@ |
42 | 45 | static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, |
43 | 46 | int value) |
44 | 47 | { |
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; | |
46 | 50 | |
47 | 51 | if (value) |
48 | 52 | tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset, |
... | ... | @@ -55,7 +59,8 @@ |
55 | 59 | static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, |
56 | 60 | int value) |
57 | 61 | { |
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; | |
59 | 64 | |
60 | 65 | /* Set the initial value */ |
61 | 66 | tps65912_gpio_set(gc, offset, value); |
... | ... | @@ -66,7 +71,8 @@ |
66 | 71 | |
67 | 72 | static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset) |
68 | 73 | { |
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; | |
70 | 76 | |
71 | 77 | return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, |
72 | 78 | GPIO_CFG_MASK); |
drivers/gpio/gpiolib-of.c
... | ... | @@ -46,12 +46,13 @@ |
46 | 46 | |
47 | 47 | ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); |
48 | 48 | 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. | |
52 | 53 | */ |
53 | 54 | gg_data->out_gpio = ERR_PTR(ret); |
54 | - return true; | |
55 | + return false; | |
55 | 56 | } |
56 | 57 | |
57 | 58 | gg_data->out_gpio = gpiochip_get_desc(gc, ret); |