From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755377AbbFLNaf (ORCPT ); Fri, 12 Jun 2015 09:30:35 -0400 Received: from frisell.zx2c4.com ([192.95.5.64]:53248 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755250AbbFLNab (ORCPT ); Fri, 12 Jun 2015 09:30:31 -0400 From: "Jason A. Donenfeld" To: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH] netdevice: add netdev_pub helper function Date: Fri, 12 Jun 2015 15:30:29 +0200 Message-Id: <1434115829-22804-1-git-send-email-Jason@zx2c4.com> X-Mailer: git-send-email 2.4.2 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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