diff options
| author | Qingfang Deng <dqfext@gmail.com> | 2026-03-20 15:56:03 +0800 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-03-23 17:51:59 -0700 |
| commit | eb37011395f12138056a4d124159f1a8436662d3 (patch) | |
| tree | d9786e1de0de7504d5156e67571267b5bf7787eb /include/linux | |
| parent | 0e10381626546e3c77a11c7972d1264301abd733 (diff) | |
net: add netdev_from_priv() helper
Add a helper to get netdev from private data pointer, so drivers won't
have to store redundant netdev in priv.
Signed-off-by: Qingfang Deng <dqfext@gmail.com>
Link: https://patch.msgid.link/20260320075605.490832-1-dqfext@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netdevice.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 7ca01eb3f7d2..6882b41bb3e8 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2765,6 +2765,17 @@ static inline void *netdev_priv(const struct net_device *dev) return (void *)dev->priv; } +/** + * netdev_from_priv() - get network device from priv + * @priv: network device private data + * + * Returns: net_device to which @priv belongs + */ +static inline struct net_device *netdev_from_priv(const void *priv) +{ + return container_of(priv, struct net_device, priv); +} + /* Set the sysfs physical device reference for the network logical device * if set prior to registration will cause a symlink during initialization. */ |
