Message ID | f904fd28b2087d1463ea65f059924e3b1acc193c.1672764239.git.geert+renesas@glider.be |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp4716069wrt; Tue, 3 Jan 2023 08:51:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXuvZt8ZPNbHWeNUeyttR583vEkrtJE2fZMO7/n7ks+TklTV/lfJeQWmWREuHvj3CV+HIblj X-Received: by 2002:a17:902:f706:b0:190:fc28:8cca with SMTP id h6-20020a170902f70600b00190fc288ccamr53607010plo.10.1672764717138; Tue, 03 Jan 2023 08:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672764717; cv=none; d=google.com; s=arc-20160816; b=a2I2IVlMRr3Y6NbRIP5lEz2NO76XoG9Tr06BFwk+sezCT9VFljzezWJQlP0/eLZ22t lNPa0AYBUQxBZMKG2JKxQx5KPiBnQB7VFrGYyiWJndFv9XY6rdJaDaRIx0jgqM/LpEiw Z6Bld9tKtpLMhlA5p8AsQEe6CY9WJ+DlcVbsuGv23moQ3plaWfXZhnEC13R7d15Yg3Y4 cO/8omU6nMajqv6hG+WcbEQKUK0rUGDRcOgPPsS7DoefJGEPuZpavJg/1CALw4+4OVNl hFbR37sMnAOs2QY9Kuc5P3ptAaqlHp6rX1ufZL7gM4vUE0BTg3by4gDBjlIaHkXgN+m+ PUcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=Hfu5BKied2mLmhSCh7dIGmOf8YnYuV27lEus8SSLkK0=; b=wNDkPGXgwyTgmVzLgB2jN1APiMMvCVDHOlJRCZIq/9+TxPZQm7FwE7KcO9xmI0cjeb 5iNxg/dym+vx/L4GLB/ZPw/yCtefMWc3J7kZSB8eby6lZgZ83bK9IMCy65TjiGPeCmps RdYDHmfgpfhnD5+HFIeHBz79OIJ8Q5lSy9L0SlNKjoPF2Ug9LcokfnErwUMKKXcsXxX3 bsiMNMVqlLm1Hz5oeQHkUfi/EJvbHZv1hwQPFNsFIeEoMEFDB52pWmrGCghH8qX+UScD iosBboyzy260WWKWLXDlrNcsLOoJHDSEm5k7Yb3zW375eYUJEc+urjbZ3CfqZ6Dbeol4 0Bfw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u11-20020a170903124b00b00188d892999esi39212285plh.521.2023.01.03.08.51.43; Tue, 03 Jan 2023 08:51:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237813AbjACQph (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Tue, 3 Jan 2023 11:45:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237907AbjACQpf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Jan 2023 11:45:35 -0500 Received: from michel.telenet-ops.be (michel.telenet-ops.be [IPv6:2a02:1800:110:4::f00:18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C09B8DA0 for <linux-kernel@vger.kernel.org>; Tue, 3 Jan 2023 08:45:34 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed10:f1ca:ff0d:9dea:806e]) by michel.telenet-ops.be with bizsmtp id 4GlY2900w2YHDVW06GlYRb; Tue, 03 Jan 2023 17:45:33 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from <geert@linux-m68k.org>) id 1pCkPs-00203S-LF; Tue, 03 Jan 2023 17:45:32 +0100 Received: from geert by rox.of.borg with local (Exim 4.93) (envelope-from <geert@linux-m68k.org>) id 1pCkPs-001TJk-68; Tue, 03 Jan 2023 17:45:32 +0100 From: Geert Uytterhoeven <geert+renesas@glider.be> To: Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, Claudiu Beznea <claudiu.beznea@microchip.com>, Conor Dooley <conor.dooley@microchip.com> Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be> Subject: [PATCH] clk: microchip: mpfs-ccc: Use devm_kasprintf() for allocating formatted strings Date: Tue, 3 Jan 2023 17:45:30 +0100 Message-Id: <f904fd28b2087d1463ea65f059924e3b1acc193c.1672764239.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754020936261459600?= X-GMAIL-MSGID: =?utf-8?q?1754020936261459600?= |
Series |
clk: microchip: mpfs-ccc: Use devm_kasprintf() for allocating formatted strings
|
|
Commit Message
Geert Uytterhoeven
Jan. 3, 2023, 4:45 p.m. UTC
In various places, string buffers of a fixed size are allocated, and
filled using snprintf() with the same fixed size, which is error-prone.
Replace this by calling devm_kasprintf() instead, which always uses the
appropriate size.
While at it, remove an unneeded intermediate variable, which allows us
to drop a cast as a bonus.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/clk/microchip/clk-mpfs-ccc.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
Comments
On Tue, Jan 03, 2023 at 05:45:30PM +0100, Geert Uytterhoeven wrote: > In various places, string buffers of a fixed size are allocated, and > filled using snprintf() with the same fixed size, which is error-prone. > > Replace this by calling devm_kasprintf() instead, which always uses the > appropriate size. > > While at it, remove an unneeded intermediate variable, which allows us > to drop a cast as a bonus. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Tested-by: Conor Dooley <conor.dooley@microchip.com> I half wonder if this should actually have a fixes tag too. Since it used what came after the @ in $full_name, it'd be possible to create (an incorrect) DTS that would lead to a clash between pll names & therefore probe would fail. The tag would be: Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock support") Either way, thanks for pointing out a function that does exactly what I initially wanted to do but could not find! Glad to be rid of those "oddly specific" allocations. Thanks, Conor. > --- > drivers/clk/microchip/clk-mpfs-ccc.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/clk-mpfs-ccc.c > index 32aae880a14f3b1c..0ddc73e07be42973 100644 > --- a/drivers/clk/microchip/clk-mpfs-ccc.c > +++ b/drivers/clk/microchip/clk-mpfs-ccc.c > @@ -164,12 +164,11 @@ static int mpfs_ccc_register_outputs(struct device *dev, struct mpfs_ccc_out_hw_ > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_out_hw_clock *out_hw = &out_hws[i]; > - char *name = devm_kzalloc(dev, 23, GFP_KERNEL); > + char *name = devm_kasprintf(dev, GFP_KERNEL, "%s_out%u", parent->name, i); > > if (!name) > return -ENOMEM; > > - snprintf(name, 23, "%s_out%u", parent->name, i); > out_hw->divider.hw.init = CLK_HW_INIT_HW(name, &parent->hw, &clk_divider_ops, 0); > out_hw->divider.reg = data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + > out_hw->reg_offset; > @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; > - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); > > - if (!name) > + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", > + strchrnul(dev->of_node->full_name, '@'), i); > + if (!pll_hw->name) > return -ENOMEM; > > pll_hw->base = data->pll_base[i]; > - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); > - pll_hw->name = (const char *)name; > pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, > pll_hw->parents, > &mpfs_ccc_pll_ops, 0); > -- > 2.25.1 > >
Hi Conor, On Tue, Jan 3, 2023 at 6:32 PM Conor Dooley <conor@kernel.org> wrote: > On Tue, Jan 03, 2023 at 05:45:30PM +0100, Geert Uytterhoeven wrote: > > In various places, string buffers of a fixed size are allocated, and > > filled using snprintf() with the same fixed size, which is error-prone. > > > > Replace this by calling devm_kasprintf() instead, which always uses the > > appropriate size. > > > > While at it, remove an unneeded intermediate variable, which allows us > > to drop a cast as a bonus. > > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > > Reviewed-by: Conor Dooley <conor.dooley@microchip.com> > Tested-by: Conor Dooley <conor.dooley@microchip.com> Thanks! > I half wonder if this should actually have a fixes tag too. Since it > used what came after the @ in $full_name, it'd be possible to create > (an incorrect) DTS that would lead to a clash between pll names & > therefore probe would fail. > The tag would be: > Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock support") But I don't change any of that in my patch? /me confused. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
On Wed, Jan 04, 2023 at 02:26:53PM +0100, Geert Uytterhoeven wrote: > Hi Conor, > > On Tue, Jan 3, 2023 at 6:32 PM Conor Dooley <conor@kernel.org> wrote: > > I half wonder if this should actually have a fixes tag too. Since it > > used what came after the @ in $full_name, it'd be possible to create > > (an incorrect) DTS that would lead to a clash between pll names & > > therefore probe would fail. > > The tag would be: > > Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock support") > > But I don't change any of that in my patch? > /me confused. The numbers in there were chosen to fit exactly what is in mpfs.dtsi (IOW the correct node address), so doing @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo for (unsigned int i = 0; i < num_clks; i++) { struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); - if (!name) + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", + strchrnul(dev->of_node->full_name, '@'), i); + if (!pll_hw->name) return -ENOMEM; pll_hw->base = data->pll_base[i]; - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); - pll_hw->name = (const char *)name; pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, pll_hw->parents, &mpfs_ccc_pll_ops, 0); means that we no longer have to worry that someone would provide a device tree with a node address that would make "ccc<node_address>_pll<N>" exceed 18 characters. If that happened, the <N> would be cut off & both pll 0 & 1 would be named identically. If that happens, pll1 would fail to register. Or am I misunderstanding something? Probably am.. Thanks, Conor.
Hi Conor, On Wed, Jan 4, 2023 at 2:40 PM Conor Dooley <conor@kernel.org> wrote: > On Wed, Jan 04, 2023 at 02:26:53PM +0100, Geert Uytterhoeven wrote: > > On Tue, Jan 3, 2023 at 6:32 PM Conor Dooley <conor@kernel.org> wrote: > > > I half wonder if this should actually have a fixes tag too. Since it > > > used what came after the @ in $full_name, it'd be possible to create > > > (an incorrect) DTS that would lead to a clash between pll names & > > > therefore probe would fail. > > > The tag would be: > > > Fixes: d39fb172760e ("clk: microchip: add PolarFire SoC fabric clock support") > > > > But I don't change any of that in my patch? > > /me confused. > > The numbers in there were chosen to fit exactly what is in mpfs.dtsi > (IOW the correct node address), so doing > @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; > - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); > > - if (!name) > + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", > + strchrnul(dev->of_node->full_name, '@'), i); > + if (!pll_hw->name) > return -ENOMEM; > > pll_hw->base = data->pll_base[i]; > - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); > - pll_hw->name = (const char *)name; > pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, > pll_hw->parents, > &mpfs_ccc_pll_ops, 0); > > means that we no longer have to worry that someone would provide a > device tree with a node address that would make "ccc<node_address>_pll<N>" > exceed 18 characters. If that happened, the <N> would be cut off & both > pll 0 & 1 would be named identically. If that happens, pll1 would fail > to register. Oh right. Yeah, before we would get collisions, now we would get a different broken system. DTS garbage in, garbage behavior out ;-) Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hey Claudiu, Could you pick this one up when you get a chance please? Thanks, Conor. On Tue, Jan 03, 2023 at 05:45:30PM +0100, Geert Uytterhoeven wrote: > In various places, string buffers of a fixed size are allocated, and > filled using snprintf() with the same fixed size, which is error-prone. > > Replace this by calling devm_kasprintf() instead, which always uses the > appropriate size. > > While at it, remove an unneeded intermediate variable, which allows us > to drop a cast as a bonus. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > drivers/clk/microchip/clk-mpfs-ccc.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/clk-mpfs-ccc.c > index 32aae880a14f3b1c..0ddc73e07be42973 100644 > --- a/drivers/clk/microchip/clk-mpfs-ccc.c > +++ b/drivers/clk/microchip/clk-mpfs-ccc.c > @@ -164,12 +164,11 @@ static int mpfs_ccc_register_outputs(struct device *dev, struct mpfs_ccc_out_hw_ > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_out_hw_clock *out_hw = &out_hws[i]; > - char *name = devm_kzalloc(dev, 23, GFP_KERNEL); > + char *name = devm_kasprintf(dev, GFP_KERNEL, "%s_out%u", parent->name, i); > > if (!name) > return -ENOMEM; > > - snprintf(name, 23, "%s_out%u", parent->name, i); > out_hw->divider.hw.init = CLK_HW_INIT_HW(name, &parent->hw, &clk_divider_ops, 0); > out_hw->divider.reg = data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + > out_hw->reg_offset; > @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; > - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); > > - if (!name) > + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", > + strchrnul(dev->of_node->full_name, '@'), i); > + if (!pll_hw->name) > return -ENOMEM; > > pll_hw->base = data->pll_base[i]; > - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); > - pll_hw->name = (const char *)name; > pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, > pll_hw->parents, > &mpfs_ccc_pll_ops, 0); > -- > 2.25.1 >
Hi, Conor, On 11.01.2023 21:26, Conor Dooley wrote: > Hey Claudiu, > > Could you pick this one up when you get a chance please? It's already in my tree, not pushed yet, though. It'll do it soon. I'll let you know. Claudiu > > Thanks,
On 03.01.2023 18:45, Geert Uytterhoeven wrote: > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe > > In various places, string buffers of a fixed size are allocated, and > filled using snprintf() with the same fixed size, which is error-prone. > > Replace this by calling devm_kasprintf() instead, which always uses the > appropriate size. > > While at it, remove an unneeded intermediate variable, which allows us > to drop a cast as a bonus. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Applied to clk-microchip-fixes, thanks! > --- > drivers/clk/microchip/clk-mpfs-ccc.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/clk-mpfs-ccc.c > index 32aae880a14f3b1c..0ddc73e07be42973 100644 > --- a/drivers/clk/microchip/clk-mpfs-ccc.c > +++ b/drivers/clk/microchip/clk-mpfs-ccc.c > @@ -164,12 +164,11 @@ static int mpfs_ccc_register_outputs(struct device *dev, struct mpfs_ccc_out_hw_ > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_out_hw_clock *out_hw = &out_hws[i]; > - char *name = devm_kzalloc(dev, 23, GFP_KERNEL); > + char *name = devm_kasprintf(dev, GFP_KERNEL, "%s_out%u", parent->name, i); > > if (!name) > return -ENOMEM; > > - snprintf(name, 23, "%s_out%u", parent->name, i); > out_hw->divider.hw.init = CLK_HW_INIT_HW(name, &parent->hw, &clk_divider_ops, 0); > out_hw->divider.reg = data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + > out_hw->reg_offset; > @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo > > for (unsigned int i = 0; i < num_clks; i++) { > struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; > - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); > > - if (!name) > + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", > + strchrnul(dev->of_node->full_name, '@'), i); > + if (!pll_hw->name) > return -ENOMEM; > > pll_hw->base = data->pll_base[i]; > - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); > - pll_hw->name = (const char *)name; > pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, > pll_hw->parents, > &mpfs_ccc_pll_ops, 0); > -- > 2.25.1 >
diff --git a/drivers/clk/microchip/clk-mpfs-ccc.c b/drivers/clk/microchip/clk-mpfs-ccc.c index 32aae880a14f3b1c..0ddc73e07be42973 100644 --- a/drivers/clk/microchip/clk-mpfs-ccc.c +++ b/drivers/clk/microchip/clk-mpfs-ccc.c @@ -164,12 +164,11 @@ static int mpfs_ccc_register_outputs(struct device *dev, struct mpfs_ccc_out_hw_ for (unsigned int i = 0; i < num_clks; i++) { struct mpfs_ccc_out_hw_clock *out_hw = &out_hws[i]; - char *name = devm_kzalloc(dev, 23, GFP_KERNEL); + char *name = devm_kasprintf(dev, GFP_KERNEL, "%s_out%u", parent->name, i); if (!name) return -ENOMEM; - snprintf(name, 23, "%s_out%u", parent->name, i); out_hw->divider.hw.init = CLK_HW_INIT_HW(name, &parent->hw, &clk_divider_ops, 0); out_hw->divider.reg = data->pll_base[i / MPFS_CCC_OUTPUTS_PER_PLL] + out_hw->reg_offset; @@ -201,14 +200,13 @@ static int mpfs_ccc_register_plls(struct device *dev, struct mpfs_ccc_pll_hw_clo for (unsigned int i = 0; i < num_clks; i++) { struct mpfs_ccc_pll_hw_clock *pll_hw = &pll_hws[i]; - char *name = devm_kzalloc(dev, 18, GFP_KERNEL); - if (!name) + pll_hw->name = devm_kasprintf(dev, GFP_KERNEL, "ccc%s_pll%u", + strchrnul(dev->of_node->full_name, '@'), i); + if (!pll_hw->name) return -ENOMEM; pll_hw->base = data->pll_base[i]; - snprintf(name, 18, "ccc%s_pll%u", strchrnul(dev->of_node->full_name, '@'), i); - pll_hw->name = (const char *)name; pll_hw->hw.init = CLK_HW_INIT_PARENTS_DATA_FIXED_SIZE(pll_hw->name, pll_hw->parents, &mpfs_ccc_pll_ops, 0);