Skip to contentSkip to conversation

pinctrl: cs42l43: Fix leaked pm reference on error path

PATCH In review Charles Keepax 3 participants 6 messages May 8 – May 27

Subsystems (4)
lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

PATCH 1/2 pinctrl: cs42l43: Fix leaked pm reference on error path

Returning directly if the regmap_update_bits() fails causes a pm runtime reference to be leaked, let things run to the end of the function instead.

Fixes e52c741907fb ("pinctrl: cirrus: cs42l43: use new GPIO line value setter callbacks")
---
 drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pinctrl/cirrus/pinctrl-cs42l43.c +1 -3
index 227c37c360e19..3cc1835206077 100644
@@ -499,12 +499,10 @@ static int cs42l43_gpio_set(struct gpio_chip *chip, unsigned int offset,
 
 	ret = regmap_update_bits(priv->regmap, CS42L43_GPIO_CTRL1,
 				 BIT(shift), value << shift);
-	if (ret)
-		return ret;
 
 	pm_runtime_put(priv->dev);
 
-	return 0;
+	return ret;
 }
 
 static int cs42l43_gpio_direction_out(struct gpio_chip *chip,
Signature · 1 line
2.47.3
author maintainer
#1 lore raw

PATCH 2/2 pinctrl: cs42l43: Fix polarity on debounce

The debounce bit sets a bypass on the debounce rather than enabling it, as such the current polarity of the debounce is set incorrectly. Invert the polarity to correct this.

Fixes d5282a539297 ("pinctrl: cs42l43: Add support for the cs42l43")
---
 drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/cirrus/pinctrl-cs42l43.c +1 -1
index 3cc1835206077..305233fc19876 100644
@@ -343,7 +343,7 @@ static int cs42l43_pin_set_db(struct cs42l43_pin *priv, unsigned int pin,
 
 	return regmap_update_bits(priv->regmap, CS42L43_GPIO_CTRL2,
 				  CS42L43_GPIO1_DEGLITCH_BYP_MASK << pin,
-				  !!us << pin);
+				  !us << pin);
 }
 
 static int cs42l43_pin_config_get(struct pinctrl_dev *pctldev,
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] pinctrl: cs42l43: Fix polarity on debounce

Quoted 24 lines · Charles Keepax

The debounce bit sets a bypass on the debounce rather than enabling it, as such the current polarity of the debounce is set incorrectly. Invert the polarity to correct this.

Fixes d5282a539297 ("pinctrl: cs42l43: Add support for the cs42l43")
---
 drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/cirrus/pinctrl-cs42l43.c +1 -2
index 3cc1835206077..305233fc19876 100644
@@ -343,7 +343,7 @@ static int cs42l43_pin_set_db(struct cs42l43_pin *priv, unsigned int pin,
 
 	return regmap_update_bits(priv->regmap, CS42L43_GPIO_CTRL2,
 				  CS42L43_GPIO1_DEGLITCH_BYP_MASK << pin,
-				  !!us << pin);
+				  !us << pin);
 }
 
 static int cs42l43_pin_config_get(struct pinctrl_dev *pctldev,
--
Quoted 3 lines

2.47.3

maintainer
#3 lore raw

Re: [PATCH 2/2] pinctrl: cs42l43: Fix polarity on debounce

In reply to Charles Keepax
Quoted 6 lines · Charles Keepax

The debounce bit sets a bypass on the debounce rather than enabling it, as such the current polarity of the debounce is set incorrectly. Invert the polarity to correct this.

Fixes d5282a539297 ("pinctrl: cs42l43: Add support for the cs42l43")

Patch applied!

Yours,
Linus Walleij

maintainer Reviewed-by on v1 1/2
#4 lore raw
In reply to Charles Keepax
Quoted 29 lines · Charles Keepax

Returning directly if the regmap_update_bits() fails causes a pm runtime reference to be leaked, let things run to the end of the function instead.

Fixes e52c741907fb ("pinctrl: cirrus: cs42l43: use new GPIO line value setter callbacks")
---
 drivers/pinctrl/cirrus/pinctrl-cs42l43.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pinctrl/cirrus/pinctrl-cs42l43.c +1 -4
index 227c37c360e19..3cc1835206077 100644
@@ -499,12 +499,10 @@ static int cs42l43_gpio_set(struct gpio_chip *chip, unsigned int offset,
 
 	ret = regmap_update_bits(priv->regmap, CS42L43_GPIO_CTRL1,
 				 BIT(shift), value << shift);
-	if (ret)
-		return ret;
 
 	pm_runtime_put(priv->dev);
 
-	return 0;
+	return ret;
 }
 
 static int cs42l43_gpio_direction_out(struct gpio_chip *chip,
--
Quoted 3 lines

2.47.3

maintainer
#5 lore raw
In reply to Charles Keepax
Quoted 6 lines · Charles Keepax

Returning directly if the regmap_update_bits() fails causes a pm runtime reference to be leaked, let things run to the end of the function instead.

Fixes e52c741907fb ("pinctrl: cirrus: cs42l43: use new GPIO line value setter callbacks")

Patch applied!

Yours,
Linus Walleij