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

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: convert GPIO chips to using new value setters

Merge series from Bartosz Golaszewski <brgl@bgdev.pl>:

struct gpio_chip now has callbacks for setting line values that return
an integer, allowing to indicate failures. We're in the process of
converting all GPIO drivers to using the new API. This series converts
all ASoC GPIO controllers.

+84 -50
+4 -3
sound/pci/hda/cirrus_scodec_test.c
··· 48 48 return -EOPNOTSUPP; 49 49 } 50 50 51 - static void cirrus_scodec_test_gpio_set(struct gpio_chip *chip, unsigned int offset, 52 - int value) 51 + static int cirrus_scodec_test_gpio_set(struct gpio_chip *chip, 52 + unsigned int offset, int value) 53 53 { 54 + return -EOPNOTSUPP; 54 55 } 55 56 56 57 static int cirrus_scodec_test_gpio_set_config(struct gpio_chip *gc, ··· 76 75 .direction_input = cirrus_scodec_test_gpio_direction_in, 77 76 .get = cirrus_scodec_test_gpio_get, 78 77 .direction_output = cirrus_scodec_test_gpio_direction_out, 79 - .set = cirrus_scodec_test_gpio_set, 78 + .set_rv = cirrus_scodec_test_gpio_set, 80 79 .set_config = cirrus_scodec_test_gpio_set_config, 81 80 .base = -1, 82 81 .ngpio = 32,
+12 -7
sound/soc/codecs/idt821034.c
··· 957 957 #define IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(_offset) (((_offset) / 5) % 4) 958 958 #define IDT821034_GPIO_OFFSET_TO_SLIC_MASK(_offset) BIT((_offset) % 5) 959 959 960 - static void idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val) 960 + static int idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, 961 + int val) 961 962 { 962 963 u8 ch = IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(offset); 963 964 u8 mask = IDT821034_GPIO_OFFSET_TO_SLIC_MASK(offset); ··· 974 973 else 975 974 slic_raw &= ~mask; 976 975 ret = idt821034_write_slic_raw(idt821034, ch, slic_raw); 977 - if (ret) { 978 - dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n", 979 - offset, ch, mask, ret); 980 - } 981 976 982 977 mutex_unlock(&idt821034->mutex); 978 + 979 + if (ret) 980 + dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n", 981 + offset, ch, mask, ret); 982 + 983 + return ret; 983 984 } 984 985 985 986 static int idt821034_chip_gpio_get(struct gpio_chip *c, unsigned int offset) ··· 1057 1054 u8 slic_conf; 1058 1055 int ret; 1059 1056 1060 - idt821034_chip_gpio_set(c, offset, val); 1057 + ret = idt821034_chip_gpio_set(c, offset, val); 1058 + if (ret) 1059 + return ret; 1061 1060 1062 1061 mutex_lock(&idt821034->mutex); 1063 1062 ··· 1117 1112 idt821034->gpio_chip.direction_input = idt821034_chip_direction_input; 1118 1113 idt821034->gpio_chip.direction_output = idt821034_chip_direction_output; 1119 1114 idt821034->gpio_chip.get = idt821034_chip_gpio_get; 1120 - idt821034->gpio_chip.set = idt821034_chip_gpio_set; 1115 + idt821034->gpio_chip.set_rv = idt821034_chip_gpio_set; 1121 1116 idt821034->gpio_chip.can_sleep = true; 1122 1117 1123 1118 return devm_gpiochip_add_data(&idt821034->spi->dev, &idt821034->gpio_chip,
+10 -5
sound/soc/codecs/peb2466.c
··· 1726 1726 return ret; 1727 1727 } 1728 1728 1729 - static void peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val) 1729 + static int peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset, 1730 + int val) 1730 1731 { 1731 1732 struct peb2466 *peb2466 = gpiochip_get_data(c); 1732 1733 unsigned int xr_reg; ··· 1741 1740 */ 1742 1741 dev_warn(&peb2466->spi->dev, "cannot set gpio %d (read-only)\n", 1743 1742 offset); 1744 - return; 1743 + return -EINVAL; 1745 1744 } 1746 1745 1747 1746 ret = peb2466_chip_gpio_offset_to_data_regmask(offset, &xr_reg, &mask); 1748 1747 if (ret) { 1749 1748 dev_err(&peb2466->spi->dev, "cannot set gpio %d (%d)\n", 1750 1749 offset, ret); 1751 - return; 1750 + return ret; 1752 1751 } 1753 1752 1754 1753 ret = peb2466_chip_gpio_update_bits(peb2466, xr_reg, mask, val ? mask : 0); ··· 1756 1755 dev_err(&peb2466->spi->dev, "set gpio %d (0x%x, 0x%x) failed (%d)\n", 1757 1756 offset, xr_reg, mask, ret); 1758 1757 } 1758 + 1759 + return ret; 1759 1760 } 1760 1761 1761 1762 static int peb2466_chip_gpio_get(struct gpio_chip *c, unsigned int offset) ··· 1882 1879 return -EINVAL; 1883 1880 } 1884 1881 1885 - peb2466_chip_gpio_set(c, offset, val); 1882 + ret = peb2466_chip_gpio_set(c, offset, val); 1883 + if (ret) 1884 + return ret; 1886 1885 1887 1886 if (offset < 16) { 1888 1887 /* SOx_{0,1} */ ··· 1945 1940 peb2466->gpio.gpio_chip.direction_input = peb2466_chip_direction_input; 1946 1941 peb2466->gpio.gpio_chip.direction_output = peb2466_chip_direction_output; 1947 1942 peb2466->gpio.gpio_chip.get = peb2466_chip_gpio_get; 1948 - peb2466->gpio.gpio_chip.set = peb2466_chip_gpio_set; 1943 + peb2466->gpio.gpio_chip.set_rv = peb2466_chip_gpio_set; 1949 1944 peb2466->gpio.gpio_chip.can_sleep = true; 1950 1945 1951 1946 return devm_gpiochip_add_data(&peb2466->spi->dev, &peb2466->gpio.gpio_chip,
+4 -3
sound/soc/codecs/rt5677.c
··· 4725 4725 } 4726 4726 4727 4727 #ifdef CONFIG_GPIOLIB 4728 - static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 4728 + static int rt5677_gpio_set(struct gpio_chip *chip, unsigned int offset, 4729 + int value) 4729 4730 { 4730 4731 struct rt5677_priv *rt5677 = gpiochip_get_data(chip); 4731 4732 int level = value ? RT5677_GPIOx_OUT_HI : RT5677_GPIOx_OUT_LO; 4732 4733 int m = RT5677_GPIOx_OUT_MASK; 4733 4734 4734 - rt5677_update_gpio_bits(rt5677, offset, m, level); 4735 + return rt5677_update_gpio_bits(rt5677, offset, m, level); 4735 4736 } 4736 4737 4737 4738 static int rt5677_gpio_direction_out(struct gpio_chip *chip, ··· 4835 4834 .label = RT5677_DRV_NAME, 4836 4835 .owner = THIS_MODULE, 4837 4836 .direction_output = rt5677_gpio_direction_out, 4838 - .set = rt5677_gpio_set, 4837 + .set_rv = rt5677_gpio_set, 4839 4838 .direction_input = rt5677_gpio_direction_in, 4840 4839 .get = rt5677_gpio_get, 4841 4840 .to_irq = rt5677_to_irq,
+4 -4
sound/soc/codecs/tlv320adc3xxx.c
··· 1015 1015 * so we set the output mode and output value in the same call. Hence 1016 1016 * .set in practice does the same thing as .direction_out . 1017 1017 */ 1018 - static void adc3xxx_gpio_set(struct gpio_chip *chip, unsigned int offset, 1019 - int value) 1018 + static int adc3xxx_gpio_set(struct gpio_chip *chip, unsigned int offset, 1019 + int value) 1020 1020 { 1021 - (void) adc3xxx_gpio_direction_out(chip, offset, value); 1021 + return adc3xxx_gpio_direction_out(chip, offset, value); 1022 1022 } 1023 1023 1024 1024 /* Even though we only support GPIO output for now, some GPIO clients ··· 1052 1052 .owner = THIS_MODULE, 1053 1053 .request = adc3xxx_gpio_request, 1054 1054 .direction_output = adc3xxx_gpio_direction_out, 1055 - .set = adc3xxx_gpio_set, 1055 + .set_rv = adc3xxx_gpio_set, 1056 1056 .get = adc3xxx_gpio_get, 1057 1057 .can_sleep = 1, 1058 1058 };
+6 -4
sound/soc/codecs/wm5100.c
··· 2236 2236 } 2237 2237 2238 2238 #ifdef CONFIG_GPIOLIB 2239 - static void wm5100_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 2239 + static int wm5100_gpio_set(struct gpio_chip *chip, unsigned int offset, 2240 + int value) 2240 2241 { 2241 2242 struct wm5100_priv *wm5100 = gpiochip_get_data(chip); 2242 2243 2243 - regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, 2244 - WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT); 2244 + return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset, 2245 + WM5100_GP1_LVL, 2246 + !!value << WM5100_GP1_LVL_SHIFT); 2245 2247 } 2246 2248 2247 2249 static int wm5100_gpio_direction_out(struct gpio_chip *chip, ··· 2290 2288 .label = "wm5100", 2291 2289 .owner = THIS_MODULE, 2292 2290 .direction_output = wm5100_gpio_direction_out, 2293 - .set = wm5100_gpio_set, 2291 + .set_rv = wm5100_gpio_set, 2294 2292 .direction_input = wm5100_gpio_direction_in, 2295 2293 .get = wm5100_gpio_get, 2296 2294 .can_sleep = 1,
+7 -5
sound/soc/codecs/wm8903.c
··· 1825 1825 return 0; 1826 1826 } 1827 1827 1828 - static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 1828 + static int wm8903_gpio_set(struct gpio_chip *chip, unsigned int offset, 1829 + int value) 1829 1830 { 1830 1831 struct wm8903_priv *wm8903 = gpiochip_get_data(chip); 1831 1832 1832 - regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset, 1833 - WM8903_GP1_LVL_MASK, 1834 - !!value << WM8903_GP1_LVL_SHIFT); 1833 + return regmap_update_bits(wm8903->regmap, 1834 + WM8903_GPIO_CONTROL_1 + offset, 1835 + WM8903_GP1_LVL_MASK, 1836 + !!value << WM8903_GP1_LVL_SHIFT); 1835 1837 } 1836 1838 1837 1839 static const struct gpio_chip wm8903_template_chip = { ··· 1843 1841 .direction_input = wm8903_gpio_direction_in, 1844 1842 .get = wm8903_gpio_get, 1845 1843 .direction_output = wm8903_gpio_direction_out, 1846 - .set = wm8903_gpio_set, 1844 + .set_rv = wm8903_gpio_set, 1847 1845 .can_sleep = 1, 1848 1846 }; 1849 1847
+7 -4
sound/soc/codecs/wm8962.c
··· 3407 3407 return 0; 3408 3408 } 3409 3409 3410 - static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 3410 + static int wm8962_gpio_set(struct gpio_chip *chip, unsigned int offset, 3411 + int value) 3411 3412 { 3412 3413 struct wm8962_priv *wm8962 = gpiochip_get_data(chip); 3413 3414 struct snd_soc_component *component = wm8962->component; 3414 3415 3415 - snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset, 3416 - WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT); 3416 + return snd_soc_component_update_bits(component, 3417 + WM8962_GPIO_BASE + offset, 3418 + WM8962_GP2_LVL, 3419 + !!value << WM8962_GP2_LVL_SHIFT); 3417 3420 } 3418 3421 3419 3422 static int wm8962_gpio_direction_out(struct gpio_chip *chip, ··· 3442 3439 .owner = THIS_MODULE, 3443 3440 .request = wm8962_gpio_request, 3444 3441 .direction_output = wm8962_gpio_direction_out, 3445 - .set = wm8962_gpio_set, 3442 + .set_rv = wm8962_gpio_set, 3446 3443 .can_sleep = 1, 3447 3444 }; 3448 3445
+6 -4
sound/soc/codecs/wm8996.c
··· 2136 2136 } 2137 2137 2138 2138 #ifdef CONFIG_GPIOLIB 2139 - static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value) 2139 + static int wm8996_gpio_set(struct gpio_chip *chip, unsigned int offset, 2140 + int value) 2140 2141 { 2141 2142 struct wm8996_priv *wm8996 = gpiochip_get_data(chip); 2142 2143 2143 - regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2144 - WM8996_GP1_LVL, !!value << WM8996_GP1_LVL_SHIFT); 2144 + return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset, 2145 + WM8996_GP1_LVL, 2146 + !!value << WM8996_GP1_LVL_SHIFT); 2145 2147 } 2146 2148 2147 2149 static int wm8996_gpio_direction_out(struct gpio_chip *chip, ··· 2186 2184 .label = "wm8996", 2187 2185 .owner = THIS_MODULE, 2188 2186 .direction_output = wm8996_gpio_direction_out, 2189 - .set = wm8996_gpio_set, 2187 + .set_rv = wm8996_gpio_set, 2190 2188 .direction_input = wm8996_gpio_direction_in, 2191 2189 .get = wm8996_gpio_get, 2192 2190 .can_sleep = 1,
+8 -4
sound/soc/codecs/zl38060.c
··· 387 387 .endianness = 1, 388 388 }; 389 389 390 - static void chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val) 390 + static int chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val) 391 391 { 392 392 struct regmap *regmap = gpiochip_get_data(c); 393 393 unsigned int mask = BIT(offset); 394 394 395 - regmap_update_bits(regmap, REG_GPIO_DAT, mask, val ? mask : 0); 395 + return regmap_update_bits(regmap, REG_GPIO_DAT, mask, val ? mask : 0); 396 396 } 397 397 398 398 static int chip_gpio_get(struct gpio_chip *c, unsigned int offset) ··· 422 422 { 423 423 struct regmap *regmap = gpiochip_get_data(c); 424 424 unsigned int mask = BIT(offset); 425 + int ret; 425 426 426 - chip_gpio_set(c, offset, val); 427 + ret = chip_gpio_set(c, offset, val); 428 + if (ret) 429 + return ret; 430 + 427 431 return regmap_update_bits(regmap, REG_GPIO_DIR, mask, mask); 428 432 } 429 433 ··· 440 436 .direction_input = chip_direction_input, 441 437 .direction_output = chip_direction_output, 442 438 .get = chip_gpio_get, 443 - .set = chip_gpio_set, 439 + .set_rv = chip_gpio_set, 444 440 445 441 .can_sleep = true, 446 442 };
+11 -4
sound/soc/soc-ac97.c
··· 87 87 return !!(ret & (1 << offset)); 88 88 } 89 89 90 - static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset, 91 - int value) 90 + static int snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset, 91 + int value) 92 92 { 93 93 struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip); 94 94 struct snd_soc_component *component = gpio_to_component(chip); ··· 98 98 snd_soc_component_write(component, AC97_GPIO_STATUS, 99 99 gpio_priv->gpios_set); 100 100 dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value); 101 + 102 + return 0; 101 103 } 102 104 103 105 static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip, 104 106 unsigned offset, int value) 105 107 { 106 108 struct snd_soc_component *component = gpio_to_component(chip); 109 + int ret; 107 110 108 111 dev_dbg(component->dev, "set gpio %d to output\n", offset); 109 - snd_soc_ac97_gpio_set(chip, offset, value); 112 + 113 + ret = snd_soc_ac97_gpio_set(chip, offset, value); 114 + if (ret) 115 + return ret; 116 + 110 117 return snd_soc_component_update_bits(component, AC97_GPIO_CFG, 111 118 1 << offset, 0); 112 119 } ··· 125 118 .direction_input = snd_soc_ac97_gpio_direction_in, 126 119 .get = snd_soc_ac97_gpio_get, 127 120 .direction_output = snd_soc_ac97_gpio_direction_out, 128 - .set = snd_soc_ac97_gpio_set, 121 + .set_rv = snd_soc_ac97_gpio_set, 129 122 .can_sleep = 1, 130 123 }; 131 124
+5 -3
sound/soc/ti/davinci-mcasp.c
··· 2157 2157 return 0; 2158 2158 } 2159 2159 2160 - static void davinci_mcasp_gpio_set(struct gpio_chip *chip, unsigned offset, 2161 - int value) 2160 + static int davinci_mcasp_gpio_set(struct gpio_chip *chip, unsigned int offset, 2161 + int value) 2162 2162 { 2163 2163 struct davinci_mcasp *mcasp = gpiochip_get_data(chip); 2164 2164 ··· 2166 2166 mcasp_set_bits(mcasp, DAVINCI_MCASP_PDOUT_REG, BIT(offset)); 2167 2167 else 2168 2168 mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDOUT_REG, BIT(offset)); 2169 + 2170 + return 0; 2169 2171 } 2170 2172 2171 2173 static int davinci_mcasp_gpio_direction_in(struct gpio_chip *chip, ··· 2218 2216 .request = davinci_mcasp_gpio_request, 2219 2217 .free = davinci_mcasp_gpio_free, 2220 2218 .direction_output = davinci_mcasp_gpio_direction_out, 2221 - .set = davinci_mcasp_gpio_set, 2219 + .set_rv = davinci_mcasp_gpio_set, 2222 2220 .direction_input = davinci_mcasp_gpio_direction_in, 2223 2221 .get = davinci_mcasp_gpio_get, 2224 2222 .get_direction = davinci_mcasp_gpio_get_direction,