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: <028169559976d3daecb754cddf4ca96928819538.camel@collabora.com>
Date: Wed, 04 Sep 2024 09:59:46 +0100
From: Martyn Welch <martyn.welch@...labora.com>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: Claudiu Manoil <claudiu.manoil@....com>, "David S. Miller"	
 <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski	
 <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, kernel@...labora.com, 
 Vadim Fedorenko <vadim.fedorenko@...ux.dev>, netdev@...r.kernel.org,
 linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] net: enetc: Replace ifdef with IS_ENABLED

On Wed, 2024-09-04 at 01:44 +0300, Vladimir Oltean wrote:
> Hi Martyn,
> 
> On Tue, Sep 03, 2024 at 03:04:18PM +0100, Martyn Welch wrote:
> > The enetc driver uses ifdefs when checking whether
> > CONFIG_FSL_ENETC_PTP_CLOCK is enabled in a number of places. This
> > works
> > if the driver is compiled in but fails if the driver is available
> > as a
> > kernel module. Replace the instances of ifdef with use of the
> > IS_ENABLED
> > macro, that will evaluate as true when this feature is built as a
> > kernel
> > module and follows the kernel's coding style.
> > 
> > Cc: Vadim Fedorenko <vadim.fedorenko@...ux.dev>
> > Signed-off-by: Martyn Welch <martyn.welch@...labora.com>
> > ---
> > 
> > Changes since v1:
> >   - Switched from preprocessor conditionals to normal C
> > conditionals.
> 
> Thanks for the patch. Can you please send a v3 rebased on the latest
> net-next, which now contains commit 3dd261ca7f84 ("net: enetc: Remove
> setting of RX software timestamp")? The change needs rethinking a
> bit.
> 

Sure no worries.

> Also, could you git format-patch --subject-prefix="PATCH net-next v3"
> next time? The networking subsystem tends to require that from patch
> submitters, to indicate the tree that the patch should be applied to.
> 
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> > b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> > index 5e684b23c5f5..a9402c1907bf 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> > @@ -853,24 +853,25 @@ static int enetc_get_ts_info(struct
> > net_device *ndev,
> >  		info->phc_index = -1;
> >  	}
> >  
> > -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> > -	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
> > -				SOF_TIMESTAMPING_RX_HARDWARE |
> > -				SOF_TIMESTAMPING_RAW_HARDWARE |
> > -				SOF_TIMESTAMPING_TX_SOFTWARE |
> > -				SOF_TIMESTAMPING_RX_SOFTWARE |
> > -				SOF_TIMESTAMPING_SOFTWARE;
> > -
> > -	info->tx_types = (1 << HWTSTAMP_TX_OFF) |
> > -			 (1 << HWTSTAMP_TX_ON) |
> > -			 (1 << HWTSTAMP_TX_ONESTEP_SYNC);
> > -	info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
> > -			   (1 << HWTSTAMP_FILTER_ALL);
> > -#else
> > -	info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE |
> > -				SOF_TIMESTAMPING_TX_SOFTWARE |
> > -				SOF_TIMESTAMPING_SOFTWARE;
> > -#endif
> > +	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
> > +		info->so_timestamping =
> > SOF_TIMESTAMPING_TX_HARDWARE |
> > +					SOF_TIMESTAMPING_RX_HARDWA
> > RE |
> > +					SOF_TIMESTAMPING_RAW_HARDW
> > ARE |
> > +					SOF_TIMESTAMPING_TX_SOFTWA
> > RE |
> > +					SOF_TIMESTAMPING_RX_SOFTWA
> > RE |
> > +					SOF_TIMESTAMPING_SOFTWARE;
> > +
> > +		info->tx_types = (1 << HWTSTAMP_TX_OFF) |
> > +				 (1 << HWTSTAMP_TX_ON) |
> > +				 (1 << HWTSTAMP_TX_ONESTEP_SYNC);
> > +		info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
> > +				   (1 << HWTSTAMP_FILTER_ALL);
> > +	} else {
> > +		info->so_timestamping =
> > SOF_TIMESTAMPING_RX_SOFTWARE |
> > +					SOF_TIMESTAMPING_TX_SOFTWA
> > RE |
> > +					SOF_TIMESTAMPING_SOFTWARE;
> > +	}
> > +
> 
> How about:
> 
> 	if (!IS_ENABLED()) {
> 		info->so_timestamping =
> SOF_TIMESTAMPING_TX_SOFTWARE;
> 		return 0;
> 	}
> 
> 	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
> 				SOF_TIMESTAMPING_RX_HARDWARE |
> 				SOF_TIMESTAMPING_RAW_HARDWARE |
> 				SOF_TIMESTAMPING_TX_SOFTWARE;
> 
> 	info->tx_types = (1 << HWTSTAMP_TX_OFF) |
> 			 (1 << HWTSTAMP_TX_ON) |
> 			 (1 << HWTSTAMP_TX_ONESTEP_SYNC);
> 	info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
> 			   (1 << HWTSTAMP_FILTER_ALL);
> 
> 	return 0;
> ?
> 
> I think I prefer the style with the early return.
> 

Works for me. I'd actually considered that whilst reworking from v1,
but decided to keep the flow close to what it currently was.

Martyn

> >  	return 0;
> >  }
> >  
> > -- 
> > 2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ