netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: enetc: Replace ifdef with IS_ENABLED
@ 2024-08-30 17:50 Martyn Welch
  2024-09-02  9:21 ` Vadim Fedorenko
  2024-09-03 17:04 ` Simon Horman
  0 siblings, 2 replies; 4+ messages in thread
From: Martyn Welch @ 2024-08-30 17:50 UTC (permalink / raw)
  To: Claudiu Manoil, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: kernel, Martyn Welch, netdev, linux-kernel

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.

Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
---
 drivers/net/ethernet/freescale/enetc/enetc.c         | 8 ++++----
 drivers/net/ethernet/freescale/enetc/enetc.h         | 4 ++--
 drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
index 5c45f42232d3..276bc96dd1ef 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc.c
@@ -977,7 +977,7 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
 	return j;
 }
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
+#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 static void enetc_get_rx_tstamp(struct net_device *ndev,
 				union enetc_rx_bd *rxbd,
 				struct sk_buff *skb)
@@ -1041,7 +1041,7 @@ 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 	if (priv->active_offloads & ENETC_F_RX_TSTAMP)
 		enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
 #endif
@@ -2882,7 +2882,7 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features)
 }
 EXPORT_SYMBOL_GPL(enetc_set_features);
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
+#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
 {
 	struct enetc_ndev_priv *priv = netdev_priv(ndev);
@@ -2956,7 +2956,7 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 	if (cmd == SIOCSHWTSTAMP)
 		return enetc_hwtstamp_set(ndev, rq);
 	if (cmd == SIOCGHWTSTAMP)
diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index a9c2ff22431c..b527bb3d51b4 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -184,7 +184,7 @@ 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 	if (rx_ring->ext_en)
 		hw_idx = 2 * i;
 #endif
@@ -199,7 +199,7 @@ static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
 
 	new_rxbd++;
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
+#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 	if (rx_ring->ext_en)
 		new_rxbd++;
 #endif
diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
index 5e684b23c5f5..d6fdec2220ce 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
+++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
@@ -853,7 +853,7 @@ static int enetc_get_ts_info(struct net_device *ndev,
 		info->phc_index = -1;
 	}
 
-#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
+#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
 	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
 				SOF_TIMESTAMPING_RX_HARDWARE |
 				SOF_TIMESTAMPING_RAW_HARDWARE |
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: enetc: Replace ifdef with IS_ENABLED
  2024-08-30 17:50 [PATCH] net: enetc: Replace ifdef with IS_ENABLED Martyn Welch
@ 2024-09-02  9:21 ` Vadim Fedorenko
  2024-09-03 14:00   ` Martyn Welch
  2024-09-03 17:04 ` Simon Horman
  1 sibling, 1 reply; 4+ messages in thread
From: Vadim Fedorenko @ 2024-09-02  9:21 UTC (permalink / raw)
  To: Martyn Welch, Claudiu Manoil, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: kernel, netdev, linux-kernel

On 30/08/2024 18:50, 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.
> 
> Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
> ---
>   drivers/net/ethernet/freescale/enetc/enetc.c         | 8 ++++----
>   drivers/net/ethernet/freescale/enetc/enetc.h         | 4 ++--
>   drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 2 +-
>   3 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c
> index 5c45f42232d3..276bc96dd1ef 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> @@ -977,7 +977,7 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
>   	return j;
>   }
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   static void enetc_get_rx_tstamp(struct net_device *ndev,
>   				union enetc_rx_bd *rxbd,
>   				struct sk_buff *skb)
> @@ -1041,7 +1041,7 @@ 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   	if (priv->active_offloads & ENETC_F_RX_TSTAMP)
>   		enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);

I believe IS_ENABLED can go directly to if statement and there should be
no macros dances anymore. You can change these lines into
	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) &&
	    priv->active_offloads & ENETC_F_RX_TSTAMP)

The same applies to other spots in the patch.

>   #endif
> @@ -2882,7 +2882,7 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features)
>   }
>   EXPORT_SYMBOL_GPL(enetc_set_features);
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
>   {
>   	struct enetc_ndev_priv *priv = netdev_priv(ndev);
> @@ -2956,7 +2956,7 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
>   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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   	if (cmd == SIOCSHWTSTAMP)
>   		return enetc_hwtstamp_set(ndev, rq);
>   	if (cmd == SIOCGHWTSTAMP)
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
> index a9c2ff22431c..b527bb3d51b4 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.h
> @@ -184,7 +184,7 @@ 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   	if (rx_ring->ext_en)
>   		hw_idx = 2 * i;
>   #endif
> @@ -199,7 +199,7 @@ static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
>   
>   	new_rxbd++;
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   	if (rx_ring->ext_en)
>   		new_rxbd++;
>   #endif
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> index 5e684b23c5f5..d6fdec2220ce 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
> @@ -853,7 +853,7 @@ static int enetc_get_ts_info(struct net_device *ndev,
>   		info->phc_index = -1;
>   	}
>   
> -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
>   	info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
>   				SOF_TIMESTAMPING_RX_HARDWARE |
>   				SOF_TIMESTAMPING_RAW_HARDWARE |


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: enetc: Replace ifdef with IS_ENABLED
  2024-09-02  9:21 ` Vadim Fedorenko
@ 2024-09-03 14:00   ` Martyn Welch
  0 siblings, 0 replies; 4+ messages in thread
From: Martyn Welch @ 2024-09-03 14:00 UTC (permalink / raw)
  To: Vadim Fedorenko, Claudiu Manoil, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: kernel, netdev, linux-kernel

On Mon, 2024-09-02 at 10:21 +0100, Vadim Fedorenko wrote:
> On 30/08/2024 18:50, 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.
> > 
> > Signed-off-by: Martyn Welch <martyn.welch@collabora.com>
> > ---
> >   drivers/net/ethernet/freescale/enetc/enetc.c         | 8 ++++----
> >   drivers/net/ethernet/freescale/enetc/enetc.h         | 4 ++--
> >   drivers/net/ethernet/freescale/enetc/enetc_ethtool.c | 2 +-
> >   3 files changed, 7 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c
> > b/drivers/net/ethernet/freescale/enetc/enetc.c
> > index 5c45f42232d3..276bc96dd1ef 100644
> > --- a/drivers/net/ethernet/freescale/enetc/enetc.c
> > +++ b/drivers/net/ethernet/freescale/enetc/enetc.c
> > @@ -977,7 +977,7 @@ static int enetc_refill_rx_ring(struct
> > enetc_bdr *rx_ring, const int buff_cnt)
> >   	return j;
> >   }
> >   
> > -#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
> > +#if IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
> >   static void enetc_get_rx_tstamp(struct net_device *ndev,
> >   				union enetc_rx_bd *rxbd,
> >   				struct sk_buff *skb)
> > @@ -1041,7 +1041,7 @@ 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 IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)
> >   	if (priv->active_offloads & ENETC_F_RX_TSTAMP)
> >   		enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
> 
> I believe IS_ENABLED can go directly to if statement and there should
> be
> no macros dances anymore. You can change these lines into
> 	if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) &&
> 	    priv->active_offloads & ENETC_F_RX_TSTAMP)
> 
> The same applies to other spots in the patch.
> 

Thanks, v2 on the way....

Martyn

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] net: enetc: Replace ifdef with IS_ENABLED
  2024-08-30 17:50 [PATCH] net: enetc: Replace ifdef with IS_ENABLED Martyn Welch
  2024-09-02  9:21 ` Vadim Fedorenko
@ 2024-09-03 17:04 ` Simon Horman
  1 sibling, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-09-03 17:04 UTC (permalink / raw)
  To: Martyn Welch
  Cc: Claudiu Manoil, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, kernel, netdev, linux-kernel

On Fri, Aug 30, 2024 at 06:50:50PM +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

maybe: compiled -> built-in

> 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.
> 
> Signed-off-by: Martyn Welch <martyn.welch@collabora.com>

...

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-03 17:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-30 17:50 [PATCH] net: enetc: Replace ifdef with IS_ENABLED Martyn Welch
2024-09-02  9:21 ` Vadim Fedorenko
2024-09-03 14:00   ` Martyn Welch
2024-09-03 17:04 ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).