Commit d310124c authored by Rahul Tanwar's avatar Rahul Tanwar Committed by Stephen Boyd

clk: intel: Avoid unnecessary memset by improving code

memset can be avoided in a loop if the variables used are declared
inside the loop. Move such variables declaration inside the loop
to avoid memset.
Signed-off-by: default avatarRahul Tanwar <rahul.tanwar@linux.intel.com>
Link: https://lore.kernel.org/r/26624b65d0e6b958c4765a406b9929d1a9ce1c2c.1594880946.git.rahul.tanwar@linux.intel.com
[sboyd@kernel.org: Drop NULL assignment that is overwritten]
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent c9e28fe6
...@@ -581,19 +581,18 @@ int lgm_clk_register_ddiv(struct lgm_clk_provider *ctx, ...@@ -581,19 +581,18 @@ int lgm_clk_register_ddiv(struct lgm_clk_provider *ctx,
unsigned int nr_clk) unsigned int nr_clk)
{ {
struct device *dev = ctx->dev; struct device *dev = ctx->dev;
struct clk_init_data init = {};
struct lgm_clk_ddiv *ddiv;
struct clk_hw *hw; struct clk_hw *hw;
unsigned int idx; unsigned int idx;
int ret; int ret;
for (idx = 0; idx < nr_clk; idx++, list++) { for (idx = 0; idx < nr_clk; idx++, list++) {
ddiv = NULL; struct clk_init_data init = {};
struct lgm_clk_ddiv *ddiv;
ddiv = devm_kzalloc(dev, sizeof(*ddiv), GFP_KERNEL); ddiv = devm_kzalloc(dev, sizeof(*ddiv), GFP_KERNEL);
if (!ddiv) if (!ddiv)
return -ENOMEM; return -ENOMEM;
memset(&init, 0, sizeof(init));
init.name = list->name; init.name = list->name;
init.ops = &lgm_clk_ddiv_ops; init.ops = &lgm_clk_ddiv_ops;
init.flags = list->flags; init.flags = list->flags;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment