#include <linux/delay.h>
 #include <linux/pm.h>
 #include <linux/gcd.h>
-#include <linux/gpio.h>
+#include <linux/gpio/driver.h>
 #include <linux/i2c.h>
 #include <linux/input.h>
 #include <linux/pm_runtime.h>
 }
 
 #ifdef CONFIG_GPIOLIB
-static inline struct wm8962_priv *gpio_to_wm8962(struct gpio_chip *chip)
-{
-       return container_of(chip, struct wm8962_priv, gpio_chip);
-}
-
 static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
 {
-       struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+       struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
 
        /* The WM8962 GPIOs aren't linearly numbered.  For simplicity
         * we export linear numbers and error out if the unsupported
 
 static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 {
-       struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+       struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
        struct snd_soc_codec *codec = wm8962->codec;
 
        snd_soc_update_bits(codec, WM8962_GPIO_BASE + offset,
 static int wm8962_gpio_direction_out(struct gpio_chip *chip,
                                     unsigned offset, int value)
 {
-       struct wm8962_priv *wm8962 = gpio_to_wm8962(chip);
+       struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
        struct snd_soc_codec *codec = wm8962->codec;
        int ret, val;
 
        else
                wm8962->gpio_chip.base = -1;
 
-       ret = gpiochip_add(&wm8962->gpio_chip);
+       ret = gpiochip_add_data(&wm8962->gpio_chip, wm8962);
        if (ret != 0)
                dev_err(codec->dev, "Failed to add GPIOs: %d\n", ret);
 }