sx150x_pin_is_oscio(pctl, offset))
return 0;
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->pri.x789.reg_drain,
BIT(offset), 0);
- mutex_unlock(&pctl->lock);
- if (ret < 0)
- return ret;
break;
case LINE_MODE_OPEN_DRAIN:
sx150x_pin_is_oscio(pctl, offset))
return -ENOTSUPP;
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->pri.x789.reg_drain,
BIT(offset), BIT(offset));
- mutex_unlock(&pctl->lock);
- if (ret < 0)
- return ret;
break;
-
default:
- return -ENOTSUPP;
+ ret = -ENOTSUPP;
+ break;
}
- return 0;
+ return ret;
}
static int __sx150x_gpio_set(struct sx150x_pinctrl *pctl, unsigned int offset,
{
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
- if (sx150x_pin_is_oscio(pctl, offset)) {
- mutex_lock(&pctl->lock);
+ if (sx150x_pin_is_oscio(pctl, offset))
regmap_write(pctl->regmap,
pctl->data->pri.x789.reg_clock,
(value ? 0x1f : 0x10));
- mutex_unlock(&pctl->lock);
- } else {
- mutex_lock(&pctl->lock);
+ else
__sx150x_gpio_set(pctl, offset, value);
- mutex_unlock(&pctl->lock);
- }
+
}
static int sx150x_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
- int ret;
if (sx150x_pin_is_oscio(pctl, offset))
return -EINVAL;
- mutex_lock(&pctl->lock);
- ret = regmap_write_bits(pctl->regmap,
- pctl->data->reg_dir,
- BIT(offset), BIT(offset));
- mutex_unlock(&pctl->lock);
-
- return ret;
+ return regmap_write_bits(pctl->regmap,
+ pctl->data->reg_dir,
+ BIT(offset), BIT(offset));
}
static int sx150x_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value)
{
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
- int status;
+ int ret;
if (sx150x_pin_is_oscio(pctl, offset)) {
sx150x_gpio_set(chip, offset, value);
return 0;
}
- mutex_lock(&pctl->lock);
- status = __sx150x_gpio_set(pctl, offset, value);
- if (status >= 0)
- status = regmap_write_bits(pctl->regmap,
- pctl->data->reg_dir,
- BIT(offset), 0);
- mutex_unlock(&pctl->lock);
+ ret = __sx150x_gpio_set(pctl, offset, value);
+ if (ret < 0)
+ return ret;
- return status;
+ return regmap_write_bits(pctl->regmap,
+ pctl->data->reg_dir,
+ BIT(offset), 0);
}
static void sx150x_irq_mask(struct irq_data *d)
switch (param) {
case PIN_CONFIG_DRIVE_PUSH_PULL:
case PIN_CONFIG_OUTPUT:
- mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_clock,
&data);
- mutex_unlock(&pctl->lock);
-
if (ret < 0)
return ret;
switch (param) {
case PIN_CONFIG_BIAS_PULL_DOWN:
- mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap,
pctl->data->reg_pulldn,
&data);
data &= BIT(pin);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
break;
case PIN_CONFIG_BIAS_PULL_UP:
- mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap,
pctl->data->reg_pullup,
&data);
data &= BIT(pin);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
if (pctl->data->model != SX150X_789)
return -ENOTSUPP;
- mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_drain,
&data);
data &= BIT(pin);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
if (pctl->data->model != SX150X_789)
arg = true;
else {
- mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_drain,
&data);
data &= BIT(pin);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
switch (param) {
case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
case PIN_CONFIG_BIAS_DISABLE:
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pulldn,
BIT(pin), 0);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pullup,
BIT(pin), 0);
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
break;
case PIN_CONFIG_BIAS_PULL_UP:
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pullup,
BIT(pin), BIT(pin));
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
break;
case PIN_CONFIG_BIAS_PULL_DOWN:
- mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pulldn,
BIT(pin), BIT(pin));
- mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;