mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-11 00:42:56 -04:00
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.
This commit is contained in:
@@ -48,9 +48,10 @@ static int cirrus_scodec_test_gpio_direction_out(struct gpio_chip *chip,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static void cirrus_scodec_test_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
static int cirrus_scodec_test_gpio_set(struct gpio_chip *chip,
|
||||
unsigned int offset, int value)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static int cirrus_scodec_test_gpio_set_config(struct gpio_chip *gc,
|
||||
@@ -75,7 +76,7 @@ static const struct gpio_chip cirrus_scodec_test_gpio_chip = {
|
||||
.direction_input = cirrus_scodec_test_gpio_direction_in,
|
||||
.get = cirrus_scodec_test_gpio_get,
|
||||
.direction_output = cirrus_scodec_test_gpio_direction_out,
|
||||
.set = cirrus_scodec_test_gpio_set,
|
||||
.set_rv = cirrus_scodec_test_gpio_set,
|
||||
.set_config = cirrus_scodec_test_gpio_set_config,
|
||||
.base = -1,
|
||||
.ngpio = 32,
|
||||
|
||||
@@ -957,7 +957,8 @@ static const struct snd_soc_component_driver idt821034_component_driver = {
|
||||
#define IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(_offset) (((_offset) / 5) % 4)
|
||||
#define IDT821034_GPIO_OFFSET_TO_SLIC_MASK(_offset) BIT((_offset) % 5)
|
||||
|
||||
static void idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val)
|
||||
static int idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
|
||||
int val)
|
||||
{
|
||||
u8 ch = IDT821034_GPIO_OFFSET_TO_SLIC_CHANNEL(offset);
|
||||
u8 mask = IDT821034_GPIO_OFFSET_TO_SLIC_MASK(offset);
|
||||
@@ -973,12 +974,14 @@ static void idt821034_chip_gpio_set(struct gpio_chip *c, unsigned int offset, in
|
||||
else
|
||||
slic_raw &= ~mask;
|
||||
ret = idt821034_write_slic_raw(idt821034, ch, slic_raw);
|
||||
if (ret) {
|
||||
dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
|
||||
offset, ch, mask, ret);
|
||||
}
|
||||
|
||||
mutex_unlock(&idt821034->mutex);
|
||||
|
||||
if (ret)
|
||||
dev_err(&idt821034->spi->dev, "set gpio %d (%u, 0x%x) failed (%d)\n",
|
||||
offset, ch, mask, ret);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int idt821034_chip_gpio_get(struct gpio_chip *c, unsigned int offset)
|
||||
@@ -1054,7 +1057,9 @@ static int idt821034_chip_direction_output(struct gpio_chip *c, unsigned int off
|
||||
u8 slic_conf;
|
||||
int ret;
|
||||
|
||||
idt821034_chip_gpio_set(c, offset, val);
|
||||
ret = idt821034_chip_gpio_set(c, offset, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
mutex_lock(&idt821034->mutex);
|
||||
|
||||
@@ -1112,7 +1117,7 @@ static int idt821034_gpio_init(struct idt821034 *idt821034)
|
||||
idt821034->gpio_chip.direction_input = idt821034_chip_direction_input;
|
||||
idt821034->gpio_chip.direction_output = idt821034_chip_direction_output;
|
||||
idt821034->gpio_chip.get = idt821034_chip_gpio_get;
|
||||
idt821034->gpio_chip.set = idt821034_chip_gpio_set;
|
||||
idt821034->gpio_chip.set_rv = idt821034_chip_gpio_set;
|
||||
idt821034->gpio_chip.can_sleep = true;
|
||||
|
||||
return devm_gpiochip_add_data(&idt821034->spi->dev, &idt821034->gpio_chip,
|
||||
|
||||
@@ -1726,7 +1726,8 @@ static int peb2466_chip_gpio_update_bits(struct peb2466 *peb2466, unsigned int x
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val)
|
||||
static int peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset,
|
||||
int val)
|
||||
{
|
||||
struct peb2466 *peb2466 = gpiochip_get_data(c);
|
||||
unsigned int xr_reg;
|
||||
@@ -1740,14 +1741,14 @@ static void peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int
|
||||
*/
|
||||
dev_warn(&peb2466->spi->dev, "cannot set gpio %d (read-only)\n",
|
||||
offset);
|
||||
return;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = peb2466_chip_gpio_offset_to_data_regmask(offset, &xr_reg, &mask);
|
||||
if (ret) {
|
||||
dev_err(&peb2466->spi->dev, "cannot set gpio %d (%d)\n",
|
||||
offset, ret);
|
||||
return;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = peb2466_chip_gpio_update_bits(peb2466, xr_reg, mask, val ? mask : 0);
|
||||
@@ -1755,6 +1756,8 @@ static void peb2466_chip_gpio_set(struct gpio_chip *c, unsigned int offset, int
|
||||
dev_err(&peb2466->spi->dev, "set gpio %d (0x%x, 0x%x) failed (%d)\n",
|
||||
offset, xr_reg, mask, ret);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int peb2466_chip_gpio_get(struct gpio_chip *c, unsigned int offset)
|
||||
@@ -1879,7 +1882,9 @@ static int peb2466_chip_direction_output(struct gpio_chip *c, unsigned int offse
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
peb2466_chip_gpio_set(c, offset, val);
|
||||
ret = peb2466_chip_gpio_set(c, offset, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (offset < 16) {
|
||||
/* SOx_{0,1} */
|
||||
@@ -1940,7 +1945,7 @@ static int peb2466_gpio_init(struct peb2466 *peb2466)
|
||||
peb2466->gpio.gpio_chip.direction_input = peb2466_chip_direction_input;
|
||||
peb2466->gpio.gpio_chip.direction_output = peb2466_chip_direction_output;
|
||||
peb2466->gpio.gpio_chip.get = peb2466_chip_gpio_get;
|
||||
peb2466->gpio.gpio_chip.set = peb2466_chip_gpio_set;
|
||||
peb2466->gpio.gpio_chip.set_rv = peb2466_chip_gpio_set;
|
||||
peb2466->gpio.gpio_chip.can_sleep = true;
|
||||
|
||||
return devm_gpiochip_add_data(&peb2466->spi->dev, &peb2466->gpio.gpio_chip,
|
||||
|
||||
@@ -4725,13 +4725,14 @@ static int rt5677_update_gpio_bits(struct rt5677_priv *rt5677, unsigned offset,
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIOLIB
|
||||
static void rt5677_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int rt5677_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct rt5677_priv *rt5677 = gpiochip_get_data(chip);
|
||||
int level = value ? RT5677_GPIOx_OUT_HI : RT5677_GPIOx_OUT_LO;
|
||||
int m = RT5677_GPIOx_OUT_MASK;
|
||||
|
||||
rt5677_update_gpio_bits(rt5677, offset, m, level);
|
||||
return rt5677_update_gpio_bits(rt5677, offset, m, level);
|
||||
}
|
||||
|
||||
static int rt5677_gpio_direction_out(struct gpio_chip *chip,
|
||||
@@ -4834,7 +4835,7 @@ static const struct gpio_chip rt5677_template_chip = {
|
||||
.label = RT5677_DRV_NAME,
|
||||
.owner = THIS_MODULE,
|
||||
.direction_output = rt5677_gpio_direction_out,
|
||||
.set = rt5677_gpio_set,
|
||||
.set_rv = rt5677_gpio_set,
|
||||
.direction_input = rt5677_gpio_direction_in,
|
||||
.get = rt5677_gpio_get,
|
||||
.to_irq = rt5677_to_irq,
|
||||
|
||||
@@ -1015,10 +1015,10 @@ static int adc3xxx_gpio_direction_out(struct gpio_chip *chip,
|
||||
* so we set the output mode and output value in the same call. Hence
|
||||
* .set in practice does the same thing as .direction_out .
|
||||
*/
|
||||
static void adc3xxx_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
static int adc3xxx_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
(void) adc3xxx_gpio_direction_out(chip, offset, value);
|
||||
return adc3xxx_gpio_direction_out(chip, offset, value);
|
||||
}
|
||||
|
||||
/* Even though we only support GPIO output for now, some GPIO clients
|
||||
@@ -1052,7 +1052,7 @@ static const struct gpio_chip adc3xxx_gpio_chip = {
|
||||
.owner = THIS_MODULE,
|
||||
.request = adc3xxx_gpio_request,
|
||||
.direction_output = adc3xxx_gpio_direction_out,
|
||||
.set = adc3xxx_gpio_set,
|
||||
.set_rv = adc3xxx_gpio_set,
|
||||
.get = adc3xxx_gpio_get,
|
||||
.can_sleep = 1,
|
||||
};
|
||||
|
||||
@@ -2236,12 +2236,14 @@ static irqreturn_t wm5100_edge_irq(int irq, void *data)
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIOLIB
|
||||
static void wm5100_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int wm5100_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct wm5100_priv *wm5100 = gpiochip_get_data(chip);
|
||||
|
||||
regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
|
||||
WM5100_GP1_LVL, !!value << WM5100_GP1_LVL_SHIFT);
|
||||
return regmap_update_bits(wm5100->regmap, WM5100_GPIO_CTRL_1 + offset,
|
||||
WM5100_GP1_LVL,
|
||||
!!value << WM5100_GP1_LVL_SHIFT);
|
||||
}
|
||||
|
||||
static int wm5100_gpio_direction_out(struct gpio_chip *chip,
|
||||
@@ -2288,7 +2290,7 @@ static const struct gpio_chip wm5100_template_chip = {
|
||||
.label = "wm5100",
|
||||
.owner = THIS_MODULE,
|
||||
.direction_output = wm5100_gpio_direction_out,
|
||||
.set = wm5100_gpio_set,
|
||||
.set_rv = wm5100_gpio_set,
|
||||
.direction_input = wm5100_gpio_direction_in,
|
||||
.get = wm5100_gpio_get,
|
||||
.can_sleep = 1,
|
||||
|
||||
@@ -1825,13 +1825,15 @@ static int wm8903_gpio_direction_out(struct gpio_chip *chip,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wm8903_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int wm8903_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct wm8903_priv *wm8903 = gpiochip_get_data(chip);
|
||||
|
||||
regmap_update_bits(wm8903->regmap, WM8903_GPIO_CONTROL_1 + offset,
|
||||
WM8903_GP1_LVL_MASK,
|
||||
!!value << WM8903_GP1_LVL_SHIFT);
|
||||
return regmap_update_bits(wm8903->regmap,
|
||||
WM8903_GPIO_CONTROL_1 + offset,
|
||||
WM8903_GP1_LVL_MASK,
|
||||
!!value << WM8903_GP1_LVL_SHIFT);
|
||||
}
|
||||
|
||||
static const struct gpio_chip wm8903_template_chip = {
|
||||
@@ -1841,7 +1843,7 @@ static const struct gpio_chip wm8903_template_chip = {
|
||||
.direction_input = wm8903_gpio_direction_in,
|
||||
.get = wm8903_gpio_get,
|
||||
.direction_output = wm8903_gpio_direction_out,
|
||||
.set = wm8903_gpio_set,
|
||||
.set_rv = wm8903_gpio_set,
|
||||
.can_sleep = 1,
|
||||
};
|
||||
|
||||
|
||||
@@ -3407,13 +3407,16 @@ static int wm8962_gpio_request(struct gpio_chip *chip, unsigned offset)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void wm8962_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int wm8962_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct wm8962_priv *wm8962 = gpiochip_get_data(chip);
|
||||
struct snd_soc_component *component = wm8962->component;
|
||||
|
||||
snd_soc_component_update_bits(component, WM8962_GPIO_BASE + offset,
|
||||
WM8962_GP2_LVL, !!value << WM8962_GP2_LVL_SHIFT);
|
||||
return snd_soc_component_update_bits(component,
|
||||
WM8962_GPIO_BASE + offset,
|
||||
WM8962_GP2_LVL,
|
||||
!!value << WM8962_GP2_LVL_SHIFT);
|
||||
}
|
||||
|
||||
static int wm8962_gpio_direction_out(struct gpio_chip *chip,
|
||||
@@ -3439,7 +3442,7 @@ static const struct gpio_chip wm8962_template_chip = {
|
||||
.owner = THIS_MODULE,
|
||||
.request = wm8962_gpio_request,
|
||||
.direction_output = wm8962_gpio_direction_out,
|
||||
.set = wm8962_gpio_set,
|
||||
.set_rv = wm8962_gpio_set,
|
||||
.can_sleep = 1,
|
||||
};
|
||||
|
||||
|
||||
@@ -2136,12 +2136,14 @@ static int wm8996_set_fll(struct snd_soc_component *component, int fll_id, int s
|
||||
}
|
||||
|
||||
#ifdef CONFIG_GPIOLIB
|
||||
static void wm8996_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
|
||||
static int wm8996_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct wm8996_priv *wm8996 = gpiochip_get_data(chip);
|
||||
|
||||
regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset,
|
||||
WM8996_GP1_LVL, !!value << WM8996_GP1_LVL_SHIFT);
|
||||
return regmap_update_bits(wm8996->regmap, WM8996_GPIO_1 + offset,
|
||||
WM8996_GP1_LVL,
|
||||
!!value << WM8996_GP1_LVL_SHIFT);
|
||||
}
|
||||
|
||||
static int wm8996_gpio_direction_out(struct gpio_chip *chip,
|
||||
@@ -2184,7 +2186,7 @@ static const struct gpio_chip wm8996_template_chip = {
|
||||
.label = "wm8996",
|
||||
.owner = THIS_MODULE,
|
||||
.direction_output = wm8996_gpio_direction_out,
|
||||
.set = wm8996_gpio_set,
|
||||
.set_rv = wm8996_gpio_set,
|
||||
.direction_input = wm8996_gpio_direction_in,
|
||||
.get = wm8996_gpio_get,
|
||||
.can_sleep = 1,
|
||||
|
||||
@@ -387,12 +387,12 @@ static const struct snd_soc_component_driver zl38_component_dev = {
|
||||
.endianness = 1,
|
||||
};
|
||||
|
||||
static void chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val)
|
||||
static int chip_gpio_set(struct gpio_chip *c, unsigned int offset, int val)
|
||||
{
|
||||
struct regmap *regmap = gpiochip_get_data(c);
|
||||
unsigned int mask = BIT(offset);
|
||||
|
||||
regmap_update_bits(regmap, REG_GPIO_DAT, mask, val ? mask : 0);
|
||||
return regmap_update_bits(regmap, REG_GPIO_DAT, mask, val ? mask : 0);
|
||||
}
|
||||
|
||||
static int chip_gpio_get(struct gpio_chip *c, unsigned int offset)
|
||||
@@ -422,8 +422,12 @@ chip_direction_output(struct gpio_chip *c, unsigned int offset, int val)
|
||||
{
|
||||
struct regmap *regmap = gpiochip_get_data(c);
|
||||
unsigned int mask = BIT(offset);
|
||||
int ret;
|
||||
|
||||
ret = chip_gpio_set(c, offset, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
chip_gpio_set(c, offset, val);
|
||||
return regmap_update_bits(regmap, REG_GPIO_DIR, mask, mask);
|
||||
}
|
||||
|
||||
@@ -436,7 +440,7 @@ static const struct gpio_chip template_chip = {
|
||||
.direction_input = chip_direction_input,
|
||||
.direction_output = chip_direction_output,
|
||||
.get = chip_gpio_get,
|
||||
.set = chip_gpio_set,
|
||||
.set_rv = chip_gpio_set,
|
||||
|
||||
.can_sleep = true,
|
||||
};
|
||||
|
||||
@@ -87,8 +87,8 @@ static int snd_soc_ac97_gpio_get(struct gpio_chip *chip, unsigned int offset)
|
||||
return !!(ret & (1 << offset));
|
||||
}
|
||||
|
||||
static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
static int snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct snd_ac97_gpio_priv *gpio_priv = gpiochip_get_data(chip);
|
||||
struct snd_soc_component *component = gpio_to_component(chip);
|
||||
@@ -98,15 +98,22 @@ static void snd_soc_ac97_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
snd_soc_component_write(component, AC97_GPIO_STATUS,
|
||||
gpio_priv->gpios_set);
|
||||
dev_dbg(component->dev, "set gpio %d to %d\n", offset, !!value);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int snd_soc_ac97_gpio_direction_out(struct gpio_chip *chip,
|
||||
unsigned offset, int value)
|
||||
{
|
||||
struct snd_soc_component *component = gpio_to_component(chip);
|
||||
int ret;
|
||||
|
||||
dev_dbg(component->dev, "set gpio %d to output\n", offset);
|
||||
snd_soc_ac97_gpio_set(chip, offset, value);
|
||||
|
||||
ret = snd_soc_ac97_gpio_set(chip, offset, value);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return snd_soc_component_update_bits(component, AC97_GPIO_CFG,
|
||||
1 << offset, 0);
|
||||
}
|
||||
@@ -118,7 +125,7 @@ static const struct gpio_chip snd_soc_ac97_gpio_chip = {
|
||||
.direction_input = snd_soc_ac97_gpio_direction_in,
|
||||
.get = snd_soc_ac97_gpio_get,
|
||||
.direction_output = snd_soc_ac97_gpio_direction_out,
|
||||
.set = snd_soc_ac97_gpio_set,
|
||||
.set_rv = snd_soc_ac97_gpio_set,
|
||||
.can_sleep = 1,
|
||||
};
|
||||
|
||||
|
||||
@@ -2157,8 +2157,8 @@ static int davinci_mcasp_gpio_direction_out(struct gpio_chip *chip,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void davinci_mcasp_gpio_set(struct gpio_chip *chip, unsigned offset,
|
||||
int value)
|
||||
static int davinci_mcasp_gpio_set(struct gpio_chip *chip, unsigned int offset,
|
||||
int value)
|
||||
{
|
||||
struct davinci_mcasp *mcasp = gpiochip_get_data(chip);
|
||||
|
||||
@@ -2166,6 +2166,8 @@ static void davinci_mcasp_gpio_set(struct gpio_chip *chip, unsigned offset,
|
||||
mcasp_set_bits(mcasp, DAVINCI_MCASP_PDOUT_REG, BIT(offset));
|
||||
else
|
||||
mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDOUT_REG, BIT(offset));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int davinci_mcasp_gpio_direction_in(struct gpio_chip *chip,
|
||||
@@ -2216,7 +2218,7 @@ static const struct gpio_chip davinci_mcasp_template_chip = {
|
||||
.request = davinci_mcasp_gpio_request,
|
||||
.free = davinci_mcasp_gpio_free,
|
||||
.direction_output = davinci_mcasp_gpio_direction_out,
|
||||
.set = davinci_mcasp_gpio_set,
|
||||
.set_rv = davinci_mcasp_gpio_set,
|
||||
.direction_input = davinci_mcasp_gpio_direction_in,
|
||||
.get = davinci_mcasp_gpio_get,
|
||||
.get_direction = davinci_mcasp_gpio_get_direction,
|
||||
|
||||
Reference in New Issue
Block a user