Skip to content

Commit

Permalink
spi: cs42l43: Use devm_add_action_or_reset()
Browse files Browse the repository at this point in the history
Use devm_add_action_or_reset() rather than manually cleaning up on the
error path.

Suggested-by: Andy Shevchenko <[email protected]>
Signed-off-by: Charles Keepax <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
charleskeepax authored and broonie committed Apr 17, 2024
1 parent 1f48cbd commit 719af32
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/spi/spi-cs42l43.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,9 @@ static int cs42l43_spi_probe(struct platform_device *pdev)

if (is_of_node(fwnode)) {
fwnode = fwnode_get_named_child_node(fwnode, "spi");
ret = devm_add_action(priv->dev, cs42l43_release_of_node, fwnode);
if (ret) {
fwnode_handle_put(fwnode);
ret = devm_add_action_or_reset(priv->dev, cs42l43_release_of_node, fwnode);
if (ret)
return ret;
}
}

if (has_sidecar) {
Expand All @@ -358,11 +356,9 @@ static int cs42l43_spi_probe(struct platform_device *pdev)
return dev_err_probe(priv->dev, ret,
"Failed to register gpio swnode\n");

ret = devm_add_action(priv->dev, cs42l43_release_sw_node, NULL);
if (ret) {
software_node_unregister(&cs42l43_gpiochip_swnode);
ret = devm_add_action_or_reset(priv->dev, cs42l43_release_sw_node, NULL);
if (ret)
return ret;
}

ret = device_create_managed_software_node(&priv->ctlr->dev,
cs42l43_cs_props, NULL);
Expand Down

0 comments on commit 719af32

Please sign in to comment.