aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/drivers/net/can/dev/dev.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2025-10-31 13:12:20 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2025-10-31 13:12:20 +0100
commitcf89ae5bd71a6d581a11f33cb0591566e4038ea8 (patch)
tree221955733b2e8725ca81c2f9920f87a8084aed53 /drivers/net/can/dev/dev.c
parentMerge branch 'add-cn20k-nix-and-npa-contexts' (diff)
parentcan: peak_usb: convert to use ndo_hwtstamp callbacks (diff)
downloadwireguard-linux-cf89ae5bd71a6d581a11f33cb0591566e4038ea8.tar.xz
wireguard-linux-cf89ae5bd71a6d581a11f33cb0591566e4038ea8.zip
Merge patch series "convert can drivers to use ndo_hwtstamp callbacks"
Vadim Fedorenko <vadim.fedorenko@linux.dev> says: The patchset converts generic ioctl implementation into a pair of ndo_hwtstamp_get/ndo_hwtstamp_set generic callbacks and replaces callbacks in drivers. Link: https://patch.msgid.link/20251029231620.1135640-1-vadim.fedorenko@linux.dev Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/dev/dev.c')
-rw-r--r--drivers/net/can/dev/dev.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index 0cc3d008adb3..80e1ab18de87 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -379,34 +379,33 @@ int can_set_static_ctrlmode(struct net_device *dev, u32 static_mode)
}
EXPORT_SYMBOL_GPL(can_set_static_ctrlmode);
-/* generic implementation of netdev_ops::ndo_eth_ioctl for CAN devices
+/* generic implementation of netdev_ops::ndo_hwtstamp_get for CAN devices
* supporting hardware timestamps
*/
-int can_eth_ioctl_hwts(struct net_device *netdev, struct ifreq *ifr, int cmd)
+int can_hwtstamp_get(struct net_device *netdev,
+ struct kernel_hwtstamp_config *cfg)
{
- struct hwtstamp_config hwts_cfg = { 0 };
-
- switch (cmd) {
- case SIOCSHWTSTAMP: /* set */
- if (copy_from_user(&hwts_cfg, ifr->ifr_data, sizeof(hwts_cfg)))
- return -EFAULT;
- if (hwts_cfg.tx_type == HWTSTAMP_TX_ON &&
- hwts_cfg.rx_filter == HWTSTAMP_FILTER_ALL)
- return 0;
- return -ERANGE;
-
- case SIOCGHWTSTAMP: /* get */
- hwts_cfg.tx_type = HWTSTAMP_TX_ON;
- hwts_cfg.rx_filter = HWTSTAMP_FILTER_ALL;
- if (copy_to_user(ifr->ifr_data, &hwts_cfg, sizeof(hwts_cfg)))
- return -EFAULT;
- return 0;
+ cfg->tx_type = HWTSTAMP_TX_ON;
+ cfg->rx_filter = HWTSTAMP_FILTER_ALL;
- default:
- return -EOPNOTSUPP;
- }
+ return 0;
+}
+EXPORT_SYMBOL(can_hwtstamp_get);
+
+/* generic implementation of netdev_ops::ndo_hwtstamp_set for CAN devices
+ * supporting hardware timestamps
+ */
+int can_hwtstamp_set(struct net_device *netdev,
+ struct kernel_hwtstamp_config *cfg,
+ struct netlink_ext_ack *extack)
+{
+ if (cfg->tx_type == HWTSTAMP_TX_ON &&
+ cfg->rx_filter == HWTSTAMP_FILTER_ALL)
+ return 0;
+ NL_SET_ERR_MSG_MOD(extack, "Only TX on and RX all packets filter supported");
+ return -ERANGE;
}
-EXPORT_SYMBOL(can_eth_ioctl_hwts);
+EXPORT_SYMBOL(can_hwtstamp_set);
/* generic implementation of ethtool_ops::get_ts_info for CAN devices
* supporting hardware timestamps