From: jbrunet@baylibre.com (Jerome Brunet)
To: linus-amlogic@lists.infradead.org
Subject: [RFT net-next v4 2/5] net: stmmac: dwmac-meson8b: simplify generating the clock names
Date: Mon, 15 Jan 2018 12:46:47 +0100 [thread overview]
Message-ID: <1516016807.2608.13.camel@baylibre.com> (raw)
In-Reply-To: <20180114214858.7217-3-martin.blumenstingl@googlemail.com>
On Sun, 2018-01-14 at 22:48 +0100, Martin Blumenstingl wrote:
> Instead of using a custom buffer, snprintf() and devm_kstrdup() we can
> simplify this by using devm_kasprintf().
> No functional changes - this just makes the code shorter.
CCF copies the name from the init_data to its own structures, so the init_data
are useless after the register.
Here you'd allocate memory for each string which will remain until the driver
unload. It's not much, but still, it is wasted memory.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> index c6f87e9c4ccb..670f344f7168 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> @@ -86,7 +86,6 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> struct clk_init_data init;
> int i, ret;
> struct device *dev = &dwmac->pdev->dev;
> - char clk_name[32];
> const char *clk_div_parents[1];
> const char *mux_parent_names[MUX_CLK_NUM_PARENTS];
> static const struct clk_div_table clk_25m_div_table[] = {
> @@ -113,8 +112,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> }
>
> /* create the m250_mux */
> - snprintf(clk_name, sizeof(clk_name), "%s#m250_sel", dev_name(dev));
> - init.name = clk_name;
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m250_sel",
> + dev_name(dev));
> init.ops = &clk_mux_ops;
> init.flags = 0;
> init.parent_names = mux_parent_names;
> @@ -132,8 +131,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> return PTR_ERR(dwmac->m250_mux_clk);
>
> /* create the m250_div */
> - snprintf(clk_name, sizeof(clk_name), "%s#m250_div", dev_name(dev));
> - init.name = devm_kstrdup(dev, clk_name, GFP_KERNEL);
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m250_div",
> + dev_name(dev));
> init.ops = &clk_divider_ops;
> init.flags = CLK_SET_RATE_PARENT;
> clk_div_parents[0] = __clk_get_name(dwmac->m250_mux_clk);
> @@ -151,8 +150,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> return PTR_ERR(dwmac->m250_div_clk);
>
> /* create the m25_div */
> - snprintf(clk_name, sizeof(clk_name), "%s#m25_div", dev_name(dev));
> - init.name = devm_kstrdup(dev, clk_name, GFP_KERNEL);
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m25_div",
> + dev_name(dev));
> init.ops = &clk_divider_ops;
> init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
> clk_div_parents[0] = __clk_get_name(dwmac->m250_div_clk);
WARNING: multiple messages have this Message-ID (diff)
From: Jerome Brunet <jbrunet@baylibre.com>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
netdev@vger.kernel.org, ingrassia@epigenesys.com
Cc: linus.luessing@c0d3.blue, khilman@baylibre.com,
linux-amlogic@lists.infradead.org, narmstrong@baylibre.com,
peppe.cavallaro@st.com, alexandre.torgue@st.com
Subject: Re: [RFT net-next v4 2/5] net: stmmac: dwmac-meson8b: simplify generating the clock names
Date: Mon, 15 Jan 2018 12:46:47 +0100 [thread overview]
Message-ID: <1516016807.2608.13.camel@baylibre.com> (raw)
In-Reply-To: <20180114214858.7217-3-martin.blumenstingl@googlemail.com>
On Sun, 2018-01-14 at 22:48 +0100, Martin Blumenstingl wrote:
> Instead of using a custom buffer, snprintf() and devm_kstrdup() we can
> simplify this by using devm_kasprintf().
> No functional changes - this just makes the code shorter.
CCF copies the name from the init_data to its own structures, so the init_data
are useless after the register.
Here you'd allocate memory for each string which will remain until the driver
unload. It's not much, but still, it is wasted memory.
>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
> ---
> drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> index c6f87e9c4ccb..670f344f7168 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
> @@ -86,7 +86,6 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> struct clk_init_data init;
> int i, ret;
> struct device *dev = &dwmac->pdev->dev;
> - char clk_name[32];
> const char *clk_div_parents[1];
> const char *mux_parent_names[MUX_CLK_NUM_PARENTS];
> static const struct clk_div_table clk_25m_div_table[] = {
> @@ -113,8 +112,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> }
>
> /* create the m250_mux */
> - snprintf(clk_name, sizeof(clk_name), "%s#m250_sel", dev_name(dev));
> - init.name = clk_name;
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m250_sel",
> + dev_name(dev));
> init.ops = &clk_mux_ops;
> init.flags = 0;
> init.parent_names = mux_parent_names;
> @@ -132,8 +131,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> return PTR_ERR(dwmac->m250_mux_clk);
>
> /* create the m250_div */
> - snprintf(clk_name, sizeof(clk_name), "%s#m250_div", dev_name(dev));
> - init.name = devm_kstrdup(dev, clk_name, GFP_KERNEL);
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m250_div",
> + dev_name(dev));
> init.ops = &clk_divider_ops;
> init.flags = CLK_SET_RATE_PARENT;
> clk_div_parents[0] = __clk_get_name(dwmac->m250_mux_clk);
> @@ -151,8 +150,8 @@ static int meson8b_init_rgmii_tx_clk(struct meson8b_dwmac *dwmac)
> return PTR_ERR(dwmac->m250_div_clk);
>
> /* create the m25_div */
> - snprintf(clk_name, sizeof(clk_name), "%s#m25_div", dev_name(dev));
> - init.name = devm_kstrdup(dev, clk_name, GFP_KERNEL);
> + init.name = devm_kasprintf(dev, GFP_KERNEL, "%s#m25_div",
> + dev_name(dev));
> init.ops = &clk_divider_ops;
> init.flags = CLK_IS_BASIC | CLK_SET_RATE_PARENT;
> clk_div_parents[0] = __clk_get_name(dwmac->m250_div_clk);
next prev parent reply other threads:[~2018-01-15 11:46 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-14 21:48 [RFT net-next v4 0/5] dwmac-meson8b: clock fixes for Meson8b Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-14 21:48 ` [RFT net-next v4 1/5] net: stmmac: dwmac-meson8b: only configure the clocks in RGMII mode Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-15 11:46 ` Jerome Brunet
2018-01-15 11:46 ` Jerome Brunet
2018-01-15 12:04 ` Martin Blumenstingl
2018-01-15 12:04 ` Martin Blumenstingl
2018-01-14 21:48 ` [RFT net-next v4 2/5] net: stmmac: dwmac-meson8b: simplify generating the clock names Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-15 11:46 ` Jerome Brunet [this message]
2018-01-15 11:46 ` Jerome Brunet
2018-01-15 12:02 ` Martin Blumenstingl
2018-01-15 12:02 ` Martin Blumenstingl
2018-01-15 12:36 ` Jerome Brunet
2018-01-15 12:36 ` Jerome Brunet
2018-01-14 21:48 ` [RFT net-next v4 3/5] net: stmmac: dwmac-meson8b: fix internal RGMII clock configuration Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-15 11:49 ` Jerome Brunet
2018-01-15 11:49 ` Jerome Brunet
2018-01-15 12:08 ` Martin Blumenstingl
2018-01-15 12:08 ` Martin Blumenstingl
2018-01-15 12:45 ` Jerome Brunet
2018-01-15 12:45 ` Jerome Brunet
2018-01-16 11:20 ` Martin Blumenstingl
2018-01-18 20:05 ` Martin Blumenstingl
2018-01-18 20:05 ` Martin Blumenstingl
2018-01-14 21:48 ` [RFT net-next v4 4/5] net: stmmac: dwmac-meson8b: fix setting the RGMII TX clock on Meson8b Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-14 21:48 ` [RFT net-next v4 5/5] net: stmmac: dwmac-meson8b: propagate rate changes to the parent clock Martin Blumenstingl
2018-01-14 21:48 ` Martin Blumenstingl
2018-01-15 11:50 ` Jerome Brunet
2018-01-15 11:50 ` Jerome Brunet
2018-01-15 11:45 ` [RFT net-next v4 0/5] dwmac-meson8b: clock fixes for Meson8b Jerome Brunet
2018-01-15 11:45 ` Jerome Brunet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516016807.2608.13.camel@baylibre.com \
--to=jbrunet@baylibre.com \
--cc=linus-amlogic@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.