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]
Date:   Wed, 5 Apr 2023 21:05:54 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Sebastian Reichel <sebastian.reichel@...labora.com>
Cc:     Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Alexandre Torgue <alexandre.torgue@...s.st.com>,
        Jose Abreu <joabreu@...opsys.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        kernel@...labora.com
Subject: Re: [PATCHv2 1/2] net: ethernet: stmmac: dwmac-rk: rework optional
 clock handling

On Wed, Apr 05, 2023 at 06:10:42PM +0200, Sebastian Reichel wrote:
> The clock requesting code is quite repetitive. Fix this by requesting
> the clocks in a loop. Also use devm_clk_get_optional instead of
> devm_clk_get, since the old code effectively handles them as optional
> clocks. This removes error messages about missing clocks for platforms
> not using them and correct -EPROBE_DEFER handling.
> 
> The new code also tries to get "clk_mac_ref" and "clk_mac_refout" when
> the PHY is not configured as PHY_INTERFACE_MODE_RMII to keep the code
> simple. This is possible since we use devm_clk_get_optional() for the
> clock lookup anyways.
> 
> Suggested-by: Jakub Kicinski <kuba@...nel.org>
> Fixes: 7ad269ea1a2b7 ("GMAC: add driver for Rockchip RK3288 SoCs integrated GMAC")
> Signed-off-by: Sebastian Reichel <sebastian.reichel@...labora.com>
> ---
>  .../net/ethernet/stmicro/stmmac/dwmac-rk.c    | 63 ++++++-------------
>  1 file changed, 20 insertions(+), 43 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> index 4b8fd11563e4..6fdad0f10d6f 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
> @@ -1475,54 +1475,31 @@ static int rk_gmac_clk_init(struct plat_stmmacenet_data *plat)
>  {
>  	struct rk_priv_data *bsp_priv = plat->bsp_priv;
>  	struct device *dev = &bsp_priv->pdev->dev;
> -	int ret;
> +	int i, ret;
> +	struct {
> +		struct clk **ptr;
> +		const char *name;
> +	} clocks[] = {
> +		{ &bsp_priv->mac_clk_rx, "mac_clk_rx" },
> +		{ &bsp_priv->mac_clk_tx, "mac_clk_tx" },
> +		{ &bsp_priv->aclk_mac, "aclk_mac" },
> +		{ &bsp_priv->pclk_mac, "pclk_mac" },
> +		{ &bsp_priv->clk_mac, "stmmaceth" },
> +		{ &bsp_priv->clk_mac_ref, "clk_mac_ref" },
> +		{ &bsp_priv->clk_mac_refout, "clk_mac_refout" },
> +		{ &bsp_priv->clk_mac_speed, "clk_mac_speed" },
> +	};

> +	for (i=0; i < ARRAY_SIZE(clocks); i++) {
> +		*clocks[i].ptr = devm_clk_get_optional(dev, clocks[i].name);
> +		if (IS_ERR(*clocks[i].ptr))
> +			return dev_err_probe(dev, PTR_ERR(*clocks[i].ptr),
> +					     "cannot get clock %s\n",
> +					     clocks[i].name);
>  	}

Could devm_clk_bulk_get_optional() be used?

      Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ