Commit 360e64d8bbe7c78784d769a60d152804f5079577

Authored by Marek Vasut
Committed by Samuel Ortiz
1 parent 20fb277250

mfd: ucb1400: Pass ucb1400-gpio data through ac97 bus

Cc: Jean Delvare <jdelvare@suse.de>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>

Showing 3 changed files with 17 additions and 25 deletions Side-by-side Diff

drivers/gpio/gpio-ucb1400.c
... ... @@ -12,8 +12,6 @@
12 12 #include <linux/module.h>
13 13 #include <linux/ucb1400.h>
14 14  
15   -struct ucb1400_gpio_data *ucbdata;
16   -
17 15 static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off)
18 16 {
19 17 struct ucb1400_gpio *gpio;
... ... @@ -50,7 +48,7 @@
50 48 struct ucb1400_gpio *ucb = dev->dev.platform_data;
51 49 int err = 0;
52 50  
53   - if (!(ucbdata && ucbdata->gpio_offset)) {
  51 + if (!(ucb && ucb->gpio_offset)) {
54 52 err = -EINVAL;
55 53 goto err;
56 54 }
... ... @@ -58,7 +56,7 @@
58 56 platform_set_drvdata(dev, ucb);
59 57  
60 58 ucb->gc.label = "ucb1400_gpio";
61   - ucb->gc.base = ucbdata->gpio_offset;
  59 + ucb->gc.base = ucb->gpio_offset;
62 60 ucb->gc.ngpio = 10;
63 61 ucb->gc.owner = THIS_MODULE;
64 62  
... ... @@ -72,8 +70,8 @@
72 70 if (err)
73 71 goto err;
74 72  
75   - if (ucbdata && ucbdata->gpio_setup)
76   - err = ucbdata->gpio_setup(&dev->dev, ucb->gc.ngpio);
  73 + if (ucb && ucb->gpio_setup)
  74 + err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio);
77 75  
78 76 err:
79 77 return err;
... ... @@ -85,8 +83,8 @@
85 83 int err = 0;
86 84 struct ucb1400_gpio *ucb = platform_get_drvdata(dev);
87 85  
88   - if (ucbdata && ucbdata->gpio_teardown) {
89   - err = ucbdata->gpio_teardown(&dev->dev, ucb->gc.ngpio);
  86 + if (ucb && ucb->gpio_teardown) {
  87 + err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio);
90 88 if (err)
91 89 return err;
92 90 }
... ... @@ -102,11 +100,6 @@
102 100 .name = "ucb1400_gpio"
103 101 },
104 102 };
105   -
106   -void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data)
107   -{
108   - ucbdata = data;
109   -}
110 103  
111 104 module_platform_driver(ucb1400_gpio_driver);
112 105  
drivers/mfd/ucb1400_core.c
... ... @@ -75,6 +75,11 @@
75 75  
76 76 /* GPIO */
77 77 ucb_gpio.ac97 = ac97;
  78 + if (pdata) {
  79 + ucb_gpio.gpio_setup = pdata->gpio_setup;
  80 + ucb_gpio.gpio_teardown = pdata->gpio_teardown;
  81 + ucb_gpio.gpio_offset = pdata->gpio_offset;
  82 + }
78 83 ucb->ucb1400_gpio = platform_device_alloc("ucb1400_gpio", -1);
79 84 if (!ucb->ucb1400_gpio) {
80 85 err = -ENOMEM;
include/linux/ucb1400.h
... ... @@ -83,15 +83,12 @@
83 83 #define UCB_ID 0x7e
84 84 #define UCB_ID_1400 0x4304
85 85  
86   -struct ucb1400_gpio_data {
87   - int gpio_offset;
88   - int (*gpio_setup)(struct device *dev, int ngpio);
89   - int (*gpio_teardown)(struct device *dev, int ngpio);
90   -};
91   -
92 86 struct ucb1400_gpio {
93 87 struct gpio_chip gc;
94 88 struct snd_ac97 *ac97;
  89 + int gpio_offset;
  90 + int (*gpio_setup)(struct device *dev, int ngpio);
  91 + int (*gpio_teardown)(struct device *dev, int ngpio);
95 92 };
96 93  
97 94 struct ucb1400_ts {
... ... @@ -110,6 +107,9 @@
110 107  
111 108 struct ucb1400_pdata {
112 109 int irq;
  110 + int gpio_offset;
  111 + int (*gpio_setup)(struct device *dev, int ngpio);
  112 + int (*gpio_teardown)(struct device *dev, int ngpio);
113 113 };
114 114  
115 115 static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg)
... ... @@ -161,12 +161,6 @@
161 161  
162 162 unsigned int ucb1400_adc_read(struct snd_ac97 *ac97, u16 adc_channel,
163 163 int adcsync);
164   -
165   -#ifdef CONFIG_GPIO_UCB1400
166   -void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data);
167   -#else
168   -static inline void ucb1400_gpio_set_data(struct ucb1400_gpio_data *data) {}
169   -#endif
170 164  
171 165 #endif