From: Luis R. Rodriguez Date: Wed, 8 Jul 2009 22:34:01 +0000 (-0700) Subject: Start port work for usage on 2.6.25. We get up to: X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=72d134f2b710aa0624637e228ffff98543fa5bc4;p=openwrt%2Fstaging%2Fblogic.git Start port work for usage on 2.6.25. We get up to: CC [M] /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.o /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c: In function ‘ieee80211_stop’: /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c:388: warning: statement with no effect /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c:394: warning: statement with no effect /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c: In function ‘ieee80211_if_add’: /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c:794: error: ‘struct net_device’ has no member named ‘needed_headroom’ /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c:801: error: ‘struct net_device’ has no member named ‘needed_tailroom’ make[3]: *** [/home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.o] Error 1 make[2]: *** [/home/mcgrof/devel/compat-wireless-2.6/net/mac80211] Error 2 make[1]: *** [_module_/home/mcgrof/devel/compat-wireless-2.6] Error 2 make[1]: Leaving directory `/usr/src/linux-headers-2.6.25-020625-generic' Signed-off-by: Luis R. Rodriguez --- diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index 7f4cf2d40de6..206e2f1b7e20 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -6,6 +6,12 @@ * 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 + * Copyright (c) 2006-2007 Greg Kroah-Hartman + * Copyright (c) 2006-2007 Novell Inc. */ #include @@ -13,6 +19,12 @@ /* All things not in 2.6.25 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) +#include +#include +#include +#include +#include + static void device_create_release(struct device *dev) { pr_debug("device: '%s': %s\n", dev->bus_id, __func__); @@ -77,6 +89,52 @@ error: } 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 diff --git a/compat/compat-2.6.26.h b/compat/compat-2.6.26.h index 297bcf90c80e..b8cc70b28306 100644 --- a/compat/compat-2.6.26.h +++ b/compat/compat-2.6.26.h @@ -11,6 +11,31 @@ #include #include +#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, diff --git a/compat/compat.diff b/compat/compat.diff index d83b521024cf..6498b8ce27ae 100644 --- a/compat/compat.diff +++ b/compat/compat.diff @@ -976,3 +976,20 @@ 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 diff --git a/config.mk b/config.mk index 447a7c0ba48e..505ab2571d7b 100644 --- a/config.mk +++ b/config.mk @@ -237,8 +237,13 @@ endif 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 @@ -286,9 +291,15 @@ CONFIG_RT73USB=m 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 @@ -296,15 +307,26 @@ ifneq ($(CONFIG_SPI_MASTER),) 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. @@ -347,11 +369,15 @@ CONFIG_SSB=m 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.