Skip to content

Commit

Permalink
rtc: abx80x: use devm_add_action_or_reset()
Browse files Browse the repository at this point in the history
If devm_add_action() fails we are explicitly calling the cleanup to free
the resources allocated.  Lets use the helper devm_add_action_or_reset()
and return directly in case of error, as we know that the cleanup function
has been already called by the helper if there was any error.

Signed-off-by: Sudip Mukherjee <[email protected]>
Signed-off-by: Alexandre Belloni <[email protected]>
  • Loading branch information
sudipm-mukherjee authored and alexandrebelloni committed Jul 19, 2016
1 parent 104b2d8 commit d8cac8d
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions drivers/rtc/rtc-abx80x.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,17 +643,15 @@ static int abx80x_probe(struct i2c_client *client,
return err;
}

err = devm_add_action(&client->dev, rtc_calib_remove_sysfs_group,
&client->dev);
if (err) {
rtc_calib_remove_sysfs_group(&client->dev);
err = devm_add_action_or_reset(&client->dev,
rtc_calib_remove_sysfs_group,
&client->dev);
if (err)
dev_err(&client->dev,
"Failed to add sysfs cleanup action: %d\n",
err);
return err;
}

return 0;
return err;
}

static int abx80x_remove(struct i2c_client *client)
Expand Down

0 comments on commit d8cac8d

Please sign in to comment.