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: <20230321201012.74487996@kernel.org>
Date:   Tue, 21 Mar 2023 20:10:12 -0700
From:   Jakub Kicinski <kuba@...nel.org>
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>,
        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: [PATCHv1 1/2] net: ethernet: stmmac: dwmac-rk: fix optional
 clock handling

On Fri, 17 Mar 2023 18:42:42 +0100 Sebastian Reichel wrote:
> -	bsp_priv->mac_clk_rx = devm_clk_get(dev, "mac_clk_rx");
> +	bsp_priv->mac_clk_rx = devm_clk_get_optional(dev, "mac_clk_rx");
>  	if (IS_ERR(bsp_priv->mac_clk_rx))
> -		dev_err(dev, "cannot get clock %s\n",
> -			"mac_clk_rx");
> +		return dev_err_probe(dev, PTR_ERR(bsp_priv->mac_clk_rx),
> +				"cannot get clock %s\n", "mac_clk_rx");
>  
> -	bsp_priv->mac_clk_tx = devm_clk_get(dev, "mac_clk_tx");
> +	bsp_priv->mac_clk_tx = devm_clk_get_optional(dev, "mac_clk_tx");
>  	if (IS_ERR(bsp_priv->mac_clk_tx))
> -		dev_err(dev, "cannot get clock %s\n",
> -			"mac_clk_tx");
> +		return dev_err_probe(dev, PTR_ERR(bsp_priv->mac_clk_tx),
> +				"cannot get clock %s\n", "mac_clk_tx");
>  
> -	bsp_priv->aclk_mac = devm_clk_get(dev, "aclk_mac");
> +	bsp_priv->aclk_mac = devm_clk_get_optional(dev, "aclk_mac");
>  	if (IS_ERR(bsp_priv->aclk_mac))
> -		dev_err(dev, "cannot get clock %s\n",
> -			"aclk_mac");
> +		return dev_err_probe(dev, PTR_ERR(bsp_priv->aclk_mac),
> +				"cannot get clock %s\n", "aclk_mac");

Can we turn this into a loop

struct {
	struct whatever **ptr;
	const char *name;
} clocks[] = {
	{ &bsp_priv->mac_clk_rx, "mac_clk_rx" },
	{ &bsp_priv->mac_clk_tx, "mac_clk_tx" },
	...
}

for (i=0; i < ARRAY_SIZE...) {
	*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);
}

?

Or alternatively inline the name of the clock into the error message?
Right now the %s format printing looks neither here nor there, and also
the continuation line is misaligned (should start right under "dev").


FWIW seems like it should be fine for net-next without the fixes tag.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ