From patchwork Mon May 3 00:28:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 72 Return-Path: Received: from smtp139.mail.ukl.yahoo.com (smtp139.mail.ukl.yahoo.com [77.238.184.70]) by open-mesh.net (Postfix) with SMTP id 708BF154320 for ; Mon, 3 May 2010 02:34:22 +0200 (CEST) Received: (qmail 32244 invoked from network); 3 May 2010 00:34:21 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer:In-Reply-To:References; b=GyL5k8S5b3oCHVFn0sodz9MhcCiUfw/Gske2t4dmkHmX32sZWxLLY/pe1AAOTQKdmw/03z6kBcqpEMn16XObMAP8bFS3OVCQg9jVt8NVcJUHGLle2uBahp+2jesngDhkwHamWjG+7B0VDV3R0X2g4DlsDVzzpT1T864kGePHA7w= ; Received: from 115-81-67-196.taiwanmobile.net (lindner_marek@115.81.67.196 with plain) by smtp139.mail.ukl.yahoo.com with SMTP; 03 May 2010 00:34:19 +0000 GMT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: bJYMOwMVM1mFPkI8BTZT5.S_A_VPV6wUQWtN4bKvGPxLuOYpynJmPXX9MRKr_aCpwehIJX.94FhkpIhRSBCP5O52UqBkdOu02iZJEtMkLARQ4GpOTP3arTcXE4UrVNdMyGSG.s3I9nT7Iipq7YYg9eqklohFGyjYPDcU6MAqxxxT4qgkElf2vBZ3UKyK.oaGJhssvSfbGf1RAa0PnbflNUC_1eKtY1nUQJL1KdiLNhnmLzG01IF7MJWcYPLUmRQ2FLwgbcPGYkdyqQ-- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.net Date: Mon, 3 May 2010 08:28:38 +0800 Message-Id: <1272846518-2589-2-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.0 In-Reply-To: <201005030828.08856.lindner_marek@yahoo.de> References: <201005030828.08856.lindner_marek@yahoo.de> Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 2/2] batman-adv: adding sysfs compat X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 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: Mon, 03 May 2010 00:34:22 -0000 The linux sysfs layer changed with 2.6.25 which breaks batman-adv on older versions. This patch adds a compat layer for the affected function calls. Signed-off-by: Marek Lindner --- batman-adv-kernelland/bat_sysfs.c | 1 + batman-adv-kernelland/compat.h | 70 +++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 0 deletions(-) diff --git a/batman-adv-kernelland/bat_sysfs.c b/batman-adv-kernelland/bat_sysfs.c index c700359..7690368 100644 --- a/batman-adv-kernelland/bat_sysfs.c +++ b/batman-adv-kernelland/bat_sysfs.c @@ -27,6 +27,7 @@ #include "gateway_common.h" #include "gateway_client.h" #include "vis.h" +#include "compat.h" #define to_dev(obj) container_of(obj, struct device, kobj) diff --git a/batman-adv-kernelland/compat.h b/batman-adv-kernelland/compat.h index 4eaa128..9f21f5a 100644 --- a/batman-adv-kernelland/compat.h +++ b/batman-adv-kernelland/compat.h @@ -23,6 +23,7 @@ */ #include /* LINUX_VERSION_CODE */ +#include "bat_sysfs.h" /* struct bat_attribute */ #ifndef IPPROTO_UDP #define IPPROTO_UDP 17 @@ -80,6 +81,75 @@ static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len) ret; \ }) +#define transtable_local_read(kobj, attr, buff, off, count) \ + transtable_local_read(kobj, buff, off, count) +#define transtable_global_read(kobj, attr, buff, off, count) \ + transtable_global_read(kobj, buff, off, count) +#define originators_read(kobj, attr, buff, off, count) \ + originators_read(kobj, buff, off, count) +#define gateways_read(kobj, attr, buff, off, count) \ + gateways_read(kobj, buff, off, count) +#define vis_data_read(kobj, attr, buff, off, count) \ + vis_data_read(kobj, buff, off, count) + +#define to_battr(a) container_of(a, struct bat_attribute, attr) + +static inline ssize_t bat_wrapper_show(struct kobject *kobj, + struct attribute *attr, char *buf) +{ + struct bat_attribute *bat_attr = to_battr(attr); + + if (bat_attr->show) + return bat_attr->show(kobj, attr, buf); + + return -EIO; +} + +static inline ssize_t bat_wrapper_store(struct kobject *kobj, + struct attribute *attr, + const char *buf, size_t count) +{ + struct bat_attribute *bat_attr = to_battr(attr); + + if (bat_attr->store) + return bat_attr->store(kobj, attr, (char *)buf, count); + + return -EIO; +} + +static struct sysfs_ops bat_wrapper_ops = { + .show = bat_wrapper_show, + .store = bat_wrapper_store, +}; + +static struct kobj_type ktype_bat_wrapper = { + .sysfs_ops = &bat_wrapper_ops, +}; + +static inline struct kobject *kobject_create_and_add(const char *name, + struct kobject *parent) +{ + struct kobject *kobj; + int err; + + kobj = kzalloc(sizeof(*kobj), GFP_KERNEL); + if (!kobj) + return NULL; + + kobject_set_name(kobj, name); + kobj->ktype = &ktype_bat_wrapper; + kobj->kset = NULL; + kobj->parent = parent; + + err = kobject_register(kobj); + if (err) { + kobject_put(kobj); + return NULL; + } + + return kobj; +} + #endif /* < KERNEL_VERSION(2, 6, 25) */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)