From patchwork Sun Jun 5 08:20:19 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 1088 Return-Path: Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 48C5D1543F6 for ; Sun, 5 Jun 2011 10:20:23 +0200 (CEST) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@narfation.org; dkim-adsp=pass Received: from sven-desktop.home.narfation.org (i59F6CCC3.versanet.de [89.246.204.195]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id CA25E940F2; Sun, 5 Jun 2011 10:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=mail; t=1307262050; bh=HWCcMFOE3vrV8MXXIy4F0HA6clrZAogRUxkVIOR+01k=; h=From:To:Cc:Subject:Date:Message-Id; b=dmCCxP/jEDG1Jw3OnAt2dmUwaEsBbpcCGEtt990GPvmMyOOkMGyj4MorD8cVfB4GE LNp2RBV73T+wegIhVs8t+clI3DzP8Y2J4QU5otDSabPN/EVyNDPbORAvT6IVv/DVJ3 aRLUGEWyCQEUnbDcoup+RNEo0SsJsBVBAQ01dcew= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 5 Jun 2011 10:20:19 +0200 Message-Id: <1307262019-9147-1-git-send-email-sven@narfation.org> X-Mailer: git-send-email 1.7.5.3 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Rewrite debugfs kobj_to_* helpers as functions X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2011 08:20:23 -0000 CodingStyle "Chapter 12: Macros, Enums and RTL" highly recommends to use functions instead of macros were possible. This ensures type safety and prevents shadowing of other variables. Signed-off-by: Sven Eckelmann --- bat_sysfs.c | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) diff --git a/bat_sysfs.c b/bat_sysfs.c index df8a283..63738ec 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -28,9 +28,17 @@ #include "gateway_client.h" #include "vis.h" -#define to_dev(obj) container_of(obj, struct device, kobj) -#define kobj_to_netdev(obj) to_net_dev(to_dev(obj->parent)) -#define kobj_to_batpriv(obj) netdev_priv(kobj_to_netdev(obj)) +static struct net_device *kobj_to_netdev(struct kobject *obj) +{ + struct device *dev = container_of(obj->parent, struct device, kobj); + return to_net_dev(dev); +} + +static struct bat_priv *kobj_to_batpriv(struct kobject *obj) +{ + struct net_device *net_dev = kobj_to_netdev(obj); + return netdev_priv(net_dev); +} /* Use this, if you have customized show and store functions */ #define BAT_ATTR(_name, _mode, _show, _store) \