diff mbox series

[v2] net: enetc: Replace ifdef with IS_ENABLED

Message ID 20240903140420.2150707-1-martyn.welch@collabora.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [v2] net: enetc: Replace ifdef with IS_ENABLED | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 20 this patch: 20
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 141 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Martyn Welch Sept. 3, 2024, 2:04 p.m. UTC
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@linux.dev>
Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
---

Changes since v1:
  - Switched from preprocessor conditionals to normal C conditionals.

 drivers/net/ethernet/freescale/enetc/enetc.c  | 34 ++++++++---------
 drivers/net/ethernet/freescale/enetc/enetc.h  |  9 ++---
 .../ethernet/freescale/enetc/enetc_ethtool.c  | 37 ++++++++++---------
 3 files changed, 38 insertions(+), 42 deletions(-)

Comments

Vadim Fedorenko Sept. 3, 2024, 2:39 p.m. UTC | #1
On 03/09/2024 15:04, 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@linux.dev>
> Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
> ---
> 
> Changes since v1:
>    - Switched from preprocessor conditionals to normal C conditionals.
> 
>   drivers/net/ethernet/freescale/enetc/enetc.c  | 34 ++++++++---------
>   drivers/net/ethernet/freescale/enetc/enetc.h  |  9 ++---
>   .../ethernet/freescale/enetc/enetc_ethtool.c  | 37 ++++++++++---------
>   3 files changed, 38 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 5c45f42232d3..361464a5b6c4 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -977,10 +977,9 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
>   	return j;
>   }
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -static void enetc_get_rx_tstamp(struct net_device *ndev,
> -				union enetc_rx_bd *rxbd,
> -				struct sk_buff *skb)
> +static void __maybe_unused enetc_get_rx_tstamp(struct net_device *ndev,
> +					       union enetc_rx_bd *rxbd,
> +					       struct sk_buff *skb)
>   {
>   	struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
>   	struct enetc_ndev_priv *priv = netdev_priv(ndev);
> @@ -1001,7 +1000,6 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
>   		shhwtstamps->hwtstamp = ns_to_ktime(tstamp);
>   	}
>   }
> -#endif
>   
>   static void enetc_get_offloads(struct enetc_bdr *rx_ring,
>   			       union enetc_rx_bd *rxbd, struct sk_buff *skb)
> @@ -1041,10 +1039,9 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring,
>   		__vlan_hwaccel_put_tag(skb, tpid, le16_to_cpu(rxbd->r.vlan_opt));
>   	}
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -	if (priv->active_offloads & ENETC_F_RX_TSTAMP)
> +	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) &&
> +	    (priv->active_offloads & ENETC_F_RX_TSTAMP))
>   		enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
> -#endif
>   }
>   
>   /* This gets called during the non-XDP NAPI poll cycle as well as on XDP_PASS,
> @@ -2882,8 +2879,8 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features)
>   }
>   EXPORT_SYMBOL_GPL(enetc_set_features);
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
> +static int __maybe_unused enetc_hwtstamp_set(struct net_device *ndev,
> +					     struct ifreq *ifr)
>   {
>   	struct enetc_ndev_priv *priv = netdev_priv(ndev);
>   	int err, new_offloads = priv->active_offloads;
> @@ -2931,7 +2928,8 @@ static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
>   	       -EFAULT : 0;
>   }
>   
> -static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
> +static int __maybe_unused enetc_hwtstamp_get(struct net_device *ndev,
> +					     struct ifreq *ifr)
>   {
>   	struct enetc_ndev_priv *priv = netdev_priv(ndev);
>   	struct hwtstamp_config config;
> @@ -2951,17 +2949,17 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
>   	return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
>   	       -EFAULT : 0;
>   }
> -#endif
>   
>   int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
>   {
>   	struct enetc_ndev_priv *priv = netdev_priv(ndev);
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -	if (cmd == SIOCSHWTSTAMP)
> -		return enetc_hwtstamp_set(ndev, rq);
> -	if (cmd == SIOCGHWTSTAMP)
> -		return enetc_hwtstamp_get(ndev, rq);
> -#endif
> +
> +	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
> +		if (cmd == SIOCSHWTSTAMP)
> +			return enetc_hwtstamp_set(ndev, rq);
> +		if (cmd == SIOCGHWTSTAMP)
> +			return enetc_hwtstamp_get(ndev, rq);
> +	}
>   
>   	if (!priv->phylink)
>   		return -EOPNOTSUPP;
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
> index a9c2ff22431c..97524dfa234c 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.h
> @@ -184,10 +184,9 @@ static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i)
>   {
>   	int hw_idx = i;
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -	if (rx_ring->ext_en)
> +	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
>   		hw_idx = 2 * i;
> -#endif
> +
>   	return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]);
>   }
>   
> @@ -199,10 +198,8 @@ static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
>   
>   	new_rxbd++;
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> -	if (rx_ring->ext_en)
> +	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
>   		new_rxbd++;
> -#endif
>   
>   	if (unlikely(++new_index == rx_ring->bd_count)) {
>   		new_rxbd = rx_ring->bd_base;
> 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_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;
> +	}
> +
>   	return 0;
>   }
>   

LGTM! You still need ack/review from driver's maintainers, but:

Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Vladimir Oltean Sept. 3, 2024, 10:44 p.m. UTC | #2
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@linux.dev>
> Signed-off-by: Martyn Welch <martyn.welch@collabora.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.

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_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;
> +	}
> +

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.

>  	return 0;
>  }
>  
> -- 
> 2.45.2
Martyn Welch Sept. 4, 2024, 8:59 a.m. UTC | #3
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@linux.dev>
> > Signed-off-by: Martyn Welch <martyn.welch@collabora.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
diff mbox series

Patch

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 5c45f42232d3..361464a5b6c4 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -977,10 +977,9 @@  static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 	return j;
 }
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-static void enetc_get_rx_tstamp(struct net_device *ndev,
-				union enetc_rx_bd *rxbd,
-				struct sk_buff *skb)
+static void __maybe_unused enetc_get_rx_tstamp(struct net_device *ndev,
+					       union enetc_rx_bd *rxbd,
+					       struct sk_buff *skb)
 {
 	struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb);
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
@@ -1001,7 +1000,6 @@  static void enetc_get_rx_tstamp(struct net_device *ndev,
 		shhwtstamps->hwtstamp = ns_to_ktime(tstamp);
 	}
 }
-#endif
 
 static void enetc_get_offloads(struct enetc_bdr *rx_ring,
 			       union enetc_rx_bd *rxbd, struct sk_buff *skb)
@@ -1041,10 +1039,9 @@  static void enetc_get_offloads(struct enetc_bdr *rx_ring,
 		__vlan_hwaccel_put_tag(skb, tpid, le16_to_cpu(rxbd->r.vlan_opt));
 	}
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-	if (priv->active_offloads & ENETC_F_RX_TSTAMP)
+	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) &&
+	    (priv->active_offloads & ENETC_F_RX_TSTAMP))
 		enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
-#endif
 }
 
 /* This gets called during the non-XDP NAPI poll cycle as well as on XDP_PASS,
@@ -2882,8 +2879,8 @@  void enetc_set_features(struct net_device *ndev, netdev_features_t features)
 }
 EXPORT_SYMBOL_GPL(enetc_set_features);
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
+static int __maybe_unused enetc_hwtstamp_set(struct net_device *ndev,
+					     struct ifreq *ifr)
 {
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
 	int err, new_offloads = priv->active_offloads;
@@ -2931,7 +2928,8 @@  static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
 	       -EFAULT : 0;
 }
 
-static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
+static int __maybe_unused enetc_hwtstamp_get(struct net_device *ndev,
+					     struct ifreq *ifr)
 {
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
 	struct hwtstamp_config config;
@@ -2951,17 +2949,17 @@  static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
 	return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
 	       -EFAULT : 0;
 }
-#endif
 
 int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 {
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-	if (cmd == SIOCSHWTSTAMP)
-		return enetc_hwtstamp_set(ndev, rq);
-	if (cmd == SIOCGHWTSTAMP)
-		return enetc_hwtstamp_get(ndev, rq);
-#endif
+
+	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
+		if (cmd == SIOCSHWTSTAMP)
+			return enetc_hwtstamp_set(ndev, rq);
+		if (cmd == SIOCGHWTSTAMP)
+			return enetc_hwtstamp_get(ndev, rq);
+	}
 
 	if (!priv->phylink)
 		return -EOPNOTSUPP;
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index a9c2ff22431c..97524dfa234c 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -184,10 +184,9 @@  static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i)
 {
 	int hw_idx = i;
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-	if (rx_ring->ext_en)
+	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
 		hw_idx = 2 * i;
-#endif
+
 	return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]);
 }
 
@@ -199,10 +198,8 @@  static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
 
 	new_rxbd++;
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
-	if (rx_ring->ext_en)
+	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
 		new_rxbd++;
-#endif
 
 	if (unlikely(++new_index == rx_ring->bd_count)) {
 		new_rxbd = rx_ring->bd_base;
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_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;
+	}
+
 	return 0;
 }