Skip to content

Commit 470b525

Browse files
caihuoqing1990suryasaimadhu
authored andcommitted
EDAC/al_mc: Make use of the helper function devm_add_action_or_reset()
The helper function devm_add_action_or_reset() will internally call devm_add_action(), and if devm_add_action() fails then it will execute the action mentioned and return the error code. So use devm_add_action_or_reset() instead of devm_add_action() to simplify the error handling, reduce the code. Signed-off-by: Cai Huoqing <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Talel Shenhar <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent fca6116 commit 470b525

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/edac/al_mc_edac.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,9 @@ static int al_mc_edac_probe(struct platform_device *pdev)
238238
if (!mci)
239239
return -ENOMEM;
240240

241-
ret = devm_add_action(&pdev->dev, devm_al_mc_edac_free, mci);
242-
if (ret) {
243-
edac_mc_free(mci);
241+
ret = devm_add_action_or_reset(&pdev->dev, devm_al_mc_edac_free, mci);
242+
if (ret)
244243
return ret;
245-
}
246244

247245
platform_set_drvdata(pdev, mci);
248246
al_mc = mci->pvt_info;
@@ -293,11 +291,9 @@ static int al_mc_edac_probe(struct platform_device *pdev)
293291
return ret;
294292
}
295293

296-
ret = devm_add_action(&pdev->dev, devm_al_mc_edac_del, &pdev->dev);
297-
if (ret) {
298-
edac_mc_del_mc(&pdev->dev);
294+
ret = devm_add_action_or_reset(&pdev->dev, devm_al_mc_edac_del, &pdev->dev);
295+
if (ret)
299296
return ret;
300-
}
301297

302298
if (al_mc->irq_ue > 0) {
303299
ret = devm_request_irq(&pdev->dev,

0 commit comments

Comments
 (0)