* [PATCH net-next] net: add netdev_from_priv() helper
@ 2026-03-19 2:26 Qingfang Deng
2026-03-19 17:12 ` Andrew Lunn
2026-03-19 20:27 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Qingfang Deng @ 2026-03-19 2:26 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel
Cc: Alexander Lobakin, Breno Leitao, Przemek Kitszel, Kees Cook
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>
---
include/linux/netdevice.h | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index ae269a2e7f4d..dba96736202a 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2764,6 +2764,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
+ *
+ * Get network device from private data pointer
+ */
+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.
*/
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: add netdev_from_priv() helper
2026-03-19 2:26 [PATCH net-next] net: add netdev_from_priv() helper Qingfang Deng
@ 2026-03-19 17:12 ` Andrew Lunn
2026-03-19 20:27 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2026-03-19 17:12 UTC (permalink / raw)
To: Qingfang Deng
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel,
Alexander Lobakin, Breno Leitao, Przemek Kitszel, Kees Cook
On Thu, Mar 19, 2026 at 10:26:08AM +0800, Qingfang Deng wrote:
> Add a helper to get netdev from private data pointer, so drivers won't
> have to store redundant netdev in priv.
You always need to include a user when adding a new API.
Andrew
---
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: add netdev_from_priv() helper
2026-03-19 2:26 [PATCH net-next] net: add netdev_from_priv() helper Qingfang Deng
2026-03-19 17:12 ` Andrew Lunn
@ 2026-03-19 20:27 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-03-19 20:27 UTC (permalink / raw)
To: Qingfang Deng
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Simon Horman, netdev, linux-kernel, Alexander Lobakin,
Breno Leitao, Przemek Kitszel, Kees Cook
On Thu, 19 Mar 2026 10:26:08 +0800 Qingfang Deng wrote:
> +/**
> + * netdev_from_priv - get network device from priv
> + * @priv: network device private data
> + *
> + * Get network device from private data pointer
> + */
> +static inline struct net_device *netdev_from_priv(const void *priv)
> +{
> + return container_of(priv, struct net_device, priv);
When you repost this with a user please format the kdoc as:
+/**
+ * netdev_from_priv() - get network device from priv
+ * @priv: network device private data
+ *
+ * Returns: net_device to which @priv belongs
+ */
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-19 20:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-19 2:26 [PATCH net-next] net: add netdev_from_priv() helper Qingfang Deng
2026-03-19 17:12 ` Andrew Lunn
2026-03-19 20:27 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox