* published by the Free Software Foundation.
*
* Compatibility file for Linux wireless for kernels 2.6.26.
+ *
+ * Copyright holders from ported work:
+ *
+ * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org>
+ * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com>
+ * Copyright (c) 2006-2007 Novell Inc.
*/
#include <net/compat.h>
/* All things not in 2.6.25 */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
+#include <linux/kobject.h>
+#include <linux/string.h>
+#include <linux/module.h>
+#include <linux/stat.h>
+#include <linux/slab.h>
+
static void device_create_release(struct device *dev)
{
pr_debug("device: '%s': %s\n", dev->bus_id, __func__);
}
EXPORT_SYMBOL_GPL(device_create_vargs);
+/**
+ * kobject_set_name_vargs - Set the name of an kobject
+ * @kobj: struct kobject to set the name of
+ * @fmt: format string used to build the name
+ * @vargs: vargs to format the string.
+ */
+static
+int kobject_set_name_vargs(struct kobject *kobj, const char *fmt,
+ va_list vargs)
+{
+ const char *old_name = kobj->name;
+ char *s;
+
+ if (kobj->name && !fmt)
+ return 0;
+
+ kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs);
+ if (!kobj->name)
+ return -ENOMEM;
+
+ /* ewww... some of these buggers have '/' in the name ... */
+ while ((s = strchr(kobj->name, '/')))
+ s[0] = '!';
+
+ kfree(old_name);
+ return 0;
+}
+
+/**
+ * dev_set_name - set a device name
+ * @dev: device
+ * @fmt: format string for the device's name
+ */
+int dev_set_name(struct device *dev, const char *fmt, ...)
+{
+ va_list vargs;
+ int err;
+
+ va_start(vargs, fmt);
+ err = kobject_set_name_vargs(&dev->kobj, fmt, vargs);
+ va_end(vargs);
+ return err;
+}
+EXPORT_SYMBOL_GPL(dev_set_name);
+
+
/**
* device_create_drvdata - creates a device and registers it with sysfs
* @class: pointer to the struct class that this device should be registered to
#include <linux/list.h>
#include <linux/kernel.h>
+#define USHORT_MAX ((u16)(~0U))
+#define SHORT_MAX ((s16)(USHORT_MAX>>1))
+#define SHORT_MIN (-SHORT_MAX - 1)
+
+extern int dev_set_name(struct device *dev, const char *name, ...)
+ __attribute__((format(printf, 2, 3)));
+
+/**
+ * clamp_t - return a value clamped to a given range using a given type
+ * @type: the type of variable to use
+ * @val: current value
+ * @min: minimum allowable value
+ * @max: maximum allowable value
+ *
+ * This macro does no typechecking and uses temporary variables of type
+ * 'type' to make all the comparisons.
+ */
+#define clamp_t(type, val, min, max) ({ \
+ type __val = (val); \
+ type __min = (min); \
+ type __max = (max); \
+ __val = __val < __min ? __min: __val; \
+ __val > __max ? __max: __val; })
+
+
/* from include/linux/device.h */
/* device_create_drvdata() is new */
extern struct device *device_create_drvdata(struct class *cls,
return -EOPNOTSUPP;
}
+--- a/drivers/net/wireless/libertas/defs.h 2009-07-08 14:04:29.692256519 -0700
++++ b/drivers/net/wireless/libertas/defs.h 2009-07-08 14:03:26.712279246 -0700
+@@ -16,6 +16,14 @@
+ #define DRV_NAME "libertas"
+ #endif
+
++/*
++ * Really nasty hack to avoid stuffing compat.diff with tons of ifdefs,
++ * we could add this to a compat header file but too lazy to check ml_priv
++ * is not used anywhere else
++ */
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26))
++#define ml_priv priv
++#endif
+
+ #define LBS_DEB_ENTER 0x00000001
+ #define LBS_DEB_LEAVE 0x00000002
ifneq ($(CONFIG_PCMCIA),)
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -le 26 && echo yes),yes)
+CONFIG_LIBERTAS=n
+CONFIG_LIBERTAS_CS=n
+else
CONFIG_LIBERTAS_CS=m
NEED_LIBERTAS=y
+endif
endif
## end of PCMCIA
NEED_RT2X00_FIRMWARE=y
endif
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -le 26 && echo yes),yes)
+CONFIG_LIBERTAS_THINFIRM_USB=n
+CONFIG_LIBERTAS_USB=n
+NEED_LIBERTAS=n
+else
CONFIG_LIBERTAS_THINFIRM_USB=m
CONFIG_LIBERTAS_USB=m
NEED_LIBERTAS=y
+endif
endif # end of USB driver list
CONFIG_WL1251=m
CONFIG_P54_SPI=m
+
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -le 26 && echo yes),yes)
+CONFIG_LIBERTAS_SPI=n
+NEED_LIBERTAS=n
+else
CONFIG_LIBERTAS_SPI=m
NEED_LIBERTAS=y
+endif
endif # end of SPI driver list
ifneq ($(CONFIG_MMC),)
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -le 26 && echo yes),yes)
+CONFIG_LIBERTAS_SDIO=n
+NEED_LIBERTAS=n
+else
CONFIG_LIBERTAS_SDIO=m
NEED_LIBERTAS=y
+endif
# Activate iwmc3200wifi support only on kernel >= 2.6.29.
# iwmc3200wifi uses new netdev_ops api no supported by old kernel.
CONFIG_SSB_SPROM=y
# CONFIG_SSB_DEBUG=y
+ifeq ($(shell test $(KERNEL_SUBLEVEL) -le 26 && echo yes),yes)
+CONFIG_LIBERTAS=n
+else
ifeq ($(NEED_LIBERTAS),y)
CONFIG_LIBERTAS_THINFIRM=m
CONFIG_LIBERTAS=m
# CONFIG_LIBERTAS_DEBUG=y
endif
+endif
# We need the backported rfkill module on kernel < 2.6.31.
# In more recent kernel versions use the in kernel rfkill module.