From: Florian Fainelli <f.fainelli@gmail.com>
To: Robert Hancock <robert.hancock@calian.com>, netdev@vger.kernel.org
Cc: woojung.huh@microchip.com, UNGLinuxDriver@microchip.com,
andrew@lunn.ch, vivien.didelot@gmail.com, olteanv@gmail.com,
davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org,
marex@denx.de, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: microchip: Add property to disable reference clock
Date: Wed, 26 Jan 2022 16:42:45 -0800 [thread overview]
Message-ID: <c9f68d34-285e-63ff-8140-691c77f8d212@gmail.com> (raw)
In-Reply-To: <20220127003318.3633212-3-robert.hancock@calian.com>
On 1/26/2022 4:33 PM, Robert Hancock wrote:
> Add a new microchip,synclko-disable property which can be specified
> to disable the reference clock output from the device if not required
> by the board design.
>
> Signed-off-by: Robert Hancock <robert.hancock@calian.com>
This looks good, I would just have done the hunk below a bit differently:
> ---
> drivers/net/dsa/microchip/ksz9477.c | 7 ++++++-
> drivers/net/dsa/microchip/ksz_common.c | 6 ++++++
> drivers/net/dsa/microchip/ksz_common.h | 1 +
> 3 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c
> index 353b5f981740..33d52050cd68 100644
> --- a/drivers/net/dsa/microchip/ksz9477.c
> +++ b/drivers/net/dsa/microchip/ksz9477.c
> @@ -222,9 +222,14 @@ static int ksz9477_reset_switch(struct ksz_device *dev)
> (BROADCAST_STORM_VALUE *
> BROADCAST_STORM_PROT_RATE) / 100);
>
> - if (dev->synclko_125)
> + if (dev->synclko_disable)
> + ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, 0);
> + else if (dev->synclko_125)
> ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
> SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ);
> + else
> + ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1,
> + SW_ENABLE_REFCLKO);
Since you write to the same register in all of these branches, why not
do this:
u32 tmp = SW_ENABLE_REFCLKO;
if (dev->synclko_disable)
tmp = 0
else if (dev->synclko_125)
tmp = SW_ENABLE_REFCLKO | SW_REFCLKO_IS_125MHZ;
ksz_write8(dev, REG_SW_GLOBAL_OUTPUT_CTRL__1, tmp);
even though the compiler may just do that for you under the hood.
--
Florian
prev parent reply other threads:[~2022-01-27 0:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-27 0:33 [PATCH net-next v3 0/2] Allow disabling KSZ switch refclock Robert Hancock
2022-01-27 0:33 ` [PATCH net-next v3 1/2] net: dsa: microchip: Document property to disable reference clock Robert Hancock
2022-01-27 0:33 ` [PATCH net-next v3 2/2] net: dsa: microchip: Add " Robert Hancock
2022-01-27 0:42 ` Florian Fainelli [this message]
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=c9f68d34-285e-63ff-8140-691c77f8d212@gmail.com \
--to=f.fainelli@gmail.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=marex@denx.de \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=robert.hancock@calian.com \
--cc=robh+dt@kernel.org \
--cc=vivien.didelot@gmail.com \
--cc=woojung.huh@microchip.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox