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: <48c2a26c-b7ad-4449-921c-7dd65fd2909a@lunn.ch>
Date: Thu, 5 Sep 2024 15:17:29 +0200
From: Andrew Lunn <andrew@...n.ch>
To: MD Danish Anwar <danishanwar@...com>
Cc: saikrishnag@...vell.com, robh@...nel.org, jan.kiszka@...mens.com,
	dan.carpenter@...aro.org, hkallweit1@...il.com,
	diogo.ivo@...mens.com, kory.maincent@...tlin.com, pabeni@...hat.com,
	kuba@...nel.org, edumazet@...gle.com, davem@...emloft.net,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	linux-arm-kernel@...ts.infradead.org, srk@...com,
	Vignesh Raghavendra <vigneshr@...com>,
	Roger Quadros <rogerq@...nel.org>
Subject: Re: [PATCH net-next] net: ti: icssg-prueth: Make pa_stats optional

On Thu, Sep 05, 2024 at 03:47:39PM +0530, MD Danish Anwar wrote:
> pa_stats is optional in dt bindings, make it optional in driver as well.
> Currently if pa_stats syscon regmap is not found driver returns -ENODEV.
> Fix this by not returning an error in case pa_stats is not found and
> continue generating ethtool stats without pa_stats.
> 
> Fixes: 550ee90ac61c ("net: ti: icssg-prueth: Add support for PA Stats")
> Signed-off-by: MD Danish Anwar <danishanwar@...com>
> ---
> Cc: Jan Kiszka <jan.kiszka@...mens.com>
> NOTE: This fix is targetted to net-next because the concerned commit is not
> yet synced to net. So the issue isn't present in net.
> 
>  drivers/net/ethernet/ti/icssg/icssg_ethtool.c | 17 ++++++++++-----
>  drivers/net/ethernet/ti/icssg/icssg_prueth.c  |  4 +---
>  drivers/net/ethernet/ti/icssg/icssg_stats.c   | 21 ++++++++++++-------
>  3 files changed, 26 insertions(+), 16 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> index 5073ec195854..b85c03172f68 100644
> --- a/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> +++ b/drivers/net/ethernet/ti/icssg/icssg_ethtool.c
> @@ -68,9 +68,13 @@ static int emac_nway_reset(struct net_device *ndev)
>  
>  static int emac_get_sset_count(struct net_device *ndev, int stringset)
>  {
> +	struct prueth_emac *emac = netdev_priv(ndev);
>  	switch (stringset) {
>  	case ETH_SS_STATS:
> -		return ICSSG_NUM_ETHTOOL_STATS;
> +		if (IS_ERR(emac->prueth->pa_stats))

All these IS_ERR() are not so nice. What you often see is during
probe, if getting an optional resource returns an error, you replace
the error code with NULL. The code then becomes

> +		if (emac->prueth->pa_stats)
> +			return ICSSG_NUM_ETHTOOL_STATS;
> +		else
> +			return ICSSG_NUM_ETHTOOL_STATS - ICSSG_NUM_PA_STATS;

which looks nicer.

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ