Commit 9c699a8f authored by Martyn Welch's avatar Martyn Welch Committed by Jakub Kicinski

net: enetc: Replace ifdef with IS_ENABLED

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 built-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.
Reviewed-by: default avatarVadim Fedorenko <vadim.fedorenko@linux.dev>
Signed-off-by: default avatarMartyn Welch <martyn.welch@collabora.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240912173742.484549-1-martyn.welch@collabora.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9297886f
...@@ -977,7 +977,6 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt) ...@@ -977,7 +977,6 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
return j; return j;
} }
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
static void enetc_get_rx_tstamp(struct net_device *ndev, static void enetc_get_rx_tstamp(struct net_device *ndev,
union enetc_rx_bd *rxbd, union enetc_rx_bd *rxbd,
struct sk_buff *skb) struct sk_buff *skb)
...@@ -1001,7 +1000,6 @@ static void enetc_get_rx_tstamp(struct net_device *ndev, ...@@ -1001,7 +1000,6 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
shhwtstamps->hwtstamp = ns_to_ktime(tstamp); shhwtstamps->hwtstamp = ns_to_ktime(tstamp);
} }
} }
#endif
static void enetc_get_offloads(struct enetc_bdr *rx_ring, static void enetc_get_offloads(struct enetc_bdr *rx_ring,
union enetc_rx_bd *rxbd, struct sk_buff *skb) union enetc_rx_bd *rxbd, struct sk_buff *skb)
...@@ -1041,10 +1039,9 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring, ...@@ -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)); __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) (priv->active_offloads & ENETC_F_RX_TSTAMP))
enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb); 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, /* This gets called during the non-XDP NAPI poll cycle as well as on XDP_PASS,
...@@ -2881,7 +2878,6 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features) ...@@ -2881,7 +2878,6 @@ void enetc_set_features(struct net_device *ndev, netdev_features_t features)
} }
EXPORT_SYMBOL_GPL(enetc_set_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 enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
{ {
struct enetc_ndev_priv *priv = netdev_priv(ndev); struct enetc_ndev_priv *priv = netdev_priv(ndev);
...@@ -2950,17 +2946,17 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr) ...@@ -2950,17 +2946,17 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ? return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-EFAULT : 0; -EFAULT : 0;
} }
#endif
int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
{ {
struct enetc_ndev_priv *priv = netdev_priv(ndev); 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) if (cmd == SIOCSHWTSTAMP)
return enetc_hwtstamp_set(ndev, rq); return enetc_hwtstamp_set(ndev, rq);
if (cmd == SIOCGHWTSTAMP) if (cmd == SIOCGHWTSTAMP)
return enetc_hwtstamp_get(ndev, rq); return enetc_hwtstamp_get(ndev, rq);
#endif }
if (!priv->phylink) if (!priv->phylink)
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
...@@ -184,10 +184,9 @@ static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i) ...@@ -184,10 +184,9 @@ static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i)
{ {
int hw_idx = i; int hw_idx = i;
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
if (rx_ring->ext_en)
hw_idx = 2 * i; hw_idx = 2 * i;
#endif
return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]); 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, ...@@ -199,10 +198,8 @@ static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
new_rxbd++; new_rxbd++;
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
if (rx_ring->ext_en)
new_rxbd++; new_rxbd++;
#endif
if (unlikely(++new_index == rx_ring->bd_count)) { if (unlikely(++new_index == rx_ring->bd_count)) {
new_rxbd = rx_ring->bd_base; new_rxbd = rx_ring->bd_base;
......
...@@ -851,7 +851,12 @@ static int enetc_get_ts_info(struct net_device *ndev, ...@@ -851,7 +851,12 @@ static int enetc_get_ts_info(struct net_device *ndev,
symbol_put(enetc_phc_index); symbol_put(enetc_phc_index);
} }
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK if (!IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE;
return 0;
}
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE | info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE | SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE | SOF_TIMESTAMPING_RAW_HARDWARE |
...@@ -860,11 +865,10 @@ static int enetc_get_ts_info(struct net_device *ndev, ...@@ -860,11 +865,10 @@ static int enetc_get_ts_info(struct net_device *ndev,
info->tx_types = (1 << HWTSTAMP_TX_OFF) | info->tx_types = (1 << HWTSTAMP_TX_OFF) |
(1 << HWTSTAMP_TX_ON) | (1 << HWTSTAMP_TX_ON) |
(1 << HWTSTAMP_TX_ONESTEP_SYNC); (1 << HWTSTAMP_TX_ONESTEP_SYNC);
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) | info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
(1 << HWTSTAMP_FILTER_ALL); (1 << HWTSTAMP_FILTER_ALL);
#else
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE;
#endif
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment