bool
# FIXME: REDHAT_6_0 also requires this
default y if !BACKPORT_KERNEL_2_6_33
+
+config BACKPORT_BUILD_AVERAGE
+ bool
+ default y if !AVERAGE && BACKPORT_AVERAGE
+
+config BACKPORT_AVERAGE
+ bool
compat-$(CPTCFG_BACKPORT_KERNEL_2_6_35) += compat-2.6.35.o
compat-$(CPTCFG_BACKPORT_KERNEL_2_6_36) += compat-2.6.36.o
compat-$(CPTCFG_BACKPORT_KERNEL_2_6_37) += compat-2.6.37.o
-compat-$(CPTCFG_BACKPORT_KERNEL_2_6_38) += compat-2.6.38.o
+compat-$(CPTCFG_BACKPORT_BUILD_AVERAGE) += average.o
compat-$(CPTCFG_BACKPORT_KERNEL_2_6_39) += compat-2.6.39.o kstrtox.o
compat-$(CPTCFG_BACKPORT_KERNEL_3_0) += compat-3.0.o
compat-$(CPTCFG_BACKPORT_KERNEL_3_1) += compat-3.1.o
--- /dev/null
+/*
+ * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Compatibility file for Linux wireless for kernels 2.6.38.
+ */
+
+#include <linux/average.h>
+#include <linux/module.h>
+#include <linux/bug.h>
+
+/**
+ * ewma_init() - Initialize EWMA parameters
+ * @avg: Average structure
+ * @factor: Factor to use for the scaled up internal value. The maximum value
+ * of averages can be ULONG_MAX/(factor*weight).
+ * @weight: Exponential weight, or decay rate. This defines how fast the
+ * influence of older values decreases. Has to be bigger than 1.
+ *
+ * Initialize the EWMA parameters for a given struct ewma @avg.
+ */
+void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight)
+{
+ WARN_ON(weight <= 1 || factor == 0);
+ avg->internal = 0;
+ avg->weight = weight;
+ avg->factor = factor;
+}
+EXPORT_SYMBOL_GPL(ewma_init);
+
+/**
+ * ewma_add() - Exponentially weighted moving average (EWMA)
+ * @avg: Average structure
+ * @val: Current value
+ *
+ * Add a sample to the average.
+ */
+struct ewma *ewma_add(struct ewma *avg, unsigned long val)
+{
+ avg->internal = avg->internal ?
+ (((avg->internal * (avg->weight - 1)) +
+ (val * avg->factor)) / avg->weight) :
+ (val * avg->factor);
+ return avg;
+}
+EXPORT_SYMBOL_GPL(ewma_add);
+
+++ /dev/null
-/*
- * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Compatibility file for Linux wireless for kernels 2.6.38.
- */
-
-#include <linux/compat.h>
-#include <linux/module.h>
-#include <linux/bug.h>
-
-/**
- * ewma_init() - Initialize EWMA parameters
- * @avg: Average structure
- * @factor: Factor to use for the scaled up internal value. The maximum value
- * of averages can be ULONG_MAX/(factor*weight).
- * @weight: Exponential weight, or decay rate. This defines how fast the
- * influence of older values decreases. Has to be bigger than 1.
- *
- * Initialize the EWMA parameters for a given struct ewma @avg.
- */
-void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight)
-{
- WARN_ON(weight <= 1 || factor == 0);
- avg->internal = 0;
- avg->weight = weight;
- avg->factor = factor;
-}
-EXPORT_SYMBOL_GPL(ewma_init);
-
-/**
- * ewma_add() - Exponentially weighted moving average (EWMA)
- * @avg: Average structure
- * @val: Current value
- *
- * Add a sample to the average.
- */
-struct ewma *ewma_add(struct ewma *avg, unsigned long val)
-{
- avg->internal = avg->internal ?
- (((avg->internal * (avg->weight - 1)) +
- (val * avg->factor)) / avg->weight) :
- (val * avg->factor);
- return avg;
-}
-EXPORT_SYMBOL_GPL(ewma_add);
-
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37))
#include_next <linux/average.h>
+#else
+/* Exponentially weighted moving average (EWMA) */
+
+/* For more documentation see lib/average.c */
+
+struct ewma {
+ unsigned long internal;
+ unsigned long factor;
+ unsigned long weight;
+};
+
+#define ewma_init LINUX_BACKPORT(ewma_init)
+extern void ewma_init(struct ewma *avg, unsigned long factor,
+ unsigned long weight);
+
+#define ewma_add LINUX_BACKPORT(ewma_add)
+extern struct ewma *ewma_add(struct ewma *avg, unsigned long val);
+
+#define ewma_read LINUX_BACKPORT(ewma_read)
+/**
+ * ewma_read() - Get average value
+ * @avg: Average structure
+ *
+ * Returns the average value held in @avg.
+ */
+static inline unsigned long ewma_read(const struct ewma *avg)
+{
+ return DIV_ROUND_CLOSEST(avg->internal, avg->factor);
+}
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) */
#define max_segs max_hw_segs
-/* Exponentially weighted moving average (EWMA) */
-
-/* For more documentation see lib/average.c */
-
-struct ewma {
- unsigned long internal;
- unsigned long factor;
- unsigned long weight;
-};
-
-#define ewma_init LINUX_BACKPORT(ewma_init)
-extern void ewma_init(struct ewma *avg, unsigned long factor,
- unsigned long weight);
-
-#define ewma_add LINUX_BACKPORT(ewma_add)
-extern struct ewma *ewma_add(struct ewma *avg, unsigned long val);
-
-#define ewma_read LINUX_BACKPORT(ewma_read)
-/**
- * ewma_read() - Get average value
- * @avg: Average structure
- *
- * Returns the average value held in @avg.
- */
-static inline unsigned long ewma_read(const struct ewma *avg)
-{
- return DIV_ROUND_CLOSEST(avg->internal, avg->factor);
-}
-
#define pr_warn pr_warning
#define create_freezable_workqueue create_freezeable_workqueue