]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: atlantic: convert to ndo_hwtstamp API
authorVadim Fedorenko <vadim.fedorenko@linux.dev>
Thu, 16 Oct 2025 15:25:12 +0000 (15:25 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Oct 2025 00:30:26 +0000 (17:30 -0700)
Convert driver to .ndo_hwtstamp_get()/.ndo_hwtstamp_set() callbacks.
.ndo_eth_ioctl() becomes empty so remove it. Also simplify code with no
functional changes.

Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20251016152515.3510991-5-vadim.fedorenko@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/aquantia/atlantic/aq_main.c
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
drivers/net/ethernet/aquantia/atlantic/aq_ptp.h

index b565189e591398be52ec549961ad1c4ff1ce5f91..4ef4fe64b8ac13e4afef8615a3e7486c40033aa0 100644 (file)
@@ -258,10 +258,15 @@ static void aq_ndev_set_multicast_settings(struct net_device *ndev)
        (void)aq_nic_set_multicast_list(aq_nic, ndev);
 }
 
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
-                                  struct hwtstamp_config *config)
+static int aq_ndev_hwtstamp_set(struct net_device *netdev,
+                               struct kernel_hwtstamp_config *config,
+                               struct netlink_ext_ack *extack)
 {
+       struct aq_nic_s *aq_nic = netdev_priv(netdev);
+
+       if (!IS_REACHABLE(CONFIG_PTP_1588_CLOCK) || !aq_nic->aq_ptp)
+               return -EOPNOTSUPP;
+
        switch (config->tx_type) {
        case HWTSTAMP_TX_OFF:
        case HWTSTAMP_TX_ON:
@@ -290,59 +295,17 @@ static int aq_ndev_config_hwtstamp(struct aq_nic_s *aq_nic,
 
        return aq_ptp_hwtstamp_config_set(aq_nic->aq_ptp, config);
 }
-#endif
-
-static int aq_ndev_hwtstamp_set(struct aq_nic_s *aq_nic, struct ifreq *ifr)
-{
-       struct hwtstamp_config config;
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-       int ret_val;
-#endif
-
-       if (!aq_nic->aq_ptp)
-               return -EOPNOTSUPP;
-
-       if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
-               return -EFAULT;
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-       ret_val = aq_ndev_config_hwtstamp(aq_nic, &config);
-       if (ret_val)
-               return ret_val;
-#endif
-
-       return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-              -EFAULT : 0;
-}
 
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-static int aq_ndev_hwtstamp_get(struct aq_nic_s *aq_nic, struct ifreq *ifr)
+static int aq_ndev_hwtstamp_get(struct net_device *netdev,
+                               struct kernel_hwtstamp_config *config)
 {
-       struct hwtstamp_config config;
+       struct aq_nic_s *aq_nic = netdev_priv(netdev);
 
        if (!aq_nic->aq_ptp)
                return -EOPNOTSUPP;
 
-       aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, &config);
-       return copy_to_user(ifr->ifr_data, &config, sizeof(config)) ?
-              -EFAULT : 0;
-}
-#endif
-
-static int aq_ndev_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
-{
-       struct aq_nic_s *aq_nic = netdev_priv(netdev);
-
-       switch (cmd) {
-       case SIOCSHWTSTAMP:
-               return aq_ndev_hwtstamp_set(aq_nic, ifr);
-
-#if IS_REACHABLE(CONFIG_PTP_1588_CLOCK)
-       case SIOCGHWTSTAMP:
-               return aq_ndev_hwtstamp_get(aq_nic, ifr);
-#endif
-       }
-
-       return -EOPNOTSUPP;
+       aq_ptp_hwtstamp_config_get(aq_nic->aq_ptp, config);
+       return 0;
 }
 
 static int aq_ndo_vlan_rx_add_vid(struct net_device *ndev, __be16 proto,
@@ -500,12 +463,13 @@ static const struct net_device_ops aq_ndev_ops = {
        .ndo_set_mac_address = aq_ndev_set_mac_address,
        .ndo_set_features = aq_ndev_set_features,
        .ndo_fix_features = aq_ndev_fix_features,
-       .ndo_eth_ioctl = aq_ndev_ioctl,
        .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid,
        .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid,
        .ndo_setup_tc = aq_ndo_setup_tc,
        .ndo_bpf = aq_xdp,
        .ndo_xdp_xmit = aq_xdp_xmit,
+       .ndo_hwtstamp_get = aq_ndev_hwtstamp_get,
+       .ndo_hwtstamp_set = aq_ndev_hwtstamp_set,
 };
 
 static int __init aq_ndev_init_module(void)
index 5acb3e16b5677b7826e488942ff6efb2c3cdf400..0fa0f891c0e03f236110b26ea6f20cc6e49cb8ad 100644 (file)
@@ -51,7 +51,7 @@ struct ptp_tx_timeout {
 
 struct aq_ptp_s {
        struct aq_nic_s *aq_nic;
-       struct hwtstamp_config hwtstamp_config;
+       struct kernel_hwtstamp_config hwtstamp_config;
        spinlock_t ptp_lock;
        spinlock_t ptp_ring_lock;
        struct ptp_clock *ptp_clock;
@@ -567,7 +567,7 @@ static void aq_ptp_rx_hwtstamp(struct aq_ptp_s *aq_ptp, struct skb_shared_hwtsta
 }
 
 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
-                               struct hwtstamp_config *config)
+                               struct kernel_hwtstamp_config *config)
 {
        *config = aq_ptp->hwtstamp_config;
 }
@@ -588,7 +588,7 @@ static void aq_ptp_prepare_filters(struct aq_ptp_s *aq_ptp)
 }
 
 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
-                              struct hwtstamp_config *config)
+                              struct kernel_hwtstamp_config *config)
 {
        struct aq_nic_s *aq_nic = aq_ptp->aq_nic;
        const struct aq_hw_ops *hw_ops;
index 210b723f22072cdbe09ca89111916346a7316803..5e643ec7cc06a521ad54c85a8ef0da0d592f5b58 100644 (file)
@@ -60,9 +60,9 @@ void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp);
 
 /* Must be to check available of PTP before call */
 void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
-                               struct hwtstamp_config *config);
+                               struct kernel_hwtstamp_config *config);
 int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
-                              struct hwtstamp_config *config);
+                              struct kernel_hwtstamp_config *config);
 
 /* Return either ring is belong to PTP or not*/
 bool aq_ptp_ring(struct aq_nic_s *aq_nic, struct aq_ring_s *ring);
@@ -130,9 +130,9 @@ static inline int aq_ptp_xmit(struct aq_nic_s *aq_nic, struct sk_buff *skb)
 
 static inline void aq_ptp_tx_hwtstamp(struct aq_nic_s *aq_nic, u64 timestamp) {}
 static inline void aq_ptp_hwtstamp_config_get(struct aq_ptp_s *aq_ptp,
-                                             struct hwtstamp_config *config) {}
+                                             struct kernel_hwtstamp_config *config) {}
 static inline int aq_ptp_hwtstamp_config_set(struct aq_ptp_s *aq_ptp,
-                                            struct hwtstamp_config *config)
+                                            struct kernel_hwtstamp_config *config)
 {
        return 0;
 }