All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] netdevice: add netdev_pub helper function
@ 2015-06-12 13:30 Jason A. Donenfeld
  2015-06-12 21:20 ` David Miller
  2016-10-05  0:52 ` [PATCH] " Jason A. Donenfeld
  0 siblings, 2 replies; 7+ messages in thread
From: Jason A. Donenfeld @ 2015-06-12 13:30 UTC (permalink / raw)
  To: David S. Miller, netdev, linux-kernel; +Cc: Jason A. Donenfeld

Being able to utilize this makes much code a lot simpler and cleaner.
It's a nice convenience function.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 include/linux/netdevice.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 05b9a69..f85be18 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1871,6 +1871,17 @@ static inline void *netdev_priv(const struct net_device *dev)
 	return (char *)dev + ALIGN(sizeof(struct net_device), NETDEV_ALIGN);
 }
 
+/**
+ * 	netdev_pub - access network device from private pointer
+ * 	@priv: private data pointer of network device
+ *
+ * Get network device from a network device private data pointer
+ */
+static inline struct net_device *netdev_pub(void *priv)
+{
+	return (struct net_device *)((char *)priv - ALIGN(sizeof(struct net_device), NETDEV_ALIGN));
+}
+
 /* Set the sysfs physical device reference for the network logical device
  * if set prior to registration will cause a symlink during initialization.
  */
-- 
2.4.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-07-10 11:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-12 13:30 [PATCH] netdevice: add netdev_pub helper function Jason A. Donenfeld
2015-06-12 21:20 ` David Miller
2017-07-10  3:19   ` [PATCH 1/2] " Jason A. Donenfeld
2017-07-10  3:19     ` [PATCH 2/2] ioc3-eth: use netdev_pub instead of handrolling alignment Jason A. Donenfeld
2017-07-10  8:04     ` [PATCH 1/2] netdevice: add netdev_pub helper function David Miller
2017-07-10 11:52       ` Jason A. Donenfeld
2016-10-05  0:52 ` [PATCH] " Jason A. Donenfeld

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.