Skip to content

Commit ea8c8c8

Browse files
vladimirolteanNipaLocal
authored and
NipaLocal
committed
net: lan743x: convert to ndo_hwtstamp_set()
New timestamping API was introduced in commit 66f7223 ("net: add NDOs for configuring hardware timestamping") from kernel v6.6. It is time to convert the lan743x driver to the new API, so that timestamping configuration can be removed from the ndo_eth_ioctl() path completely. Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Gerhard Engleder <[email protected]> Reviewed-by: Vadim Fedorenko <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent cf2ef00 commit ea8c8c8

File tree

3 files changed

+12
-27
lines changed

3 files changed

+12
-27
lines changed

drivers/net/ethernet/microchip/lan743x_main.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,8 +3351,6 @@ static int lan743x_netdev_ioctl(struct net_device *netdev,
33513351

33523352
if (!netif_running(netdev))
33533353
return -EINVAL;
3354-
if (cmd == SIOCSHWTSTAMP)
3355-
return lan743x_ptp_ioctl(netdev, ifr, cmd);
33563354

33573355
return phylink_mii_ioctl(adapter->phylink, ifr, cmd);
33583356
}
@@ -3447,6 +3445,7 @@ static const struct net_device_ops lan743x_netdev_ops = {
34473445
.ndo_change_mtu = lan743x_netdev_change_mtu,
34483446
.ndo_get_stats64 = lan743x_netdev_get_stats64,
34493447
.ndo_set_mac_address = lan743x_netdev_set_mac_address,
3448+
.ndo_hwtstamp_set = lan743x_ptp_hwtstamp_set,
34503449
};
34513450

34523451
static void lan743x_hardware_cleanup(struct lan743x_adapter *adapter)

drivers/net/ethernet/microchip/lan743x_ptp.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,23 +1736,14 @@ void lan743x_ptp_tx_timestamp_skb(struct lan743x_adapter *adapter,
17361736
lan743x_ptp_tx_ts_complete(adapter);
17371737
}
17381738

1739-
int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
1739+
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
1740+
struct kernel_hwtstamp_config *config,
1741+
struct netlink_ext_ack *extack)
17401742
{
17411743
struct lan743x_adapter *adapter = netdev_priv(netdev);
1742-
struct hwtstamp_config config;
1743-
int ret = 0;
17441744
int index;
17451745

1746-
if (!ifr) {
1747-
netif_err(adapter, drv, adapter->netdev,
1748-
"SIOCSHWTSTAMP, ifr == NULL\n");
1749-
return -EINVAL;
1750-
}
1751-
1752-
if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
1753-
return -EFAULT;
1754-
1755-
switch (config.tx_type) {
1746+
switch (config->tx_type) {
17561747
case HWTSTAMP_TX_OFF:
17571748
for (index = 0; index < adapter->used_tx_channels;
17581749
index++)
@@ -1776,19 +1767,12 @@ int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
17761767
lan743x_ptp_set_sync_ts_insert(adapter, true);
17771768
break;
17781769
case HWTSTAMP_TX_ONESTEP_P2P:
1779-
ret = -ERANGE;
1780-
break;
1770+
return -ERANGE;
17811771
default:
17821772
netif_warn(adapter, drv, adapter->netdev,
1783-
" tx_type = %d, UNKNOWN\n", config.tx_type);
1784-
ret = -EINVAL;
1785-
break;
1773+
" tx_type = %d, UNKNOWN\n", config->tx_type);
1774+
return -EINVAL;
17861775
}
17871776

1788-
ret = lan743x_rx_set_tstamp_mode(adapter, config.rx_filter);
1789-
1790-
if (!ret)
1791-
return copy_to_user(ifr->ifr_data, &config,
1792-
sizeof(config)) ? -EFAULT : 0;
1793-
return ret;
1777+
return lan743x_rx_set_tstamp_mode(adapter, config->rx_filter);
17941778
}

drivers/net/ethernet/microchip/lan743x_ptp.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ void lan743x_ptp_close(struct lan743x_adapter *adapter);
5252
void lan743x_ptp_update_latency(struct lan743x_adapter *adapter,
5353
u32 link_speed);
5454

55-
int lan743x_ptp_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd);
55+
int lan743x_ptp_hwtstamp_set(struct net_device *netdev,
56+
struct kernel_hwtstamp_config *config,
57+
struct netlink_ext_ack *extack);
5658

5759
#define LAN743X_PTP_NUMBER_OF_TX_TIMESTAMPS (4)
5860

0 commit comments

Comments
 (0)