Commit d977a876 authored by Andrey Smirnov's avatar Andrey Smirnov Committed by Linus Walleij

pinctrl-sx150x: Remove excessive locking

Gpiochip and irqchip aspects of this driver do not access any shared
registers on the chip itself and atomicity of various regmap operations
is ensured by that API's implementation, so there doesn't seem to be a
reason to hold the lock in as many places as it is held now.
Tested-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Signed-off-by: default avatarAndrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 6489677f
...@@ -343,13 +343,9 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip, ...@@ -343,13 +343,9 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
sx150x_pin_is_oscio(pctl, offset)) sx150x_pin_is_oscio(pctl, offset))
return 0; return 0;
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->pri.x789.reg_drain, pctl->data->pri.x789.reg_drain,
BIT(offset), 0); BIT(offset), 0);
mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
break; break;
case LINE_MODE_OPEN_DRAIN: case LINE_MODE_OPEN_DRAIN:
...@@ -357,20 +353,16 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip, ...@@ -357,20 +353,16 @@ static int sx150x_gpio_set_single_ended(struct gpio_chip *chip,
sx150x_pin_is_oscio(pctl, offset)) sx150x_pin_is_oscio(pctl, offset))
return -ENOTSUPP; return -ENOTSUPP;
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->pri.x789.reg_drain, pctl->data->pri.x789.reg_drain,
BIT(offset), BIT(offset)); BIT(offset), BIT(offset));
mutex_unlock(&pctl->lock);
if (ret < 0)
return ret;
break; break;
default: default:
return -ENOTSUPP; ret = -ENOTSUPP;
break;
} }
return 0; return ret;
} }
static int __sx150x_gpio_set(struct sx150x_pinctrl *pctl, unsigned int offset, static int __sx150x_gpio_set(struct sx150x_pinctrl *pctl, unsigned int offset,
...@@ -385,57 +377,46 @@ static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset, ...@@ -385,57 +377,46 @@ static void sx150x_gpio_set(struct gpio_chip *chip, unsigned int offset,
{ {
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
if (sx150x_pin_is_oscio(pctl, offset)) { if (sx150x_pin_is_oscio(pctl, offset))
mutex_lock(&pctl->lock);
regmap_write(pctl->regmap, regmap_write(pctl->regmap,
pctl->data->pri.x789.reg_clock, pctl->data->pri.x789.reg_clock,
(value ? 0x1f : 0x10)); (value ? 0x1f : 0x10));
mutex_unlock(&pctl->lock); else
} else {
mutex_lock(&pctl->lock);
__sx150x_gpio_set(pctl, offset, value); __sx150x_gpio_set(pctl, offset, value);
mutex_unlock(&pctl->lock);
}
} }
static int sx150x_gpio_direction_input(struct gpio_chip *chip, static int sx150x_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset) unsigned int offset)
{ {
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
int ret;
if (sx150x_pin_is_oscio(pctl, offset)) if (sx150x_pin_is_oscio(pctl, offset))
return -EINVAL; return -EINVAL;
mutex_lock(&pctl->lock); return regmap_write_bits(pctl->regmap,
ret = regmap_write_bits(pctl->regmap, pctl->data->reg_dir,
pctl->data->reg_dir, BIT(offset), BIT(offset));
BIT(offset), BIT(offset));
mutex_unlock(&pctl->lock);
return ret;
} }
static int sx150x_gpio_direction_output(struct gpio_chip *chip, static int sx150x_gpio_direction_output(struct gpio_chip *chip,
unsigned int offset, int value) unsigned int offset, int value)
{ {
struct sx150x_pinctrl *pctl = gpiochip_get_data(chip); struct sx150x_pinctrl *pctl = gpiochip_get_data(chip);
int status; int ret;
if (sx150x_pin_is_oscio(pctl, offset)) { if (sx150x_pin_is_oscio(pctl, offset)) {
sx150x_gpio_set(chip, offset, value); sx150x_gpio_set(chip, offset, value);
return 0; return 0;
} }
mutex_lock(&pctl->lock); ret = __sx150x_gpio_set(pctl, offset, value);
status = __sx150x_gpio_set(pctl, offset, value); if (ret < 0)
if (status >= 0) return ret;
status = regmap_write_bits(pctl->regmap,
pctl->data->reg_dir,
BIT(offset), 0);
mutex_unlock(&pctl->lock);
return status; return regmap_write_bits(pctl->regmap,
pctl->data->reg_dir,
BIT(offset), 0);
} }
static void sx150x_irq_mask(struct irq_data *d) static void sx150x_irq_mask(struct irq_data *d)
...@@ -536,12 +517,9 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -536,12 +517,9 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
switch (param) { switch (param) {
case PIN_CONFIG_DRIVE_PUSH_PULL: case PIN_CONFIG_DRIVE_PUSH_PULL:
case PIN_CONFIG_OUTPUT: case PIN_CONFIG_OUTPUT:
mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap, ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_clock, pctl->data->pri.x789.reg_clock,
&data); &data);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -566,12 +544,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -566,12 +544,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
switch (param) { switch (param) {
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap, ret = regmap_read(pctl->regmap,
pctl->data->reg_pulldn, pctl->data->reg_pulldn,
&data); &data);
data &= BIT(pin); data &= BIT(pin);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -583,12 +559,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -583,12 +559,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
break; break;
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap, ret = regmap_read(pctl->regmap,
pctl->data->reg_pullup, pctl->data->reg_pullup,
&data); &data);
data &= BIT(pin); data &= BIT(pin);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -603,12 +577,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -603,12 +577,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
if (pctl->data->model != SX150X_789) if (pctl->data->model != SX150X_789)
return -ENOTSUPP; return -ENOTSUPP;
mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap, ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_drain, pctl->data->pri.x789.reg_drain,
&data); &data);
data &= BIT(pin); data &= BIT(pin);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -623,12 +595,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -623,12 +595,10 @@ static int sx150x_pinconf_get(struct pinctrl_dev *pctldev, unsigned int pin,
if (pctl->data->model != SX150X_789) if (pctl->data->model != SX150X_789)
arg = true; arg = true;
else { else {
mutex_lock(&pctl->lock);
ret = regmap_read(pctl->regmap, ret = regmap_read(pctl->regmap,
pctl->data->pri.x789.reg_drain, pctl->data->pri.x789.reg_drain,
&data); &data);
data &= BIT(pin); data &= BIT(pin);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -693,41 +663,33 @@ static int sx150x_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, ...@@ -693,41 +663,33 @@ static int sx150x_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
switch (param) { switch (param) {
case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT: case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
case PIN_CONFIG_BIAS_DISABLE: case PIN_CONFIG_BIAS_DISABLE:
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pulldn, pctl->data->reg_pulldn,
BIT(pin), 0); BIT(pin), 0);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pullup, pctl->data->reg_pullup,
BIT(pin), 0); BIT(pin), 0);
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
break; break;
case PIN_CONFIG_BIAS_PULL_UP: case PIN_CONFIG_BIAS_PULL_UP:
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pullup, pctl->data->reg_pullup,
BIT(pin), BIT(pin)); BIT(pin), BIT(pin));
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
break; break;
case PIN_CONFIG_BIAS_PULL_DOWN: case PIN_CONFIG_BIAS_PULL_DOWN:
mutex_lock(&pctl->lock);
ret = regmap_write_bits(pctl->regmap, ret = regmap_write_bits(pctl->regmap,
pctl->data->reg_pulldn, pctl->data->reg_pulldn,
BIT(pin), BIT(pin)); BIT(pin), BIT(pin));
mutex_unlock(&pctl->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment