Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

can: peak_usb: convert to use ndo_hwtstamp callbacks

Convert driver to use ndo_hwtstamp_set()/ndo_hwtstamp_get() callbacks.
ndo_eth_ioctl handler does nothing after conversion - remove it.

Signed-off-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Reviewed-by: Vincent Mailhol <mailhol@kernel.org>
Link: https://patch.msgid.link/20251029231620.1135640-4-vadim.fedorenko@linux.dev
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Vadim Fedorenko and committed by
Marc Kleine-Budde
243449f9 336e2232

+16 -19
+16 -19
drivers/net/can/usb/peak_usb/pcan_usb_core.c
··· 784 784 return 0; 785 785 } 786 786 787 - static int peak_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) 787 + static int peak_hwtstamp_get(struct net_device *netdev, 788 + struct kernel_hwtstamp_config *config) 788 789 { 789 - struct hwtstamp_config hwts_cfg = { 0 }; 790 + config->tx_type = HWTSTAMP_TX_OFF; 791 + config->rx_filter = HWTSTAMP_FILTER_ALL; 790 792 791 - switch (cmd) { 792 - case SIOCSHWTSTAMP: /* set */ 793 - if (copy_from_user(&hwts_cfg, ifr->ifr_data, sizeof(hwts_cfg))) 794 - return -EFAULT; 795 - if (hwts_cfg.tx_type == HWTSTAMP_TX_OFF && 796 - hwts_cfg.rx_filter == HWTSTAMP_FILTER_ALL) 797 - return 0; 798 - return -ERANGE; 793 + return 0; 794 + } 799 795 800 - case SIOCGHWTSTAMP: /* get */ 801 - hwts_cfg.tx_type = HWTSTAMP_TX_OFF; 802 - hwts_cfg.rx_filter = HWTSTAMP_FILTER_ALL; 803 - if (copy_to_user(ifr->ifr_data, &hwts_cfg, sizeof(hwts_cfg))) 804 - return -EFAULT; 796 + static int peak_hwtstamp_set(struct net_device *netdev, 797 + struct kernel_hwtstamp_config *config, 798 + struct netlink_ext_ack *extack) 799 + { 800 + if (config->tx_type == HWTSTAMP_TX_OFF && 801 + config->rx_filter == HWTSTAMP_FILTER_ALL) 805 802 return 0; 806 803 807 - default: 808 - return -EOPNOTSUPP; 809 - } 804 + NL_SET_ERR_MSG_MOD(extack, "Only RX HWTSTAMP_FILTER_ALL is supported"); 805 + return -ERANGE; 810 806 } 811 807 812 808 static const struct net_device_ops peak_usb_netdev_ops = { 813 809 .ndo_open = peak_usb_ndo_open, 814 810 .ndo_stop = peak_usb_ndo_stop, 815 - .ndo_eth_ioctl = peak_eth_ioctl, 816 811 .ndo_start_xmit = peak_usb_ndo_start_xmit, 812 + .ndo_hwtstamp_get = peak_hwtstamp_get, 813 + .ndo_hwtstamp_set = peak_hwtstamp_set, 817 814 }; 818 815 819 816 /* CAN-USB devices generally handle 32-bit CAN channel IDs.