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

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: Rahul 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: Stephen Boyd <sboyd@kernel.org>

authored by

Rahul Tanwar and committed by
Stephen Boyd
d310124c c9e28fe6

+3 -4
+3 -4
drivers/clk/x86/clk-cgu.c
··· 581 581 unsigned int nr_clk) 582 582 { 583 583 struct device *dev = ctx->dev; 584 - struct clk_init_data init = {}; 585 - struct lgm_clk_ddiv *ddiv; 586 584 struct clk_hw *hw; 587 585 unsigned int idx; 588 586 int ret; 589 587 590 588 for (idx = 0; idx < nr_clk; idx++, list++) { 591 - ddiv = NULL; 589 + struct clk_init_data init = {}; 590 + struct lgm_clk_ddiv *ddiv; 591 + 592 592 ddiv = devm_kzalloc(dev, sizeof(*ddiv), GFP_KERNEL); 593 593 if (!ddiv) 594 594 return -ENOMEM; 595 595 596 - memset(&init, 0, sizeof(init)); 597 596 init.name = list->name; 598 597 init.ops = &lgm_clk_ddiv_ops; 599 598 init.flags = list->flags;