Author: marek Date: 2010-05-04 04:07:21 +0200 (Tue, 04 May 2010) New Revision: 1653
Modified: trunk/batman-adv-kernelland/bat_sysfs.c trunk/batman-adv-kernelland/compat.h Log: batman-adv: adding sysfs compat
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 lindner_marek@yahoo.de Signed-off-by: Simon Wunderlich siwu@hrz.tu-chemnitz.de
Modified: trunk/batman-adv-kernelland/bat_sysfs.c =================================================================== --- trunk/batman-adv-kernelland/bat_sysfs.c 2010-05-04 02:07:17 UTC (rev 1652) +++ trunk/batman-adv-kernelland/bat_sysfs.c 2010-05-04 02:07:21 UTC (rev 1653) @@ -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)
Modified: trunk/batman-adv-kernelland/compat.h =================================================================== --- trunk/batman-adv-kernelland/compat.h 2010-05-04 02:07:17 UTC (rev 1652) +++ trunk/batman-adv-kernelland/compat.h 2010-05-04 02:07:21 UTC (rev 1653) @@ -23,6 +23,7 @@ */
#include <linux/version.h> /* LINUX_VERSION_CODE */ +#include "bat_sysfs.h" /* struct bat_attribute */
#ifndef IPPROTO_UDP #define IPPROTO_UDP 17 @@ -52,6 +53,17 @@
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23)
+#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) + static inline int skb_clone_writable(struct sk_buff *skb, unsigned int len) { /* skb->hdr_len not available, just "not writable" to enforce a copy */ @@ -80,6 +92,64 @@ ret; \ })
+#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)