Skip to content

Commit

Permalink
iio: imu: mpu6050: Replace devm_add_action() followed by failure acti…
Browse files Browse the repository at this point in the history
…on with devm_add_action_or_reset()

devm_add_action_or_reset() is introduced as a helper function which
internally calls devm_add_action(). If devm_add_action() fails
then it will execute the action mentioned and return the error code.
This reduce source code size (avoid writing the action twice)
and reduce the likelyhood of bugs.

Signed-off-by: Fuqian Huang <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
Yellow-Pay authored and jic23 committed Jul 27, 2019
1 parent 46916de commit d284fea
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1096,10 +1096,9 @@ int inv_mpu_core_probe(struct regmap *regmap, int irq, const char *name,
if (result)
return result;

result = devm_add_action(dev, inv_mpu_core_disable_regulator_action,
result = devm_add_action_or_reset(dev, inv_mpu_core_disable_regulator_action,
st);
if (result) {
inv_mpu_core_disable_regulator_action(st);
dev_err(dev, "Failed to setup regulator cleanup action %d\n",
result);
return result;
Expand Down

0 comments on commit d284fea

Please sign in to comment.