gpio: wm8994: 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: patches@opensource.wolfsonmicro.com Cc: Mark Brown <broonie@kernel.org> Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Родитель
dfcdf7214e
Коммит
765aa58778
|
@ -31,14 +31,9 @@ struct wm8994_gpio {
|
||||||
struct gpio_chip gpio_chip;
|
struct gpio_chip gpio_chip;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline struct wm8994_gpio *to_wm8994_gpio(struct gpio_chip *chip)
|
|
||||||
{
|
|
||||||
return container_of(chip, struct wm8994_gpio, gpio_chip);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset)
|
static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
|
|
||||||
switch (wm8994->type) {
|
switch (wm8994->type) {
|
||||||
|
@ -61,7 +56,7 @@ static int wm8994_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||||
|
|
||||||
static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
|
|
||||||
return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset,
|
return wm8994_set_bits(wm8994, WM8994_GPIO_1 + offset,
|
||||||
|
@ -70,7 +65,7 @@ static int wm8994_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
|
||||||
|
|
||||||
static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset)
|
static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -87,7 +82,7 @@ static int wm8994_gpio_get(struct gpio_chip *chip, unsigned offset)
|
||||||
static int wm8994_gpio_direction_out(struct gpio_chip *chip,
|
static int wm8994_gpio_direction_out(struct gpio_chip *chip,
|
||||||
unsigned offset, int value)
|
unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -99,7 +94,7 @@ static int wm8994_gpio_direction_out(struct gpio_chip *chip,
|
||||||
|
|
||||||
static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
|
|
||||||
if (value)
|
if (value)
|
||||||
|
@ -110,7 +105,7 @@ static void wm8994_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||||
|
|
||||||
static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
|
static int wm8994_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
|
|
||||||
return regmap_irq_get_virq(wm8994->irq_data, offset);
|
return regmap_irq_get_virq(wm8994->irq_data, offset);
|
||||||
|
@ -174,7 +169,7 @@ static const char *wm8994_gpio_fn(u16 fn)
|
||||||
|
|
||||||
static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
static void wm8994_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
|
||||||
{
|
{
|
||||||
struct wm8994_gpio *wm8994_gpio = to_wm8994_gpio(chip);
|
struct wm8994_gpio *wm8994_gpio = gpiochip_get_data(chip);
|
||||||
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
struct wm8994 *wm8994 = wm8994_gpio->wm8994;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -266,7 +261,7 @@ static int wm8994_gpio_probe(struct platform_device *pdev)
|
||||||
else
|
else
|
||||||
wm8994_gpio->gpio_chip.base = -1;
|
wm8994_gpio->gpio_chip.base = -1;
|
||||||
|
|
||||||
ret = gpiochip_add(&wm8994_gpio->gpio_chip);
|
ret = gpiochip_add_data(&wm8994_gpio->gpio_chip, wm8994_gpio);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
|
dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
|
||||||
ret);
|
ret);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче