net: ethernet: Add net_eth_get_ptp_clock_by_index() function
This can be used to get the PTP clock if only network interface index is known. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
def6b14aa7
commit
11b06fab76
2 changed files with 34 additions and 0 deletions
|
@ -682,6 +682,26 @@ static inline struct device *net_eth_get_ptp_clock(struct net_if *iface)
|
|||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Return PTP clock that is tied to this ethernet network interface
|
||||
* index.
|
||||
*
|
||||
* @param index Network interface index
|
||||
*
|
||||
* @return Pointer to PTP clock if found, NULL if not found or if this
|
||||
* ethernet interface index does not support PTP.
|
||||
*/
|
||||
#if defined(CONFIG_PTP_CLOCK)
|
||||
struct device *net_eth_get_ptp_clock_by_index(int index);
|
||||
#else
|
||||
static inline struct device *net_eth_get_ptp_clock_by_index(int index)
|
||||
{
|
||||
ARG_UNUSED(index);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Return gPTP port number attached to this interface.
|
||||
*
|
||||
|
|
|
@ -987,6 +987,20 @@ struct device *net_eth_get_ptp_clock(struct net_if *iface)
|
|||
}
|
||||
#endif /* CONFIG_PTP_CLOCK */
|
||||
|
||||
#if defined(CONFIG_PTP_CLOCK)
|
||||
struct device *net_eth_get_ptp_clock_by_index(int index)
|
||||
{
|
||||
struct net_if *iface;
|
||||
|
||||
iface = net_if_get_by_index(index);
|
||||
if (!iface) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return net_eth_get_ptp_clock(iface);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NET_GPTP)
|
||||
int net_eth_get_ptp_port(struct net_if *iface)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue