diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-03-02 17:13:39 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-03-02 17:13:39 -0500 |
commit | 023a6007a08d342b64895a7342e426d12d9627dd (patch) | |
tree | 3fb3e1a0a0d93b5c35f67986a3547bc5247cebcc | |
parent | 10d6dfc1979ba3b2533c544ed1a4df21aa113a1f (diff) | |
parent | 2f97c20e5f7c3582c7310f65a04465bfb0fd0e85 (diff) |
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
-rw-r--r-- | drivers/gpio/gpio-tps65912.c | 14 | ||||
-rw-r--r-- | drivers/gpio/gpiolib-of.c | 9 |
2 files changed, 15 insertions, 8 deletions
diff --git a/drivers/gpio/gpio-tps65912.c b/drivers/gpio/gpio-tps65912.c index 472fb5b8779f..9cdbc0c9cb2d 100644 --- a/drivers/gpio/gpio-tps65912.c +++ b/drivers/gpio/gpio-tps65912.c | |||
@@ -26,9 +26,12 @@ struct tps65912_gpio_data { | |||
26 | struct gpio_chip gpio_chip; | 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 | static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) | 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 | int val; | 35 | int val; |
33 | 36 | ||
34 | val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset); | 37 | val = tps65912_reg_read(tps65912, TPS65912_GPIO1 + offset); |
@@ -42,7 +45,8 @@ static int tps65912_gpio_get(struct gpio_chip *gc, unsigned offset) | |||
42 | static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, | 45 | static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, |
43 | int value) | 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 | if (value) | 51 | if (value) |
48 | tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset, | 52 | tps65912_set_bits(tps65912, TPS65912_GPIO1 + offset, |
@@ -55,7 +59,8 @@ static void tps65912_gpio_set(struct gpio_chip *gc, unsigned offset, | |||
55 | static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, | 59 | static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, |
56 | int value) | 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 | /* Set the initial value */ | 65 | /* Set the initial value */ |
61 | tps65912_gpio_set(gc, offset, value); | 66 | tps65912_gpio_set(gc, offset, value); |
@@ -66,7 +71,8 @@ static int tps65912_gpio_output(struct gpio_chip *gc, unsigned offset, | |||
66 | 71 | ||
67 | static int tps65912_gpio_input(struct gpio_chip *gc, unsigned offset) | 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 | return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, | 77 | return tps65912_clear_bits(tps65912, TPS65912_GPIO1 + offset, |
72 | GPIO_CFG_MASK); | 78 | GPIO_CFG_MASK); |
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 8cad8e400b44..4650bf830d6b 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c | |||
@@ -46,12 +46,13 @@ static int of_gpiochip_find_and_xlate(struct gpio_chip *gc, void *data) | |||
46 | 46 | ||
47 | ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); | 47 | ret = gc->of_xlate(gc, &gg_data->gpiospec, gg_data->flags); |
48 | if (ret < 0) { | 48 | if (ret < 0) { |
49 | /* We've found the gpio chip, but the translation failed. | 49 | /* We've found a gpio chip, but the translation failed. |
50 | * Return true to stop looking and return the translation | 50 | * Store translation error in out_gpio. |
51 | * error via out_gpio | 51 | * Return false to keep looking, as more than one gpio chip |
52 | * could be registered per of-node. | ||
52 | */ | 53 | */ |
53 | gg_data->out_gpio = ERR_PTR(ret); | 54 | gg_data->out_gpio = ERR_PTR(ret); |
54 | return true; | 55 | return false; |
55 | } | 56 | } |
56 | 57 | ||
57 | gg_data->out_gpio = gpiochip_get_desc(gc, ret); | 58 | gg_data->out_gpio = gpiochip_get_desc(gc, ret); |