]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - sound/soc/codecs/wm8962.c
ASoC: constify snd_soc_codec_driver structures
[karo-tx-linux.git] / sound / soc / codecs / wm8962.c
index 720a14e0687d8140f95279b4bbe662ded13ff2e2..392b920670116d6bd6e08e7579e6a8ebe1bf90ad 100644 (file)
@@ -18,7 +18,7 @@
 #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>
@@ -3307,14 +3307,9 @@ static void wm8962_set_gpio_mode(struct wm8962_priv *wm8962, int gpio)
 }
 
 #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
@@ -3337,7 +3332,7 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
 
 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,
@@ -3347,7 +3342,7 @@ static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
 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;
 
@@ -3386,7 +3381,7 @@ static void wm8962_init_gpio(struct snd_soc_codec *codec)
        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);
 }
@@ -3484,7 +3479,7 @@ static int wm8962_remove(struct snd_soc_codec *codec)
        return 0;
 }
 
-static struct snd_soc_codec_driver soc_codec_dev_wm8962 = {
+static const struct snd_soc_codec_driver soc_codec_dev_wm8962 = {
        .probe =        wm8962_probe,
        .remove =       wm8962_remove,
        .set_bias_level = wm8962_set_bias_level,
@@ -3798,9 +3793,8 @@ static int wm8962_runtime_resume(struct device *dev)
        ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies),
                                    wm8962->supplies);
        if (ret != 0) {
-               dev_err(dev,
-                       "Failed to enable supplies: %d\n", ret);
-               return ret;
+               dev_err(dev, "Failed to enable supplies: %d\n", ret);
+               goto disable_clock;
        }
 
        regcache_cache_only(wm8962->regmap, false);
@@ -3838,6 +3832,10 @@ static int wm8962_runtime_resume(struct device *dev)
        msleep(5);
 
        return 0;
+
+disable_clock:
+       clk_disable_unprepare(wm8962->pdata.mclk);
+       return ret;
 }
 
 static int wm8962_runtime_suspend(struct device *dev)