lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c9f68d34-285e-63ff-8140-691c77f8d212@gmail.com>
Date:   Wed, 26 Jan 2022 16:42:45 -0800
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Robert Hancock <robert.hancock@...ian.com>, netdev@...r.kernel.org
Cc:     woojung.huh@...rochip.com, UNGLinuxDriver@...rochip.com,
        andrew@...n.ch, vivien.didelot@...il.com, olteanv@...il.com,
        davem@...emloft.net, kuba@...nel.org, robh+dt@...nel.org,
        marex@...x.de, devicetree@...r.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: microchip: Add property to
 disable reference clock



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@...ian.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ