[1/2] batman-adv: Don't include bat_sysfs.h in compat.h
Commit Message
bat_sysfs.h is included in compat.h to provide bat_attribute which is
used in bat_wrapper_show and bat_wrapper_store. This could create a
include loop which prevents that functions or datastructures defined
elsewhere cannot be found in bat_sysfs.h when batman-adv gets compiled
as external module, but are available when it is used as in-kernel
module.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
compat.c | 29 +++++++++++++++++++++++++++++
compat.h | 26 ++++----------------------
2 files changed, 33 insertions(+), 22 deletions(-)
Comments
On Saturday 07 May 2011 21:48:03 Sven Eckelmann wrote:
> bat_sysfs.h is included in compat.h to provide bat_attribute which is
> used in bat_wrapper_show and bat_wrapper_store. This could create a
> include loop which prevents that functions or datastructures defined
> elsewhere cannot be found in bat_sysfs.h when batman-adv gets compiled
> as external module, but are available when it is used as in-kernel
> module.
Applied in revision 741fb5d.
Thanks,
Marek
@@ -1,4 +1,33 @@
#include <linux/version.h>
+#include "main.h"
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
+
+#include "bat_sysfs.h" /* struct bat_attribute */
+
+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;
+}
+
+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;
+}
+
+#endif /* < KERNEL_VERSION(2, 6, 25) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
@@ -26,7 +26,6 @@
#define _NET_BATMAN_ADV_COMPAT_H_
#include <linux/version.h> /* LINUX_VERSION_CODE */
-#include "bat_sysfs.h" /* struct bat_attribute */
#ifndef IPPROTO_UDP
#define IPPROTO_UDP 17
@@ -107,28 +106,11 @@ static inline int skb_cow_head(struct sk_buff *skb, unsigned int headroom)
#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);
+ssize_t bat_wrapper_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
- 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;
-}
+ssize_t bat_wrapper_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t count);
static struct sysfs_ops bat_wrapper_ops = {
.show = bat_wrapper_show,