mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 10:20:49 +07:00
reset: Align logic and flow in managed helpers
__devm_reset_control_get() and devm_reset_control_array_get() are very similar, but they do not look similar, due to inverted logic. Make them more similar, following the "bail out early" paradigm. Adjust the logic and flow in devm_reset_controller_register() to match the two other functions. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
This commit is contained in:
parent
9c81b2ccf8
commit
a9457ed2eb
@ -150,13 +150,14 @@ int devm_reset_controller_register(struct device *dev,
|
||||
return -ENOMEM;
|
||||
|
||||
ret = reset_controller_register(rcdev);
|
||||
if (!ret) {
|
||||
*rcdevp = rcdev;
|
||||
devres_add(dev, rcdevp);
|
||||
} else {
|
||||
if (ret) {
|
||||
devres_free(rcdevp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
*rcdevp = rcdev;
|
||||
devres_add(dev, rcdevp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_reset_controller_register);
|
||||
@ -787,13 +788,14 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
rstc = __reset_control_get(dev, id, index, shared, optional, acquired);
|
||||
if (!IS_ERR_OR_NULL(rstc)) {
|
||||
*ptr = rstc;
|
||||
devres_add(dev, ptr);
|
||||
} else {
|
||||
if (IS_ERR_OR_NULL(rstc)) {
|
||||
devres_free(ptr);
|
||||
return rstc;
|
||||
}
|
||||
|
||||
*ptr = rstc;
|
||||
devres_add(dev, ptr);
|
||||
|
||||
return rstc;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(__devm_reset_control_get);
|
||||
@ -919,22 +921,21 @@ EXPORT_SYMBOL_GPL(of_reset_control_array_get);
|
||||
struct reset_control *
|
||||
devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
|
||||
{
|
||||
struct reset_control **devres;
|
||||
struct reset_control *rstc;
|
||||
struct reset_control **ptr, *rstc;
|
||||
|
||||
devres = devres_alloc(devm_reset_control_release, sizeof(*devres),
|
||||
GFP_KERNEL);
|
||||
if (!devres)
|
||||
ptr = devres_alloc(devm_reset_control_release, sizeof(*ptr),
|
||||
GFP_KERNEL);
|
||||
if (!ptr)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
|
||||
if (IS_ERR_OR_NULL(rstc)) {
|
||||
devres_free(devres);
|
||||
devres_free(ptr);
|
||||
return rstc;
|
||||
}
|
||||
|
||||
*devres = rstc;
|
||||
devres_add(dev, devres);
|
||||
*ptr = rstc;
|
||||
devres_add(dev, ptr);
|
||||
|
||||
return rstc;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user