Skip to contentSkip to conversation

iio: tsl2772: Use devm_add_action_or_reset

PATCH Applied Chuhong Yuan 3 participants 4 messages Aug 1, 2019 – Aug 5, 2019 IIO

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/4 iio: tsl2772: Use devm_add_action_or_reset

Use devm_add_action_or_reset to remove the call to tsl2772_disable_regulators_action to simplify the error path.

---
Changes in v4:
- Split v3 into three patches.
- Revise description to make it more precise.

 drivers/iio/light/tsl2772.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2772.c +3 -3
index 83cece921843..29cfd8ae2700 100644
@@ -1807,10 +1807,10 @@ static int tsl2772_probe(struct i2c_client *clientp,
 		return PTR_ERR(chip->vdd_supply);
 	}
 
-	ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action,
-			      chip);
+	ret = devm_add_action_or_reset(&clientp->dev,
+					tsl2772_disable_regulators_action,
+					chip);
 	if (ret < 0) {
-		tsl2772_disable_regulators_action(chip);
 		dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n",
 			ret);
 		return ret;
Signature · 1 line
2.20.1
Reviewed-by on v4 1/4
#1 lore raw
Quoted 4 lines · Chuhong Yuan

Use devm_add_action_or_reset to remove the call to tsl2772_disable_regulators_action to simplify the error path.

For the whole series:

I forgot to mention this before, but next time please use a cover letter if you're sending more than one patch: git format-patch --cover-letter.

Brian

Quoted 28 lines

---
Changes in v4:
- Split v3 into three patches.
- Revise description to make it more precise.

 drivers/iio/light/tsl2772.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2772.c +3 -3
index 83cece921843..29cfd8ae2700 100644
@@ -1807,10 +1807,10 @@ static int tsl2772_probe(struct i2c_client *clientp,
 		return PTR_ERR(chip->vdd_supply);
 	}
 
-	ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action,
-			      chip);
+	ret = devm_add_action_or_reset(&clientp->dev,
+					tsl2772_disable_regulators_action,
+					chip);
 	if (ret < 0) {
-		tsl2772_disable_regulators_action(chip);
 		dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n",
 			ret);
 		return ret;
Signature · 1 line
2.20.1
Tested-by
#2 lore raw
Quoted 9 lines · Brian Masney
Quoted 4 lines · Chuhong Yuan

Use devm_add_action_or_reset to remove the call to tsl2772_disable_regulators_action to simplify the error path.

For the whole series:

Oops, I forgot to add this as well:

I tested this on a Nexus 5 phone.

Brian

Quoted 35 lines

I forgot to mention this before, but next time please use a cover letter if you're sending more than one patch: git format-patch --cover-letter.

Brian

Quoted 28 lines

---
Changes in v4:
- Split v3 into three patches.
- Revise description to make it more precise.

 drivers/iio/light/tsl2772.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2772.c +3 -3
index 83cece921843..29cfd8ae2700 100644
@@ -1807,10 +1807,10 @@ static int tsl2772_probe(struct i2c_client *clientp,
 		return PTR_ERR(chip->vdd_supply);
 	}
 
-	ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action,
-			      chip);
+	ret = devm_add_action_or_reset(&clientp->dev,
+					tsl2772_disable_regulators_action,
+					chip);
 	if (ret < 0) {
-		tsl2772_disable_regulators_action(chip);
 		dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n",
 			ret);
 		return ret;
Signature · 1 line
2.20.1
maintainer
#3 lore raw
Quoted 11 lines · On Thu, 1 Aug 2019 05:37:31 -0400 Brian Masney <[email protected]> wrote:
Quoted 9 lines · Brian Masney
Quoted 4 lines · Chuhong Yuan

Use devm_add_action_or_reset to remove the call to tsl2772_disable_regulators_action to simplify the error path.

For the whole series:

Quoted 8 lines

Oops, I forgot to add this as well:

I tested this on a Nexus 5 phone.

Brian

Applied to the togreg branch of iio.git and pushed out as testing.

Now the fact we have a fix in the middle of this series is a bit unfortunate as it'll mean we need an explicit backport to take that for stable.

Oh well, if anyone wants it up to them to do the work ;)

Thanks,

Jonathan

Quoted 36 lines
Quoted 36 lines

I forgot to mention this before, but next time please use a cover letter if you're sending more than one patch: git format-patch --cover-letter.

Brian

Quoted 28 lines

---
Changes in v4:
- Split v3 into three patches.
- Revise description to make it more precise.

 drivers/iio/light/tsl2772.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/light/tsl2772.c +3 -3
index 83cece921843..29cfd8ae2700 100644
@@ -1807,10 +1807,10 @@ static int tsl2772_probe(struct i2c_client *clientp,
 		return PTR_ERR(chip->vdd_supply);
 	}
 
-	ret = devm_add_action(&clientp->dev, tsl2772_disable_regulators_action,
-			      chip);
+	ret = devm_add_action_or_reset(&clientp->dev,
+					tsl2772_disable_regulators_action,
+					chip);
 	if (ret < 0) {
-		tsl2772_disable_regulators_action(chip);
 		dev_err(&clientp->dev, "Failed to setup regulator cleanup action %d\n",
 			ret);
 		return ret;
Signature · 1 line
2.20.1