@@ -5630,10 +5630,7 @@ static int tg3_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info)
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
- if (tp->ptp_clock)
- info->phc_index = ptp_clock_index(tp->ptp_clock);
- else
- info->phc_index = -1;
+ info->phc_index = ptp_clock_index(tp->ptp_clock);
info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON);
@@ -1240,10 +1240,7 @@ static int fec_enet_get_ts_info(struct net_device *ndev,
SOF_TIMESTAMPING_TX_HARDWARE |
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
- if (fep->ptp_clock)
- info->phc_index = ptp_clock_index(fep->ptp_clock);
- else
- info->phc_index = -1;
+ info->phc_index = ptp_clock_index(fep->ptp_clock);
info->tx_types = (1 << HWTSTAMP_TX_OFF) |
(1 << HWTSTAMP_TX_ON);
@@ -2224,8 +2224,7 @@ static int e1000e_get_ts_info(struct net_device *netdev,
(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) |
(1 << HWTSTAMP_FILTER_ALL));
- if (adapter->ptp_clock)
- info->phc_index = ptp_clock_index(adapter->ptp_clock);
+ info->phc_index = ptp_clock_index(adapter->ptp_clock);
return 0;
}
@@ -2293,10 +2293,7 @@ static int igb_get_ts_info(struct net_device *dev,
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
- if (adapter->ptp_clock)
- info->phc_index = ptp_clock_index(adapter->ptp_clock);
- else
- info->phc_index = -1;
+ info->phc_index = ptp_clock_index(adapter->ptp_clock);
info->tx_types =
(1 << HWTSTAMP_TX_OFF) |
@@ -2723,10 +2723,7 @@ static int ixgbe_get_ts_info(struct net_device *dev,
SOF_TIMESTAMPING_RX_HARDWARE |
SOF_TIMESTAMPING_RAW_HARDWARE;
- if (adapter->ptp_clock)
- info->phc_index = ptp_clock_index(adapter->ptp_clock);
- else
- info->phc_index = -1;
+ info->phc_index = ptp_clock_index(adapter->ptp_clock);
info->tx_types =
(1 << HWTSTAMP_TX_OFF) |
@@ -314,7 +314,7 @@ EXPORT_SYMBOL(ptp_clock_event);
int ptp_clock_index(struct ptp_clock *ptp)
{
- return ptp->index;
+ return ptp ? ptp->index : -1;
}
EXPORT_SYMBOL(ptp_clock_index);
@@ -148,12 +148,24 @@ struct ptp_clock_event {
extern void ptp_clock_event(struct ptp_clock *ptp,
struct ptp_clock_event *event);
+#if IS_ENABLED(CONFIG_PTP_1588_CLOCK)
+
/**
* ptp_clock_index() - obtain the device index of a PTP clock
+ * returns -1 if @ptp is NULL
*
* @ptp: The clock obtained from ptp_clock_register().
*/
extern int ptp_clock_index(struct ptp_clock *ptp);
+#else /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
+
+static inline int ptp_clock_index(struct ptp_clock *ptp)
+{
+ return -1;
+}
+
+#endif /* IS_ENABLED(CONFIG_PTP_1588_CLOCK) */
+
#endif
After this patch function ptp_clock_index(struct ptp_clock *ptp) returns -1 if ptp is NULL or CONFIG_PTP_1588_CLOCK disabled. Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org> Cc: Richard Cochran <richardcochran@gmail.com> --- drivers/net/ethernet/broadcom/tg3.c | 5 +---- drivers/net/ethernet/freescale/fec.c | 5 +---- drivers/net/ethernet/intel/e1000e/ethtool.c | 3 +-- drivers/net/ethernet/intel/igb/igb_ethtool.c | 5 +---- drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | 5 +---- drivers/ptp/ptp_clock.c | 2 +- include/linux/ptp_clock_kernel.h | 12 ++++++++++++ 7 files changed, 18 insertions(+), 19 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html