Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Andy Shevchenko and committed by
Stephen Boyd
d61876a2 07bdf48d

+9 -13
+9 -13
drivers/clk/clkdev.c
··· 346 346 } 347 347 EXPORT_SYMBOL(clk_hw_register_clkdev); 348 348 349 - static void devm_clkdev_release(struct device *dev, void *res) 349 + static void devm_clkdev_release(void *res) 350 350 { 351 - clkdev_drop(*(struct clk_lookup **)res); 351 + clkdev_drop(res); 352 352 } 353 353 354 354 /** ··· 369 369 int devm_clk_hw_register_clkdev(struct device *dev, struct clk_hw *hw, 370 370 const char *con_id, const char *dev_id) 371 371 { 372 - int rval = -ENOMEM; 373 - struct clk_lookup **cl; 372 + struct clk_lookup *cl; 373 + int rval; 374 374 375 - cl = devres_alloc(devm_clkdev_release, sizeof(*cl), GFP_KERNEL); 376 - if (cl) { 377 - rval = do_clk_register_clkdev(hw, cl, con_id, dev_id); 378 - if (!rval) 379 - devres_add(dev, cl); 380 - else 381 - devres_free(cl); 382 - } 383 - return rval; 375 + rval = do_clk_register_clkdev(hw, &cl, con_id, dev_id); 376 + if (rval) 377 + return rval; 378 + 379 + return devm_add_action_or_reset(dev, devm_clkdev_release, cl); 384 380 } 385 381 EXPORT_SYMBOL(devm_clk_hw_register_clkdev);