clkdev: Simplify devm_clk_hw_register_clkdev() function

Use devm_add_action_or_reset() instead of devres_alloc() and
devres_add(), which works the same. This will simplify the
code. There is no functional changes.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220623115719.52683-3-andriy.shevchenko@linux.intel.com
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
Andy Shevchenko 2022-06-23 14:57:19 +03:00 committed by Stephen Boyd
parent 07bdf48d3f
commit d61876a285

View File

@ -346,9 +346,9 @@ int clk_hw_register_clkdev(struct clk_hw *hw, const char *con_id,
} }
EXPORT_SYMBOL(clk_hw_register_clkdev); EXPORT_SYMBOL(clk_hw_register_clkdev);
static void devm_clkdev_release(struct device *dev, void *res) static void devm_clkdev_release(void *res)
{ {
clkdev_drop(*(struct clk_lookup **)res); clkdev_drop(res);
} }
/** /**
@ -369,17 +369,13 @@ static void devm_clkdev_release(struct device *dev, void *res)
int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw,
const char *con_id, const char *dev_id) const char *con_id, const char *dev_id)
{ {
int rval = -ENOMEM; struct clk_lookup *cl;
struct clk_lookup **cl; int rval;
cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL); rval = do_clk_register_clkdev(hw, &cl, con_id, dev_id);
if (cl) { if (rval)
rval = do_clk_register_clkdev(hw, cl, con_id, dev_id); return rval;
if (!rval)
devres_add(dev, cl); return devm_add_action_or_reset(dev, devm_clkdev_release, cl);
else
devres_free(cl);
}
return rval;
} }
EXPORT_SYMBOL(devm_clk_hw_register_clkdev); EXPORT_SYMBOL(devm_clk_hw_register_clkdev);