Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: simple-gpio: use gpiochip data pointer

This makes the driver use the data pointer added to the gpio_chip
to store a pointer to the state container instead of relying on
container_of().

Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

+4 -9
+4 -9
arch/powerpc/sysdev/simple_gpio.c
··· 19 19 #include <linux/io.h> 20 20 #include <linux/of.h> 21 21 #include <linux/of_gpio.h> 22 - #include <linux/gpio.h> 22 + #include <linux/gpio/driver.h> 23 23 #include <linux/slab.h> 24 24 #include <asm/prom.h> 25 25 #include "simple_gpio.h" ··· 31 31 /* shadowed data register to clear/set bits safely */ 32 32 u8 data; 33 33 }; 34 - 35 - static struct u8_gpio_chip *to_u8_gpio_chip(struct of_mm_gpio_chip *mm_gc) 36 - { 37 - return container_of(mm_gc, struct u8_gpio_chip, mm_gc); 38 - } 39 34 40 35 static u8 u8_pin2mask(unsigned int pin) 41 36 { ··· 47 52 static void u8_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) 48 53 { 49 54 struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc); 50 - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); 55 + struct u8_gpio_chip *u8_gc = gpiochip_get_data(gc); 51 56 unsigned long flags; 52 57 53 58 spin_lock_irqsave(&u8_gc->lock, flags); ··· 75 80 76 81 static void u8_gpio_save_regs(struct of_mm_gpio_chip *mm_gc) 77 82 { 78 - struct u8_gpio_chip *u8_gc = to_u8_gpio_chip(mm_gc); 83 + struct u8_gpio_chip *u8_gc = gpiochip_get_data(&mm_gc->gc); 79 84 80 85 u8_gc->data = in_8(mm_gc->regs); 81 86 } ··· 103 108 gc->get = u8_gpio_get; 104 109 gc->set = u8_gpio_set; 105 110 106 - ret = of_mm_gpiochip_add(np, mm_gc); 111 + ret = of_mm_gpiochip_add_data(np, mm_gc, u8_gc); 107 112 if (ret) 108 113 goto err; 109 114 return 0;