mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
net: move the netdev_ops checks into a helper
register_netdevice() already does two ops sanity checks and is about to get a third. Collect them in netdev_check_ops(). The call stays after ndo_init() because drivers set features from there. Signed-off-by: Nicolai Buchwitz <nb@tipi-net.de> Link: https://patch.msgid.link/20261002094211.2350702-2-nb@tipi-net.de Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
a032c03527
commit
57f66330c6
|
|
@ -11451,6 +11451,24 @@ static void netdev_free_phy_link_topology(struct net_device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
static int netdev_check_ops(struct net_device *dev)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
|
||||
if (((dev->hw_features | dev->features) &
|
||||
NETIF_F_HW_VLAN_CTAG_FILTER) &&
|
||||
(!ops->ndo_vlan_rx_add_vid || !ops->ndo_vlan_rx_kill_vid)) {
|
||||
netdev_WARN(dev, "Buggy VLAN acceleration in driver!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (netdev_need_ops_lock(dev) && ops->ndo_set_rx_mode &&
|
||||
!ops->ndo_set_rx_mode_async)
|
||||
netdev_WARN(dev, "ops-locked drivers should use ndo_set_rx_mode_async\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* register_netdevice() - register a network device
|
||||
* @dev: device to register
|
||||
|
|
@ -11506,19 +11524,9 @@ int register_netdevice(struct net_device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
if (((dev->hw_features | dev->features) &
|
||||
NETIF_F_HW_VLAN_CTAG_FILTER) &&
|
||||
(!dev->netdev_ops->ndo_vlan_rx_add_vid ||
|
||||
!dev->netdev_ops->ndo_vlan_rx_kill_vid)) {
|
||||
netdev_WARN(dev, "Buggy VLAN acceleration in driver!\n");
|
||||
ret = -EINVAL;
|
||||
ret = netdev_check_ops(dev);
|
||||
if (ret)
|
||||
goto err_uninit;
|
||||
}
|
||||
|
||||
if (netdev_need_ops_lock(dev) &&
|
||||
dev->netdev_ops->ndo_set_rx_mode &&
|
||||
!dev->netdev_ops->ndo_set_rx_mode_async)
|
||||
netdev_WARN(dev, "ops-locked drivers should use ndo_set_rx_mode_async\n");
|
||||
|
||||
ret = netdev_do_alloc_pcpu_stats(dev);
|
||||
if (ret)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user