]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ASoC: WM8903: Fix platform data gpio_cfg confusion
authorStephen Warren <swarren@nvidia.com>
Fri, 2 Dec 2011 22:08:37 +0000 (15:08 -0700)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Tue, 6 Dec 2011 10:29:22 +0000 (10:29 +0000)
wm8903_platform_data.gpio_cfg[] was intended to be interpreted as follows:
0:       Don't touch this GPIO's configuration register
1..7fff: Write that value to the GPIO's configuration register
8000:    Write zero to the GPIO's configuration register
other:   Undefined (invalid)

The rationale is that platform data is usually global data, and a value of
zero means that the field wasn't explicitly set to anything (e.g. because
the field was new to the pdata type, and existing users weren't update to
initialize it) and hence the value zero should be ignored. 0x8000 is an
explicit way to get 0 in the register.

The code worked this way until commit 7cfe561 "ASoC: wm8903: Expose GPIOs
through gpiolib", where the behaviour was changed due to my lack of
awareness of the above rationale.

This patch reverts to the intended behaviour, and updates all in-tree users
to use the correct scheme. This also makes WM8903 consistent with other
devices that use a similar scheme.

WM8903_GPIO_NO_CONFIG is also renamed to WM8903_GPIO_CONFIG_ZERO so that
its name accurately reflects its purpose.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: Colin Cross <ccross@android.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
arch/arm/mach-tegra/board-harmony.c
arch/arm/mach-tegra/board-seaboard.c
include/sound/wm8903.h
sound/soc/codecs/wm8903.c

index f0bdc5e3fe527a3a34d61b269a0ee0cc816a657e..3c57cdcdff4dfdcbdd70e94b2425a92bc63ca8fe 100644 (file)
@@ -89,11 +89,11 @@ static struct wm8903_platform_data harmony_wm8903_pdata = {
        .micdet_delay = 100,
        .gpio_base = HARMONY_GPIO_WM8903(0),
        .gpio_cfg = {
-               WM8903_GPIO_NO_CONFIG,
-               WM8903_GPIO_NO_CONFIG,
                0,
-               WM8903_GPIO_NO_CONFIG,
-               WM8903_GPIO_NO_CONFIG,
+               0,
+               WM8903_GPIO_CONFIG_ZERO,
+               0,
+               0,
        },
 };
 
index bf13ea355efcc5049642f78f9e2869609a0bff91..5c2f7751a33a2035dae3ba8e206c0f9dfa2472b5 100644 (file)
@@ -171,11 +171,11 @@ static struct wm8903_platform_data wm8903_pdata = {
        .micdet_delay = 100,
        .gpio_base = SEABOARD_GPIO_WM8903(0),
        .gpio_cfg = {
-               WM8903_GPIO_NO_CONFIG,
-               WM8903_GPIO_NO_CONFIG,
                0,
-               WM8903_GPIO_NO_CONFIG,
-               WM8903_GPIO_NO_CONFIG,
+               0,
+               WM8903_GPIO_CONFIG_ZERO,
+               0,
+               0,
        },
 };
 
index cf7ccb76a8de8ad7f7a409aad3a703addd574d06..b310c5a3a958dfd1e71f026e9c2e527c93071b61 100644 (file)
 #ifndef __LINUX_SND_WM8903_H
 #define __LINUX_SND_WM8903_H
 
-/* Used to enable configuration of a GPIO to all zeros */
-#define WM8903_GPIO_NO_CONFIG 0x8000
+/*
+ * Used to enable configuration of a GPIO to all zeros; a gpio_cfg value of
+ * zero in platform data means "don't touch this pin".
+ */
+#define WM8903_GPIO_CONFIG_ZERO 0x8000
 
 /*
  * R6 (0x06) - Mic Bias Control 0
index e6ecede576dc414e663552be07bf76215d6358b2..184b67730c3951acc3ade937e7f89c2254e1630e 100644 (file)
@@ -1893,7 +1893,8 @@ static int wm8903_probe(struct snd_soc_codec *codec)
                bool mic_gpio = false;
 
                for (i = 0; i < ARRAY_SIZE(pdata->gpio_cfg); i++) {
-                       if (pdata->gpio_cfg[i] > 0x7fff)
+                       if ((!pdata->gpio_cfg[i]) ||
+                           (pdata->gpio_cfg[i] > WM8903_GPIO_CONFIG_ZERO))
                                continue;
 
                        snd_soc_write(codec, WM8903_GPIO_CONTROL_1 + i,