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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 26 Jan 2022 14:07:38 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Tobias Waldekranz <tobias@...dekranz.com>
Cc:     davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org,
        Marcin Wojtas <mw@...ihalf.com>,
        Calvin Johnson <calvin.johnson@....nxp.com>,
        Markus Koch <markus@...syncing.net>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 4/5] net/fsl: xgmac_mdio: Support setting the
 MDC frequency

Hi Tobias

>  struct mdio_fsl_priv {
>  	struct	tgec_mdio_controller __iomem *mdio_base;
> +	struct clk *enet_clk;

It looks like there is a whitespace issue here?

> +	u32	mdc_freq;
>  	bool	is_little_endian;
>  	bool	has_a009885;
>  	bool	has_a011043;
> @@ -255,6 +258,34 @@ static int xgmac_mdio_read(struct mii_bus *bus, int phy_id, int regnum)
>  	return ret;
>  }
>  
> +static void xgmac_mdio_set_mdc_freq(struct mii_bus *bus)
> +{
> +	struct mdio_fsl_priv *priv = (struct mdio_fsl_priv *)bus->priv;
> +	struct tgec_mdio_controller __iomem *regs = priv->mdio_base;
> +	struct device *dev = bus->parent;
> +	u32 mdio_stat, div;
> +
> +	if (device_property_read_u32(dev, "clock-frequency", &priv->mdc_freq))
> +		return;
> +
> +	priv->enet_clk = devm_clk_get(dev, NULL);
> +	if (IS_ERR(priv->enet_clk)) {
> +		dev_err(dev, "Input clock unknown, not changing MDC frequency");

Is the clock optional or mandatory?

If mandatory, then i would prefer -ENODEV and fail the probe.

> +		return;
> +	}
> +
> +	div = ((clk_get_rate(priv->enet_clk) / priv->mdc_freq) - 1) / 2;
> +	if (div < 5 || div > 0x1ff) {
> +		dev_err(dev, "Requested MDC frequecy is out of range, ignoring");

and here return -EINVAL.

I always think it is best to make it obvious something is broken. One
additional line on the console can be missed for a while. All the
Ethernet devices missing because the PHYs are missing, because the
MDIO bus is missing is going to get noticed very quickly.

     Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ