Skip to content

Commit 9c699a8

Browse files
mwelchukkuba-moo
authored andcommitted
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: Vadim Fedorenko <[email protected]> Signed-off-by: Martyn Welch <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9297886 commit 9c699a8

File tree

3 files changed

+20
-23
lines changed

3 files changed

+20
-23
lines changed

drivers/net/ethernet/freescale/enetc/enetc.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt)
977977
return j;
978978
}
979979

980-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
981980
static void enetc_get_rx_tstamp(struct net_device *ndev,
982981
union enetc_rx_bd *rxbd,
983982
struct sk_buff *skb)
@@ -1001,7 +1000,6 @@ static void enetc_get_rx_tstamp(struct net_device *ndev,
10011000
shhwtstamps->hwtstamp = ns_to_ktime(tstamp);
10021001
}
10031002
}
1004-
#endif
10051003

10061004
static void enetc_get_offloads(struct enetc_bdr *rx_ring,
10071005
union enetc_rx_bd *rxbd, struct sk_buff *skb)
@@ -1041,10 +1039,9 @@ static void enetc_get_offloads(struct enetc_bdr *rx_ring,
10411039
__vlan_hwaccel_put_tag(skb, tpid, le16_to_cpu(rxbd->r.vlan_opt));
10421040
}
10431041

1044-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
1045-
if (priv->active_offloads & ENETC_F_RX_TSTAMP)
1042+
if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) &&
1043+
(priv->active_offloads & ENETC_F_RX_TSTAMP))
10461044
enetc_get_rx_tstamp(rx_ring->ndev, rxbd, skb);
1047-
#endif
10481045
}
10491046

10501047
/* 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)
28812878
}
28822879
EXPORT_SYMBOL_GPL(enetc_set_features);
28832880

2884-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
28852881
static int enetc_hwtstamp_set(struct net_device *ndev, struct ifreq *ifr)
28862882
{
28872883
struct enetc_ndev_priv *priv = netdev_priv(ndev);
@@ -2950,17 +2946,17 @@ static int enetc_hwtstamp_get(struct net_device *ndev, struct ifreq *ifr)
29502946
return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
29512947
-EFAULT : 0;
29522948
}
2953-
#endif
29542949

29552950
int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
29562951
{
29572952
struct enetc_ndev_priv *priv = netdev_priv(ndev);
2958-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
2959-
if (cmd == SIOCSHWTSTAMP)
2960-
return enetc_hwtstamp_set(ndev, rq);
2961-
if (cmd == SIOCGHWTSTAMP)
2962-
return enetc_hwtstamp_get(ndev, rq);
2963-
#endif
2953+
2954+
if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
2955+
if (cmd == SIOCSHWTSTAMP)
2956+
return enetc_hwtstamp_set(ndev, rq);
2957+
if (cmd == SIOCGHWTSTAMP)
2958+
return enetc_hwtstamp_get(ndev, rq);
2959+
}
29642960

29652961
if (!priv->phylink)
29662962
return -EOPNOTSUPP;

drivers/net/ethernet/freescale/enetc/enetc.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,9 @@ static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i)
184184
{
185185
int hw_idx = i;
186186

187-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
188-
if (rx_ring->ext_en)
187+
if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
189188
hw_idx = 2 * i;
190-
#endif
189+
191190
return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]);
192191
}
193192

@@ -199,10 +198,8 @@ static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring,
199198

200199
new_rxbd++;
201200

202-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
203-
if (rx_ring->ext_en)
201+
if (IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK) && rx_ring->ext_en)
204202
new_rxbd++;
205-
#endif
206203

207204
if (unlikely(++new_index == rx_ring->bd_count)) {
208205
new_rxbd = rx_ring->bd_base;

drivers/net/ethernet/freescale/enetc/enetc_ethtool.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,12 @@ static int enetc_get_ts_info(struct net_device *ndev,
851851
symbol_put(enetc_phc_index);
852852
}
853853

854-
#ifdef CONFIG_FSL_ENETC_PTP_CLOCK
854+
if (!IS_ENABLED(CONFIG_FSL_ENETC_PTP_CLOCK)) {
855+
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE;
856+
857+
return 0;
858+
}
859+
855860
info->so_timestamping = SOF_TIMESTAMPING_TX_HARDWARE |
856861
SOF_TIMESTAMPING_RX_HARDWARE |
857862
SOF_TIMESTAMPING_RAW_HARDWARE |
@@ -860,11 +865,10 @@ static int enetc_get_ts_info(struct net_device *ndev,
860865
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
861866
(1 << HWTSTAMP_TX_ON) |
862867
(1 << HWTSTAMP_TX_ONESTEP_SYNC);
868+
863869
info->rx_filters = (1 << HWTSTAMP_FILTER_NONE) |
864870
(1 << HWTSTAMP_FILTER_ALL);
865-
#else
866-
info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE;
867-
#endif
871+
868872
return 0;
869873
}
870874

0 commit comments

Comments
 (0)