[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <159558097978.3847286.7904651694237654748@swboyd.mtv.corp.google.com>
Date: Fri, 24 Jul 2020 01:56:19 -0700
From: Stephen Boyd <sboyd@...nel.org>
To: Rahul Tanwar <rahul.tanwar@...ux.intel.com>,
linux-clk@...r.kernel.org, mturquette@...libre.com
Cc: linux-kernel@...r.kernel.org, andriy.shevchenko@...el.com,
qi-ming.wu@...el.com, yixin.zhu@...ux.intel.com,
cheol.yong.kim@...el.com, rahul.tanwar.linux@...il.com,
Rahul Tanwar <rahul.tanwar@...ux.intel.com>
Subject: Re: [PATCH v2 3/3] clk: intel: Avoid unnecessary memset by improving code
Quoting Rahul Tanwar (2020-07-15 23:30:32)
> 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@...ux.intel.com>
> ---
> drivers/clk/x86/clk-cgu.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/clk/x86/clk-cgu.c b/drivers/clk/x86/clk-cgu.c
> index c379fedfb9f2..9a1be7035fd0 100644
> --- a/drivers/clk/x86/clk-cgu.c
> +++ b/drivers/clk/x86/clk-cgu.c
> @@ -581,19 +581,18 @@ int lgm_clk_register_ddiv(struct lgm_clk_provider *ctx,
> unsigned int nr_clk)
> {
> struct device *dev = ctx->dev;
> - struct clk_init_data init = {};
> - struct lgm_clk_ddiv *ddiv;
> struct clk_hw *hw;
> unsigned int idx;
> int ret;
>
> for (idx = 0; idx < nr_clk; idx++, list++) {
> - ddiv = NULL;
> + struct clk_init_data init = {};
> + struct lgm_clk_ddiv *ddiv = NULL;
Assigning to NULL isn't necessary...
> +
> ddiv = devm_kzalloc(dev, sizeof(*ddiv), GFP_KERNEL);
because it's assigned right here. I'll just fix it.
> if (!ddiv)
> return -ENOMEM;
>
> - memset(&init, 0, sizeof(init));
> init.name = list->name;
> init.ops = &lgm_clk_ddiv_ops;
> init.flags = list->flags;
Powered by blists - more mailing lists