]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
generic: 6.18: backport netdev_from_priv() helper
authorChristian Marangi <ansuelsmth@gmail.com>
Wed, 17 Jun 2026 17:44:29 +0000 (19:44 +0200)
committerChristian Marangi <ansuelsmth@gmail.com>
Fri, 19 Jun 2026 07:06:15 +0000 (09:06 +0200)
Backport netdev_from_priv() helper from upstream kernel to reduce patch
delta on backporting new driver and fixes from upstream kernel.

Link: https://github.com/openwrt/openwrt/pull/23849
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
target/linux/generic/backport-6.18/601-v7.1-net-add-netdev_from_priv-helper.patch [new file with mode: 0644]

diff --git a/target/linux/generic/backport-6.18/601-v7.1-net-add-netdev_from_priv-helper.patch b/target/linux/generic/backport-6.18/601-v7.1-net-add-netdev_from_priv-helper.patch
new file mode 100644 (file)
index 0000000..3586c3f
--- /dev/null
@@ -0,0 +1,35 @@
+From eb37011395f12138056a4d124159f1a8436662d3 Mon Sep 17 00:00:00 2001
+From: Qingfang Deng <dqfext@gmail.com>
+Date: Fri, 20 Mar 2026 15:56:03 +0800
+Subject: [PATCH] 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>
+---
+ include/linux/netdevice.h | 11 +++++++++++
+ 1 file changed, 11 insertions(+)
+
+--- a/include/linux/netdevice.h
++++ b/include/linux/netdevice.h
+@@ -2750,6 +2750,17 @@ static inline void *netdev_priv(const st
+       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.
+  */