Skip to content

Commit 2f97c20

Browse files
vianpllinusw
authored andcommitted
gpio: tps65912: fix wrong container_of arguments
The gpio_chip operations receive a pointer the gpio_chip struct which is contained in the driver's private struct, yet the container_of call in those functions point to the mfd struct defined in include/linux/mfd/tps65912.h. Cc: Stable <stable@vger.kernel.org> Signed-off-by: Nicolas Saenz Julienne <nicolassaenzj@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 9cf75e9 commit 2f97c20

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
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);

0 commit comments

Comments
 (0)