Skip to contentSkip to conversation

regulator: tps65219: fix matching interrupts for their regulators

PATCH In review Jerome Neanne 2 participants 3 messages Jun 8, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: tps65219: fix matching interrupts for their regulators

From: Krzysztof Kozlowski <[email protected]>

The driver's probe() first registers regulators in a loop and then in a second loop passes them as irq data to the interrupt handlers. However the function to get the regulator for given name tps65219_get_rdev_by_name() was a no-op due to argument passed by value, not pointer, thus the second loop assigned always same value - from previous loop. The interrupts, when fired, where executed with wrong data. Compiler also noticed it:

drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]

Fixes c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support")

---

Notes:
This is backport of upstream fix in TI mainline:

 drivers/regulator/tps65219-regulator.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/regulator/tps65219-regulator.c +3 -3
index 58f6541b6417..b0d8d6fed24d 100644
@@ -289,13 +289,13 @@ static irqreturn_t tps65219_regulator_irq_handler(int irq, void *data)
 
 static int tps65219_get_rdev_by_name(const char *regulator_name,
 				     struct regulator_dev *rdevtbl[7],
-				     struct regulator_dev *dev)
+				     struct regulator_dev **dev)
 {
 	int i;
 
 	for (i = 0; i < ARRAY_SIZE(regulators); i++) {
 		if (strcmp(regulator_name, regulators[i].name) == 0) {
-			dev = rdevtbl[i];
+			*dev = rdevtbl[i];
 			return 0;
 		}
 	}
@@ -348,7 +348,7 @@ static int tps65219_regulator_probe(struct platform_device *pdev)
 		irq_data[i].dev = tps->dev;
 		irq_data[i].type = irq_type;
 
-		tps65219_get_rdev_by_name(irq_type->regulator_name, rdevtbl, rdev);
+		tps65219_get_rdev_by_name(irq_type->regulator_name, rdevtbl, &rdev);
 		if (IS_ERR(rdev)) {
 			dev_err(tps->dev, "Failed to get rdev for %s\n",
 				irq_type->regulator_name);
Signature · 1 line
2.34.1
#1 lore raw
Quoted 18 lines · Jerome Neanne

From: Krzysztof Kozlowski <[email protected]>

The driver's probe() first registers regulators in a loop and then in a second loop passes them as irq data to the interrupt handlers. However the function to get the regulator for given name tps65219_get_rdev_by_name() was a no-op due to argument passed by value, not pointer, thus the second loop assigned always same value - from previous loop. The interrupts, when fired, where executed with wrong data. Compiler also noticed it:

drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]

Fixes c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support")
Quoted 5 lines

---

Notes:
This is backport of upstream fix in TI mainline:

What is the upstream commit id here?

thanks,

greg k-h

#2 lore raw
Quoted 25 lines · Greg KH
Quoted 18 lines · Jerome Neanne

From: Krzysztof Kozlowski <[email protected]>

The driver's probe() first registers regulators in a loop and then in a second loop passes them as irq data to the interrupt handlers. However the function to get the regulator for given name tps65219_get_rdev_by_name() was a no-op due to argument passed by value, not pointer, thus the second loop assigned always same value - from previous loop. The interrupts, when fired, where executed with wrong data. Compiler also noticed it:

drivers/regulator/tps65219-regulator.c: In function ‘tps65219_get_rdev_by_name’:
drivers/regulator/tps65219-regulator.c:292:60: error: parameter ‘dev’ set but not used [-Werror=unused-but-set-parameter]

Fixes c12ac5fc3e0a ("regulator: drivers: Add TI TPS65219 PMIC regulators support")
Quoted 5 lines

---

Notes:
This is backport of upstream fix in TI mainline:

Quoted 5 lines

What is the upstream commit id here?

thanks,

greg k-h

This was not intended to reach the whole list but TI only(I did not remove -cc all).

Non TI folks please ignore this patch.

Sorry for disturbance.