Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Marek Vasut and committed by
Samuel Ortiz
360e64d8 20fb2772

+17 -25
+6 -13
drivers/gpio/gpio-ucb1400.c
··· 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; ··· 48 50 struct ucb1400_gpio *ucb = dev->dev.platform_data; 49 51 int err = 0; 50 52 51 - if (!(ucbdata && ucbdata->gpio_offset)) { 53 + if (!(ucb && ucb->gpio_offset)) { 52 54 err = -EINVAL; 53 55 goto err; 54 56 } ··· 56 58 platform_set_drvdata(dev, ucb); 57 59 58 60 ucb->gc.label = "ucb1400_gpio"; 59 - ucb->gc.base = ucbdata->gpio_offset; 61 + ucb->gc.base = ucb->gpio_offset; 60 62 ucb->gc.ngpio = 10; 61 63 ucb->gc.owner = THIS_MODULE; 62 64 ··· 70 72 if (err) 71 73 goto err; 72 74 73 - if (ucbdata && ucbdata->gpio_setup) 74 - err = ucbdata->gpio_setup(&dev->dev, ucb->gc.ngpio); 75 + if (ucb && ucb->gpio_setup) 76 + err = ucb->gpio_setup(&dev->dev, ucb->gc.ngpio); 75 77 76 78 err: 77 79 return err; ··· 83 85 int err = 0; 84 86 struct ucb1400_gpio *ucb = platform_get_drvdata(dev); 85 87 86 - if (ucbdata && ucbdata->gpio_teardown) { 87 - err = ucbdata->gpio_teardown(&dev->dev, ucb->gc.ngpio); 88 + if (ucb && ucb->gpio_teardown) { 89 + err = ucb->gpio_teardown(&dev->dev, ucb->gc.ngpio); 88 90 if (err) 89 91 return err; 90 92 } ··· 100 102 .name = "ucb1400_gpio" 101 103 }, 102 104 }; 103 - 104 - void __init ucb1400_gpio_set_data(struct ucb1400_gpio_data *data) 105 - { 106 - ucbdata = data; 107 - } 108 105 109 106 module_platform_driver(ucb1400_gpio_driver); 110 107
+5
drivers/mfd/ucb1400_core.c
··· 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;
+6 -12
include/linux/ucb1400.h
··· 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 { ··· 107 110 108 111 struct ucb1400_pdata { 109 112 int irq; 113 + int gpio_offset; 114 + int (*gpio_setup)(struct device *dev, int ngpio); 115 + int (*gpio_teardown)(struct device *dev, int ngpio); 110 116 }; 111 117 112 118 static inline u16 ucb1400_reg_read(struct snd_ac97 *ac97, u16 reg) ··· 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