Commit cf89ae5b authored by Marc Kleine-Budde's avatar Marc Kleine-Budde
Browse files

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: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parents ea7d0d60 243449f9
Loading
Loading
Loading
Loading
+22 −23
Original line number Diff line number Diff line
@@ -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;
	cfg->tx_type = HWTSTAMP_TX_ON;
	cfg->rx_filter = HWTSTAMP_FILTER_ALL;

	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;

	default:
		return -EOPNOTSUPP;
}
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
+2 −1
Original line number Diff line number Diff line
@@ -86,7 +86,8 @@ static const struct net_device_ops pci402_acc_netdev_ops = {
	.ndo_open = acc_open,
	.ndo_stop = acc_close,
	.ndo_start_xmit = acc_start_xmit,
	.ndo_eth_ioctl = can_eth_ioctl_hwts,
	.ndo_hwtstamp_get = can_hwtstamp_get,
	.ndo_hwtstamp_set = can_hwtstamp_set,
};

static const struct ethtool_ops pci402_acc_ethtool_ops = {
+2 −1
Original line number Diff line number Diff line
@@ -902,8 +902,9 @@ static void kvaser_pciefd_bec_poll_timer(struct timer_list *data)
static const struct net_device_ops kvaser_pciefd_netdev_ops = {
	.ndo_open = kvaser_pciefd_open,
	.ndo_stop = kvaser_pciefd_stop,
	.ndo_eth_ioctl = can_eth_ioctl_hwts,
	.ndo_start_xmit = kvaser_pciefd_start_xmit,
	.ndo_hwtstamp_get = can_hwtstamp_get,
	.ndo_hwtstamp_set = can_hwtstamp_set,
};

static int kvaser_pciefd_set_phys_id(struct net_device *netdev,
+16 −19
Original line number Diff line number Diff line
@@ -743,36 +743,33 @@ static netdev_tx_t peak_canfd_start_xmit(struct sk_buff *skb,
	return NETDEV_TX_OK;
}

static int peak_eth_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
static int peak_eth_hwtstamp_get(struct net_device *netdev,
				 struct kernel_hwtstamp_config *config)
{
	struct hwtstamp_config hwts_cfg = { 0 };
	config->tx_type = HWTSTAMP_TX_OFF;
	config->rx_filter = HWTSTAMP_FILTER_ALL;

	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_OFF &&
		    hwts_cfg.rx_filter == HWTSTAMP_FILTER_ALL)
	return 0;
		return -ERANGE;
}

	case SIOCGHWTSTAMP: /* get */
		hwts_cfg.tx_type = HWTSTAMP_TX_OFF;
		hwts_cfg.rx_filter = HWTSTAMP_FILTER_ALL;
		if (copy_to_user(ifr->ifr_data, &hwts_cfg, sizeof(hwts_cfg)))
			return -EFAULT;
static int peak_eth_hwtstamp_set(struct net_device *netdev,
				 struct kernel_hwtstamp_config *config,
				 struct netlink_ext_ack *extack)
{
	if (config->tx_type == HWTSTAMP_TX_OFF &&
	    config->rx_filter == HWTSTAMP_FILTER_ALL)
		return 0;

	default:
		return -EOPNOTSUPP;
	}
	NL_SET_ERR_MSG_MOD(extack, "Only RX HWTSTAMP_FILTER_ALL is supported");
	return -ERANGE;
}

static const struct net_device_ops peak_canfd_netdev_ops = {
	.ndo_open = peak_canfd_open,
	.ndo_stop = peak_canfd_close,
	.ndo_eth_ioctl = peak_eth_ioctl,
	.ndo_start_xmit = peak_canfd_start_xmit,
	.ndo_hwtstamp_get = peak_eth_hwtstamp_get,
	.ndo_hwtstamp_set = peak_eth_hwtstamp_set,
};

static int peak_get_ts_info(struct net_device *dev,
+2 −1
Original line number Diff line number Diff line
@@ -1714,7 +1714,8 @@ static const struct net_device_ops mcp251xfd_netdev_ops = {
	.ndo_open = mcp251xfd_open,
	.ndo_stop = mcp251xfd_stop,
	.ndo_start_xmit	= mcp251xfd_start_xmit,
	.ndo_eth_ioctl = can_eth_ioctl_hwts,
	.ndo_hwtstamp_get = can_hwtstamp_get,
	.ndo_hwtstamp_set = can_hwtstamp_set,
};

static void
Loading