From patchwork Sat Mar 10 22:17:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1608 Return-Path: Received: from nm5.bullet.mail.ukl.yahoo.com (nm5.bullet.mail.ukl.yahoo.com [217.146.182.226]) by open-mesh.org (Postfix) with SMTP id D71DC60086C for ; Sat, 10 Mar 2012 23:18:55 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.180] by nm5.bullet.mail.ukl.yahoo.com with NNFMP; 10 Mar 2012 22:18:55 -0000 Received: from [217.146.183.108] by tm11.bullet.mail.ukl.yahoo.com with NNFMP; 10 Mar 2012 22:18:55 -0000 Received: from [127.0.0.1] by smtp109.mail.ukl.yahoo.com with NNFMP; 10 Mar 2012 22:18:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1331417935; bh=JHN9YIHH7XSvlxwGWkR727sWIf+hXlv/eb3hCUHvqjY=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=rXxY1M21uNXpSC9TjQcLY3jcagOjiaZ1m8CZ7DjoRk8TZWMymUnXIdxppD/XzVeRASvbGZLXl4Ue6yKnN6xIDPv1meCnQkrVOA4n5GTVMfxqX07grXkHoIkpWc2GNe7xAbO1c6JMaP+OXwnDkUcF2EDd5kz+Xow7nSlvgFZNluw= X-Yahoo-Newman-Id: 272513.57411.bm@smtp109.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: TBOR83oVM1kBqAuf_m8LQVkrpIWeacjVX_TMBIIz_tS0vTz I3eTkAZ6nIIx3TbQXFRFYpHskocj4LHnNWmk_CSktjEqGMcnnD.y.nsLOwX8 hS5yZHBKagnCZG606Dv6IFw4Xh9EwCTYhNQFRdC86zgnl71BBjtnnCNfUPSl z2OwBzMgU0bp3CfxqiZZnDa3FlsTk5iUVtX0VUkukRt9.V5w_umgM4.V5rYj 1V9klWjuvm4BI8BM5kQ3yuLrtL3hUeDoX9Zoa40bLevwlj9MbHPMIvmQ3faT rMsEi0.SWIEA0ps88h7hzrEbzKRwlSNVbDsXaNIR05.OVUvJktmvNGCF3O6I sjnOlciL8vO7h5PUwTb_WUvDgUGEMkT5aHngntJxPwhlmg.oiuUz2vrEWD2D 3BU2jtCqZ9fqD9CjFToLnN8a.5kCHnhroJ6x9 X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@119.236.110.45 with plain) by smtp109.mail.ukl.yahoo.com with SMTP; 10 Mar 2012 14:18:53 -0800 PST From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 11 Mar 2012 06:17:52 +0800 Message-Id: <1331417873-19354-4-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.9.1 In-Reply-To: <1331417873-19354-1-git-send-email-lindner_marek@yahoo.de> References: <1331417873-19354-1-git-send-email-lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 4/5] batman-adv: Adding hard_iface specific sysfs wrapper macros for UINT 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: Sat, 10 Mar 2012 22:18:56 -0000 From: Linus Luessing This allows us to easily add a sysfs parameter for an unsigned int later, which is not for a batman mesh interface (e.g. bat0), but for a common interface instead. It allows reading and writing an atomic_t in hard_iface (instead of bat_priv compared to the mesh variant). Developed by Linus during a 6 months trainee study period in Ascom (Switzerland) AG. Signed-off-by: Linus Luessing Signed-off-by: Marek Lindner --- bat_sysfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/bat_sysfs.c b/bat_sysfs.c index 91107fd..35c15e9 100644 --- a/bat_sysfs.c +++ b/bat_sysfs.c @@ -117,6 +117,49 @@ ssize_t show_##_name(struct kobject *kobj, \ static BAT_ATTR(_name, _mode, show_##_name, store_##_name) +#define BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ +ssize_t store_##_name(struct kobject *kobj, struct attribute *attr, \ + char *buff, size_t count) \ +{ \ + struct net_device *net_dev = kobj_to_netdev(kobj); \ + struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \ + ssize_t length; \ + \ + if (!hard_iface) \ + return 0; \ + \ + length = __store_uint_attr(buff, count, _min, _max, _post_func, \ + attr, &hard_iface->_name, net_dev); \ + \ + hardif_free_ref(hard_iface); \ + return length; \ +} + +#define BAT_ATTR_HIF_SHOW_UINT(_name) \ +ssize_t show_##_name(struct kobject *kobj, \ + struct attribute *attr, char *buff) \ +{ \ + struct net_device *net_dev = kobj_to_netdev(kobj); \ + struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev); \ + ssize_t length; \ + \ + if (!hard_iface) \ + return 0; \ + \ + length = sprintf(buff, "%i\n", atomic_read(&hard_iface->_name));\ + \ + hardif_free_ref(hard_iface); \ + return length; \ +} + +/* Use this, if you are going to set [name] in hard_iface to an + * unsigned integer value*/ +#define BAT_ATTR_HIF_UINT(_name, _mode, _min, _max, _post_func) \ + static BAT_ATTR_HIF_STORE_UINT(_name, _min, _max, _post_func) \ + static BAT_ATTR_HIF_SHOW_UINT(_name) \ + static BAT_ATTR(_name, _mode, show_##_name, store_##_name) + + static int store_bool_attr(char *buff, size_t count, struct net_device *net_dev, const char *attr_name, atomic_t *attr)