From fb12e8f8a57908c23cd8dd7f30511ebea8370924 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 20 Nov 2009 16:54:34 -0800 Subject: Add new kernel compatibilty module code Signed-off-by: Luis R. Rodriguez --- Makefile | 47 +++++++ compat-2.6.22.c | 18 +++ compat-2.6.22.h | 105 ++++++++++++++++ compat-2.6.23.c | 185 +++++++++++++++++++++++++++ compat-2.6.23.h | 136 ++++++++++++++++++++ compat-2.6.24.c | 237 +++++++++++++++++++++++++++++++++++ compat-2.6.24.h | 195 +++++++++++++++++++++++++++++ compat-2.6.25.c | 378 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ compat-2.6.25.h | 103 +++++++++++++++ compat-2.6.26.c | 69 +++++++++++ compat-2.6.26.h | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ compat-2.6.27.c | 207 +++++++++++++++++++++++++++++++ compat-2.6.27.h | 183 +++++++++++++++++++++++++++ compat-2.6.28.c | 278 +++++++++++++++++++++++++++++++++++++++++ compat-2.6.28.h | 182 +++++++++++++++++++++++++++ compat-2.6.29.c | 40 ++++++ compat-2.6.29.h | 54 ++++++++ compat-2.6.30.c | 18 +++ compat-2.6.30.h | 20 +++ compat-2.6.31.c | 64 ++++++++++ compat-2.6.31.h | 182 +++++++++++++++++++++++++++ compat-2.6.32.c | 124 +++++++++++++++++++ compat-2.6.32.h | 50 ++++++++ compat.h | 24 ++++ main.c | 18 +++ 25 files changed, 3294 insertions(+) create mode 100644 Makefile create mode 100644 compat-2.6.22.c create mode 100644 compat-2.6.22.h create mode 100644 compat-2.6.23.c create mode 100644 compat-2.6.23.h create mode 100644 compat-2.6.24.c create mode 100644 compat-2.6.24.h create mode 100644 compat-2.6.25.c create mode 100644 compat-2.6.25.h create mode 100644 compat-2.6.26.c create mode 100644 compat-2.6.26.h create mode 100644 compat-2.6.27.c create mode 100644 compat-2.6.27.h create mode 100644 compat-2.6.28.c create mode 100644 compat-2.6.28.h create mode 100644 compat-2.6.29.c create mode 100644 compat-2.6.29.h create mode 100644 compat-2.6.30.c create mode 100644 compat-2.6.30.h create mode 100644 compat-2.6.31.c create mode 100644 compat-2.6.31.h create mode 100644 compat-2.6.32.c create mode 100644 compat-2.6.32.h create mode 100644 compat.h create mode 100644 main.c diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..be95c6af --- /dev/null +++ b/Makefile @@ -0,0 +1,47 @@ +export KMODDIR?= updates/ +KMODDIR_ARG:= "INSTALL_MOD_DIR=$(KMODDIR)" +ifneq ($(origin $(KLIB)), undefined) +KMODPATH_ARG:= "INSTALL_MOD_PATH=$(KLIB)" +else +export KLIB:= /lib/modules/$(shell uname -r) +endif +export KLIB_BUILD ?= $(KLIB)/build + +export PWD := $(shell pwd) + +ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) +COMPAT_LATEST_VERSION = 32 +KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') +COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) +$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_$(ver)=y)) +endif + +obj-m += compat.o +#compat-objs := + +compat-y += main.o + +# Compat kernel compatibility code +compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o +compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o +compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o +compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o +compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o +compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o +compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o +compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o +compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o +compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o +compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o + +modules: + $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules +install: modules + $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \ + modules_install + depmod -a +clean: + $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean +all: modules + +clean-files := Module.symvers modules.order Module.markers diff --git a/compat-2.6.22.c b/compat-2.6.22.c new file mode 100644 index 00000000..b1ff1f3b --- /dev/null +++ b/compat-2.6.22.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.22. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) + +/* 2.6.22 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ + diff --git a/compat-2.6.22.h b/compat-2.6.22.h new file mode 100644 index 00000000..85cd9d56 --- /dev/null +++ b/compat-2.6.22.h @@ -0,0 +1,105 @@ +#ifndef LINUX_26_22_COMPAT_H +#define LINUX_26_22_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) + +#include +#include + +/* reuse ax25_ptr */ +#define ieee80211_ptr ax25_ptr + +#ifdef CONFIG_AX25 +#error Compat reuses the AX.25 pointer so that may not be enabled! +#endif + +static inline unsigned char *skb_mac_header(const struct sk_buff *skb) +{ + return skb->mac.raw; +} + +static inline void skb_set_mac_header(struct sk_buff *skb, int offset) +{ + skb->mac.raw = skb->data + offset; +} + +static inline void skb_reset_mac_header(struct sk_buff *skb) +{ + skb->mac.raw = skb->data; +} + +static inline void skb_reset_network_header(struct sk_buff *skb) +{ + skb->nh.raw = skb->data; +} + +static inline void skb_set_network_header(struct sk_buff *skb, int offset) +{ + skb->nh.raw = skb->data + offset; +} + +static inline void skb_set_transport_header(struct sk_buff *skb, int offset) +{ + skb->h.raw = skb->data + offset; +} + +static inline unsigned char *skb_transport_header(struct sk_buff *skb) +{ + return skb->h.raw; +} + +static inline unsigned char *skb_network_header(const struct sk_buff *skb) +{ + return skb->nh.raw; +} + +static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) +{ + return skb->tail; +} + +static inline struct iphdr *ip_hdr(const struct sk_buff *skb) +{ + return (struct iphdr *)skb_network_header(skb); +} + +static inline void skb_copy_from_linear_data(const struct sk_buff *skb, + void *to, + const unsigned int len) +{ + memcpy(to, skb->data, len); +} + +static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, + const int offset, void *to, + const unsigned int len) +{ + memcpy(to, skb->data + offset, len); +} + +#define __maybe_unused __attribute__((unused)) + +#define uninitialized_var(x) x = x + +/* This will lead to very weird behaviour... */ +#define NLA_BINARY NLA_STRING + +static inline int pci_set_mwi(struct pci_dev *dev) +{ + return -ENOSYS; +} + +static inline void pci_clear_mwi(struct pci_dev *dev) +{ +} + +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) */ + +#endif /* LINUX_26_22_COMPAT_H */ diff --git a/compat-2.6.23.c b/compat-2.6.23.c new file mode 100644 index 00000000..9845b82d --- /dev/null +++ b/compat-2.6.23.c @@ -0,0 +1,185 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.23. + */ + +#include + +/* All things not in 2.6.22 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) + +/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. + * Since da->da_synced is not part of 2.6.22 we need to take longer route when + * syncing */ + +/** + * dev_mc_sync - Synchronize device's multicast list to another device + * @to: destination device + * @from: source device + * + * Add newly added addresses to the destination device and release + * addresses that have no users left. The source device must be + * locked by netif_tx_lock_bh. + * + * This function is intended to be called from the dev->set_multicast_list + * function of layered software devices. + */ +int dev_mc_sync(struct net_device *to, struct net_device *from) +{ + struct dev_addr_list *da, *next, *da_to; + int err = 0; + + netif_tx_lock_bh(to); + da = from->mc_list; + while (da != NULL) { + int synced = 0; + next = da->next; + da_to = to->mc_list; + /* 2.6.22 does not have da->da_synced so lets take the long route */ + while (da_to != NULL) { + if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && + da->da_addrlen == da_to->da_addrlen) + synced = 1; + break; + } + if (!synced) { + err = __dev_addr_add(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + if (!err) + __dev_set_rx_mode(to); + netif_tx_unlock_bh(to); + + return err; +} +EXPORT_SYMBOL(dev_mc_sync); + + +/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. + * Since da->da_synced is not part of 2.6.22 we need to take longer route when + * unsyncing */ + +/** + * dev_mc_unsync - Remove synchronized addresses from the destination + * device + * @to: destination device + * @from: source device + * + * Remove all addresses that were added to the destination device by + * dev_mc_sync(). This function is intended to be called from the + * dev->stop function of layered software devices. + */ +void dev_mc_unsync(struct net_device *to, struct net_device *from) +{ + struct dev_addr_list *da, *next, *da_to; + + netif_tx_lock_bh(from); + netif_tx_lock_bh(to); + + da = from->mc_list; + while (da != NULL) { + bool synced = false; + next = da->next; + da_to = to->mc_list; + /* 2.6.22 does not have da->da_synced so lets take the long route */ + while (da_to != NULL) { + if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && + da->da_addrlen == da_to->da_addrlen) + synced = true; + break; + } + if (!synced) { + da = next; + continue; + } + __dev_addr_delete(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen, 0); + da = next; + } + __dev_set_rx_mode(to); + + netif_tx_unlock_bh(to); + netif_tx_unlock_bh(from); +} +EXPORT_SYMBOL(dev_mc_unsync); + +/* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on + * 2.6.22 so ignore that. */ + +/* + * Upload unicast and multicast address lists to device and + * configure RX filtering. When the device doesn't support unicast + * filtering it is put in promiscous mode while unicast addresses + * are present. + */ +void __dev_set_rx_mode(struct net_device *dev) +{ + /* dev_open will call this function so the list will stay sane. */ + if (!(dev->flags&IFF_UP)) + return; + + if (!netif_device_present(dev)) + return; + +/* This needs to be ported to 2.6.22 framework */ +#if 0 + /* Unicast addresses changes may only happen under the rtnl, + * therefore calling __dev_set_promiscuity here is safe. + */ + if (dev->uc_count > 0 && !dev->uc_promisc) { + __dev_set_promiscuity(dev, 1); + dev->uc_promisc = 1; + } else if (dev->uc_count == 0 && dev->uc_promisc) { + __dev_set_promiscuity(dev, -1); + dev->uc_promisc = 0; + } +#endif + + if (dev->set_multicast_list) + dev->set_multicast_list(dev); +} + +#ifndef HAVE_PCI_SET_MWI +int pci_try_set_mwi(struct pci_dev *dev) +{ + return 0; +} +EXPORT_SYMBOL(pci_try_set_mwi); +#else + +/** + * pci_try_set_mwi - enables memory-write-invalidate PCI transaction + * @dev: the PCI device for which MWI is enabled + * + * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND. + * Callers are not required to check the return value. + * + * RETURNS: An appropriate -ERRNO error value on error, or zero for success. + */ +int pci_try_set_mwi(struct pci_dev *dev) +{ + int rc = pci_set_mwi(dev); + return rc; +} +EXPORT_SYMBOL(pci_try_set_mwi); +#endif + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ + diff --git a/compat-2.6.23.h b/compat-2.6.23.h new file mode 100644 index 00000000..5eb6dbf2 --- /dev/null +++ b/compat-2.6.23.h @@ -0,0 +1,136 @@ +#ifndef LINUX_26_23_COMPAT_H +#define LINUX_26_23_COMPAT_H + +#include +#include + +/* Compat work for < 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) + +#include +#include +#include +#include + +/* + * Tell gcc if a function is cold. The compiler will assume any path + * directly leading to the call is unlikely. + */ + +#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* Mark functions as cold. gcc will assume any path leading to a call + * to them will be unlikely. This means a lot of manual unlikely()s + * are unnecessary now for any paths leading to the usual suspects + * like BUG(), printk(), panic() etc. [but let's keep them for now for + * older compilers] + * + * Early snapshots of gcc 4.3 don't support this and we can't detect this + * in the preprocessor, but we can live with this because they're unreleased. + * Maketime probing would be overkill here. + * + * gcc also has a __attribute__((__hot__)) to move hot functions into + * a special section, but I don't see any sense in this right now in + * the kernel context */ +#define __cold __attribute__((__cold__)) +#endif /* gcc 4.3 check */ + +#ifndef __cold +#define __cold +#endif + +/* Added as of 2.6.23 in include/linux/netdevice.h */ +#define alloc_netdev_mq(sizeof_priv, name, setup, queue) \ + alloc_netdev(sizeof_priv, name, setup) +#define NETIF_F_MULTI_QUEUE 16384 + +/* Added as of 2.6.23 on include/linux/netdevice.h */ +static inline int netif_is_multiqueue(const struct net_device *dev) +{ + return (!!(NETIF_F_MULTI_QUEUE & dev->features)); +} + +/* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */ +static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) +{ + struct tcf_proto *tp; + + while ((tp = *fl) != NULL) { + *fl = tp->next; + tp->ops->destroy(tp); + module_put(tp->ops->owner); + kfree(tp); + } +} + +/* dev_mc_list was replaced with dev_addr_list as of 2.6.23, + * only new member added is da_synced. */ +#define dev_addr_list dev_mc_list +#define da_addr dmi_addr +#define da_addrlen dmi_addrlen +#define da_users dmi_users +#define da_gusers dmi_gusers + +/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and + * dev_set_promiscuity() became a wrapper. */ +#define __dev_set_promiscuity dev_set_promiscuity + +/* Our own 2.6.22 port on compat.c */ +extern void dev_mc_unsync(struct net_device *to, struct net_device *from); +extern int dev_mc_sync(struct net_device *to, struct net_device *from); + +/* Our own 2.6.22 port on compat.c */ +extern void __dev_set_rx_mode(struct net_device *dev); + +/* Simple to add this */ +extern int cancel_delayed_work_sync(struct delayed_work *work); + +#define cancel_delayed_work_sync cancel_rearming_delayed_work + +#define debugfs_rename(a, b, c, d) 1 + +/* nl80211 requires multicast group support which is new and added on + * 2.6.23. We can't add support for it for older kernels to support it + * genl_family structure was changed. Lets just let through the + * genl_register_mc_group call. This means no multicast group suppport */ + +#define genl_register_mc_group(a, b) 0 + +/** + * struct genl_multicast_group - generic netlink multicast group + * @name: name of the multicast group, names are per-family + * @id: multicast group ID, assigned by the core, to use with + * genlmsg_multicast(). + * @list: list entry for linking + * @family: pointer to family, need not be set before registering + */ +struct genl_multicast_group +{ + struct genl_family *family; /* private */ + struct list_head list; /* private */ + char name[GENL_NAMSIZ]; + u32 id; +}; + + +/* Added as of 2.6.23 */ +int pci_try_set_mwi(struct pci_dev *dev); + +/* Added as of 2.6.23 */ +#ifdef CONFIG_PM_SLEEP +/* + * Tell the freezer that the current task should be frozen by it + */ +static inline void set_freezable(void) +{ + current->flags &= ~PF_NOFREEZE; +} + +#else +static inline void set_freezable(void) {} +#endif /* CONFIG_PM_SLEEP */ + +#else +#define tcf_destroy_chain_compat tcf_destroy_chain +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ + +#endif /* LINUX_26_23_COMPAT_H */ diff --git a/compat-2.6.24.c b/compat-2.6.24.c new file mode 100644 index 00000000..977eb45e --- /dev/null +++ b/compat-2.6.24.c @@ -0,0 +1,237 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.24. + */ + +#include + +/* All things not in 2.6.22 and 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + +/* Part of net/ethernet/eth.c as of 2.6.24 */ +char *print_mac(char *buf, const u8 *addr) +{ + sprintf(buf, MAC_FMT, + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); + return buf; +} +EXPORT_SYMBOL(print_mac); + +/* On net/core/dev.c as of 2.6.24 */ +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} + +/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but + * might as well add it */ +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kmalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} + +/* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header_cache_update - update cache entry + * @hh: destination cache entry + * @dev: network device + * @haddr: new hardware address + * + * Called by Address Resolution module to notify changes in address. + */ +void eth_header_cache_update(struct hh_cache *hh, + struct net_device *dev, + unsigned char *haddr) +{ + memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), + haddr, ETH_ALEN); +} +EXPORT_SYMBOL(eth_header_cache_update); + +/* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header_cache - fill cache entry from neighbour + * @neigh: source neighbour + * @hh: destination cache entry + * Create an Ethernet header template from the neighbour. + */ +int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) +{ + __be16 type = hh->hh_type; + struct ethhdr *eth; + const struct net_device *dev = neigh->dev; + + eth = (struct ethhdr *) + (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); + + if (type == htons(ETH_P_802_3)) + return -1; + + eth->h_proto = type; + memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); + memcpy(eth->h_dest, neigh->ha, ETH_ALEN); + hh->hh_len = ETH_HLEN; + return 0; +} +EXPORT_SYMBOL(eth_header_cache); + +/* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header - create the Ethernet header + * @skb: buffer to alter + * @dev: source device + * @type: Ethernet type field + * @daddr: destination address (NULL leave destination address) + * @saddr: source address (NULL use device source address) + * @len: packet length (<= skb->len) + * + * + * Set the protocol type. For a packet of type ETH_P_802_3 we put the length + * in here instead. It is up to the 802.2 layer to carry protocol information. + */ +int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, + void *daddr, void *saddr, unsigned len) +{ + struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); + + if (type != ETH_P_802_3) + eth->h_proto = htons(type); + else + eth->h_proto = htons(len); + + /* + * Set the source hardware address. + */ + + if (!saddr) + saddr = dev->dev_addr; + memcpy(eth->h_source, saddr, dev->addr_len); + + if (daddr) { + memcpy(eth->h_dest, daddr, dev->addr_len); + return ETH_HLEN; + } + + /* + * Anyway, the loopback-device should never use this function... + */ + + if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) { + memset(eth->h_dest, 0, dev->addr_len); + return ETH_HLEN; + } + + return -ETH_HLEN; +} + +EXPORT_SYMBOL(eth_header); + +/* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_rebuild_header- rebuild the Ethernet MAC header. + * @skb: socket buffer to update + * + * This is called after an ARP or IPV6 ndisc it's resolution on this + * sk_buff. We now let protocol (ARP) fill in the other fields. + * + * This routine CANNOT use cached dst->neigh! + * Really, it is used only when dst->neigh is wrong. + */ +int eth_rebuild_header(struct sk_buff *skb) +{ + struct ethhdr *eth = (struct ethhdr *)skb->data; + struct net_device *dev = skb->dev; + + switch (eth->h_proto) { +#ifdef CONFIG_INET + case __constant_htons(ETH_P_IP): + return arp_find(eth->h_dest, skb); +#endif + default: + printk(KERN_DEBUG + "%s: unable to resolve type %X addresses.\n", + dev->name, (int)eth->h_proto); + + memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); + break; + } + + return 0; +} +EXPORT_SYMBOL(eth_rebuild_header); + +/* 2.6.24 will introduce struct pci_dev is_pcie bit. To help + * with the compatibility code (compat.diff) being smaller, we provide a helper + * so in cases where that will be used we can simply slap ifdefs with this + * routine. Use compat_ prefex to not pollute namespace. */ +int compat_is_pcie(struct pci_dev *pdev) +{ + int cap; + cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + return cap ? 1 : 0; +} +EXPORT_SYMBOL(compat_is_pcie); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) */ + diff --git a/compat-2.6.24.h b/compat-2.6.24.h new file mode 100644 index 00000000..d8f7c2ca --- /dev/null +++ b/compat-2.6.24.h @@ -0,0 +1,195 @@ +#ifndef LINUX_26_24_COMPAT_H +#define LINUX_26_24_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + +/* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ +typedef unsigned long uintptr_t; + +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */ +/* Added as of 2.6.24 in include/linux/skbuff.h. + * + * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE + * this helper was not added until 2.6.24. This implementation + * is exactly as it is on newer kernels. + * + * For older kernels we use the an internal mac80211 hack. + * For details see changes to include/net/mac80211.h through + * compat.diff and compat/mq_compat.h */ +static inline u16 skb_get_queue_mapping(struct sk_buff *skb) +{ +#ifdef CONFIG_NETDEVICES_MULTIQUEUE + return skb->queue_mapping; +#else + return 0; +#endif +} +#endif /* Local 2.6.23 check */ + +/* On older kernels we handle this a bit differently, so we yield to that + * code for its implementation in mq_compat.h as we want to make + * use of the internal mac80211 __ieee80211_queue_stopped() which itself + * uses internal mac80211 data structure hacks. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */ +/** + * netif_subqueue_stopped - test status of subqueue + * @dev: network device + * @queue_index: sub queue index + * + * Check individual transmit queue of a device with multiple transmit queues. + */ +static inline int __netif_subqueue_stopped(const struct net_device *dev, + u16 queue_index) +{ +#ifdef CONFIG_NETDEVICES_MULTIQUEUE + return test_bit(__LINK_STATE_XOFF, + &dev->egress_subqueue[queue_index].state); +#else + return 0; +#endif +} + +/* Note: although the backport implementation for netif_subqueue_stopped + * on older kernels is identical to upstream __netif_subqueue_stopped() + * (except for a const qualifier) we implement netif_subqueue_stopped() + * as part of mac80211 as it relies on internal mac80211 structures we + * use for MQ support. We this implement it in mq_compat.h */ + +#endif /* Local 2.6.23 check */ + +/* + * Force link bug if constructor is used, can't be done compatibly + * because constructor arguments were swapped since then! + */ +extern void __incompatible_kmem_cache_create(void); + +/* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#define kmem_cache_create(name, objsize, align, flags, ctor) \ + ({ \ + if (ctor) __incompatible_kmem_cache_create(); \ + kmem_cache_create((name), (objsize), (align), \ + (flags), NULL, NULL); \ + }) +#endif + +/* 2.6.23 kmem_cache_create() takes 5 arguments */ +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) +#define kmem_cache_create(name, objsize, align, flags, ctor) \ + ({ \ + if (ctor) __incompatible_kmem_cache_create(); \ + kmem_cache_create((name), (objsize), (align), \ + (flags), NULL); \ + }) +#endif + +/* From include/linux/mod_devicetable.h */ + +/* SSB core, see drivers/ssb/ */ +#ifndef SSB_DEVICE +struct ssb_device_id { + __u16 vendor; + __u16 coreid; + __u8 revision; +}; +#define SSB_DEVICE(_vendor, _coreid, _revision) \ + { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } +#define SSB_DEVTABLE_END \ + { 0, }, + +#define SSB_ANY_VENDOR 0xFFFF +#define SSB_ANY_ID 0xFFFF +#define SSB_ANY_REV 0xFF +#endif + + +/* Namespace stuff, introduced on 2.6.24 */ +#define dev_get_by_index(a, b) dev_get_by_index(b) +#define __dev_get_by_index(a, b) __dev_get_by_index(b) + +/* + * Display a 6 byte device address (MAC) in a readable format. + */ +#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" +extern char *print_mac(char *buf, const u8 *addr); +#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused + +extern int eth_header(struct sk_buff *skb, struct net_device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len); +extern int eth_rebuild_header(struct sk_buff *skb); +extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, + unsigned char * haddr); +extern int eth_header_cache(struct neighbour *neigh, + struct hh_cache *hh); + +/* This structure is simply not present on 2.6.22 and 2.6.23 */ +struct header_ops { + int (*create) (struct sk_buff *skb, struct net_device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len); + int (*parse)(const struct sk_buff *skb, unsigned char *haddr); + int (*rebuild)(struct sk_buff *skb); + #define HAVE_HEADER_CACHE + int (*cache)(struct neighbour *neigh, struct hh_cache *hh); + void (*cache_update)(struct hh_cache *hh, + struct net_device *dev, + unsigned char *haddr); +}; + +/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on + * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore + * the debug stuff. Note that adding this required changes to the struct + * scatterlist on include/asm/scatterlist*, so the right way to port this + * is to simply ignore the new structure changes and zero the scatterlist + * array. We lave the kdoc intact for reference. + */ + +/** + * sg_mark_end - Mark the end of the scatterlist + * @sg: SG entryScatterlist + * + * Description: + * Marks the passed in sg entry as the termination point for the sg + * table. A call to sg_next() on this entry will return NULL. + * + **/ +static inline void sg_mark_end(struct scatterlist *sg) +{ +} + +/** + * sg_init_table - Initialize SG table + * @sgl: The SG table + * @nents: Number of entries in table + * + * Notes: + * If this is part of a chained sg table, sg_mark_end() should be + * used only on the last table part. + * + **/ +{ + memset(sgl, 0, sizeof(*sgl) * nents); +} + +/** + * usb_endpoint_num - get the endpoint's number + * @epd: endpoint to be checked + * + * Returns @epd's number: 0 to 15. + */ +static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) +{ + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; +} + +/* Helper to make struct pci_dev is_pcie compatibility code smaller */ +int compat_is_pcie(struct pci_dev *pdev); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */ + +#endif /* LINUX_26_24_COMPAT_H */ diff --git a/compat-2.6.25.c b/compat-2.6.25.c new file mode 100644 index 00000000..e39971a5 --- /dev/null +++ b/compat-2.6.25.c @@ -0,0 +1,378 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.25. + */ + +#include + +/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) + +/* Backport work for QoS dependencies (kernel/pm_qos_params.c) + * ipw2100 now makes use of + * pm_qos_add_requirement(), + * pm_qos_update_requirement() and + * pm_qos_remove_requirement() from it + * + * */ + +/* + * locking rule: all changes to target_value or requirements or notifiers lists + * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock + * held, taken with _irqsave. One lock to rule them all + */ +struct requirement_list { + struct list_head list; + union { + s32 value; + s32 usec; + s32 kbps; + }; + char *name; +}; + +static s32 max_compare(s32 v1, s32 v2); +static s32 min_compare(s32 v1, s32 v2); + +struct pm_qos_object { + struct requirement_list requirements; + struct blocking_notifier_head *notifiers; + struct miscdevice pm_qos_power_miscdev; + char *name; + s32 default_value; + s32 target_value; + s32 (*comparitor)(s32, s32); +}; + +static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); +static struct pm_qos_object cpu_dma_pm_qos = { + .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, + .notifiers = &cpu_dma_lat_notifier, + .name = "cpu_dma_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + +static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); +static struct pm_qos_object network_lat_pm_qos = { + .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, + .notifiers = &network_lat_notifier, + .name = "network_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + + +static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); +static struct pm_qos_object network_throughput_pm_qos = { + .requirements = + {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, + .notifiers = &network_throughput_notifier, + .name = "network_throughput", + .default_value = 0, + .target_value = 0, + .comparitor = max_compare +}; + + +static struct pm_qos_object *pm_qos_array[] = { + &null_pm_qos, + &cpu_dma_pm_qos, + &network_lat_pm_qos, + &network_throughput_pm_qos +}; + +static DEFINE_SPINLOCK(pm_qos_lock); + +/* static helper functions */ +static s32 max_compare(s32 v1, s32 v2) +{ + return max(v1, v2); +} + +static s32 min_compare(s32 v1, s32 v2) +{ + return min(v1, v2); +} + +static void update_target(int target) +{ + s32 extreme_value; + struct requirement_list *node; + unsigned long flags; + int call_notifier = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + extreme_value = pm_qos_array[target]->default_value; + list_for_each_entry(node, + &pm_qos_array[target]->requirements.list, list) { + extreme_value = pm_qos_array[target]->comparitor( + extreme_value, node->value); + } + if (pm_qos_array[target]->target_value != extreme_value) { + call_notifier = 1; + pm_qos_array[target]->target_value = extreme_value; + pr_debug(KERN_ERR "new target for qos %d is %d\n", target, + pm_qos_array[target]->target_value); + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + + if (call_notifier) + blocking_notifier_call_chain(pm_qos_array[target]->notifiers, + (unsigned long) extreme_value, NULL); +} + + +/** + * pm_qos_add_requirement - inserts new qos request into the list + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * This function inserts a new entry in the pm_qos_class list of requested qos + * performance charactoistics. It recomputes the agregate QoS expectations for + * the pm_qos_class of parrameters. + */ +int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) +{ + struct requirement_list *dep; + unsigned long flags; + + dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); + if (dep) { + if (value == PM_QOS_DEFAULT_VALUE) + dep->value = pm_qos_array[pm_qos_class]->default_value; + else + dep->value = value; + dep->name = kstrdup(name, GFP_KERNEL); + if (!dep->name) + goto cleanup; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_add(&dep->list, + &pm_qos_array[pm_qos_class]->requirements.list); + spin_unlock_irqrestore(&pm_qos_lock, flags); + update_target(pm_qos_class); + + return 0; + } + +cleanup: + kfree(dep); + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(pm_qos_add_requirement); + +/** + * pm_qos_update_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * Updates an existing qos requierement for the pm_qos_class of parameters along + * with updating the target pm_qos_class value. + * + * If the named request isn't in the lest then no change is made. + */ +int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + if (new_value == PM_QOS_DEFAULT_VALUE) + node->value = + pm_qos_array[pm_qos_class]->default_value; + else + node->value = new_value; + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); + + return 0; +} +EXPORT_SYMBOL_GPL(pm_qos_update_requirement); + +/** + * pm_qos_remove_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * + * Will remove named qos request from pm_qos_class list of parrameters and + * recompute the current target value for the pm_qos_class. + */ +void pm_qos_remove_requirement(int pm_qos_class, char *name) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + kfree(node->name); + list_del(&node->list); + kfree(node); + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); +} +EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); + + +/** + * The following things are out of ./lib/vsprintf.c + * The new iwlwifi driver is using them. + */ + +/** + * strict_strtoul - convert a string to an unsigned long strictly + * @cp: The string to be converted + * @base: The number base to use + * @res: The converted result value + * + * strict_strtoul converts a string to an unsigned long only if the + * string is really an unsigned long string, any string containing + * any invalid char at the tail will be rejected and -EINVAL is returned, + * only a newline char at the tail is acceptible because people generally + * change a module parameter in the following way: + * + * echo 1024 > /sys/module/e1000/parameters/copybreak + * + * echo will append a newline to the tail. + * + * It returns 0 if conversion is successful and *res is set to the converted + * value, otherwise it returns -EINVAL and *res is set to 0. + * + * simple_strtoul just ignores the successive invalid characters and + * return the converted value of prefix part of the string. + */ +int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); + +/** + * strict_strtol - convert a string to a long strictly + * @cp: The string to be converted + * @base: The number base to use + * @res: The converted result value + * + * strict_strtol is similiar to strict_strtoul, but it allows the first + * character of a string is '-'. + * + * It returns 0 if conversion is successful and *res is set to the converted + * value, otherwise it returns -EINVAL and *res is set to 0. + */ +int strict_strtol(const char *cp, unsigned int base, long *res); + +#define define_strict_strtoux(type, valtype) \ +int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\ +{ \ + char *tail; \ + valtype val; \ + size_t len; \ + \ + *res = 0; \ + len = strlen(cp); \ + if (len == 0) \ + return -EINVAL; \ + \ + val = simple_strtou##type(cp, &tail, base); \ + if ((*tail == '\0') || \ + ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\ + *res = val; \ + return 0; \ + } \ + \ + return -EINVAL; \ +} \ + +#define define_strict_strtox(type, valtype) \ +int strict_strto##type(const char *cp, unsigned int base, valtype *res) \ +{ \ + int ret; \ + if (*cp == '-') { \ + ret = strict_strtou##type(cp+1, base, res); \ + if (!ret) \ + *res = -(*res); \ + } else \ + ret = strict_strtou##type(cp, base, res); \ + \ + return ret; \ +} \ + +define_strict_strtoux(l, unsigned long) +define_strict_strtox(l, long) + +EXPORT_SYMBOL(strict_strtoul); +EXPORT_SYMBOL(strict_strtol); + +int __dev_addr_sync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + int err = 0; + + da = *from; + while (da != NULL) { + next = da->next; + if (!da->da_synced) { + err = __dev_addr_add(to, to_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_synced = 1; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + return err; +} +EXPORT_SYMBOL_GPL(__dev_addr_sync); + +void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + + da = *from; + while (da != NULL) { + next = da->next; + if (da->da_synced) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + da->da_synced = 0; + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } +} +EXPORT_SYMBOL_GPL(__dev_addr_unsync); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ + diff --git a/compat-2.6.25.h b/compat-2.6.25.h new file mode 100644 index 00000000..5502741a --- /dev/null +++ b/compat-2.6.25.h @@ -0,0 +1,103 @@ +#ifndef LINUX_26_25_COMPAT_H +#define LINUX_26_25_COMPAT_H + +#include +#include + +/* Compat work for 2.6.24 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) + +#include +#include +#include +#include +#include +#include +#include + +#define __WARN(foo) dump_stack() + +#define dev_emerg(dev, format, arg...) \ + dev_printk(KERN_EMERG , dev , format , ## arg) +#define dev_alert(dev, format, arg...) \ + dev_printk(KERN_ALERT , dev , format , ## arg) +#define dev_crit(dev, format, arg...) \ + dev_printk(KERN_CRIT , dev , format , ## arg) + +extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); +extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); + +#define seq_file_net &init_net; + +/* The patch: + * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865 + * Author: Marcin Slusarz + * Date: Fri Feb 8 04:20:12 2008 -0800 + * + * byteorder: move le32_add_cpu & friends from OCFS2 to core + * + * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core + * header (1st) and converted some existing code to it. We port + * it here as later kernels will most likely use it. + */ +static inline void le16_add_cpu(__le16 *var, u16 val) +{ + *var = cpu_to_le16(le16_to_cpu(*var) + val); +} + +static inline void le32_add_cpu(__le32 *var, u32 val) +{ + *var = cpu_to_le32(le32_to_cpu(*var) + val); +} + +static inline void le64_add_cpu(__le64 *var, u64 val) +{ + *var = cpu_to_le64(le64_to_cpu(*var) + val); +} + +static inline void be16_add_cpu(__be16 *var, u16 val) +{ + u16 v = be16_to_cpu(*var); + *var = cpu_to_be16(v + val); +} + +static inline void be32_add_cpu(__be32 *var, u32 val) +{ + u32 v = be32_to_cpu(*var); + *var = cpu_to_be32(v + val); +} + +static inline void be64_add_cpu(__be64 *var, u64 val) +{ + u64 v = be64_to_cpu(*var); + *var = cpu_to_be64(v + val); +} + +/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting + * suspend of its parent device (the misc device, which is itself the + * hardware random number generator). It does this by passing a parameter to + * unregister_miscdev() which is not supported in older kernels. The suspend + * parameter allows us to enable access to the device's hardware + * number generator during suspend. As far as wireless is concerned this means + * if a driver goes to suspend it you won't have the HNR available in + * older kernels. */ +static inline void __hwrng_unregister(struct hwrng *rng, bool suspended) +{ + hwrng_unregister(rng); +} + +static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) +{ + led_classdev_unregister(lcd); +} + +/** + * The following things are out of ./include/linux/kernel.h + * The new iwlwifi driver is using them. + */ +extern int strict_strtoul(const char *, unsigned int, unsigned long *); +extern int strict_strtol(const char *, unsigned int, long *); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ + +#endif /* LINUX_26_25_COMPAT_H */ diff --git a/compat-2.6.26.c b/compat-2.6.26.c new file mode 100644 index 00000000..960a79a1 --- /dev/null +++ b/compat-2.6.26.c @@ -0,0 +1,69 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.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 + +/* All things not in 2.6.25 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) + + +/** + * 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); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ + diff --git a/compat-2.6.26.h b/compat-2.6.26.h new file mode 100644 index 00000000..7f1a9f19 --- /dev/null +++ b/compat-2.6.26.h @@ -0,0 +1,377 @@ +#ifndef LINUX_26_26_COMPAT_H +#define LINUX_26_26_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) + +#include +#include +#include +#include +#include +#include + +/* These jiffie helpers added as of 2.6.26 */ + +/* + * These four macros compare jiffies and 'a' for convenience. + */ + +/* time_is_before_jiffies(a) return true if a is before jiffies */ +#define time_is_before_jiffies(a) time_after(jiffies, a) + +/* time_is_after_jiffies(a) return true if a is after jiffies */ +#define time_is_after_jiffies(a) time_before(jiffies, a) + +/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/ +#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a) + +/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/ +#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a) + +/* This comes from include/linux/input.h */ +#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" + set = radio enabled */ + +/* From 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, + struct device *parent, + dev_t devt, + void *drvdata, + const char *fmt, ...) +__attribute__((format(printf, 5, 6))); + +/* This is from include/linux/list.h */ + +/** + * list_is_singular - tests whether a list has just one entry. + * @head: the list to test. + */ +static inline int list_is_singular(const struct list_head *head) +{ + return !list_empty(head) && (head->next == head->prev); +} + +/* This is from include/linux/device.h, which was added as of 2.6.26 */ +static inline const char *dev_name(struct device *dev) +{ + /* will be changed into kobject_name(&dev->kobj) in the near future */ + return dev->bus_id; +} + +/* This is from include/linux/kernel.h, which was added as of 2.6.26 */ + +/** + * clamp_val - return a value clamped to a given range using val's type + * @val: current value + * @min: minimum allowable value + * @max: maximum allowable value + * + * This macro does no typechecking and uses temporary variables of whatever + * type the input argument 'val' is. This is useful when val is an unsigned + * type and min and max are literals that will otherwise be assigned a signed + * integer type. + */ + +#define clamp_val(val, min, max) ({ \ + typeof(val) __val = (val); \ + typeof(val) __min = (min); \ + typeof(val) __max = (max); \ + __val = __val < __min ? __min: __val; \ + __val > __max ? __max: __val; }) + +/* This comes from include/net/net_namespace.h */ + +#ifdef CONFIG_NET_NS +static inline +int net_eq(const struct net *net1, const struct net *net2) +{ + return net1 == net2; +} +#else +static inline +int net_eq(const struct net *net1, const struct net *net2) +{ + return 1; +} +#endif + +static inline +void dev_net_set(struct net_device *dev, struct net *net) +{ +#ifdef CONFIG_NET_NS + release_net(dev->nd_net); + dev->nd_net = hold_net(net); +#endif +} + +static inline +struct net *sock_net(const struct sock *sk) +{ +#ifdef CONFIG_NET_NS + return sk->sk_net; +#else + return &init_net; +#endif +} + +/* This comes from include/linux/netdevice.h */ + +/* + * Net namespace inlines + */ +static inline +struct net *dev_net(const struct net_device *dev) +{ +#ifdef CONFIG_NET_NS + /* + * compat-wirelss backport note: + * For older kernels we may just need to always return init_net, + * not sure when we added dev->nd_net. + */ + return dev->nd_net; +#else + return &init_net; +#endif +} + + +/* + * 2.6.26 added its own unaligned API which the + * new drivers can use. Lets port it here by including it in older + * kernels and also deal with the architecture handling here. + */ + +#ifdef CONFIG_ALPHA + +#include +#include +#include + +#endif /* alpha */ +#ifdef CONFIG_ARM + +/* arm */ +#include +#include +#include + +#endif /* arm */ +#ifdef CONFIG_AVR32 + +/* + * AVR32 can handle some unaligned accesses, depending on the + * implementation. The AVR32 AP implementation can handle unaligned + * words, but halfwords must be halfword-aligned, and doublewords must + * be word-aligned. + * + * However, swapped word loads must be word-aligned so we can't + * optimize word loads in general. + */ + +#include +#include +#include + +#endif +#ifdef CONFIG_BLACKFIN + +#include +#include +#include + +#endif /* blackfin */ +#ifdef CONFIG_CRIS + +/* + * CRIS can do unaligned accesses itself. + */ +#include +#include + +#endif /* cris */ +#ifdef CONFIG_FRV + +#include +#include +#include + +#endif /* frv */ +#ifdef CONFIG_H8300 + +#include +#include +#include + +#endif /* h8300 */ +#ifdef CONFIG_IA64 + +#include +#include +#include + +#endif /* ia64 */ +#ifdef CONFIG_M32R + +#if defined(__LITTLE_ENDIAN__) +# include +# include +# include +#else +# include +# include +# include +#endif + +#endif /* m32r */ +#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */ + +#ifdef CONFIG_COLDFIRE +#include +#include +#include +#else + +/* + * The m68k can do unaligned accesses itself. + */ +#include +#include +#endif + +#endif /* m68k and m68knommu */ +#ifdef CONFIG_MIPS + +#if defined(__MIPSEB__) +# include +# include +# include +# define get_unaligned __get_unaligned_be +# define put_unaligned __put_unaligned_be +#elif defined(__MIPSEL__) +# include +# include +# include +#endif + +#endif /* mips */ +#ifdef CONFIG_MN10300 + +#include +#include + +#endif /* mn10300 */ +#ifdef CONFIG_PARISC + +#include +#include +#include + +#endif /* parisc */ +#ifdef CONFIG_PPC +/* + * The PowerPC can do unaligned accesses itself in big endian mode. + */ +#include +#include + +#endif /* ppc */ +#ifdef CONFIG_S390 + +/* + * The S390 can do unaligned accesses itself. + */ +#include +#include + +#endif /* s390 */ +#ifdef CONFIG_SUPERH + +/* SH can't handle unaligned accesses. */ +#ifdef __LITTLE_ENDIAN__ +# include +# include +# include +#else +# include +# include +# include +#endif + +#endif /* sh - SUPERH */ +#ifdef CONFIG_SPARC + +/* sparc and sparc64 */ +#include +#include +#include + +#endif /* sparc */ +#ifdef CONFIG_UML + +#include "asm/arch/unaligned.h" + +#endif /* um - uml */ +#ifdef CONFIG_V850 + +#include +#include +#include + +#endif /* v850 */ +#ifdef CONFIG_X86 +/* + * The x86 can do unaligned accesses itself. + */ +#include +#include + +#endif /* x86 */ +#ifdef CONFIG_XTENSA + +#ifdef __XTENSA_EL__ +# include +# include +# include +#elif defined(__XTENSA_EB__) +# include +# include +# include +#else +# error processor byte order undefined! +#endif + +#endif /* xtensa */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ + +#endif /* LINUX_26_26_COMPAT_H */ diff --git a/compat-2.6.27.c b/compat-2.6.27.c new file mode 100644 index 00000000..996aab5d --- /dev/null +++ b/compat-2.6.27.c @@ -0,0 +1,207 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.27 + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) + +#include +#include +#include +#include +#include + +/* rfkill notification chain */ +#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill + switch has changed */ + +/* + * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external, + * it was defined internally, some drivers want access to this information. + * + * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so + * we have to call the PCI routines directly. + */ + +/** + * pci_pme_capable - check the capability of PCI device to generate PME# + * @dev: PCI device to handle. + * @state: PCI state from which device will issue PME#. + * + * This is the backport code for older kernels for compat-wireless, we read stuff + * from the initialization stuff from pci_pm_init(). + */ +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) +{ + int pm; + u16 pmc = 0; + u16 pme_support; /* as from the pci dev */ + /* find PCI PM capability in list */ + pm = pci_find_capability(dev, PCI_CAP_ID_PM); + if (!pm) + return false; + + if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { + dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", + pmc & PCI_PM_CAP_VER_MASK); + return false; + } + + pmc &= PCI_PM_CAP_PME_MASK; + + if (!pmc) + return false; + + pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; + + /* Check device's ability to generate PME# */ + + return !!(pme_support & (1 << state)); +} +EXPORT_SYMBOL(pci_pme_capable); + +/** + * mmc_align_data_size - pads a transfer size to a more optimal value + * @card: the MMC card associated with the data transfer + * @sz: original transfer size + * + * Pads the original data size with a number of extra bytes in + * order to avoid controller bugs and/or performance hits + * (e.g. some controllers revert to PIO for certain sizes). + * + * Returns the improved size, which might be unmodified. + * + * Note that this function is only relevant when issuing a + * single scatter gather entry. + */ +unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) +{ + /* + * FIXME: We don't have a system for the controller to tell + * the core about its problems yet, so for now we just 32-bit + * align the size. + */ + sz = ((sz + 3) / 4) * 4; + + return sz; +} +EXPORT_SYMBOL(mmc_align_data_size); + +/* + * Calculate the maximum byte mode transfer size + */ +static inline unsigned int sdio_max_byte_size(struct sdio_func *func) +{ + unsigned int mval = (unsigned int) min(func->card->host->max_seg_size, + func->card->host->max_blk_size); + mval = min(mval, func->max_blksize); + return min(mval, 512u); /* maximum size for byte mode */ +} + +/** + * sdio_align_size - pads a transfer size to a more optimal value + * @func: SDIO function + * @sz: original transfer size + * + * Pads the original data size with a number of extra bytes in + * order to avoid controller bugs and/or performance hits + * (e.g. some controllers revert to PIO for certain sizes). + * + * If possible, it will also adjust the size so that it can be + * handled in just a single request. + * + * Returns the improved size, which might be unmodified. + */ +unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) +{ + unsigned int orig_sz; + unsigned int blk_sz, byte_sz; + unsigned chunk_sz; + + orig_sz = sz; + + /* + * Do a first check with the controller, in case it + * wants to increase the size up to a point where it + * might need more than one block. + */ + sz = mmc_align_data_size(func->card, sz); + + /* + * If we can still do this with just a byte transfer, then + * we're done. + */ + if (sz <= sdio_max_byte_size(func)) + return sz; + + if (func->card->cccr.multi_block) { + /* + * Check if the transfer is already block aligned + */ + if ((sz % func->cur_blksize) == 0) + return sz; + + /* + * Realign it so that it can be done with one request, + * and recheck if the controller still likes it. + */ + blk_sz = ((sz + func->cur_blksize - 1) / + func->cur_blksize) * func->cur_blksize; + blk_sz = mmc_align_data_size(func->card, blk_sz); + + /* + * This value is only good if it is still just + * one request. + */ + if ((blk_sz % func->cur_blksize) == 0) + return blk_sz; + + /* + * We failed to do one request, but at least try to + * pad the remainder properly. + */ + byte_sz = mmc_align_data_size(func->card, + sz % func->cur_blksize); + if (byte_sz <= sdio_max_byte_size(func)) { + blk_sz = sz / func->cur_blksize; + return blk_sz * func->cur_blksize + byte_sz; + } + } else { + /* + * We need multiple requests, so first check that the + * controller can handle the chunk size; + */ + chunk_sz = mmc_align_data_size(func->card, + sdio_max_byte_size(func)); + if (chunk_sz == sdio_max_byte_size(func)) { + /* + * Fix up the size of the remainder (if any) + */ + byte_sz = orig_sz % chunk_sz; + if (byte_sz) { + byte_sz = mmc_align_data_size(func->card, + byte_sz); + } + + return (orig_sz / chunk_sz) * chunk_sz + byte_sz; + } + } + + /* + * The controller is simply incapable of transferring the size + * we want in decent manner, so just return the original size. + */ + return orig_sz; +} +EXPORT_SYMBOL_GPL(sdio_align_size); + + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ + diff --git a/compat-2.6.27.h b/compat-2.6.27.h new file mode 100644 index 00000000..ed10a6c4 --- /dev/null +++ b/compat-2.6.27.h @@ -0,0 +1,183 @@ +#ifndef LINUX_26_27_COMPAT_H +#define LINUX_26_27_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PCI_PM_CAP_PME_SHIFT 11 + +/* I can't find a more suitable replacement... */ +#define flush_work(work) cancel_work_sync(work) + +/* + * On older kernels we do not have net_device Multi Queue support, but + * since we no longer use MQ on mac80211 we can simply use the 0 queue. + * Note that if other fullmac drivers make use of this they then need + * to be backported somehow or deal with just 1 queueue from MQ. + */ +static inline void netif_tx_wake_all_queues(struct net_device *dev) +{ + netif_wake_queue(dev); +} +static inline void netif_tx_start_all_queues(struct net_device *dev) +{ + netif_start_queue(dev); +} +static inline void netif_tx_stop_all_queues(struct net_device *dev) +{ + netif_stop_queue(dev); +} + +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); + +/* + * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck + */ +#define netif_addr_lock_bh +#define netif_addr_unlock_bh + +/* + * To port this properly we'd have to port warn_slowpath_null(), + * which I'm lazy to do so just do a regular print for now. If you + * want to port this read kernel/panic.c + */ +#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) + +/* This is ported directly as-is on newer kernels */ +#ifndef WARN +#define WARN(condition, format...) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + __WARN_printf(format); \ + unlikely(__ret_warn_on); \ +}) +#endif + +/* On 2.6.27 a second argument was added, on older kernels we ignore it */ +#define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr) +#define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr) + +/* This is from include/linux/ieee80211.h */ +#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 + +/* New link list changes added as of 2.6.27, needed for ath9k */ + +static inline void __list_cut_position(struct list_head *list, + struct list_head *head, struct list_head *entry) +{ + struct list_head *new_first = entry->next; + list->next = head->next; + list->next->prev = list; + list->prev = entry; + entry->next = list; + head->next = new_first; + new_first->prev = head; +} + +/** + * list_cut_position - cut a list into two + * @list: a new list to add all removed entries + * @head: a list with entries + * @entry: an entry within head, could be the head itself + * and if so we won't cut the list + * + * This helper moves the initial part of @head, up to and + * including @entry, from @head to @list. You should + * pass on @entry an element you know is on @head. @list + * should be an empty list or a list you do not care about + * losing its data. + * + */ +static inline void list_cut_position(struct list_head *list, + struct list_head *head, struct list_head *entry) +{ + if (list_empty(head)) + return; + if (list_is_singular(head) && + (head->next != entry && head != entry)) + return; + if (entry == head) + INIT_LIST_HEAD(list); + else + __list_cut_position(list, head, entry); +} + + +/* __list_splice as re-implemented on 2.6.27, we backport it */ +static inline void __compat_list_splice_new_27(const struct list_head *list, + struct list_head *prev, + struct list_head *next) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +/** + * list_splice_tail - join two lists, each list being a queue + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +static inline void list_splice_tail(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) + __compat_list_splice_new_27(list, head->prev, head); +} + +/** + * list_splice_tail_init - join two lists and reinitialise the emptied list + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * Each of the lists is a queue. + * The list at @list is reinitialised + */ +static inline void list_splice_tail_init(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) { + __compat_list_splice_new_27(list, head->prev, head); + INIT_LIST_HEAD(list); + } +} + +extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); +extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); + +#define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len) +#define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra) +#define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len) + +/* Flags available in struct iw_request_info */ +#define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */ + +static inline int iwe_stream_lcp_len(struct iw_request_info *info) +{ +#ifdef CONFIG_COMPAT + if (info->flags & IW_REQUEST_FLAG_COMPAT) + return IW_EV_COMPAT_LCP_LEN; +#endif + return IW_EV_LCP_LEN; +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ + +#endif /* LINUX_26_27_COMPAT_H */ diff --git a/compat-2.6.28.c b/compat-2.6.28.c new file mode 100644 index 00000000..4b3ea21a --- /dev/null +++ b/compat-2.6.28.c @@ -0,0 +1,278 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.28. + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) + +#include + +/* 2.6.28 compat code goes here */ + +/* + * Compat-wireless notes for USB backport stuff: + * + * urb->reject exists on 2.6.27, the poison/unpoison helpers + * did not though. The anchor poison does not exist so we cannot use them. + * + * USB anchor poising seems to exist to prevent future driver sumbissions + * of usb_anchor_urb() to an anchor marked as poisoned. For older kernels + * we cannot use that, so new usb_anchor_urb()s will be anchored. The down + * side to this should be submission of URBs will continue being anchored + * on an anchor instead of having them being rejected immediately when the + * driver realized we needed to stop. For ar9170 we poison URBs upon the + * ar9170 mac80211 stop callback(), don't think this should be so bad. + * It mean there is period of time in older kernels for which we continue + * to anchor new URBs to a known stopped anchor. We have two anchors + * (TX, and RX) + */ + +#if 0 +/** + * usb_poison_urb - reliably kill a transfer and prevent further use of an URB + * @urb: pointer to URB describing a previously submitted request, + * may be NULL + * + * This routine cancels an in-progress request. It is guaranteed that + * upon return all completion handlers will have finished and the URB + * will be totally idle and cannot be reused. These features make + * this an ideal way to stop I/O in a disconnect() callback. + * If the request has not already finished or been unlinked + * the completion handler will see urb->status == -ENOENT. + * + * After and while the routine runs, attempts to resubmit the URB will fail + * with error -EPERM. Thus even if the URB's completion handler always + * tries to resubmit, it will not succeed and the URB will become idle. + * + * This routine may not be used in an interrupt context (such as a bottom + * half or a completion handler), or when holding a spinlock, or in other + * situations where the caller can't schedule(). + * + * This routine should not be called by a driver after its disconnect + * method has returned. + */ +void usb_poison_urb(struct urb *urb) +{ + might_sleep(); + if (!(urb && urb->dev && urb->ep)) + return; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_lock_irq(&usb_reject_lock); +#endif + ++urb->reject; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_unlock_irq(&usb_reject_lock); +#endif + /* + * XXX: usb_hcd_unlink_urb() needs backporting... this is defined + * on usb hcd.c but urb.c gets access to it. That is, older kernels + * have usb_hcd_unlink_urb() but its not exported, nor can we + * re-implement it exactly. This essentially dequeues the urb from + * hw, we need to figure out a way to backport this. + */ + //usb_hcd_unlink_urb(urb, -ENOENT); + + wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); +} +EXPORT_SYMBOL_GPL(usb_poison_urb); +#endif + +void usb_unpoison_urb(struct urb *urb) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + unsigned long flags; +#endif + + if (!urb) + return; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_lock_irqsave(&usb_reject_lock, flags); +#endif + --urb->reject; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_unlock_irqrestore(&usb_reject_lock, flags); +#endif +} +EXPORT_SYMBOL_GPL(usb_unpoison_urb); + + +#if 0 +/** + * usb_poison_anchored_urbs - cease all traffic from an anchor + * @anchor: anchor the requests are bound to + * + * this allows all outstanding URBs to be poisoned starting + * from the back of the queue. Newly added URBs will also be + * poisoned + * + * This routine should not be called by a driver after its disconnect + * method has returned. + */ +void usb_poison_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + + spin_lock_irq(&anchor->lock); + // anchor->poisoned = 1; /* XXX: Cannot backport */ + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + /* we must make sure the URB isn't freed before we kill it*/ + usb_get_urb(victim); + spin_unlock_irq(&anchor->lock); + /* this will unanchor the URB */ + usb_poison_urb(victim); + usb_put_urb(victim); + spin_lock_irq(&anchor->lock); + } + spin_unlock_irq(&anchor->lock); +} +EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); +#endif + +/** + * usb_get_from_anchor - get an anchor's oldest urb + * @anchor: the anchor whose urb you want + * + * this will take the oldest urb from an anchor, + * unanchor and return it + */ +struct urb *usb_get_from_anchor(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + if (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.next, struct urb, + anchor_list); + usb_get_urb(victim); + spin_unlock_irqrestore(&anchor->lock, flags); + usb_unanchor_urb(victim); + } else { + spin_unlock_irqrestore(&anchor->lock, flags); + victim = NULL; + } + + return victim; +} + +EXPORT_SYMBOL_GPL(usb_get_from_anchor); + +/** + * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs + * @anchor: the anchor whose urbs you want to unanchor + * + * use this to get rid of all an anchor's urbs + */ +void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + usb_get_urb(victim); + spin_unlock_irqrestore(&anchor->lock, flags); + /* this may free the URB */ + usb_unanchor_urb(victim); + usb_put_urb(victim); + spin_lock_irqsave(&anchor->lock, flags); + } + spin_unlock_irqrestore(&anchor->lock, flags); +} + +EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); + +/** + * usb_anchor_empty - is an anchor empty + * @anchor: the anchor you want to query + * + * returns 1 if the anchor has no urbs associated with it + */ +int usb_anchor_empty(struct usb_anchor *anchor) +{ + return list_empty(&anchor->urb_list); +} + +EXPORT_SYMBOL_GPL(usb_anchor_empty); + + +void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) +{ + /* + * Make sure the BAR is actually a memory resource, not an IO resource + */ + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { + WARN_ON(1); + return NULL; + } + return ioremap_nocache(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} +EXPORT_SYMBOL_GPL(pci_ioremap_bar); + +static unsigned long round_jiffies_common(unsigned long j, int cpu, + bool force_up) +{ + int rem; + unsigned long original = j; + + /* + * We don't want all cpus firing their timers at once hitting the + * same lock or cachelines, so we skew each extra cpu with an extra + * 3 jiffies. This 3 jiffies came originally from the mm/ code which + * already did this. + * The skew is done by adding 3*cpunr, then round, then subtract this + * extra offset again. + */ + j += cpu * 3; + + rem = j % HZ; + + /* + * If the target jiffie is just after a whole second (which can happen + * due to delays of the timer irq, long irq off times etc etc) then + * we should round down to the whole second, not up. Use 1/4th second + * as cutoff for this rounding as an extreme upper bound for this. + * But never round down if @force_up is set. + */ + if (rem < HZ/4 && !force_up) /* round down */ + j = j - rem; + else /* round up */ + j = j - rem + HZ; + + /* now that we have rounded, subtract the extra skew again */ + j -= cpu * 3; + + if (j <= jiffies) /* rounding ate our timeout entirely; */ + return original; + return j; +} + +/** + * round_jiffies_up - function to round jiffies up to a full second + * @j: the time in (absolute) jiffies that should be rounded + * + * This is the same as round_jiffies() except that it will never + * round down. This is useful for timeouts for which the exact time + * of firing does not matter too much, as long as they don't fire too + * early. + */ +unsigned long round_jiffies_up(unsigned long j) +{ + return round_jiffies_common(j, raw_smp_processor_id(), true); +} +EXPORT_SYMBOL_GPL(round_jiffies_up); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/compat-2.6.28.h b/compat-2.6.28.h new file mode 100644 index 00000000..69ddae6a --- /dev/null +++ b/compat-2.6.28.h @@ -0,0 +1,182 @@ +#ifndef LINUX_26_28_COMPAT_H +#define LINUX_26_28_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) + +#include +#include +#include + +#ifndef ETH_P_PAE +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#endif + +#include + +#ifndef WARN_ONCE +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) \ + if (WARN(!__warned, format)) \ + __warned = 1; \ + unlikely(__ret_warn_once); \ +}) +#endif /* From include/asm-generic/bug.h */ + +#include +#include +#include +#ifdef pcmcia_parse_tuple +#undef pcmcia_parse_tuple +#define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse) +#endif + +#if 0 +extern void usb_poison_urb(struct urb *urb); +#endif +extern void usb_unpoison_urb(struct urb *urb); + +#if 0 +extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); +#endif + +extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); +extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); +extern int usb_anchor_empty(struct usb_anchor *anchor); + + +void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); + +/** + * skb_queue_is_last - check if skb is the last entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the last buffer on the list. + */ +static inline bool skb_queue_is_last(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->next == (struct sk_buff *) list); +} + +/** + * skb_queue_next - return the next packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the next packet in @list after @skb. It is only valid to + * call this if skb_queue_is_last() evaluates to false. + */ +static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_last(list, skb)); + return skb->next; +} + +/** + * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head + * @list: queue to initialize + * + * This initializes only the list and queue length aspects of + * an sk_buff_head object. This allows to initialize the list + * aspects of an sk_buff_head without reinitializing things like + * the spinlock. It can also be used for on-stack sk_buff_head + * objects where the spinlock is known to not be used. + */ +static inline void __skb_queue_head_init(struct sk_buff_head *list) +{ + list->prev = list->next = (struct sk_buff *)list; + list->qlen = 0; +} + +static inline void __skb_queue_splice(const struct sk_buff_head *list, + struct sk_buff *prev, + struct sk_buff *next) +{ + struct sk_buff *first = list->next; + struct sk_buff *last = list->prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +/** + * skb_queue_splice - join two skb lists, this is designed for stacks + * @list: the new list to add + * @head: the place to add it in the first list + */ +static inline void skb_queue_splice(const struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, (struct sk_buff *) head, head->next); + head->qlen += list->qlen; + } +} + +/** + * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list + * @list: the new list to add + * @head: the place to add it in the first list + * + * Each of the lists is a queue. + * The list at @list is reinitialised + */ +static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, head->prev, (struct sk_buff *) head); + head->qlen += list->qlen; + __skb_queue_head_init(list); + } +} /* From include/linux/skbuff.h */ + +#ifndef DECLARE_TRACE + +#define TP_PROTO(args...) args +#define TP_ARGS(args...) args + +#define DECLARE_TRACE(name, proto, args) \ + static inline void _do_trace_##name(struct tracepoint *tp, proto) \ + { } \ + static inline void trace_##name(proto) \ + { } \ + static inline int register_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline int unregister_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } + +#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) +#define EXPORT_TRACEPOINT_SYMBOL(name) + + +#endif + +/* openSuse includes round_jiffies_up in it's kernel 2.6.27. + * This is needed to prevent conflicts with the openSuse definition. + */ +#define round_jiffies_up backport_round_jiffies_up + +unsigned long round_jiffies_up(unsigned long j); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ + +#endif /* LINUX_26_28_COMPAT_H */ diff --git a/compat-2.6.29.c b/compat-2.6.29.c new file mode 100644 index 00000000..664be923 --- /dev/null +++ b/compat-2.6.29.c @@ -0,0 +1,40 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.29. + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) + +#include + +/** + * usb_unpoison_anchored_urbs - let an anchor be used successfully again + * @anchor: anchor the requests are bound to + * + * Reverses the effect of usb_poison_anchored_urbs + * the anchor can be used normally after it returns + */ +void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) +{ + unsigned long flags; + struct urb *lazarus; + + spin_lock_irqsave(&anchor->lock, flags); + list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { + usb_unpoison_urb(lazarus); + } + //anchor->poisoned = 0; /* XXX: cannot backport */ + spin_unlock_irqrestore(&anchor->lock, flags); +} +EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); + + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ + diff --git a/compat-2.6.29.h b/compat-2.6.29.h new file mode 100644 index 00000000..ff97b37b --- /dev/null +++ b/compat-2.6.29.h @@ -0,0 +1,54 @@ +#ifndef LINUX_26_29_COMPAT_H +#define LINUX_26_29_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) + +#include +#include + +/** + * skb_queue_is_first - check if skb is the first entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the first buffer on the list. + */ +static inline bool skb_queue_is_first(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->prev == (struct sk_buff *) list); +} + +/** + * skb_queue_prev - return the prev packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the prev packet in @list before @skb. It is only valid to + * call this if skb_queue_is_first() evaluates to false. + */ +static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_first(list, skb)); + return skb->prev; +} + +extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); + +#define DIV_ROUND_CLOSEST(x, divisor)( \ +{ \ + typeof(divisor) __divisor = divisor; \ + (((x) + ((__divisor) / 2)) / (__divisor)); \ +} \ +) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ + +#endif /* LINUX_26_29_COMPAT_H */ diff --git a/compat-2.6.30.c b/compat-2.6.30.c new file mode 100644 index 00000000..6e0d69c5 --- /dev/null +++ b/compat-2.6.30.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.30. + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) + +/* 2.6.30 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ + diff --git a/compat-2.6.30.h b/compat-2.6.30.h new file mode 100644 index 00000000..fe3233c2 --- /dev/null +++ b/compat-2.6.30.h @@ -0,0 +1,20 @@ +#ifndef LINUX_26_30_COMPAT_H +#define LINUX_26_30_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) + +#ifndef TP_PROTO +#define TP_PROTO(args...) TPPROTO(args) +#endif +#ifndef TP_ARGS +#define TP_ARGS(args...) TPARGS(args) +#endif + +#define IRQ_WAKE_THREAD (2) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ + +#endif /* LINUX_26_30_COMPAT_H */ diff --git a/compat-2.6.31.c b/compat-2.6.31.c new file mode 100644 index 00000000..90b6a411 --- /dev/null +++ b/compat-2.6.31.c @@ -0,0 +1,64 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.31. + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) + +#include + +/** + * genl_register_family_with_ops - register a generic netlink family + * @family: generic netlink family + * @ops: operations to be registered + * @n_ops: number of elements to register + * + * Registers the specified family and operations from the specified table. + * Only one family may be registered with the same family name or identifier. + * + * The family id may equal GENL_ID_GENERATE causing an unique id to + * be automatically generated and assigned. + * + * Either a doit or dumpit callback must be specified for every registered + * operation or the function will fail. Only one operation structure per + * command identifier may be registered. + * + * See include/net/genetlink.h for more documenation on the operations + * structure. + * + * This is equivalent to calling genl_register_family() followed by + * genl_register_ops() for every operation entry in the table taking + * care to unregister the family on error path. + * + * Return 0 on success or a negative error code. + */ +int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops) +{ + int err, i; + + err = genl_register_family(family); + if (err) + return err; + + for (i = 0; i < n_ops; ++i, ++ops) { + err = genl_register_ops(family, ops); + if (err) + goto err_out; + } + return 0; +err_out: + genl_unregister_family(family); + return err; +} +EXPORT_SYMBOL(genl_register_family_with_ops); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + diff --git a/compat-2.6.31.h b/compat-2.6.31.h new file mode 100644 index 00000000..a91e0333 --- /dev/null +++ b/compat-2.6.31.h @@ -0,0 +1,182 @@ +#ifndef LINUX_26_31_COMPAT_H +#define LINUX_26_31_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) + +#include +#include +#include +#include +#include + +/* + * These macros allow us to backport rfkill without any + * changes on cfg80211 through compat.diff. Note that this + * file will be included by rfkill_backport.h so we must + * not conflict with things there. + */ +#define rfkill_get_led_trigger_name backport_rfkill_get_led_trigger_name +#define rfkill_set_led_trigger_name backport_rfkill_set_led_trigger_name +#define rfkill_set_hw_state backport_rfkill_set_hw_state +#define rfkill_set_sw_state backport_rfkill_set_sw_state +#define rfkill_init_sw_state backport_rfkill_init_sw_state +#define rfkill_set_states backport_rfkill_set_states +#define rfkill_pause_polling backport_rfkill_pause_polling +#define rfkill_resume_polling backport_rfkill_resume_polling +#define rfkill_blocked backport_rfkill_blocked +#define rfkill_alloc backport_rfkill_alloc +#define rfkill_register backport_rfkill_register +#define rfkill_unregister backport_rfkill_unregister +#define rfkill_destroy backport_rfkill_destroy + +#ifndef ERFKILL +#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC) +#define ERFKILL 132 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_ALPHA +#define ERFKILL 138 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_MIPS +#define ERFKILL 167 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_PARISC +#define ERFKILL 256 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_SPARC +#define ERFKILL 134 /* Operation not possible due to RF-kill */ +#endif +#endif + +#ifndef NETDEV_PRE_UP +#define NETDEV_PRE_UP 0x000D +#endif + +#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN +#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 +#endif + +struct compat_threaded_irq { + unsigned int irq; + irq_handler_t handler; + irq_handler_t thread_fn; + void *dev_id; + char wq_name[64]; + struct workqueue_struct *wq; + struct work_struct work; +}; + +/* + * kmemleak was introduced on 2.6.31, since older kernels do not have + * we simply ignore its tuning. + */ +static inline void kmemleak_ignore(const void *ptr) +{ + return; +} + +static inline void kmemleak_not_leak(const void *ptr) +{ + return; +} + +static inline void kmemleak_no_scan(const void *ptr) +{ + return; +} + +/* + * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5 + * + * There is no _sk_dst on older kernels, so just set the + * old dst to NULL and release it directly. + */ +static inline void skb_dst_drop(struct sk_buff *skb) +{ + dst_release(skb->dst); + skb->dst = NULL; +} + +extern int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops); + + +/* Backport threaded IRQ support */ + +static inline +void compat_irq_work(struct work_struct *work) +{ + struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work); + comp->thread_fn(comp->irq, comp->dev_id); +} + +static inline +irqreturn_t compat_irq_dispatcher(int irq, void *dev_id) +{ + struct compat_threaded_irq *comp = dev_id; + irqreturn_t res; + + res = comp->handler(irq, comp->dev_id); + if (res == IRQ_WAKE_THREAD) { + queue_work(comp->wq, &comp->work); + res = IRQ_HANDLED; + } + + return res; +} + +static inline +int compat_request_threaded_irq(struct compat_threaded_irq *comp, + unsigned int irq, + irq_handler_t handler, + irq_handler_t thread_fn, + unsigned long flags, + const char *name, + void *dev_id) +{ + comp->irq = irq; + comp->handler = handler; + comp->thread_fn = thread_fn; + comp->dev_id = dev_id; + INIT_WORK(&comp->work, compat_irq_work); + + if (!comp->wq) { + snprintf(comp->wq_name, sizeof(comp->wq_name), + "compirq/%u-%s", irq, name); + comp->wq = create_singlethread_workqueue(comp->wq_name); + if (!comp->wq) { + printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n", + comp->wq_name); + return -ENOMEM; + } + } + return request_irq(irq, compat_irq_dispatcher, flags, name, comp); +} + +static inline +void compat_free_threaded_irq(struct compat_threaded_irq *comp) +{ + free_irq(comp->irq, comp); +} + +static inline +void compat_destroy_threaded_irq(struct compat_threaded_irq *comp) +{ + if (comp->wq) + destroy_workqueue(comp->wq); + comp->wq = NULL; +} + +static inline +void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) +{ + synchronize_irq(comp->irq); + cancel_work_sync(&comp->work); +} + + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + +#endif /* LINUX_26_31_COMPAT_H */ diff --git a/compat-2.6.32.c b/compat-2.6.32.c new file mode 100644 index 00000000..5d085e6e --- /dev/null +++ b/compat-2.6.32.c @@ -0,0 +1,124 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.32. + */ + +#include "compat.h" + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) + +#include + +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kzalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} + +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} + +int __dev_addr_sync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + int err = 0; + + da = *from; + while (da != NULL) { + next = da->next; + if (!da->da_synced) { + err = __dev_addr_add(to, to_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_synced = 1; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + return err; +} +EXPORT_SYMBOL_GPL(__dev_addr_sync); + +void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + + da = *from; + while (da != NULL) { + next = da->next; + if (da->da_synced) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + da->da_synced = 0; + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } +} +EXPORT_SYMBOL_GPL(__dev_addr_unsync); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ + diff --git a/compat-2.6.32.h b/compat-2.6.32.h new file mode 100644 index 00000000..cef18998 --- /dev/null +++ b/compat-2.6.32.h @@ -0,0 +1,50 @@ +#ifndef LINUX_26_32_COMPAT_H +#define LINUX_26_32_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) + +#include +#include + +#define SDIO_VENDOR_ID_INTEL 0x0089 +#define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 +#define SDIO_DEVICE_ID_INTEL_IWMC3200WIFI 0x1403 +#define SDIO_DEVICE_ID_INTEL_IWMC3200TOP 0x1404 +#define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405 +#define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406 + +/* + * struct genl_multicast_group was made netns aware through + * patch "genetlink: make netns aware" by johannes, we just + * force this to always use the default init_net + */ +#define genl_info_net(x) &init_net +/* Just use init_net for older kernels */ +#define get_net_ns_by_pid(x) &init_net + +/* net namespace is lost */ +#define genlmsg_multicast_netns(a, b, c, d, e) genlmsg_multicast(b, c, d, e) +#define genlmsg_multicast_allns(a, b, c, d) genlmsg_multicast(a, b, c, d) + +#define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP) + +#define SET_NETDEV_DEVTYPE(netdev, type) + +#ifdef __KERNEL__ +/* Driver transmit return codes */ +enum netdev_tx { + BACKPORT_NETDEV_TX_OK = NETDEV_TX_OK, /* driver took care of packet */ + BACKPORT_NETDEV_TX_BUSY = NETDEV_TX_BUSY, /* driver tx path was busy*/ + BACKPORT_NETDEV_TX_LOCKED = NETDEV_TX_LOCKED, /* driver tx lock was already taken */ +}; +typedef enum netdev_tx netdev_tx_t; +#endif /* __KERNEL__ */ + +#define wireless_send_event(a, b, c, d) wireless_send_event(a, b, c, (char * ) d) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ + +#endif /* LINUX_26_32_COMPAT_H */ diff --git a/compat.h b/compat.h new file mode 100644 index 00000000..5c9c8034 --- /dev/null +++ b/compat.h @@ -0,0 +1,24 @@ +#ifndef LINUX_26_COMPAT_H +#define LINUX_26_COMPAT_H + +#include +#include + +/* + * Each compat file represents compatibility code for new kernel + * code introduced for *that* kernel revision. + */ + +#include "compat-2.6.22.h" +#include "compat-2.6.23.h" +#include "compat-2.6.24.h" +#include "compat-2.6.25.h" +#include "compat-2.6.26.h" +#include "compat-2.6.27.h" +#include "compat-2.6.28.h" +#include "compat-2.6.29.h" +#include "compat-2.6.30.h" +#include "compat-2.6.31.h" +#include "compat-2.6.32.h" + +#endif /* LINUX_26_COMPAT_H */ diff --git a/main.c b/main.c new file mode 100644 index 00000000..390278db --- /dev/null +++ b/main.c @@ -0,0 +1,18 @@ +#include + +MODULE_AUTHOR("Luis R. Rodriguez"); +MODULE_DESCRIPTION("Kernel compatibility module"); +MODULE_LICENSE("GPL"); + +static int __init compat_init(void) +{ + return 0; +} +module_init(compat_init); + +static void __exit compat_exit(void) +{ + return; +} +module_exit(compat_exit); + -- cgit v1.2.3 From ae45738826139d5325581a3779712c4d1a704552 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 20 Nov 2009 18:24:05 -0800 Subject: Add COPYRIGHT from the kernel This is based on the Linux kernel code anyway. Signed-off-by: Luis R. Rodriguez --- COPYRIGHT | 356 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 356 insertions(+) create mode 100644 COPYRIGHT diff --git a/COPYRIGHT b/COPYRIGHT new file mode 100644 index 00000000..ca442d31 --- /dev/null +++ b/COPYRIGHT @@ -0,0 +1,356 @@ + + NOTE! This copyright does *not* cover user programs that use kernel + services by normal system calls - this is merely considered normal use + of the kernel, and does *not* fall under the heading of "derived work". + Also note that the GPL below is copyrighted by the Free Software + Foundation, but the instance of code that it refers to (the Linux + kernel) is copyrighted by me and others who actually wrote it. + + Also note that the only valid version of the GPL as far as the kernel + is concerned is _this_ particular version of the license (ie v2, not + v2.2 or v3.x or whatever), unless explicitly otherwise stated. + + Linus Torvalds + +---------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. -- cgit v1.2.3 From 0091212dabec9b3a10595551a891d96d83a906b6 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:23:46 -0500 Subject: Add skeleton for 2.6.14 Signed-off-by: Arnaud Lacombe --- Makefile | 1 + compat-2.6.14.c | 18 ++++++++++++++++++ compat-2.6.14.h | 12 ++++++++++++ compat.h | 1 + 4 files changed, 32 insertions(+) create mode 100644 compat-2.6.14.c create mode 100644 compat-2.6.14.h diff --git a/Makefile b/Makefile index be95c6af..fe008df5 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ obj-m += compat.o compat-y += main.o # Compat kernel compatibility code +compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o diff --git a/compat-2.6.14.c b/compat-2.6.14.c new file mode 100644 index 00000000..e0af181f --- /dev/null +++ b/compat-2.6.14.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.14. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) + +/* 2.6.14 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) */ + diff --git a/compat-2.6.14.h b/compat-2.6.14.h new file mode 100644 index 00000000..ec12941d --- /dev/null +++ b/compat-2.6.14.h @@ -0,0 +1,12 @@ +#ifndef LINUX_26_14_COMPAT_H +#define LINUX_26_14_COMPAT_H + +#include +#include + +/* Compat work for 2.6.14 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) */ + +#endif /* LINUX_26_14_COMPAT_H */ diff --git a/compat.h b/compat.h index 5c9c8034..e537c235 100644 --- a/compat.h +++ b/compat.h @@ -9,6 +9,7 @@ * code introduced for *that* kernel revision. */ +#include "compat-2.6.14.h" #include "compat-2.6.22.h" #include "compat-2.6.23.h" #include "compat-2.6.24.h" -- cgit v1.2.3 From 917dd4a0f693307d427d17f9556f12320a60f022 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:23:59 -0500 Subject: Add typedef for `gfp_t' Added on commit dd0fc66f by Al Viro in include/linux/types.h. Signed-off-by: Arnaud Lacombe --- compat-2.6.14.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat-2.6.14.h b/compat-2.6.14.h index ec12941d..22e7e319 100644 --- a/compat-2.6.14.h +++ b/compat-2.6.14.h @@ -7,6 +7,8 @@ /* Compat work for 2.6.14 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) +typedef unsigned int gfp_t; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) */ #endif /* LINUX_26_14_COMPAT_H */ -- cgit v1.2.3 From e05296d2b9111aa5a1c4106395a50b07f55375df Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:24:08 -0500 Subject: Add skeleton for 2.6.18 Signed-off-by: Arnaud Lacombe --- Makefile | 1 + compat-2.6.18.c | 18 ++++++++++++++++++ compat-2.6.18.h | 12 ++++++++++++ compat.h | 1 + 4 files changed, 32 insertions(+) create mode 100644 compat-2.6.18.c create mode 100644 compat-2.6.18.h diff --git a/Makefile b/Makefile index fe008df5..9afc6875 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ compat-y += main.o # Compat kernel compatibility code compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o +compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o diff --git a/compat-2.6.18.c b/compat-2.6.18.c new file mode 100644 index 00000000..c7fb2e41 --- /dev/null +++ b/compat-2.6.18.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.18. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) + +/* 2.6.18 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ + diff --git a/compat-2.6.18.h b/compat-2.6.18.h new file mode 100644 index 00000000..077f28bb --- /dev/null +++ b/compat-2.6.18.h @@ -0,0 +1,12 @@ +#ifndef LINUX_26_18_COMPAT_H +#define LINUX_26_18_COMPAT_H + +#include +#include + +/* Compat work for 2.6.18 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */ + +#endif /* LINUX_26_18_COMPAT_H */ diff --git a/compat.h b/compat.h index e537c235..433840c8 100644 --- a/compat.h +++ b/compat.h @@ -10,6 +10,7 @@ */ #include "compat-2.6.14.h" +#include "compat-2.6.18.h" #include "compat-2.6.22.h" #include "compat-2.6.23.h" #include "compat-2.6.24.h" -- cgit v1.2.3 From 802708a593aa035e3c4d5179842a36c5f2539e08 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:24:15 -0500 Subject: Add roundup() compatibility macro Added on commit b4cac1a0 by David Howells in include/linux/kernel.h. Signed-off-by: Arnaud Lacombe --- compat-2.6.18.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat-2.6.18.h b/compat-2.6.18.h index 077f28bb..3245c42c 100644 --- a/compat-2.6.18.h +++ b/compat-2.6.18.h @@ -7,6 +7,8 @@ /* Compat work for 2.6.18 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */ #endif /* LINUX_26_18_COMPAT_H */ -- cgit v1.2.3 From e7db808ef507c163045db7081b45515868bbc9ce Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:24:23 -0500 Subject: Add skeleton for 2.6.19 Signed-off-by: Arnaud Lacombe --- Makefile | 1 + compat-2.6.19.c | 18 ++++++++++++++++++ compat-2.6.19.h | 12 ++++++++++++ compat.h | 1 + 4 files changed, 32 insertions(+) create mode 100644 compat-2.6.19.c create mode 100644 compat-2.6.19.h diff --git a/Makefile b/Makefile index 9afc6875..3f1a4add 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ compat-y += main.o # Compat kernel compatibility code compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o +compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o diff --git a/compat-2.6.19.c b/compat-2.6.19.c new file mode 100644 index 00000000..fc75b64d --- /dev/null +++ b/compat-2.6.19.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.19. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + +/* 2.6.19 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ + diff --git a/compat-2.6.19.h b/compat-2.6.19.h new file mode 100644 index 00000000..79673904 --- /dev/null +++ b/compat-2.6.19.h @@ -0,0 +1,12 @@ +#ifndef LINUX_26_19_COMPAT_H +#define LINUX_26_19_COMPAT_H + +#include +#include + +/* Compat work for 2.6.19 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */ + +#endif /* LINUX_26_19_COMPAT_H */ diff --git a/compat.h b/compat.h index 433840c8..f835aefc 100644 --- a/compat.h +++ b/compat.h @@ -11,6 +11,7 @@ #include "compat-2.6.14.h" #include "compat-2.6.18.h" +#include "compat-2.6.19.h" #include "compat-2.6.22.h" #include "compat-2.6.23.h" #include "compat-2.6.24.h" -- cgit v1.2.3 From 305d186c7300dd7894db6a6749775d7ee31a019a Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:24:42 -0500 Subject: Add compatibility call for kmem_cache_destroy() On commit 133d205a, kmem_cache_destroy() was made returning void, while older kernel could return an error value. Signed-off-by: Arnaud Lacombe --- compat-2.6.19.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compat-2.6.19.h b/compat-2.6.19.h index 79673904..017044cf 100644 --- a/compat-2.6.19.h +++ b/compat-2.6.19.h @@ -7,6 +7,19 @@ /* Compat work for 2.6.19 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) +#include + +static inline int +compat_kmem_cache_destroy(struct kmem_cache *cachep) +{ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + return kmem_cache_destroy(cachep); +#else + kmem_cache_destroy(cachep); + return 0; +#endif +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */ #endif /* LINUX_26_19_COMPAT_H */ -- cgit v1.2.3 From 80de9db19b5e4b732a11a06b8441213ca46304a9 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:24:31 -0500 Subject: Add skeleton for 2.6.21 Signed-off-by: Arnaud Lacombe --- Makefile | 1 + compat-2.6.21.c | 18 ++++++++++++++++++ compat-2.6.21.h | 12 ++++++++++++ compat.h | 1 + 4 files changed, 32 insertions(+) create mode 100644 compat-2.6.21.c create mode 100644 compat-2.6.21.h diff --git a/Makefile b/Makefile index 3f1a4add..16775896 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ compat-y += main.o compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o +compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o diff --git a/compat-2.6.21.c b/compat-2.6.21.c new file mode 100644 index 00000000..e2737fb2 --- /dev/null +++ b/compat-2.6.21.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.21. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + +/* 2.6.21 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ + diff --git a/compat-2.6.21.h b/compat-2.6.21.h new file mode 100644 index 00000000..c185cfb0 --- /dev/null +++ b/compat-2.6.21.h @@ -0,0 +1,12 @@ +#ifndef LINUX_26_21_COMPAT_H +#define LINUX_26_21_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) */ + +#endif /* LINUX_26_21_COMPAT_H */ diff --git a/compat.h b/compat.h index f835aefc..ceedc471 100644 --- a/compat.h +++ b/compat.h @@ -12,6 +12,7 @@ #include "compat-2.6.14.h" #include "compat-2.6.18.h" #include "compat-2.6.19.h" +#include "compat-2.6.21.h" #include "compat-2.6.22.h" #include "compat-2.6.23.h" #include "compat-2.6.24.h" -- cgit v1.2.3 From 117d4c91d3eda5b8a1f11a4f8d61ed27f2da18b2 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 23 Nov 2009 21:25:09 -0500 Subject: Add compatibility macro for register_sysctl_table() The API was changed on commit 0b4d4147. register_sysctl_table() lost its last argument. Signed-off-by: Arnaud Lacombe --- compat-2.6.21.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compat-2.6.21.h b/compat-2.6.21.h index c185cfb0..263ebd2f 100644 --- a/compat-2.6.21.h +++ b/compat-2.6.21.h @@ -7,6 +7,13 @@ /* Compat work for 2.6.21 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) +#include + +#define register_sysctl_table(table) \ + ({ \ + register_sysctl_table((table), 0); \ + }) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) */ #endif /* LINUX_26_21_COMPAT_H */ -- cgit v1.2.3 From f09c783cbe244678b683389656da9a0a6e7c6a93 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 1 Dec 2009 03:38:17 -0500 Subject: Add posix SHUT_RD/SHUT_WR/SHUT_RDWR macros Added on commit 91cf45f0 by Trond Myklebust in include/linux/net.h. Signed-off-by: Arnaud Lacombe --- compat-2.6.24.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compat-2.6.24.h b/compat-2.6.24.h index d8f7c2ca..68d33c76 100644 --- a/compat-2.6.24.h +++ b/compat-2.6.24.h @@ -10,6 +10,13 @@ /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; +/* From include/linux/net.h */ +enum sock_shutdown_cmd { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2, +}; + #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */ /* Added as of 2.6.24 in include/linux/skbuff.h. * -- cgit v1.2.3 From ca7993599cd0fdf74604849f7045d4aa707da8b0 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 1 Dec 2009 03:38:18 -0500 Subject: Add compatibility call for dev_get_stats() Added on commit eeda3fd6 by Stephen Hemminger in include/linux/netdevice.h. Signed-off-by: Arnaud Lacombe --- compat-2.6.29.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/compat-2.6.29.h b/compat-2.6.29.h index ff97b37b..cad5e6b4 100644 --- a/compat-2.6.29.h +++ b/compat-2.6.29.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) +#include #include #include @@ -40,6 +41,12 @@ static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list, return skb->prev; } + +static inline struct net_device_stats *dev_get_stats(struct net_device *dev) +{ + return dev->get_stats(dev); +} + extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); #define DIV_ROUND_CLOSEST(x, divisor)( \ -- cgit v1.2.3 From 5593be4418689cc3278003e698848400c42b3e79 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 1 Dec 2009 03:38:19 -0500 Subject: Add more `skb->dst' accessors Signed-off-by: Arnaud Lacombe --- compat-2.6.31.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/compat-2.6.31.h b/compat-2.6.31.h index a91e0333..6b2dd5ef 100644 --- a/compat-2.6.31.h +++ b/compat-2.6.31.h @@ -99,6 +99,21 @@ static inline void skb_dst_drop(struct sk_buff *skb) skb->dst = NULL; } +static inline struct dst_entry *skb_dst(const struct sk_buff *skb) +{ + return (struct dst_entry *)skb->dst; +} + +static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) +{ + skb->dst = (unsigned long)dst; +} + +static inline struct rtable *skb_rtable(const struct sk_buff *skb) +{ + return (struct rtable *)skb_dst(skb); +} + extern int genl_register_family_with_ops(struct genl_family *family, struct genl_ops *ops, size_t n_ops); -- cgit v1.2.3 From e69e797191283aa9c1dbed17d18b0063e59d8899 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 1 Dec 2009 03:38:20 -0500 Subject: Add `enum nf_inet_hooks' Introduced on commit 6e23ae2a by Patrick McHardy in include/linux/netfilter.h in order to factor common macro value used by IPv6 and IPv4 code. Signed-off-by: Arnaud Lacombe --- compat-2.6.25.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compat-2.6.25.h b/compat-2.6.25.h index 5502741a..fa42fd95 100644 --- a/compat-2.6.25.h +++ b/compat-2.6.25.h @@ -29,6 +29,15 @@ extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct #define seq_file_net &init_net; +enum nf_inet_hooks { + NF_INET_PRE_ROUTING = 0, + NF_INET_LOCAL_IN = 1, + NF_INET_FORWARD = 2, + NF_INET_LOCAL_OUT = 3, + NF_INET_POST_ROUTING = 4, + NF_INET_NUMHOOKS = 5 +}; + /* The patch: * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865 * Author: Marcin Slusarz -- cgit v1.2.3 From ee18b8562960aead93e3fb546449c32cd795f69e Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 1 Dec 2009 03:38:21 -0500 Subject: Trailing space nits Signed-off-by: Arnaud Lacombe --- Makefile | 4 ++-- compat-2.6.23.c | 6 +++--- compat-2.6.23.h | 2 +- compat-2.6.24.h | 2 +- compat-2.6.25.c | 2 +- compat-2.6.25.h | 2 +- compat-2.6.26.h | 16 ++++++++-------- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 16775896..d2c08d10 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,8 @@ compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o -modules: - $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules +modules: + $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules install: modules $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \ modules_install diff --git a/compat-2.6.23.c b/compat-2.6.23.c index 9845b82d..d232b1aa 100644 --- a/compat-2.6.23.c +++ b/compat-2.6.23.c @@ -14,7 +14,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. - * Since da->da_synced is not part of 2.6.22 we need to take longer route when + * Since da->da_synced is not part of 2.6.22 we need to take longer route when * syncing */ /** @@ -70,8 +70,8 @@ int dev_mc_sync(struct net_device *to, struct net_device *from) EXPORT_SYMBOL(dev_mc_sync); -/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. - * Since da->da_synced is not part of 2.6.22 we need to take longer route when +/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. + * Since da->da_synced is not part of 2.6.22 we need to take longer route when * unsyncing */ /** diff --git a/compat-2.6.23.h b/compat-2.6.23.h index 5eb6dbf2..c36f90d4 100644 --- a/compat-2.6.23.h +++ b/compat-2.6.23.h @@ -70,7 +70,7 @@ static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) #define da_users dmi_users #define da_gusers dmi_gusers -/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and +/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and * dev_set_promiscuity() became a wrapper. */ #define __dev_set_promiscuity dev_set_promiscuity diff --git a/compat-2.6.24.h b/compat-2.6.24.h index 68d33c76..43e63022 100644 --- a/compat-2.6.24.h +++ b/compat-2.6.24.h @@ -148,7 +148,7 @@ struct header_ops { unsigned char *haddr); }; -/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on +/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore * the debug stuff. Note that adding this required changes to the struct * scatterlist on include/asm/scatterlist*, so the right way to port this diff --git a/compat-2.6.25.c b/compat-2.6.25.c index e39971a5..e872447a 100644 --- a/compat-2.6.25.c +++ b/compat-2.6.25.c @@ -15,7 +15,7 @@ /* Backport work for QoS dependencies (kernel/pm_qos_params.c) * ipw2100 now makes use of - * pm_qos_add_requirement(), + * pm_qos_add_requirement(), * pm_qos_update_requirement() and * pm_qos_remove_requirement() from it * diff --git a/compat-2.6.25.h b/compat-2.6.25.h index fa42fd95..23cf4876 100644 --- a/compat-2.6.25.h +++ b/compat-2.6.25.h @@ -82,7 +82,7 @@ static inline void be64_add_cpu(__be64 *var, u64 val) *var = cpu_to_be64(v + val); } -/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting +/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting * suspend of its parent device (the misc device, which is itself the * hardware random number generator). It does this by passing a parameter to * unregister_miscdev() which is not supported in older kernels. The suspend diff --git a/compat-2.6.26.h b/compat-2.6.26.h index 7f1a9f19..b7c3b057 100644 --- a/compat-2.6.26.h +++ b/compat-2.6.26.h @@ -88,19 +88,19 @@ static inline const char *dev_name(struct device *dev) return dev->bus_id; } -/* This is from include/linux/kernel.h, which was added as of 2.6.26 */ +/* This is from include/linux/kernel.h, which was added as of 2.6.26 */ /** * clamp_val - return a value clamped to a given range using val's type * @val: current value * @min: minimum allowable value * @max: maximum allowable value - * + * * This macro does no typechecking and uses temporary variables of whatever * type the input argument 'val' is. This is useful when val is an unsigned * type and min and max are literals that will otherwise be assigned a signed * integer type. - */ + */ #define clamp_val(val, min, max) ({ \ typeof(val) __val = (val); \ @@ -193,10 +193,10 @@ struct net *dev_net(const struct net_device *dev) * implementation. The AVR32 AP implementation can handle unaligned * words, but halfwords must be halfword-aligned, and doublewords must * be word-aligned. - * + * * However, swapped word loads must be word-aligned so we can't * optimize word loads in general. - */ + */ #include #include @@ -213,7 +213,7 @@ struct net *dev_net(const struct net_device *dev) #ifdef CONFIG_CRIS /* - * CRIS can do unaligned accesses itself. + * CRIS can do unaligned accesses itself. */ #include #include @@ -300,7 +300,7 @@ struct net *dev_net(const struct net_device *dev) #ifdef CONFIG_PPC /* * The PowerPC can do unaligned accesses itself in big endian mode. - */ + */ #include #include @@ -308,7 +308,7 @@ struct net *dev_net(const struct net_device *dev) #ifdef CONFIG_S390 /* - * The S390 can do unaligned accesses itself. + * The S390 can do unaligned accesses itself. */ #include #include -- cgit v1.2.3 From 34492988d48c39b3f35b6404e43669474ec92421 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 10:20:55 -0800 Subject: Update based on newer stuff on compat-wireless Sorry for the large change-in-one to on this commit but this won't happen often, this is just the final step to start making use of compat.ko on compat-wireless. Signed-off-by: Luis R. Rodriguez --- compat-2.6.28.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ compat-2.6.28.h | 27 ++++++++++++++++++ compat-2.6.30.h | 9 ++++++ compat-2.6.31.h | 3 +- compat-2.6.32.h | 26 ++++++++++++++++++ 5 files changed, 149 insertions(+), 1 deletion(-) diff --git a/compat-2.6.28.c b/compat-2.6.28.c index 4b3ea21a..a8dfcbb9 100644 --- a/compat-2.6.28.c +++ b/compat-2.6.28.c @@ -84,6 +84,81 @@ void usb_poison_urb(struct urb *urb) EXPORT_SYMBOL_GPL(usb_poison_urb); #endif +#include +struct pcmcia_cfg_mem { + tuple_t tuple; + cisparse_t parse; + u8 buf[256]; + cistpl_cftable_entry_t dflt; +}; +/** + * pcmcia_loop_config() - loop over configuration options + * @p_dev: the struct pcmcia_device which we need to loop for. + * @conf_check: function to call for each configuration option. + * It gets passed the struct pcmcia_device, the CIS data + * describing the configuration option, and private data + * being passed to pcmcia_loop_config() + * @priv_data: private data to be passed to the conf_check function. + * + * pcmcia_loop_config() loops over all configuration options, and calls + * the driver-specific conf_check() for each one, checking whether + * it is a valid one. Returns 0 on success or errorcode otherwise. + */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + unsigned int vcc, + void *priv_data), + void *priv_data) +{ + struct pcmcia_cfg_mem *cfg_mem; + + tuple_t *tuple; + int ret; + unsigned int vcc; + + cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); + if (cfg_mem == NULL) + return -ENOMEM; + + /* get the current Vcc setting */ + vcc = p_dev->socket->socket.Vcc; + + tuple = &cfg_mem->tuple; + tuple->TupleData = cfg_mem->buf; + tuple->TupleDataMax = 255; + tuple->TupleOffset = 0; + tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; + tuple->Attributes = 0; + + ret = pcmcia_get_first_tuple(p_dev, tuple); + while (!ret) { + cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry; + + if (pcmcia_get_tuple_data(p_dev, tuple)) + goto next_entry; + + if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) + goto next_entry; + + /* default values */ + p_dev->conf.ConfigIndex = cfg->index; + if (cfg->flags & CISTPL_CFTABLE_DEFAULT) + cfg_mem->dflt = *cfg; + + ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); + if (!ret) + break; + +next_entry: + ret = pcmcia_get_next_tuple(p_dev, tuple); + } + + return ret; +} +EXPORT_SYMBOL(pcmcia_loop_config); + void usb_unpoison_urb(struct urb *urb) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) @@ -275,4 +350,14 @@ unsigned long round_jiffies_up(unsigned long j) } EXPORT_SYMBOL_GPL(round_jiffies_up); +void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, + int size) +{ + skb_fill_page_desc(skb, i, page, off, size); + skb->len += size; + skb->data_len += size; + skb->truesize += size; +} +EXPORT_SYMBOL(skb_add_rx_frag); + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/compat-2.6.28.h b/compat-2.6.28.h index 69ddae6a..8f90edc6 100644 --- a/compat-2.6.28.h +++ b/compat-2.6.28.h @@ -36,6 +36,16 @@ #define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse) #endif +/* From : include/pcmcia/ds.h */ +/* loop CIS entries for valid configuration */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + unsigned int vcc, + void *priv_data), + void *priv_data); + #if 0 extern void usb_poison_urb(struct urb *urb); #endif @@ -145,6 +155,20 @@ static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, } } /* From include/linux/skbuff.h */ +/** + * skb_queue_splice_tail - join two skb lists, each list being a queue + * @list: the new list to add + * @head: the place to add it in the first list + */ +static inline void skb_queue_splice_tail(const struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, head->prev, (struct sk_buff *) head); + head->qlen += list->qlen; + } +} + #ifndef DECLARE_TRACE #define TP_PROTO(args...) args @@ -177,6 +201,9 @@ static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, unsigned long round_jiffies_up(unsigned long j); +extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, + int off, int size); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ diff --git a/compat-2.6.30.h b/compat-2.6.30.h index fe3233c2..2ff1d691 100644 --- a/compat-2.6.30.h +++ b/compat-2.6.30.h @@ -15,6 +15,15 @@ #define IRQ_WAKE_THREAD (2) +/* From : include/linux/pm.h */ +/* How to reorder dpm_list after device_move() */ +enum dpm_order { + DPM_ORDER_NONE, + DPM_ORDER_DEV_AFTER_PARENT, + DPM_ORDER_PARENT_BEFORE_DEV, + DPM_ORDER_DEV_LAST, +}; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ #endif /* LINUX_26_30_COMPAT_H */ diff --git a/compat-2.6.31.h b/compat-2.6.31.h index 6b2dd5ef..27dc6a1d 100644 --- a/compat-2.6.31.h +++ b/compat-2.6.31.h @@ -11,6 +11,7 @@ #include #include #include +#include /* * These macros allow us to backport rfkill without any @@ -106,7 +107,7 @@ static inline struct dst_entry *skb_dst(const struct sk_buff *skb) static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) { - skb->dst = (unsigned long)dst; + skb->dst = dst; } static inline struct rtable *skb_rtable(const struct sk_buff *skb) diff --git a/compat-2.6.32.h b/compat-2.6.32.h index cef18998..3e8725a1 100644 --- a/compat-2.6.32.h +++ b/compat-2.6.32.h @@ -43,8 +43,34 @@ enum netdev_tx { typedef enum netdev_tx netdev_tx_t; #endif /* __KERNEL__ */ +/* + * dev_pm_ops is only available on kernels >= 2.6.29, for + * older kernels we rely on reverting the work to old + * power management style stuff. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) +/* + * Use this if you want to use the same suspend and resume callbacks for suspend + * to RAM and hibernation. + */ +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ +struct dev_pm_ops name = { \ + .suspend = suspend_fn, \ + .resume = resume_fn, \ + .freeze = suspend_fn, \ + .thaw = resume_fn, \ + .poweroff = suspend_fn, \ + .restore = resume_fn, \ +} +#else +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) +#endif /* >= 2.6.29 */ + #define wireless_send_event(a, b, c, d) wireless_send_event(a, b, c, (char * ) d) +/* The export symbol in changed in compat/patches/15-symbol-export-conflicts.patch */ +#define ieee80211_rx(hw, skb) mac80211_ieee80211_rx(hw, skb) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ #endif /* LINUX_26_32_COMPAT_H */ -- cgit v1.2.3 From ca2d92df5649c3233ccf5bb3f92d621e461728db Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 13:38:29 -0800 Subject: Rearrange module order for easy placement on external builds You will typically cp -a compat/ to your own build and then cp include/linux/*.h to your own header space on your build as well. Provided on this Makefile is also a hack to let you use include/linux without having to add or mucking the user's header files or directory. Example compat autoconf is also provided. Signed-off-by: Luis R. Rodriguez --- Makefile | 27 +-- compat-2.6.14.c | 18 -- compat-2.6.14.h | 14 -- compat-2.6.18.c | 18 -- compat-2.6.18.h | 14 -- compat-2.6.19.c | 18 -- compat-2.6.19.h | 25 --- compat-2.6.21.c | 18 -- compat-2.6.21.h | 19 -- compat-2.6.22.c | 18 -- compat-2.6.22.h | 105 ----------- compat-2.6.23.c | 185 -------------------- compat-2.6.23.h | 136 --------------- compat-2.6.24.c | 237 ------------------------- compat-2.6.24.h | 202 --------------------- compat-2.6.25.c | 378 ---------------------------------------- compat-2.6.25.h | 112 ------------ compat-2.6.26.c | 69 -------- compat-2.6.26.h | 377 --------------------------------------- compat-2.6.27.c | 207 ---------------------- compat-2.6.27.h | 183 ------------------- compat-2.6.28.c | 363 -------------------------------------- compat-2.6.28.h | 209 ---------------------- compat-2.6.29.c | 40 ----- compat-2.6.29.h | 61 ------- compat-2.6.30.c | 18 -- compat-2.6.30.h | 29 --- compat-2.6.31.c | 64 ------- compat-2.6.31.h | 198 --------------------- compat-2.6.32.c | 124 ------------- compat-2.6.32.h | 76 -------- compat.h | 28 --- compat/Makefile | 21 +++ compat/compat-2.6.14.c | 18 ++ compat/compat-2.6.18.c | 18 ++ compat/compat-2.6.19.c | 18 ++ compat/compat-2.6.21.c | 18 ++ compat/compat-2.6.22.c | 18 ++ compat/compat-2.6.23.c | 185 ++++++++++++++++++++ compat/compat-2.6.24.c | 237 +++++++++++++++++++++++++ compat/compat-2.6.25.c | 378 ++++++++++++++++++++++++++++++++++++++++ compat/compat-2.6.26.c | 69 ++++++++ compat/compat-2.6.27.c | 207 ++++++++++++++++++++++ compat/compat-2.6.28.c | 363 ++++++++++++++++++++++++++++++++++++++ compat/compat-2.6.29.c | 40 +++++ compat/compat-2.6.30.c | 18 ++ compat/compat-2.6.31.c | 64 +++++++ compat/compat-2.6.32.c | 124 +++++++++++++ compat/main.c | 18 ++ include/linux/compat-2.6.14.h | 14 ++ include/linux/compat-2.6.18.h | 14 ++ include/linux/compat-2.6.19.h | 25 +++ include/linux/compat-2.6.21.h | 19 ++ include/linux/compat-2.6.22.h | 105 +++++++++++ include/linux/compat-2.6.23.h | 136 +++++++++++++++ include/linux/compat-2.6.24.h | 202 +++++++++++++++++++++ include/linux/compat-2.6.25.h | 112 ++++++++++++ include/linux/compat-2.6.26.h | 377 +++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.27.h | 183 +++++++++++++++++++ include/linux/compat-2.6.28.h | 209 ++++++++++++++++++++++ include/linux/compat-2.6.29.h | 61 +++++++ include/linux/compat-2.6.30.h | 29 +++ include/linux/compat-2.6.31.h | 198 +++++++++++++++++++++ include/linux/compat-2.6.32.h | 76 ++++++++ include/linux/compat-2.6.33.h | 15 ++ include/linux/compat.h | 26 +++ include/linux/compat_autoconf.h | 37 ++++ main.c | 18 -- 68 files changed, 3659 insertions(+), 3601 deletions(-) delete mode 100644 compat-2.6.14.c delete mode 100644 compat-2.6.14.h delete mode 100644 compat-2.6.18.c delete mode 100644 compat-2.6.18.h delete mode 100644 compat-2.6.19.c delete mode 100644 compat-2.6.19.h delete mode 100644 compat-2.6.21.c delete mode 100644 compat-2.6.21.h delete mode 100644 compat-2.6.22.c delete mode 100644 compat-2.6.22.h delete mode 100644 compat-2.6.23.c delete mode 100644 compat-2.6.23.h delete mode 100644 compat-2.6.24.c delete mode 100644 compat-2.6.24.h delete mode 100644 compat-2.6.25.c delete mode 100644 compat-2.6.25.h delete mode 100644 compat-2.6.26.c delete mode 100644 compat-2.6.26.h delete mode 100644 compat-2.6.27.c delete mode 100644 compat-2.6.27.h delete mode 100644 compat-2.6.28.c delete mode 100644 compat-2.6.28.h delete mode 100644 compat-2.6.29.c delete mode 100644 compat-2.6.29.h delete mode 100644 compat-2.6.30.c delete mode 100644 compat-2.6.30.h delete mode 100644 compat-2.6.31.c delete mode 100644 compat-2.6.31.h delete mode 100644 compat-2.6.32.c delete mode 100644 compat-2.6.32.h delete mode 100644 compat.h create mode 100644 compat/Makefile create mode 100644 compat/compat-2.6.14.c create mode 100644 compat/compat-2.6.18.c create mode 100644 compat/compat-2.6.19.c create mode 100644 compat/compat-2.6.21.c create mode 100644 compat/compat-2.6.22.c create mode 100644 compat/compat-2.6.23.c create mode 100644 compat/compat-2.6.24.c create mode 100644 compat/compat-2.6.25.c create mode 100644 compat/compat-2.6.26.c create mode 100644 compat/compat-2.6.27.c create mode 100644 compat/compat-2.6.28.c create mode 100644 compat/compat-2.6.29.c create mode 100644 compat/compat-2.6.30.c create mode 100644 compat/compat-2.6.31.c create mode 100644 compat/compat-2.6.32.c create mode 100644 compat/main.c create mode 100644 include/linux/compat-2.6.14.h create mode 100644 include/linux/compat-2.6.18.h create mode 100644 include/linux/compat-2.6.19.h create mode 100644 include/linux/compat-2.6.21.h create mode 100644 include/linux/compat-2.6.22.h create mode 100644 include/linux/compat-2.6.23.h create mode 100644 include/linux/compat-2.6.24.h create mode 100644 include/linux/compat-2.6.25.h create mode 100644 include/linux/compat-2.6.26.h create mode 100644 include/linux/compat-2.6.27.h create mode 100644 include/linux/compat-2.6.28.h create mode 100644 include/linux/compat-2.6.29.h create mode 100644 include/linux/compat-2.6.30.h create mode 100644 include/linux/compat-2.6.31.h create mode 100644 include/linux/compat-2.6.32.h create mode 100644 include/linux/compat-2.6.33.h create mode 100644 include/linux/compat.h create mode 100644 include/linux/compat_autoconf.h delete mode 100644 main.c diff --git a/Makefile b/Makefile index d2c08d10..0433a14d 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,8 @@ export KLIB_BUILD ?= $(KLIB)/build export PWD := $(shell pwd) +# This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for +# each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) COMPAT_LATEST_VERSION = 32 KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') @@ -16,27 +18,12 @@ COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNE $(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_$(ver)=y)) endif -obj-m += compat.o -#compat-objs := +obj-y += compat/ -compat-y += main.o - -# Compat kernel compatibility code -compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o -compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o -compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o -compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o -compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o -compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o -compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o -compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o -compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o -compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o -compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o -compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o -compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o -compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o -compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o +# This hack lets us put our include path first than the kernel's +# when building our compat modules. Your own makefile would look +# the same. +NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat.h $(CFLAGS) modules: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules diff --git a/compat-2.6.14.c b/compat-2.6.14.c deleted file mode 100644 index e0af181f..00000000 --- a/compat-2.6.14.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.14. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) - -/* 2.6.14 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) */ - diff --git a/compat-2.6.14.h b/compat-2.6.14.h deleted file mode 100644 index 22e7e319..00000000 --- a/compat-2.6.14.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LINUX_26_14_COMPAT_H -#define LINUX_26_14_COMPAT_H - -#include -#include - -/* Compat work for 2.6.14 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) - -typedef unsigned int gfp_t; - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) */ - -#endif /* LINUX_26_14_COMPAT_H */ diff --git a/compat-2.6.18.c b/compat-2.6.18.c deleted file mode 100644 index c7fb2e41..00000000 --- a/compat-2.6.18.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.18. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) - -/* 2.6.18 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ - diff --git a/compat-2.6.18.h b/compat-2.6.18.h deleted file mode 100644 index 3245c42c..00000000 --- a/compat-2.6.18.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef LINUX_26_18_COMPAT_H -#define LINUX_26_18_COMPAT_H - -#include -#include - -/* Compat work for 2.6.18 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) - -#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */ - -#endif /* LINUX_26_18_COMPAT_H */ diff --git a/compat-2.6.19.c b/compat-2.6.19.c deleted file mode 100644 index fc75b64d..00000000 --- a/compat-2.6.19.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.19. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) - -/* 2.6.19 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ - diff --git a/compat-2.6.19.h b/compat-2.6.19.h deleted file mode 100644 index 017044cf..00000000 --- a/compat-2.6.19.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef LINUX_26_19_COMPAT_H -#define LINUX_26_19_COMPAT_H - -#include -#include - -/* Compat work for 2.6.19 */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) - -#include - -static inline int -compat_kmem_cache_destroy(struct kmem_cache *cachep) -{ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) - return kmem_cache_destroy(cachep); -#else - kmem_cache_destroy(cachep); - return 0; -#endif -} - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */ - -#endif /* LINUX_26_19_COMPAT_H */ diff --git a/compat-2.6.21.c b/compat-2.6.21.c deleted file mode 100644 index e2737fb2..00000000 --- a/compat-2.6.21.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.21. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) - -/* 2.6.21 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ - diff --git a/compat-2.6.21.h b/compat-2.6.21.h deleted file mode 100644 index 263ebd2f..00000000 --- a/compat-2.6.21.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef LINUX_26_21_COMPAT_H -#define LINUX_26_21_COMPAT_H - -#include -#include - -/* Compat work for 2.6.21 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) - -#include - -#define register_sysctl_table(table) \ - ({ \ - register_sysctl_table((table), 0); \ - }) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) */ - -#endif /* LINUX_26_21_COMPAT_H */ diff --git a/compat-2.6.22.c b/compat-2.6.22.c deleted file mode 100644 index b1ff1f3b..00000000 --- a/compat-2.6.22.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.22. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) - -/* 2.6.22 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ - diff --git a/compat-2.6.22.h b/compat-2.6.22.h deleted file mode 100644 index 85cd9d56..00000000 --- a/compat-2.6.22.h +++ /dev/null @@ -1,105 +0,0 @@ -#ifndef LINUX_26_22_COMPAT_H -#define LINUX_26_22_COMPAT_H - -#include -#include - -/* Compat work for 2.6.21 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) - -#include -#include - -/* reuse ax25_ptr */ -#define ieee80211_ptr ax25_ptr - -#ifdef CONFIG_AX25 -#error Compat reuses the AX.25 pointer so that may not be enabled! -#endif - -static inline unsigned char *skb_mac_header(const struct sk_buff *skb) -{ - return skb->mac.raw; -} - -static inline void skb_set_mac_header(struct sk_buff *skb, int offset) -{ - skb->mac.raw = skb->data + offset; -} - -static inline void skb_reset_mac_header(struct sk_buff *skb) -{ - skb->mac.raw = skb->data; -} - -static inline void skb_reset_network_header(struct sk_buff *skb) -{ - skb->nh.raw = skb->data; -} - -static inline void skb_set_network_header(struct sk_buff *skb, int offset) -{ - skb->nh.raw = skb->data + offset; -} - -static inline void skb_set_transport_header(struct sk_buff *skb, int offset) -{ - skb->h.raw = skb->data + offset; -} - -static inline unsigned char *skb_transport_header(struct sk_buff *skb) -{ - return skb->h.raw; -} - -static inline unsigned char *skb_network_header(const struct sk_buff *skb) -{ - return skb->nh.raw; -} - -static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) -{ - return skb->tail; -} - -static inline struct iphdr *ip_hdr(const struct sk_buff *skb) -{ - return (struct iphdr *)skb_network_header(skb); -} - -static inline void skb_copy_from_linear_data(const struct sk_buff *skb, - void *to, - const unsigned int len) -{ - memcpy(to, skb->data, len); -} - -static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, - const int offset, void *to, - const unsigned int len) -{ - memcpy(to, skb->data + offset, len); -} - -#define __maybe_unused __attribute__((unused)) - -#define uninitialized_var(x) x = x - -/* This will lead to very weird behaviour... */ -#define NLA_BINARY NLA_STRING - -static inline int pci_set_mwi(struct pci_dev *dev) -{ - return -ENOSYS; -} - -static inline void pci_clear_mwi(struct pci_dev *dev) -{ -} - -#define list_first_entry(ptr, type, member) \ - list_entry((ptr)->next, type, member) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) */ - -#endif /* LINUX_26_22_COMPAT_H */ diff --git a/compat-2.6.23.c b/compat-2.6.23.c deleted file mode 100644 index d232b1aa..00000000 --- a/compat-2.6.23.c +++ /dev/null @@ -1,185 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.23. - */ - -#include - -/* All things not in 2.6.22 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) - -/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. - * Since da->da_synced is not part of 2.6.22 we need to take longer route when - * syncing */ - -/** - * dev_mc_sync - Synchronize device's multicast list to another device - * @to: destination device - * @from: source device - * - * Add newly added addresses to the destination device and release - * addresses that have no users left. The source device must be - * locked by netif_tx_lock_bh. - * - * This function is intended to be called from the dev->set_multicast_list - * function of layered software devices. - */ -int dev_mc_sync(struct net_device *to, struct net_device *from) -{ - struct dev_addr_list *da, *next, *da_to; - int err = 0; - - netif_tx_lock_bh(to); - da = from->mc_list; - while (da != NULL) { - int synced = 0; - next = da->next; - da_to = to->mc_list; - /* 2.6.22 does not have da->da_synced so lets take the long route */ - while (da_to != NULL) { - if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && - da->da_addrlen == da_to->da_addrlen) - synced = 1; - break; - } - if (!synced) { - err = __dev_addr_add(&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen, 0); - if (err < 0) - break; - da->da_users++; - } else if (da->da_users == 1) { - __dev_addr_delete(&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } - if (!err) - __dev_set_rx_mode(to); - netif_tx_unlock_bh(to); - - return err; -} -EXPORT_SYMBOL(dev_mc_sync); - - -/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. - * Since da->da_synced is not part of 2.6.22 we need to take longer route when - * unsyncing */ - -/** - * dev_mc_unsync - Remove synchronized addresses from the destination - * device - * @to: destination device - * @from: source device - * - * Remove all addresses that were added to the destination device by - * dev_mc_sync(). This function is intended to be called from the - * dev->stop function of layered software devices. - */ -void dev_mc_unsync(struct net_device *to, struct net_device *from) -{ - struct dev_addr_list *da, *next, *da_to; - - netif_tx_lock_bh(from); - netif_tx_lock_bh(to); - - da = from->mc_list; - while (da != NULL) { - bool synced = false; - next = da->next; - da_to = to->mc_list; - /* 2.6.22 does not have da->da_synced so lets take the long route */ - while (da_to != NULL) { - if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && - da->da_addrlen == da_to->da_addrlen) - synced = true; - break; - } - if (!synced) { - da = next; - continue; - } - __dev_addr_delete(&to->mc_list, &to->mc_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(&from->mc_list, &from->mc_count, - da->da_addr, da->da_addrlen, 0); - da = next; - } - __dev_set_rx_mode(to); - - netif_tx_unlock_bh(to); - netif_tx_unlock_bh(from); -} -EXPORT_SYMBOL(dev_mc_unsync); - -/* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on - * 2.6.22 so ignore that. */ - -/* - * Upload unicast and multicast address lists to device and - * configure RX filtering. When the device doesn't support unicast - * filtering it is put in promiscous mode while unicast addresses - * are present. - */ -void __dev_set_rx_mode(struct net_device *dev) -{ - /* dev_open will call this function so the list will stay sane. */ - if (!(dev->flags&IFF_UP)) - return; - - if (!netif_device_present(dev)) - return; - -/* This needs to be ported to 2.6.22 framework */ -#if 0 - /* Unicast addresses changes may only happen under the rtnl, - * therefore calling __dev_set_promiscuity here is safe. - */ - if (dev->uc_count > 0 && !dev->uc_promisc) { - __dev_set_promiscuity(dev, 1); - dev->uc_promisc = 1; - } else if (dev->uc_count == 0 && dev->uc_promisc) { - __dev_set_promiscuity(dev, -1); - dev->uc_promisc = 0; - } -#endif - - if (dev->set_multicast_list) - dev->set_multicast_list(dev); -} - -#ifndef HAVE_PCI_SET_MWI -int pci_try_set_mwi(struct pci_dev *dev) -{ - return 0; -} -EXPORT_SYMBOL(pci_try_set_mwi); -#else - -/** - * pci_try_set_mwi - enables memory-write-invalidate PCI transaction - * @dev: the PCI device for which MWI is enabled - * - * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND. - * Callers are not required to check the return value. - * - * RETURNS: An appropriate -ERRNO error value on error, or zero for success. - */ -int pci_try_set_mwi(struct pci_dev *dev) -{ - int rc = pci_set_mwi(dev); - return rc; -} -EXPORT_SYMBOL(pci_try_set_mwi); -#endif - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ - diff --git a/compat-2.6.23.h b/compat-2.6.23.h deleted file mode 100644 index c36f90d4..00000000 --- a/compat-2.6.23.h +++ /dev/null @@ -1,136 +0,0 @@ -#ifndef LINUX_26_23_COMPAT_H -#define LINUX_26_23_COMPAT_H - -#include -#include - -/* Compat work for < 2.6.23 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) - -#include -#include -#include -#include - -/* - * Tell gcc if a function is cold. The compiler will assume any path - * directly leading to the call is unlikely. - */ - -#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3) -/* Mark functions as cold. gcc will assume any path leading to a call - * to them will be unlikely. This means a lot of manual unlikely()s - * are unnecessary now for any paths leading to the usual suspects - * like BUG(), printk(), panic() etc. [but let's keep them for now for - * older compilers] - * - * Early snapshots of gcc 4.3 don't support this and we can't detect this - * in the preprocessor, but we can live with this because they're unreleased. - * Maketime probing would be overkill here. - * - * gcc also has a __attribute__((__hot__)) to move hot functions into - * a special section, but I don't see any sense in this right now in - * the kernel context */ -#define __cold __attribute__((__cold__)) -#endif /* gcc 4.3 check */ - -#ifndef __cold -#define __cold -#endif - -/* Added as of 2.6.23 in include/linux/netdevice.h */ -#define alloc_netdev_mq(sizeof_priv, name, setup, queue) \ - alloc_netdev(sizeof_priv, name, setup) -#define NETIF_F_MULTI_QUEUE 16384 - -/* Added as of 2.6.23 on include/linux/netdevice.h */ -static inline int netif_is_multiqueue(const struct net_device *dev) -{ - return (!!(NETIF_F_MULTI_QUEUE & dev->features)); -} - -/* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */ -static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) -{ - struct tcf_proto *tp; - - while ((tp = *fl) != NULL) { - *fl = tp->next; - tp->ops->destroy(tp); - module_put(tp->ops->owner); - kfree(tp); - } -} - -/* dev_mc_list was replaced with dev_addr_list as of 2.6.23, - * only new member added is da_synced. */ -#define dev_addr_list dev_mc_list -#define da_addr dmi_addr -#define da_addrlen dmi_addrlen -#define da_users dmi_users -#define da_gusers dmi_gusers - -/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and - * dev_set_promiscuity() became a wrapper. */ -#define __dev_set_promiscuity dev_set_promiscuity - -/* Our own 2.6.22 port on compat.c */ -extern void dev_mc_unsync(struct net_device *to, struct net_device *from); -extern int dev_mc_sync(struct net_device *to, struct net_device *from); - -/* Our own 2.6.22 port on compat.c */ -extern void __dev_set_rx_mode(struct net_device *dev); - -/* Simple to add this */ -extern int cancel_delayed_work_sync(struct delayed_work *work); - -#define cancel_delayed_work_sync cancel_rearming_delayed_work - -#define debugfs_rename(a, b, c, d) 1 - -/* nl80211 requires multicast group support which is new and added on - * 2.6.23. We can't add support for it for older kernels to support it - * genl_family structure was changed. Lets just let through the - * genl_register_mc_group call. This means no multicast group suppport */ - -#define genl_register_mc_group(a, b) 0 - -/** - * struct genl_multicast_group - generic netlink multicast group - * @name: name of the multicast group, names are per-family - * @id: multicast group ID, assigned by the core, to use with - * genlmsg_multicast(). - * @list: list entry for linking - * @family: pointer to family, need not be set before registering - */ -struct genl_multicast_group -{ - struct genl_family *family; /* private */ - struct list_head list; /* private */ - char name[GENL_NAMSIZ]; - u32 id; -}; - - -/* Added as of 2.6.23 */ -int pci_try_set_mwi(struct pci_dev *dev); - -/* Added as of 2.6.23 */ -#ifdef CONFIG_PM_SLEEP -/* - * Tell the freezer that the current task should be frozen by it - */ -static inline void set_freezable(void) -{ - current->flags &= ~PF_NOFREEZE; -} - -#else -static inline void set_freezable(void) {} -#endif /* CONFIG_PM_SLEEP */ - -#else -#define tcf_destroy_chain_compat tcf_destroy_chain -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ - -#endif /* LINUX_26_23_COMPAT_H */ diff --git a/compat-2.6.24.c b/compat-2.6.24.c deleted file mode 100644 index 977eb45e..00000000 --- a/compat-2.6.24.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.24. - */ - -#include - -/* All things not in 2.6.22 and 2.6.23 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - -/* Part of net/ethernet/eth.c as of 2.6.24 */ -char *print_mac(char *buf, const u8 *addr) -{ - sprintf(buf, MAC_FMT, - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); - return buf; -} -EXPORT_SYMBOL(print_mac); - -/* On net/core/dev.c as of 2.6.24 */ -int __dev_addr_delete(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (; (da = *list) != NULL; list = &da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - alen == da->da_addrlen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 0; - if (old_glbl == 0) - break; - } - if (--da->da_users) - return 0; - - *list = da->next; - kfree(da); - (*count)--; - return 0; - } - } - return -ENOENT; -} - -/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but - * might as well add it */ -int __dev_addr_add(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (da = *list; da != NULL; da = da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - da->da_addrlen == alen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 1; - if (old_glbl) - return 0; - } - da->da_users++; - return 0; - } - } - - da = kmalloc(sizeof(*da), GFP_ATOMIC); - if (da == NULL) - return -ENOMEM; - memcpy(da->da_addr, addr, alen); - da->da_addrlen = alen; - da->da_users = 1; - da->da_gusers = glbl ? 1 : 0; - da->next = *list; - *list = da; - (*count)++; - return 0; -} - -/* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h - * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ - -/** - * eth_header_cache_update - update cache entry - * @hh: destination cache entry - * @dev: network device - * @haddr: new hardware address - * - * Called by Address Resolution module to notify changes in address. - */ -void eth_header_cache_update(struct hh_cache *hh, - struct net_device *dev, - unsigned char *haddr) -{ - memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), - haddr, ETH_ALEN); -} -EXPORT_SYMBOL(eth_header_cache_update); - -/* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h - * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ - -/** - * eth_header_cache - fill cache entry from neighbour - * @neigh: source neighbour - * @hh: destination cache entry - * Create an Ethernet header template from the neighbour. - */ -int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) -{ - __be16 type = hh->hh_type; - struct ethhdr *eth; - const struct net_device *dev = neigh->dev; - - eth = (struct ethhdr *) - (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); - - if (type == htons(ETH_P_802_3)) - return -1; - - eth->h_proto = type; - memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); - memcpy(eth->h_dest, neigh->ha, ETH_ALEN); - hh->hh_len = ETH_HLEN; - return 0; -} -EXPORT_SYMBOL(eth_header_cache); - -/* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h - * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ - -/** - * eth_header - create the Ethernet header - * @skb: buffer to alter - * @dev: source device - * @type: Ethernet type field - * @daddr: destination address (NULL leave destination address) - * @saddr: source address (NULL use device source address) - * @len: packet length (<= skb->len) - * - * - * Set the protocol type. For a packet of type ETH_P_802_3 we put the length - * in here instead. It is up to the 802.2 layer to carry protocol information. - */ -int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, - void *daddr, void *saddr, unsigned len) -{ - struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); - - if (type != ETH_P_802_3) - eth->h_proto = htons(type); - else - eth->h_proto = htons(len); - - /* - * Set the source hardware address. - */ - - if (!saddr) - saddr = dev->dev_addr; - memcpy(eth->h_source, saddr, dev->addr_len); - - if (daddr) { - memcpy(eth->h_dest, daddr, dev->addr_len); - return ETH_HLEN; - } - - /* - * Anyway, the loopback-device should never use this function... - */ - - if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) { - memset(eth->h_dest, 0, dev->addr_len); - return ETH_HLEN; - } - - return -ETH_HLEN; -} - -EXPORT_SYMBOL(eth_header); - -/* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h - * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ - -/** - * eth_rebuild_header- rebuild the Ethernet MAC header. - * @skb: socket buffer to update - * - * This is called after an ARP or IPV6 ndisc it's resolution on this - * sk_buff. We now let protocol (ARP) fill in the other fields. - * - * This routine CANNOT use cached dst->neigh! - * Really, it is used only when dst->neigh is wrong. - */ -int eth_rebuild_header(struct sk_buff *skb) -{ - struct ethhdr *eth = (struct ethhdr *)skb->data; - struct net_device *dev = skb->dev; - - switch (eth->h_proto) { -#ifdef CONFIG_INET - case __constant_htons(ETH_P_IP): - return arp_find(eth->h_dest, skb); -#endif - default: - printk(KERN_DEBUG - "%s: unable to resolve type %X addresses.\n", - dev->name, (int)eth->h_proto); - - memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); - break; - } - - return 0; -} -EXPORT_SYMBOL(eth_rebuild_header); - -/* 2.6.24 will introduce struct pci_dev is_pcie bit. To help - * with the compatibility code (compat.diff) being smaller, we provide a helper - * so in cases where that will be used we can simply slap ifdefs with this - * routine. Use compat_ prefex to not pollute namespace. */ -int compat_is_pcie(struct pci_dev *pdev) -{ - int cap; - cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); - return cap ? 1 : 0; -} -EXPORT_SYMBOL(compat_is_pcie); - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) */ - diff --git a/compat-2.6.24.h b/compat-2.6.24.h deleted file mode 100644 index 43e63022..00000000 --- a/compat-2.6.24.h +++ /dev/null @@ -1,202 +0,0 @@ -#ifndef LINUX_26_24_COMPAT_H -#define LINUX_26_24_COMPAT_H - -#include -#include - -/* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - -/* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ -typedef unsigned long uintptr_t; - -/* From include/linux/net.h */ -enum sock_shutdown_cmd { - SHUT_RD = 0, - SHUT_WR = 1, - SHUT_RDWR = 2, -}; - -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */ -/* Added as of 2.6.24 in include/linux/skbuff.h. - * - * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE - * this helper was not added until 2.6.24. This implementation - * is exactly as it is on newer kernels. - * - * For older kernels we use the an internal mac80211 hack. - * For details see changes to include/net/mac80211.h through - * compat.diff and compat/mq_compat.h */ -static inline u16 skb_get_queue_mapping(struct sk_buff *skb) -{ -#ifdef CONFIG_NETDEVICES_MULTIQUEUE - return skb->queue_mapping; -#else - return 0; -#endif -} -#endif /* Local 2.6.23 check */ - -/* On older kernels we handle this a bit differently, so we yield to that - * code for its implementation in mq_compat.h as we want to make - * use of the internal mac80211 __ieee80211_queue_stopped() which itself - * uses internal mac80211 data structure hacks. */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */ -/** - * netif_subqueue_stopped - test status of subqueue - * @dev: network device - * @queue_index: sub queue index - * - * Check individual transmit queue of a device with multiple transmit queues. - */ -static inline int __netif_subqueue_stopped(const struct net_device *dev, - u16 queue_index) -{ -#ifdef CONFIG_NETDEVICES_MULTIQUEUE - return test_bit(__LINK_STATE_XOFF, - &dev->egress_subqueue[queue_index].state); -#else - return 0; -#endif -} - -/* Note: although the backport implementation for netif_subqueue_stopped - * on older kernels is identical to upstream __netif_subqueue_stopped() - * (except for a const qualifier) we implement netif_subqueue_stopped() - * as part of mac80211 as it relies on internal mac80211 structures we - * use for MQ support. We this implement it in mq_compat.h */ - -#endif /* Local 2.6.23 check */ - -/* - * Force link bug if constructor is used, can't be done compatibly - * because constructor arguments were swapped since then! - */ -extern void __incompatible_kmem_cache_create(void); - -/* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) -#define kmem_cache_create(name, objsize, align, flags, ctor) \ - ({ \ - if (ctor) __incompatible_kmem_cache_create(); \ - kmem_cache_create((name), (objsize), (align), \ - (flags), NULL, NULL); \ - }) -#endif - -/* 2.6.23 kmem_cache_create() takes 5 arguments */ -#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) -#define kmem_cache_create(name, objsize, align, flags, ctor) \ - ({ \ - if (ctor) __incompatible_kmem_cache_create(); \ - kmem_cache_create((name), (objsize), (align), \ - (flags), NULL); \ - }) -#endif - -/* From include/linux/mod_devicetable.h */ - -/* SSB core, see drivers/ssb/ */ -#ifndef SSB_DEVICE -struct ssb_device_id { - __u16 vendor; - __u16 coreid; - __u8 revision; -}; -#define SSB_DEVICE(_vendor, _coreid, _revision) \ - { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } -#define SSB_DEVTABLE_END \ - { 0, }, - -#define SSB_ANY_VENDOR 0xFFFF -#define SSB_ANY_ID 0xFFFF -#define SSB_ANY_REV 0xFF -#endif - - -/* Namespace stuff, introduced on 2.6.24 */ -#define dev_get_by_index(a, b) dev_get_by_index(b) -#define __dev_get_by_index(a, b) __dev_get_by_index(b) - -/* - * Display a 6 byte device address (MAC) in a readable format. - */ -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -extern char *print_mac(char *buf, const u8 *addr); -#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused - -extern int eth_header(struct sk_buff *skb, struct net_device *dev, - unsigned short type, void *daddr, - void *saddr, unsigned len); -extern int eth_rebuild_header(struct sk_buff *skb); -extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, - unsigned char * haddr); -extern int eth_header_cache(struct neighbour *neigh, - struct hh_cache *hh); - -/* This structure is simply not present on 2.6.22 and 2.6.23 */ -struct header_ops { - int (*create) (struct sk_buff *skb, struct net_device *dev, - unsigned short type, void *daddr, - void *saddr, unsigned len); - int (*parse)(const struct sk_buff *skb, unsigned char *haddr); - int (*rebuild)(struct sk_buff *skb); - #define HAVE_HEADER_CACHE - int (*cache)(struct neighbour *neigh, struct hh_cache *hh); - void (*cache_update)(struct hh_cache *hh, - struct net_device *dev, - unsigned char *haddr); -}; - -/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on - * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore - * the debug stuff. Note that adding this required changes to the struct - * scatterlist on include/asm/scatterlist*, so the right way to port this - * is to simply ignore the new structure changes and zero the scatterlist - * array. We lave the kdoc intact for reference. - */ - -/** - * sg_mark_end - Mark the end of the scatterlist - * @sg: SG entryScatterlist - * - * Description: - * Marks the passed in sg entry as the termination point for the sg - * table. A call to sg_next() on this entry will return NULL. - * - **/ -static inline void sg_mark_end(struct scatterlist *sg) -{ -} - -/** - * sg_init_table - Initialize SG table - * @sgl: The SG table - * @nents: Number of entries in table - * - * Notes: - * If this is part of a chained sg table, sg_mark_end() should be - * used only on the last table part. - * - **/ -{ - memset(sgl, 0, sizeof(*sgl) * nents); -} - -/** - * usb_endpoint_num - get the endpoint's number - * @epd: endpoint to be checked - * - * Returns @epd's number: 0 to 15. - */ -static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) -{ - return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; -} - -/* Helper to make struct pci_dev is_pcie compatibility code smaller */ -int compat_is_pcie(struct pci_dev *pdev); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */ - -#endif /* LINUX_26_24_COMPAT_H */ diff --git a/compat-2.6.25.c b/compat-2.6.25.c deleted file mode 100644 index e872447a..00000000 --- a/compat-2.6.25.c +++ /dev/null @@ -1,378 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.25. - */ - -#include - -/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) - -/* Backport work for QoS dependencies (kernel/pm_qos_params.c) - * ipw2100 now makes use of - * pm_qos_add_requirement(), - * pm_qos_update_requirement() and - * pm_qos_remove_requirement() from it - * - * */ - -/* - * locking rule: all changes to target_value or requirements or notifiers lists - * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock - * held, taken with _irqsave. One lock to rule them all - */ -struct requirement_list { - struct list_head list; - union { - s32 value; - s32 usec; - s32 kbps; - }; - char *name; -}; - -static s32 max_compare(s32 v1, s32 v2); -static s32 min_compare(s32 v1, s32 v2); - -struct pm_qos_object { - struct requirement_list requirements; - struct blocking_notifier_head *notifiers; - struct miscdevice pm_qos_power_miscdev; - char *name; - s32 default_value; - s32 target_value; - s32 (*comparitor)(s32, s32); -}; - -static struct pm_qos_object null_pm_qos; -static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, - .notifiers = &cpu_dma_lat_notifier, - .name = "cpu_dma_latency", - .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, - .comparitor = min_compare -}; - -static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, - .notifiers = &network_lat_notifier, - .name = "network_latency", - .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, - .comparitor = min_compare -}; - - -static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .requirements = - {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, - .notifiers = &network_throughput_notifier, - .name = "network_throughput", - .default_value = 0, - .target_value = 0, - .comparitor = max_compare -}; - - -static struct pm_qos_object *pm_qos_array[] = { - &null_pm_qos, - &cpu_dma_pm_qos, - &network_lat_pm_qos, - &network_throughput_pm_qos -}; - -static DEFINE_SPINLOCK(pm_qos_lock); - -/* static helper functions */ -static s32 max_compare(s32 v1, s32 v2) -{ - return max(v1, v2); -} - -static s32 min_compare(s32 v1, s32 v2) -{ - return min(v1, v2); -} - -static void update_target(int target) -{ - s32 extreme_value; - struct requirement_list *node; - unsigned long flags; - int call_notifier = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - extreme_value = pm_qos_array[target]->default_value; - list_for_each_entry(node, - &pm_qos_array[target]->requirements.list, list) { - extreme_value = pm_qos_array[target]->comparitor( - extreme_value, node->value); - } - if (pm_qos_array[target]->target_value != extreme_value) { - call_notifier = 1; - pm_qos_array[target]->target_value = extreme_value; - pr_debug(KERN_ERR "new target for qos %d is %d\n", target, - pm_qos_array[target]->target_value); - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - - if (call_notifier) - blocking_notifier_call_chain(pm_qos_array[target]->notifiers, - (unsigned long) extreme_value, NULL); -} - - -/** - * pm_qos_add_requirement - inserts new qos request into the list - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * @value: defines the qos request - * - * This function inserts a new entry in the pm_qos_class list of requested qos - * performance charactoistics. It recomputes the agregate QoS expectations for - * the pm_qos_class of parrameters. - */ -int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) -{ - struct requirement_list *dep; - unsigned long flags; - - dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); - if (dep) { - if (value == PM_QOS_DEFAULT_VALUE) - dep->value = pm_qos_array[pm_qos_class]->default_value; - else - dep->value = value; - dep->name = kstrdup(name, GFP_KERNEL); - if (!dep->name) - goto cleanup; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_add(&dep->list, - &pm_qos_array[pm_qos_class]->requirements.list); - spin_unlock_irqrestore(&pm_qos_lock, flags); - update_target(pm_qos_class); - - return 0; - } - -cleanup: - kfree(dep); - return -ENOMEM; -} -EXPORT_SYMBOL_GPL(pm_qos_add_requirement); - -/** - * pm_qos_update_requirement - modifies an existing qos request - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * @value: defines the qos request - * - * Updates an existing qos requierement for the pm_qos_class of parameters along - * with updating the target pm_qos_class value. - * - * If the named request isn't in the lest then no change is made. - */ -int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) -{ - unsigned long flags; - struct requirement_list *node; - int pending_update = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_for_each_entry(node, - &pm_qos_array[pm_qos_class]->requirements.list, list) { - if (strcmp(node->name, name) == 0) { - if (new_value == PM_QOS_DEFAULT_VALUE) - node->value = - pm_qos_array[pm_qos_class]->default_value; - else - node->value = new_value; - pending_update = 1; - break; - } - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - if (pending_update) - update_target(pm_qos_class); - - return 0; -} -EXPORT_SYMBOL_GPL(pm_qos_update_requirement); - -/** - * pm_qos_remove_requirement - modifies an existing qos request - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * - * Will remove named qos request from pm_qos_class list of parrameters and - * recompute the current target value for the pm_qos_class. - */ -void pm_qos_remove_requirement(int pm_qos_class, char *name) -{ - unsigned long flags; - struct requirement_list *node; - int pending_update = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_for_each_entry(node, - &pm_qos_array[pm_qos_class]->requirements.list, list) { - if (strcmp(node->name, name) == 0) { - kfree(node->name); - list_del(&node->list); - kfree(node); - pending_update = 1; - break; - } - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - if (pending_update) - update_target(pm_qos_class); -} -EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); - - -/** - * The following things are out of ./lib/vsprintf.c - * The new iwlwifi driver is using them. - */ - -/** - * strict_strtoul - convert a string to an unsigned long strictly - * @cp: The string to be converted - * @base: The number base to use - * @res: The converted result value - * - * strict_strtoul converts a string to an unsigned long only if the - * string is really an unsigned long string, any string containing - * any invalid char at the tail will be rejected and -EINVAL is returned, - * only a newline char at the tail is acceptible because people generally - * change a module parameter in the following way: - * - * echo 1024 > /sys/module/e1000/parameters/copybreak - * - * echo will append a newline to the tail. - * - * It returns 0 if conversion is successful and *res is set to the converted - * value, otherwise it returns -EINVAL and *res is set to 0. - * - * simple_strtoul just ignores the successive invalid characters and - * return the converted value of prefix part of the string. - */ -int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); - -/** - * strict_strtol - convert a string to a long strictly - * @cp: The string to be converted - * @base: The number base to use - * @res: The converted result value - * - * strict_strtol is similiar to strict_strtoul, but it allows the first - * character of a string is '-'. - * - * It returns 0 if conversion is successful and *res is set to the converted - * value, otherwise it returns -EINVAL and *res is set to 0. - */ -int strict_strtol(const char *cp, unsigned int base, long *res); - -#define define_strict_strtoux(type, valtype) \ -int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\ -{ \ - char *tail; \ - valtype val; \ - size_t len; \ - \ - *res = 0; \ - len = strlen(cp); \ - if (len == 0) \ - return -EINVAL; \ - \ - val = simple_strtou##type(cp, &tail, base); \ - if ((*tail == '\0') || \ - ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\ - *res = val; \ - return 0; \ - } \ - \ - return -EINVAL; \ -} \ - -#define define_strict_strtox(type, valtype) \ -int strict_strto##type(const char *cp, unsigned int base, valtype *res) \ -{ \ - int ret; \ - if (*cp == '-') { \ - ret = strict_strtou##type(cp+1, base, res); \ - if (!ret) \ - *res = -(*res); \ - } else \ - ret = strict_strtou##type(cp, base, res); \ - \ - return ret; \ -} \ - -define_strict_strtoux(l, unsigned long) -define_strict_strtox(l, long) - -EXPORT_SYMBOL(strict_strtoul); -EXPORT_SYMBOL(strict_strtol); - -int __dev_addr_sync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - int err = 0; - - da = *from; - while (da != NULL) { - next = da->next; - if (!da->da_synced) { - err = __dev_addr_add(to, to_count, - da->da_addr, da->da_addrlen, 0); - if (err < 0) - break; - da->da_synced = 1; - da->da_users++; - } else if (da->da_users == 1) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } - return err; -} -EXPORT_SYMBOL_GPL(__dev_addr_sync); - -void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - - da = *from; - while (da != NULL) { - next = da->next; - if (da->da_synced) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - da->da_synced = 0; - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } -} -EXPORT_SYMBOL_GPL(__dev_addr_unsync); - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ - diff --git a/compat-2.6.25.h b/compat-2.6.25.h deleted file mode 100644 index 23cf4876..00000000 --- a/compat-2.6.25.h +++ /dev/null @@ -1,112 +0,0 @@ -#ifndef LINUX_26_25_COMPAT_H -#define LINUX_26_25_COMPAT_H - -#include -#include - -/* Compat work for 2.6.24 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) - -#include -#include -#include -#include -#include -#include -#include - -#define __WARN(foo) dump_stack() - -#define dev_emerg(dev, format, arg...) \ - dev_printk(KERN_EMERG , dev , format , ## arg) -#define dev_alert(dev, format, arg...) \ - dev_printk(KERN_ALERT , dev , format , ## arg) -#define dev_crit(dev, format, arg...) \ - dev_printk(KERN_CRIT , dev , format , ## arg) - -extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); -extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); - -#define seq_file_net &init_net; - -enum nf_inet_hooks { - NF_INET_PRE_ROUTING = 0, - NF_INET_LOCAL_IN = 1, - NF_INET_FORWARD = 2, - NF_INET_LOCAL_OUT = 3, - NF_INET_POST_ROUTING = 4, - NF_INET_NUMHOOKS = 5 -}; - -/* The patch: - * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865 - * Author: Marcin Slusarz - * Date: Fri Feb 8 04:20:12 2008 -0800 - * - * byteorder: move le32_add_cpu & friends from OCFS2 to core - * - * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core - * header (1st) and converted some existing code to it. We port - * it here as later kernels will most likely use it. - */ -static inline void le16_add_cpu(__le16 *var, u16 val) -{ - *var = cpu_to_le16(le16_to_cpu(*var) + val); -} - -static inline void le32_add_cpu(__le32 *var, u32 val) -{ - *var = cpu_to_le32(le32_to_cpu(*var) + val); -} - -static inline void le64_add_cpu(__le64 *var, u64 val) -{ - *var = cpu_to_le64(le64_to_cpu(*var) + val); -} - -static inline void be16_add_cpu(__be16 *var, u16 val) -{ - u16 v = be16_to_cpu(*var); - *var = cpu_to_be16(v + val); -} - -static inline void be32_add_cpu(__be32 *var, u32 val) -{ - u32 v = be32_to_cpu(*var); - *var = cpu_to_be32(v + val); -} - -static inline void be64_add_cpu(__be64 *var, u64 val) -{ - u64 v = be64_to_cpu(*var); - *var = cpu_to_be64(v + val); -} - -/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting - * suspend of its parent device (the misc device, which is itself the - * hardware random number generator). It does this by passing a parameter to - * unregister_miscdev() which is not supported in older kernels. The suspend - * parameter allows us to enable access to the device's hardware - * number generator during suspend. As far as wireless is concerned this means - * if a driver goes to suspend it you won't have the HNR available in - * older kernels. */ -static inline void __hwrng_unregister(struct hwrng *rng, bool suspended) -{ - hwrng_unregister(rng); -} - -static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) -{ - led_classdev_unregister(lcd); -} - -/** - * The following things are out of ./include/linux/kernel.h - * The new iwlwifi driver is using them. - */ -extern int strict_strtoul(const char *, unsigned int, unsigned long *); -extern int strict_strtol(const char *, unsigned int, long *); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ - -#endif /* LINUX_26_25_COMPAT_H */ diff --git a/compat-2.6.26.c b/compat-2.6.26.c deleted file mode 100644 index 960a79a1..00000000 --- a/compat-2.6.26.c +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.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 - -/* All things not in 2.6.25 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) - - -/** - * 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); - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ - diff --git a/compat-2.6.26.h b/compat-2.6.26.h deleted file mode 100644 index b7c3b057..00000000 --- a/compat-2.6.26.h +++ /dev/null @@ -1,377 +0,0 @@ -#ifndef LINUX_26_26_COMPAT_H -#define LINUX_26_26_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) - -#include -#include -#include -#include -#include -#include - -/* These jiffie helpers added as of 2.6.26 */ - -/* - * These four macros compare jiffies and 'a' for convenience. - */ - -/* time_is_before_jiffies(a) return true if a is before jiffies */ -#define time_is_before_jiffies(a) time_after(jiffies, a) - -/* time_is_after_jiffies(a) return true if a is after jiffies */ -#define time_is_after_jiffies(a) time_before(jiffies, a) - -/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/ -#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a) - -/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/ -#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a) - -/* This comes from include/linux/input.h */ -#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" - set = radio enabled */ - -/* From 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, - struct device *parent, - dev_t devt, - void *drvdata, - const char *fmt, ...) -__attribute__((format(printf, 5, 6))); - -/* This is from include/linux/list.h */ - -/** - * list_is_singular - tests whether a list has just one entry. - * @head: the list to test. - */ -static inline int list_is_singular(const struct list_head *head) -{ - return !list_empty(head) && (head->next == head->prev); -} - -/* This is from include/linux/device.h, which was added as of 2.6.26 */ -static inline const char *dev_name(struct device *dev) -{ - /* will be changed into kobject_name(&dev->kobj) in the near future */ - return dev->bus_id; -} - -/* This is from include/linux/kernel.h, which was added as of 2.6.26 */ - -/** - * clamp_val - return a value clamped to a given range using val's type - * @val: current value - * @min: minimum allowable value - * @max: maximum allowable value - * - * This macro does no typechecking and uses temporary variables of whatever - * type the input argument 'val' is. This is useful when val is an unsigned - * type and min and max are literals that will otherwise be assigned a signed - * integer type. - */ - -#define clamp_val(val, min, max) ({ \ - typeof(val) __val = (val); \ - typeof(val) __min = (min); \ - typeof(val) __max = (max); \ - __val = __val < __min ? __min: __val; \ - __val > __max ? __max: __val; }) - -/* This comes from include/net/net_namespace.h */ - -#ifdef CONFIG_NET_NS -static inline -int net_eq(const struct net *net1, const struct net *net2) -{ - return net1 == net2; -} -#else -static inline -int net_eq(const struct net *net1, const struct net *net2) -{ - return 1; -} -#endif - -static inline -void dev_net_set(struct net_device *dev, struct net *net) -{ -#ifdef CONFIG_NET_NS - release_net(dev->nd_net); - dev->nd_net = hold_net(net); -#endif -} - -static inline -struct net *sock_net(const struct sock *sk) -{ -#ifdef CONFIG_NET_NS - return sk->sk_net; -#else - return &init_net; -#endif -} - -/* This comes from include/linux/netdevice.h */ - -/* - * Net namespace inlines - */ -static inline -struct net *dev_net(const struct net_device *dev) -{ -#ifdef CONFIG_NET_NS - /* - * compat-wirelss backport note: - * For older kernels we may just need to always return init_net, - * not sure when we added dev->nd_net. - */ - return dev->nd_net; -#else - return &init_net; -#endif -} - - -/* - * 2.6.26 added its own unaligned API which the - * new drivers can use. Lets port it here by including it in older - * kernels and also deal with the architecture handling here. - */ - -#ifdef CONFIG_ALPHA - -#include -#include -#include - -#endif /* alpha */ -#ifdef CONFIG_ARM - -/* arm */ -#include -#include -#include - -#endif /* arm */ -#ifdef CONFIG_AVR32 - -/* - * AVR32 can handle some unaligned accesses, depending on the - * implementation. The AVR32 AP implementation can handle unaligned - * words, but halfwords must be halfword-aligned, and doublewords must - * be word-aligned. - * - * However, swapped word loads must be word-aligned so we can't - * optimize word loads in general. - */ - -#include -#include -#include - -#endif -#ifdef CONFIG_BLACKFIN - -#include -#include -#include - -#endif /* blackfin */ -#ifdef CONFIG_CRIS - -/* - * CRIS can do unaligned accesses itself. - */ -#include -#include - -#endif /* cris */ -#ifdef CONFIG_FRV - -#include -#include -#include - -#endif /* frv */ -#ifdef CONFIG_H8300 - -#include -#include -#include - -#endif /* h8300 */ -#ifdef CONFIG_IA64 - -#include -#include -#include - -#endif /* ia64 */ -#ifdef CONFIG_M32R - -#if defined(__LITTLE_ENDIAN__) -# include -# include -# include -#else -# include -# include -# include -#endif - -#endif /* m32r */ -#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */ - -#ifdef CONFIG_COLDFIRE -#include -#include -#include -#else - -/* - * The m68k can do unaligned accesses itself. - */ -#include -#include -#endif - -#endif /* m68k and m68knommu */ -#ifdef CONFIG_MIPS - -#if defined(__MIPSEB__) -# include -# include -# include -# define get_unaligned __get_unaligned_be -# define put_unaligned __put_unaligned_be -#elif defined(__MIPSEL__) -# include -# include -# include -#endif - -#endif /* mips */ -#ifdef CONFIG_MN10300 - -#include -#include - -#endif /* mn10300 */ -#ifdef CONFIG_PARISC - -#include -#include -#include - -#endif /* parisc */ -#ifdef CONFIG_PPC -/* - * The PowerPC can do unaligned accesses itself in big endian mode. - */ -#include -#include - -#endif /* ppc */ -#ifdef CONFIG_S390 - -/* - * The S390 can do unaligned accesses itself. - */ -#include -#include - -#endif /* s390 */ -#ifdef CONFIG_SUPERH - -/* SH can't handle unaligned accesses. */ -#ifdef __LITTLE_ENDIAN__ -# include -# include -# include -#else -# include -# include -# include -#endif - -#endif /* sh - SUPERH */ -#ifdef CONFIG_SPARC - -/* sparc and sparc64 */ -#include -#include -#include - -#endif /* sparc */ -#ifdef CONFIG_UML - -#include "asm/arch/unaligned.h" - -#endif /* um - uml */ -#ifdef CONFIG_V850 - -#include -#include -#include - -#endif /* v850 */ -#ifdef CONFIG_X86 -/* - * The x86 can do unaligned accesses itself. - */ -#include -#include - -#endif /* x86 */ -#ifdef CONFIG_XTENSA - -#ifdef __XTENSA_EL__ -# include -# include -# include -#elif defined(__XTENSA_EB__) -# include -# include -# include -#else -# error processor byte order undefined! -#endif - -#endif /* xtensa */ - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ - -#endif /* LINUX_26_26_COMPAT_H */ diff --git a/compat-2.6.27.c b/compat-2.6.27.c deleted file mode 100644 index 996aab5d..00000000 --- a/compat-2.6.27.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.27 - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) - -#include -#include -#include -#include -#include - -/* rfkill notification chain */ -#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill - switch has changed */ - -/* - * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external, - * it was defined internally, some drivers want access to this information. - * - * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so - * we have to call the PCI routines directly. - */ - -/** - * pci_pme_capable - check the capability of PCI device to generate PME# - * @dev: PCI device to handle. - * @state: PCI state from which device will issue PME#. - * - * This is the backport code for older kernels for compat-wireless, we read stuff - * from the initialization stuff from pci_pm_init(). - */ -bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) -{ - int pm; - u16 pmc = 0; - u16 pme_support; /* as from the pci dev */ - /* find PCI PM capability in list */ - pm = pci_find_capability(dev, PCI_CAP_ID_PM); - if (!pm) - return false; - - if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { - dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", - pmc & PCI_PM_CAP_VER_MASK); - return false; - } - - pmc &= PCI_PM_CAP_PME_MASK; - - if (!pmc) - return false; - - pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; - - /* Check device's ability to generate PME# */ - - return !!(pme_support & (1 << state)); -} -EXPORT_SYMBOL(pci_pme_capable); - -/** - * mmc_align_data_size - pads a transfer size to a more optimal value - * @card: the MMC card associated with the data transfer - * @sz: original transfer size - * - * Pads the original data size with a number of extra bytes in - * order to avoid controller bugs and/or performance hits - * (e.g. some controllers revert to PIO for certain sizes). - * - * Returns the improved size, which might be unmodified. - * - * Note that this function is only relevant when issuing a - * single scatter gather entry. - */ -unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) -{ - /* - * FIXME: We don't have a system for the controller to tell - * the core about its problems yet, so for now we just 32-bit - * align the size. - */ - sz = ((sz + 3) / 4) * 4; - - return sz; -} -EXPORT_SYMBOL(mmc_align_data_size); - -/* - * Calculate the maximum byte mode transfer size - */ -static inline unsigned int sdio_max_byte_size(struct sdio_func *func) -{ - unsigned int mval = (unsigned int) min(func->card->host->max_seg_size, - func->card->host->max_blk_size); - mval = min(mval, func->max_blksize); - return min(mval, 512u); /* maximum size for byte mode */ -} - -/** - * sdio_align_size - pads a transfer size to a more optimal value - * @func: SDIO function - * @sz: original transfer size - * - * Pads the original data size with a number of extra bytes in - * order to avoid controller bugs and/or performance hits - * (e.g. some controllers revert to PIO for certain sizes). - * - * If possible, it will also adjust the size so that it can be - * handled in just a single request. - * - * Returns the improved size, which might be unmodified. - */ -unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) -{ - unsigned int orig_sz; - unsigned int blk_sz, byte_sz; - unsigned chunk_sz; - - orig_sz = sz; - - /* - * Do a first check with the controller, in case it - * wants to increase the size up to a point where it - * might need more than one block. - */ - sz = mmc_align_data_size(func->card, sz); - - /* - * If we can still do this with just a byte transfer, then - * we're done. - */ - if (sz <= sdio_max_byte_size(func)) - return sz; - - if (func->card->cccr.multi_block) { - /* - * Check if the transfer is already block aligned - */ - if ((sz % func->cur_blksize) == 0) - return sz; - - /* - * Realign it so that it can be done with one request, - * and recheck if the controller still likes it. - */ - blk_sz = ((sz + func->cur_blksize - 1) / - func->cur_blksize) * func->cur_blksize; - blk_sz = mmc_align_data_size(func->card, blk_sz); - - /* - * This value is only good if it is still just - * one request. - */ - if ((blk_sz % func->cur_blksize) == 0) - return blk_sz; - - /* - * We failed to do one request, but at least try to - * pad the remainder properly. - */ - byte_sz = mmc_align_data_size(func->card, - sz % func->cur_blksize); - if (byte_sz <= sdio_max_byte_size(func)) { - blk_sz = sz / func->cur_blksize; - return blk_sz * func->cur_blksize + byte_sz; - } - } else { - /* - * We need multiple requests, so first check that the - * controller can handle the chunk size; - */ - chunk_sz = mmc_align_data_size(func->card, - sdio_max_byte_size(func)); - if (chunk_sz == sdio_max_byte_size(func)) { - /* - * Fix up the size of the remainder (if any) - */ - byte_sz = orig_sz % chunk_sz; - if (byte_sz) { - byte_sz = mmc_align_data_size(func->card, - byte_sz); - } - - return (orig_sz / chunk_sz) * chunk_sz + byte_sz; - } - } - - /* - * The controller is simply incapable of transferring the size - * we want in decent manner, so just return the original size. - */ - return orig_sz; -} -EXPORT_SYMBOL_GPL(sdio_align_size); - - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ - diff --git a/compat-2.6.27.h b/compat-2.6.27.h deleted file mode 100644 index ed10a6c4..00000000 --- a/compat-2.6.27.h +++ /dev/null @@ -1,183 +0,0 @@ -#ifndef LINUX_26_27_COMPAT_H -#define LINUX_26_27_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define PCI_PM_CAP_PME_SHIFT 11 - -/* I can't find a more suitable replacement... */ -#define flush_work(work) cancel_work_sync(work) - -/* - * On older kernels we do not have net_device Multi Queue support, but - * since we no longer use MQ on mac80211 we can simply use the 0 queue. - * Note that if other fullmac drivers make use of this they then need - * to be backported somehow or deal with just 1 queueue from MQ. - */ -static inline void netif_tx_wake_all_queues(struct net_device *dev) -{ - netif_wake_queue(dev); -} -static inline void netif_tx_start_all_queues(struct net_device *dev) -{ - netif_start_queue(dev); -} -static inline void netif_tx_stop_all_queues(struct net_device *dev) -{ - netif_stop_queue(dev); -} - -bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); - -/* - * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck - */ -#define netif_addr_lock_bh -#define netif_addr_unlock_bh - -/* - * To port this properly we'd have to port warn_slowpath_null(), - * which I'm lazy to do so just do a regular print for now. If you - * want to port this read kernel/panic.c - */ -#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) - -/* This is ported directly as-is on newer kernels */ -#ifndef WARN -#define WARN(condition, format...) ({ \ - int __ret_warn_on = !!(condition); \ - if (unlikely(__ret_warn_on)) \ - __WARN_printf(format); \ - unlikely(__ret_warn_on); \ -}) -#endif - -/* On 2.6.27 a second argument was added, on older kernels we ignore it */ -#define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr) -#define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr) - -/* This is from include/linux/ieee80211.h */ -#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 - -/* New link list changes added as of 2.6.27, needed for ath9k */ - -static inline void __list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) -{ - struct list_head *new_first = entry->next; - list->next = head->next; - list->next->prev = list; - list->prev = entry; - entry->next = list; - head->next = new_first; - new_first->prev = head; -} - -/** - * list_cut_position - cut a list into two - * @list: a new list to add all removed entries - * @head: a list with entries - * @entry: an entry within head, could be the head itself - * and if so we won't cut the list - * - * This helper moves the initial part of @head, up to and - * including @entry, from @head to @list. You should - * pass on @entry an element you know is on @head. @list - * should be an empty list or a list you do not care about - * losing its data. - * - */ -static inline void list_cut_position(struct list_head *list, - struct list_head *head, struct list_head *entry) -{ - if (list_empty(head)) - return; - if (list_is_singular(head) && - (head->next != entry && head != entry)) - return; - if (entry == head) - INIT_LIST_HEAD(list); - else - __list_cut_position(list, head, entry); -} - - -/* __list_splice as re-implemented on 2.6.27, we backport it */ -static inline void __compat_list_splice_new_27(const struct list_head *list, - struct list_head *prev, - struct list_head *next) -{ - struct list_head *first = list->next; - struct list_head *last = list->prev; - - first->prev = prev; - prev->next = first; - - last->next = next; - next->prev = last; -} - -/** - * list_splice_tail - join two lists, each list being a queue - * @list: the new list to add. - * @head: the place to add it in the first list. - */ -static inline void list_splice_tail(struct list_head *list, - struct list_head *head) -{ - if (!list_empty(list)) - __compat_list_splice_new_27(list, head->prev, head); -} - -/** - * list_splice_tail_init - join two lists and reinitialise the emptied list - * @list: the new list to add. - * @head: the place to add it in the first list. - * - * Each of the lists is a queue. - * The list at @list is reinitialised - */ -static inline void list_splice_tail_init(struct list_head *list, - struct list_head *head) -{ - if (!list_empty(list)) { - __compat_list_splice_new_27(list, head->prev, head); - INIT_LIST_HEAD(list); - } -} - -extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); -extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); - -#define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len) -#define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra) -#define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len) - -/* Flags available in struct iw_request_info */ -#define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */ - -static inline int iwe_stream_lcp_len(struct iw_request_info *info) -{ -#ifdef CONFIG_COMPAT - if (info->flags & IW_REQUEST_FLAG_COMPAT) - return IW_EV_COMPAT_LCP_LEN; -#endif - return IW_EV_LCP_LEN; -} - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ - -#endif /* LINUX_26_27_COMPAT_H */ diff --git a/compat-2.6.28.c b/compat-2.6.28.c deleted file mode 100644 index a8dfcbb9..00000000 --- a/compat-2.6.28.c +++ /dev/null @@ -1,363 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.28. - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) - -#include - -/* 2.6.28 compat code goes here */ - -/* - * Compat-wireless notes for USB backport stuff: - * - * urb->reject exists on 2.6.27, the poison/unpoison helpers - * did not though. The anchor poison does not exist so we cannot use them. - * - * USB anchor poising seems to exist to prevent future driver sumbissions - * of usb_anchor_urb() to an anchor marked as poisoned. For older kernels - * we cannot use that, so new usb_anchor_urb()s will be anchored. The down - * side to this should be submission of URBs will continue being anchored - * on an anchor instead of having them being rejected immediately when the - * driver realized we needed to stop. For ar9170 we poison URBs upon the - * ar9170 mac80211 stop callback(), don't think this should be so bad. - * It mean there is period of time in older kernels for which we continue - * to anchor new URBs to a known stopped anchor. We have two anchors - * (TX, and RX) - */ - -#if 0 -/** - * usb_poison_urb - reliably kill a transfer and prevent further use of an URB - * @urb: pointer to URB describing a previously submitted request, - * may be NULL - * - * This routine cancels an in-progress request. It is guaranteed that - * upon return all completion handlers will have finished and the URB - * will be totally idle and cannot be reused. These features make - * this an ideal way to stop I/O in a disconnect() callback. - * If the request has not already finished or been unlinked - * the completion handler will see urb->status == -ENOENT. - * - * After and while the routine runs, attempts to resubmit the URB will fail - * with error -EPERM. Thus even if the URB's completion handler always - * tries to resubmit, it will not succeed and the URB will become idle. - * - * This routine may not be used in an interrupt context (such as a bottom - * half or a completion handler), or when holding a spinlock, or in other - * situations where the caller can't schedule(). - * - * This routine should not be called by a driver after its disconnect - * method has returned. - */ -void usb_poison_urb(struct urb *urb) -{ - might_sleep(); - if (!(urb && urb->dev && urb->ep)) - return; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) - spin_lock_irq(&usb_reject_lock); -#endif - ++urb->reject; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) - spin_unlock_irq(&usb_reject_lock); -#endif - /* - * XXX: usb_hcd_unlink_urb() needs backporting... this is defined - * on usb hcd.c but urb.c gets access to it. That is, older kernels - * have usb_hcd_unlink_urb() but its not exported, nor can we - * re-implement it exactly. This essentially dequeues the urb from - * hw, we need to figure out a way to backport this. - */ - //usb_hcd_unlink_urb(urb, -ENOENT); - - wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); -} -EXPORT_SYMBOL_GPL(usb_poison_urb); -#endif - -#include -struct pcmcia_cfg_mem { - tuple_t tuple; - cisparse_t parse; - u8 buf[256]; - cistpl_cftable_entry_t dflt; -}; -/** - * pcmcia_loop_config() - loop over configuration options - * @p_dev: the struct pcmcia_device which we need to loop for. - * @conf_check: function to call for each configuration option. - * It gets passed the struct pcmcia_device, the CIS data - * describing the configuration option, and private data - * being passed to pcmcia_loop_config() - * @priv_data: private data to be passed to the conf_check function. - * - * pcmcia_loop_config() loops over all configuration options, and calls - * the driver-specific conf_check() for each one, checking whether - * it is a valid one. Returns 0 on success or errorcode otherwise. - */ -int pcmcia_loop_config(struct pcmcia_device *p_dev, - int (*conf_check) (struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cfg, - cistpl_cftable_entry_t *dflt, - unsigned int vcc, - void *priv_data), - void *priv_data) -{ - struct pcmcia_cfg_mem *cfg_mem; - - tuple_t *tuple; - int ret; - unsigned int vcc; - - cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); - if (cfg_mem == NULL) - return -ENOMEM; - - /* get the current Vcc setting */ - vcc = p_dev->socket->socket.Vcc; - - tuple = &cfg_mem->tuple; - tuple->TupleData = cfg_mem->buf; - tuple->TupleDataMax = 255; - tuple->TupleOffset = 0; - tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; - tuple->Attributes = 0; - - ret = pcmcia_get_first_tuple(p_dev, tuple); - while (!ret) { - cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry; - - if (pcmcia_get_tuple_data(p_dev, tuple)) - goto next_entry; - - if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) - goto next_entry; - - /* default values */ - p_dev->conf.ConfigIndex = cfg->index; - if (cfg->flags & CISTPL_CFTABLE_DEFAULT) - cfg_mem->dflt = *cfg; - - ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); - if (!ret) - break; - -next_entry: - ret = pcmcia_get_next_tuple(p_dev, tuple); - } - - return ret; -} -EXPORT_SYMBOL(pcmcia_loop_config); - -void usb_unpoison_urb(struct urb *urb) -{ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) - unsigned long flags; -#endif - - if (!urb) - return; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) - spin_lock_irqsave(&usb_reject_lock, flags); -#endif - --urb->reject; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) - spin_unlock_irqrestore(&usb_reject_lock, flags); -#endif -} -EXPORT_SYMBOL_GPL(usb_unpoison_urb); - - -#if 0 -/** - * usb_poison_anchored_urbs - cease all traffic from an anchor - * @anchor: anchor the requests are bound to - * - * this allows all outstanding URBs to be poisoned starting - * from the back of the queue. Newly added URBs will also be - * poisoned - * - * This routine should not be called by a driver after its disconnect - * method has returned. - */ -void usb_poison_anchored_urbs(struct usb_anchor *anchor) -{ - struct urb *victim; - - spin_lock_irq(&anchor->lock); - // anchor->poisoned = 1; /* XXX: Cannot backport */ - while (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.prev, struct urb, - anchor_list); - /* we must make sure the URB isn't freed before we kill it*/ - usb_get_urb(victim); - spin_unlock_irq(&anchor->lock); - /* this will unanchor the URB */ - usb_poison_urb(victim); - usb_put_urb(victim); - spin_lock_irq(&anchor->lock); - } - spin_unlock_irq(&anchor->lock); -} -EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); -#endif - -/** - * usb_get_from_anchor - get an anchor's oldest urb - * @anchor: the anchor whose urb you want - * - * this will take the oldest urb from an anchor, - * unanchor and return it - */ -struct urb *usb_get_from_anchor(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - if (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.next, struct urb, - anchor_list); - usb_get_urb(victim); - spin_unlock_irqrestore(&anchor->lock, flags); - usb_unanchor_urb(victim); - } else { - spin_unlock_irqrestore(&anchor->lock, flags); - victim = NULL; - } - - return victim; -} - -EXPORT_SYMBOL_GPL(usb_get_from_anchor); - -/** - * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs - * @anchor: the anchor whose urbs you want to unanchor - * - * use this to get rid of all an anchor's urbs - */ -void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - while (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.prev, struct urb, - anchor_list); - usb_get_urb(victim); - spin_unlock_irqrestore(&anchor->lock, flags); - /* this may free the URB */ - usb_unanchor_urb(victim); - usb_put_urb(victim); - spin_lock_irqsave(&anchor->lock, flags); - } - spin_unlock_irqrestore(&anchor->lock, flags); -} - -EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); - -/** - * usb_anchor_empty - is an anchor empty - * @anchor: the anchor you want to query - * - * returns 1 if the anchor has no urbs associated with it - */ -int usb_anchor_empty(struct usb_anchor *anchor) -{ - return list_empty(&anchor->urb_list); -} - -EXPORT_SYMBOL_GPL(usb_anchor_empty); - - -void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) -{ - /* - * Make sure the BAR is actually a memory resource, not an IO resource - */ - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { - WARN_ON(1); - return NULL; - } - return ioremap_nocache(pci_resource_start(pdev, bar), - pci_resource_len(pdev, bar)); -} -EXPORT_SYMBOL_GPL(pci_ioremap_bar); - -static unsigned long round_jiffies_common(unsigned long j, int cpu, - bool force_up) -{ - int rem; - unsigned long original = j; - - /* - * We don't want all cpus firing their timers at once hitting the - * same lock or cachelines, so we skew each extra cpu with an extra - * 3 jiffies. This 3 jiffies came originally from the mm/ code which - * already did this. - * The skew is done by adding 3*cpunr, then round, then subtract this - * extra offset again. - */ - j += cpu * 3; - - rem = j % HZ; - - /* - * If the target jiffie is just after a whole second (which can happen - * due to delays of the timer irq, long irq off times etc etc) then - * we should round down to the whole second, not up. Use 1/4th second - * as cutoff for this rounding as an extreme upper bound for this. - * But never round down if @force_up is set. - */ - if (rem < HZ/4 && !force_up) /* round down */ - j = j - rem; - else /* round up */ - j = j - rem + HZ; - - /* now that we have rounded, subtract the extra skew again */ - j -= cpu * 3; - - if (j <= jiffies) /* rounding ate our timeout entirely; */ - return original; - return j; -} - -/** - * round_jiffies_up - function to round jiffies up to a full second - * @j: the time in (absolute) jiffies that should be rounded - * - * This is the same as round_jiffies() except that it will never - * round down. This is useful for timeouts for which the exact time - * of firing does not matter too much, as long as they don't fire too - * early. - */ -unsigned long round_jiffies_up(unsigned long j) -{ - return round_jiffies_common(j, raw_smp_processor_id(), true); -} -EXPORT_SYMBOL_GPL(round_jiffies_up); - -void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, - int size) -{ - skb_fill_page_desc(skb, i, page, off, size); - skb->len += size; - skb->data_len += size; - skb->truesize += size; -} -EXPORT_SYMBOL(skb_add_rx_frag); - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/compat-2.6.28.h b/compat-2.6.28.h deleted file mode 100644 index 8f90edc6..00000000 --- a/compat-2.6.28.h +++ /dev/null @@ -1,209 +0,0 @@ -#ifndef LINUX_26_28_COMPAT_H -#define LINUX_26_28_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) - -#include -#include -#include - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif - -#include - -#ifndef WARN_ONCE -#define WARN_ONCE(condition, format...) ({ \ - static int __warned; \ - int __ret_warn_once = !!(condition); \ - \ - if (unlikely(__ret_warn_once)) \ - if (WARN(!__warned, format)) \ - __warned = 1; \ - unlikely(__ret_warn_once); \ -}) -#endif /* From include/asm-generic/bug.h */ - -#include -#include -#include -#ifdef pcmcia_parse_tuple -#undef pcmcia_parse_tuple -#define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse) -#endif - -/* From : include/pcmcia/ds.h */ -/* loop CIS entries for valid configuration */ -int pcmcia_loop_config(struct pcmcia_device *p_dev, - int (*conf_check) (struct pcmcia_device *p_dev, - cistpl_cftable_entry_t *cfg, - cistpl_cftable_entry_t *dflt, - unsigned int vcc, - void *priv_data), - void *priv_data); - -#if 0 -extern void usb_poison_urb(struct urb *urb); -#endif -extern void usb_unpoison_urb(struct urb *urb); - -#if 0 -extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); -#endif - -extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); -extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); -extern int usb_anchor_empty(struct usb_anchor *anchor); - - -void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); - -/** - * skb_queue_is_last - check if skb is the last entry in the queue - * @list: queue head - * @skb: buffer - * - * Returns true if @skb is the last buffer on the list. - */ -static inline bool skb_queue_is_last(const struct sk_buff_head *list, - const struct sk_buff *skb) -{ - return (skb->next == (struct sk_buff *) list); -} - -/** - * skb_queue_next - return the next packet in the queue - * @list: queue head - * @skb: current buffer - * - * Return the next packet in @list after @skb. It is only valid to - * call this if skb_queue_is_last() evaluates to false. - */ -static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list, - const struct sk_buff *skb) -{ - /* This BUG_ON may seem severe, but if we just return then we - * are going to dereference garbage. - */ - BUG_ON(skb_queue_is_last(list, skb)); - return skb->next; -} - -/** - * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head - * @list: queue to initialize - * - * This initializes only the list and queue length aspects of - * an sk_buff_head object. This allows to initialize the list - * aspects of an sk_buff_head without reinitializing things like - * the spinlock. It can also be used for on-stack sk_buff_head - * objects where the spinlock is known to not be used. - */ -static inline void __skb_queue_head_init(struct sk_buff_head *list) -{ - list->prev = list->next = (struct sk_buff *)list; - list->qlen = 0; -} - -static inline void __skb_queue_splice(const struct sk_buff_head *list, - struct sk_buff *prev, - struct sk_buff *next) -{ - struct sk_buff *first = list->next; - struct sk_buff *last = list->prev; - - first->prev = prev; - prev->next = first; - - last->next = next; - next->prev = last; -} - -/** - * skb_queue_splice - join two skb lists, this is designed for stacks - * @list: the new list to add - * @head: the place to add it in the first list - */ -static inline void skb_queue_splice(const struct sk_buff_head *list, - struct sk_buff_head *head) -{ - if (!skb_queue_empty(list)) { - __skb_queue_splice(list, (struct sk_buff *) head, head->next); - head->qlen += list->qlen; - } -} - -/** - * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list - * @list: the new list to add - * @head: the place to add it in the first list - * - * Each of the lists is a queue. - * The list at @list is reinitialised - */ -static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, - struct sk_buff_head *head) -{ - if (!skb_queue_empty(list)) { - __skb_queue_splice(list, head->prev, (struct sk_buff *) head); - head->qlen += list->qlen; - __skb_queue_head_init(list); - } -} /* From include/linux/skbuff.h */ - -/** - * skb_queue_splice_tail - join two skb lists, each list being a queue - * @list: the new list to add - * @head: the place to add it in the first list - */ -static inline void skb_queue_splice_tail(const struct sk_buff_head *list, - struct sk_buff_head *head) -{ - if (!skb_queue_empty(list)) { - __skb_queue_splice(list, head->prev, (struct sk_buff *) head); - head->qlen += list->qlen; - } -} - -#ifndef DECLARE_TRACE - -#define TP_PROTO(args...) args -#define TP_ARGS(args...) args - -#define DECLARE_TRACE(name, proto, args) \ - static inline void _do_trace_##name(struct tracepoint *tp, proto) \ - { } \ - static inline void trace_##name(proto) \ - { } \ - static inline int register_trace_##name(void (*probe)(proto)) \ - { \ - return -ENOSYS; \ - } \ - static inline int unregister_trace_##name(void (*probe)(proto)) \ - { \ - return -ENOSYS; \ - } - -#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) -#define EXPORT_TRACEPOINT_SYMBOL(name) - - -#endif - -/* openSuse includes round_jiffies_up in it's kernel 2.6.27. - * This is needed to prevent conflicts with the openSuse definition. - */ -#define round_jiffies_up backport_round_jiffies_up - -unsigned long round_jiffies_up(unsigned long j); - -extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, - int off, int size); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ - -#endif /* LINUX_26_28_COMPAT_H */ diff --git a/compat-2.6.29.c b/compat-2.6.29.c deleted file mode 100644 index 664be923..00000000 --- a/compat-2.6.29.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.29. - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) - -#include - -/** - * usb_unpoison_anchored_urbs - let an anchor be used successfully again - * @anchor: anchor the requests are bound to - * - * Reverses the effect of usb_poison_anchored_urbs - * the anchor can be used normally after it returns - */ -void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) -{ - unsigned long flags; - struct urb *lazarus; - - spin_lock_irqsave(&anchor->lock, flags); - list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { - usb_unpoison_urb(lazarus); - } - //anchor->poisoned = 0; /* XXX: cannot backport */ - spin_unlock_irqrestore(&anchor->lock, flags); -} -EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); - - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ - diff --git a/compat-2.6.29.h b/compat-2.6.29.h deleted file mode 100644 index cad5e6b4..00000000 --- a/compat-2.6.29.h +++ /dev/null @@ -1,61 +0,0 @@ -#ifndef LINUX_26_29_COMPAT_H -#define LINUX_26_29_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) - -#include -#include -#include - -/** - * skb_queue_is_first - check if skb is the first entry in the queue - * @list: queue head - * @skb: buffer - * - * Returns true if @skb is the first buffer on the list. - */ -static inline bool skb_queue_is_first(const struct sk_buff_head *list, - const struct sk_buff *skb) -{ - return (skb->prev == (struct sk_buff *) list); -} - -/** - * skb_queue_prev - return the prev packet in the queue - * @list: queue head - * @skb: current buffer - * - * Return the prev packet in @list before @skb. It is only valid to - * call this if skb_queue_is_first() evaluates to false. - */ -static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list, - const struct sk_buff *skb) -{ - /* This BUG_ON may seem severe, but if we just return then we - * are going to dereference garbage. - */ - BUG_ON(skb_queue_is_first(list, skb)); - return skb->prev; -} - - -static inline struct net_device_stats *dev_get_stats(struct net_device *dev) -{ - return dev->get_stats(dev); -} - -extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); - -#define DIV_ROUND_CLOSEST(x, divisor)( \ -{ \ - typeof(divisor) __divisor = divisor; \ - (((x) + ((__divisor) / 2)) / (__divisor)); \ -} \ -) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ - -#endif /* LINUX_26_29_COMPAT_H */ diff --git a/compat-2.6.30.c b/compat-2.6.30.c deleted file mode 100644 index 6e0d69c5..00000000 --- a/compat-2.6.30.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.30. - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - -/* 2.6.30 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ - diff --git a/compat-2.6.30.h b/compat-2.6.30.h deleted file mode 100644 index 2ff1d691..00000000 --- a/compat-2.6.30.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef LINUX_26_30_COMPAT_H -#define LINUX_26_30_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - -#ifndef TP_PROTO -#define TP_PROTO(args...) TPPROTO(args) -#endif -#ifndef TP_ARGS -#define TP_ARGS(args...) TPARGS(args) -#endif - -#define IRQ_WAKE_THREAD (2) - -/* From : include/linux/pm.h */ -/* How to reorder dpm_list after device_move() */ -enum dpm_order { - DPM_ORDER_NONE, - DPM_ORDER_DEV_AFTER_PARENT, - DPM_ORDER_PARENT_BEFORE_DEV, - DPM_ORDER_DEV_LAST, -}; - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ - -#endif /* LINUX_26_30_COMPAT_H */ diff --git a/compat-2.6.31.c b/compat-2.6.31.c deleted file mode 100644 index 90b6a411..00000000 --- a/compat-2.6.31.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.31. - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) - -#include - -/** - * genl_register_family_with_ops - register a generic netlink family - * @family: generic netlink family - * @ops: operations to be registered - * @n_ops: number of elements to register - * - * Registers the specified family and operations from the specified table. - * Only one family may be registered with the same family name or identifier. - * - * The family id may equal GENL_ID_GENERATE causing an unique id to - * be automatically generated and assigned. - * - * Either a doit or dumpit callback must be specified for every registered - * operation or the function will fail. Only one operation structure per - * command identifier may be registered. - * - * See include/net/genetlink.h for more documenation on the operations - * structure. - * - * This is equivalent to calling genl_register_family() followed by - * genl_register_ops() for every operation entry in the table taking - * care to unregister the family on error path. - * - * Return 0 on success or a negative error code. - */ -int genl_register_family_with_ops(struct genl_family *family, - struct genl_ops *ops, size_t n_ops) -{ - int err, i; - - err = genl_register_family(family); - if (err) - return err; - - for (i = 0; i < n_ops; ++i, ++ops) { - err = genl_register_ops(family, ops); - if (err) - goto err_out; - } - return 0; -err_out: - genl_unregister_family(family); - return err; -} -EXPORT_SYMBOL(genl_register_family_with_ops); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ - diff --git a/compat-2.6.31.h b/compat-2.6.31.h deleted file mode 100644 index 27dc6a1d..00000000 --- a/compat-2.6.31.h +++ /dev/null @@ -1,198 +0,0 @@ -#ifndef LINUX_26_31_COMPAT_H -#define LINUX_26_31_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) - -#include -#include -#include -#include -#include -#include - -/* - * These macros allow us to backport rfkill without any - * changes on cfg80211 through compat.diff. Note that this - * file will be included by rfkill_backport.h so we must - * not conflict with things there. - */ -#define rfkill_get_led_trigger_name backport_rfkill_get_led_trigger_name -#define rfkill_set_led_trigger_name backport_rfkill_set_led_trigger_name -#define rfkill_set_hw_state backport_rfkill_set_hw_state -#define rfkill_set_sw_state backport_rfkill_set_sw_state -#define rfkill_init_sw_state backport_rfkill_init_sw_state -#define rfkill_set_states backport_rfkill_set_states -#define rfkill_pause_polling backport_rfkill_pause_polling -#define rfkill_resume_polling backport_rfkill_resume_polling -#define rfkill_blocked backport_rfkill_blocked -#define rfkill_alloc backport_rfkill_alloc -#define rfkill_register backport_rfkill_register -#define rfkill_unregister backport_rfkill_unregister -#define rfkill_destroy backport_rfkill_destroy - -#ifndef ERFKILL -#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC) -#define ERFKILL 132 /* Operation not possible due to RF-kill */ -#endif -#ifdef CONFIG_ALPHA -#define ERFKILL 138 /* Operation not possible due to RF-kill */ -#endif -#ifdef CONFIG_MIPS -#define ERFKILL 167 /* Operation not possible due to RF-kill */ -#endif -#ifdef CONFIG_PARISC -#define ERFKILL 256 /* Operation not possible due to RF-kill */ -#endif -#ifdef CONFIG_SPARC -#define ERFKILL 134 /* Operation not possible due to RF-kill */ -#endif -#endif - -#ifndef NETDEV_PRE_UP -#define NETDEV_PRE_UP 0x000D -#endif - -#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN -#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 -#endif - -struct compat_threaded_irq { - unsigned int irq; - irq_handler_t handler; - irq_handler_t thread_fn; - void *dev_id; - char wq_name[64]; - struct workqueue_struct *wq; - struct work_struct work; -}; - -/* - * kmemleak was introduced on 2.6.31, since older kernels do not have - * we simply ignore its tuning. - */ -static inline void kmemleak_ignore(const void *ptr) -{ - return; -} - -static inline void kmemleak_not_leak(const void *ptr) -{ - return; -} - -static inline void kmemleak_no_scan(const void *ptr) -{ - return; -} - -/* - * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5 - * - * There is no _sk_dst on older kernels, so just set the - * old dst to NULL and release it directly. - */ -static inline void skb_dst_drop(struct sk_buff *skb) -{ - dst_release(skb->dst); - skb->dst = NULL; -} - -static inline struct dst_entry *skb_dst(const struct sk_buff *skb) -{ - return (struct dst_entry *)skb->dst; -} - -static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) -{ - skb->dst = dst; -} - -static inline struct rtable *skb_rtable(const struct sk_buff *skb) -{ - return (struct rtable *)skb_dst(skb); -} - -extern int genl_register_family_with_ops(struct genl_family *family, - struct genl_ops *ops, size_t n_ops); - - -/* Backport threaded IRQ support */ - -static inline -void compat_irq_work(struct work_struct *work) -{ - struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work); - comp->thread_fn(comp->irq, comp->dev_id); -} - -static inline -irqreturn_t compat_irq_dispatcher(int irq, void *dev_id) -{ - struct compat_threaded_irq *comp = dev_id; - irqreturn_t res; - - res = comp->handler(irq, comp->dev_id); - if (res == IRQ_WAKE_THREAD) { - queue_work(comp->wq, &comp->work); - res = IRQ_HANDLED; - } - - return res; -} - -static inline -int compat_request_threaded_irq(struct compat_threaded_irq *comp, - unsigned int irq, - irq_handler_t handler, - irq_handler_t thread_fn, - unsigned long flags, - const char *name, - void *dev_id) -{ - comp->irq = irq; - comp->handler = handler; - comp->thread_fn = thread_fn; - comp->dev_id = dev_id; - INIT_WORK(&comp->work, compat_irq_work); - - if (!comp->wq) { - snprintf(comp->wq_name, sizeof(comp->wq_name), - "compirq/%u-%s", irq, name); - comp->wq = create_singlethread_workqueue(comp->wq_name); - if (!comp->wq) { - printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n", - comp->wq_name); - return -ENOMEM; - } - } - return request_irq(irq, compat_irq_dispatcher, flags, name, comp); -} - -static inline -void compat_free_threaded_irq(struct compat_threaded_irq *comp) -{ - free_irq(comp->irq, comp); -} - -static inline -void compat_destroy_threaded_irq(struct compat_threaded_irq *comp) -{ - if (comp->wq) - destroy_workqueue(comp->wq); - comp->wq = NULL; -} - -static inline -void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) -{ - synchronize_irq(comp->irq); - cancel_work_sync(&comp->work); -} - - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ - -#endif /* LINUX_26_31_COMPAT_H */ diff --git a/compat-2.6.32.c b/compat-2.6.32.c deleted file mode 100644 index 5d085e6e..00000000 --- a/compat-2.6.32.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.32. - */ - -#include "compat.h" - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) - -#include - -int __dev_addr_add(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (da = *list; da != NULL; da = da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - da->da_addrlen == alen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 1; - if (old_glbl) - return 0; - } - da->da_users++; - return 0; - } - } - - da = kzalloc(sizeof(*da), GFP_ATOMIC); - if (da == NULL) - return -ENOMEM; - memcpy(da->da_addr, addr, alen); - da->da_addrlen = alen; - da->da_users = 1; - da->da_gusers = glbl ? 1 : 0; - da->next = *list; - *list = da; - (*count)++; - return 0; -} - -int __dev_addr_delete(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (; (da = *list) != NULL; list = &da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - alen == da->da_addrlen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 0; - if (old_glbl == 0) - break; - } - if (--da->da_users) - return 0; - - *list = da->next; - kfree(da); - (*count)--; - return 0; - } - } - return -ENOENT; -} - -int __dev_addr_sync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - int err = 0; - - da = *from; - while (da != NULL) { - next = da->next; - if (!da->da_synced) { - err = __dev_addr_add(to, to_count, - da->da_addr, da->da_addrlen, 0); - if (err < 0) - break; - da->da_synced = 1; - da->da_users++; - } else if (da->da_users == 1) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } - return err; -} -EXPORT_SYMBOL_GPL(__dev_addr_sync); - -void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - - da = *from; - while (da != NULL) { - next = da->next; - if (da->da_synced) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - da->da_synced = 0; - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } -} -EXPORT_SYMBOL_GPL(__dev_addr_unsync); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ - diff --git a/compat-2.6.32.h b/compat-2.6.32.h deleted file mode 100644 index 3e8725a1..00000000 --- a/compat-2.6.32.h +++ /dev/null @@ -1,76 +0,0 @@ -#ifndef LINUX_26_32_COMPAT_H -#define LINUX_26_32_COMPAT_H - -#include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) - -#include -#include - -#define SDIO_VENDOR_ID_INTEL 0x0089 -#define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 -#define SDIO_DEVICE_ID_INTEL_IWMC3200WIFI 0x1403 -#define SDIO_DEVICE_ID_INTEL_IWMC3200TOP 0x1404 -#define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405 -#define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406 - -/* - * struct genl_multicast_group was made netns aware through - * patch "genetlink: make netns aware" by johannes, we just - * force this to always use the default init_net - */ -#define genl_info_net(x) &init_net -/* Just use init_net for older kernels */ -#define get_net_ns_by_pid(x) &init_net - -/* net namespace is lost */ -#define genlmsg_multicast_netns(a, b, c, d, e) genlmsg_multicast(b, c, d, e) -#define genlmsg_multicast_allns(a, b, c, d) genlmsg_multicast(a, b, c, d) - -#define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP) - -#define SET_NETDEV_DEVTYPE(netdev, type) - -#ifdef __KERNEL__ -/* Driver transmit return codes */ -enum netdev_tx { - BACKPORT_NETDEV_TX_OK = NETDEV_TX_OK, /* driver took care of packet */ - BACKPORT_NETDEV_TX_BUSY = NETDEV_TX_BUSY, /* driver tx path was busy*/ - BACKPORT_NETDEV_TX_LOCKED = NETDEV_TX_LOCKED, /* driver tx lock was already taken */ -}; -typedef enum netdev_tx netdev_tx_t; -#endif /* __KERNEL__ */ - -/* - * dev_pm_ops is only available on kernels >= 2.6.29, for - * older kernels we rely on reverting the work to old - * power management style stuff. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) -/* - * Use this if you want to use the same suspend and resume callbacks for suspend - * to RAM and hibernation. - */ -#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ -struct dev_pm_ops name = { \ - .suspend = suspend_fn, \ - .resume = resume_fn, \ - .freeze = suspend_fn, \ - .thaw = resume_fn, \ - .poweroff = suspend_fn, \ - .restore = resume_fn, \ -} -#else -#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) -#endif /* >= 2.6.29 */ - -#define wireless_send_event(a, b, c, d) wireless_send_event(a, b, c, (char * ) d) - -/* The export symbol in changed in compat/patches/15-symbol-export-conflicts.patch */ -#define ieee80211_rx(hw, skb) mac80211_ieee80211_rx(hw, skb) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ - -#endif /* LINUX_26_32_COMPAT_H */ diff --git a/compat.h b/compat.h deleted file mode 100644 index ceedc471..00000000 --- a/compat.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef LINUX_26_COMPAT_H -#define LINUX_26_COMPAT_H - -#include -#include - -/* - * Each compat file represents compatibility code for new kernel - * code introduced for *that* kernel revision. - */ - -#include "compat-2.6.14.h" -#include "compat-2.6.18.h" -#include "compat-2.6.19.h" -#include "compat-2.6.21.h" -#include "compat-2.6.22.h" -#include "compat-2.6.23.h" -#include "compat-2.6.24.h" -#include "compat-2.6.25.h" -#include "compat-2.6.26.h" -#include "compat-2.6.27.h" -#include "compat-2.6.28.h" -#include "compat-2.6.29.h" -#include "compat-2.6.30.h" -#include "compat-2.6.31.h" -#include "compat-2.6.32.h" - -#endif /* LINUX_26_COMPAT_H */ diff --git a/compat/Makefile b/compat/Makefile new file mode 100644 index 00000000..20d80e2d --- /dev/null +++ b/compat/Makefile @@ -0,0 +1,21 @@ +obj-m += compat.o +#compat-objs := + +compat-y += main.o + +# Compat kernel compatibility code +compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o +compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o +compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o +compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o +compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o +compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o +compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o +compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o +compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o +compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o +compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o +compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o +compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o +compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o +compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o diff --git a/compat/compat-2.6.14.c b/compat/compat-2.6.14.c new file mode 100644 index 00000000..e0af181f --- /dev/null +++ b/compat/compat-2.6.14.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.14. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) + +/* 2.6.14 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) */ + diff --git a/compat/compat-2.6.18.c b/compat/compat-2.6.18.c new file mode 100644 index 00000000..c7fb2e41 --- /dev/null +++ b/compat/compat-2.6.18.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.18. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) + +/* 2.6.18 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ + diff --git a/compat/compat-2.6.19.c b/compat/compat-2.6.19.c new file mode 100644 index 00000000..fc75b64d --- /dev/null +++ b/compat/compat-2.6.19.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.19. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + +/* 2.6.19 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ + diff --git a/compat/compat-2.6.21.c b/compat/compat-2.6.21.c new file mode 100644 index 00000000..e2737fb2 --- /dev/null +++ b/compat/compat-2.6.21.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.21. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + +/* 2.6.21 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ + diff --git a/compat/compat-2.6.22.c b/compat/compat-2.6.22.c new file mode 100644 index 00000000..b1ff1f3b --- /dev/null +++ b/compat/compat-2.6.22.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.22. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) + +/* 2.6.22 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ + diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c new file mode 100644 index 00000000..d232b1aa --- /dev/null +++ b/compat/compat-2.6.23.c @@ -0,0 +1,185 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.23. + */ + +#include + +/* All things not in 2.6.22 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) + +/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. + * Since da->da_synced is not part of 2.6.22 we need to take longer route when + * syncing */ + +/** + * dev_mc_sync - Synchronize device's multicast list to another device + * @to: destination device + * @from: source device + * + * Add newly added addresses to the destination device and release + * addresses that have no users left. The source device must be + * locked by netif_tx_lock_bh. + * + * This function is intended to be called from the dev->set_multicast_list + * function of layered software devices. + */ +int dev_mc_sync(struct net_device *to, struct net_device *from) +{ + struct dev_addr_list *da, *next, *da_to; + int err = 0; + + netif_tx_lock_bh(to); + da = from->mc_list; + while (da != NULL) { + int synced = 0; + next = da->next; + da_to = to->mc_list; + /* 2.6.22 does not have da->da_synced so lets take the long route */ + while (da_to != NULL) { + if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && + da->da_addrlen == da_to->da_addrlen) + synced = 1; + break; + } + if (!synced) { + err = __dev_addr_add(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + if (!err) + __dev_set_rx_mode(to); + netif_tx_unlock_bh(to); + + return err; +} +EXPORT_SYMBOL(dev_mc_sync); + + +/* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. + * Since da->da_synced is not part of 2.6.22 we need to take longer route when + * unsyncing */ + +/** + * dev_mc_unsync - Remove synchronized addresses from the destination + * device + * @to: destination device + * @from: source device + * + * Remove all addresses that were added to the destination device by + * dev_mc_sync(). This function is intended to be called from the + * dev->stop function of layered software devices. + */ +void dev_mc_unsync(struct net_device *to, struct net_device *from) +{ + struct dev_addr_list *da, *next, *da_to; + + netif_tx_lock_bh(from); + netif_tx_lock_bh(to); + + da = from->mc_list; + while (da != NULL) { + bool synced = false; + next = da->next; + da_to = to->mc_list; + /* 2.6.22 does not have da->da_synced so lets take the long route */ + while (da_to != NULL) { + if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 && + da->da_addrlen == da_to->da_addrlen) + synced = true; + break; + } + if (!synced) { + da = next; + continue; + } + __dev_addr_delete(&to->mc_list, &to->mc_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(&from->mc_list, &from->mc_count, + da->da_addr, da->da_addrlen, 0); + da = next; + } + __dev_set_rx_mode(to); + + netif_tx_unlock_bh(to); + netif_tx_unlock_bh(from); +} +EXPORT_SYMBOL(dev_mc_unsync); + +/* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on + * 2.6.22 so ignore that. */ + +/* + * Upload unicast and multicast address lists to device and + * configure RX filtering. When the device doesn't support unicast + * filtering it is put in promiscous mode while unicast addresses + * are present. + */ +void __dev_set_rx_mode(struct net_device *dev) +{ + /* dev_open will call this function so the list will stay sane. */ + if (!(dev->flags&IFF_UP)) + return; + + if (!netif_device_present(dev)) + return; + +/* This needs to be ported to 2.6.22 framework */ +#if 0 + /* Unicast addresses changes may only happen under the rtnl, + * therefore calling __dev_set_promiscuity here is safe. + */ + if (dev->uc_count > 0 && !dev->uc_promisc) { + __dev_set_promiscuity(dev, 1); + dev->uc_promisc = 1; + } else if (dev->uc_count == 0 && dev->uc_promisc) { + __dev_set_promiscuity(dev, -1); + dev->uc_promisc = 0; + } +#endif + + if (dev->set_multicast_list) + dev->set_multicast_list(dev); +} + +#ifndef HAVE_PCI_SET_MWI +int pci_try_set_mwi(struct pci_dev *dev) +{ + return 0; +} +EXPORT_SYMBOL(pci_try_set_mwi); +#else + +/** + * pci_try_set_mwi - enables memory-write-invalidate PCI transaction + * @dev: the PCI device for which MWI is enabled + * + * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND. + * Callers are not required to check the return value. + * + * RETURNS: An appropriate -ERRNO error value on error, or zero for success. + */ +int pci_try_set_mwi(struct pci_dev *dev) +{ + int rc = pci_set_mwi(dev); + return rc; +} +EXPORT_SYMBOL(pci_try_set_mwi); +#endif + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ + diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c new file mode 100644 index 00000000..977eb45e --- /dev/null +++ b/compat/compat-2.6.24.c @@ -0,0 +1,237 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.24. + */ + +#include + +/* All things not in 2.6.22 and 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + +/* Part of net/ethernet/eth.c as of 2.6.24 */ +char *print_mac(char *buf, const u8 *addr) +{ + sprintf(buf, MAC_FMT, + addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); + return buf; +} +EXPORT_SYMBOL(print_mac); + +/* On net/core/dev.c as of 2.6.24 */ +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} + +/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but + * might as well add it */ +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kmalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} + +/* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header_cache_update - update cache entry + * @hh: destination cache entry + * @dev: network device + * @haddr: new hardware address + * + * Called by Address Resolution module to notify changes in address. + */ +void eth_header_cache_update(struct hh_cache *hh, + struct net_device *dev, + unsigned char *haddr) +{ + memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), + haddr, ETH_ALEN); +} +EXPORT_SYMBOL(eth_header_cache_update); + +/* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header_cache - fill cache entry from neighbour + * @neigh: source neighbour + * @hh: destination cache entry + * Create an Ethernet header template from the neighbour. + */ +int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) +{ + __be16 type = hh->hh_type; + struct ethhdr *eth; + const struct net_device *dev = neigh->dev; + + eth = (struct ethhdr *) + (((u8 *) hh->hh_data) + (HH_DATA_OFF(sizeof(*eth)))); + + if (type == htons(ETH_P_802_3)) + return -1; + + eth->h_proto = type; + memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); + memcpy(eth->h_dest, neigh->ha, ETH_ALEN); + hh->hh_len = ETH_HLEN; + return 0; +} +EXPORT_SYMBOL(eth_header_cache); + +/* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_header - create the Ethernet header + * @skb: buffer to alter + * @dev: source device + * @type: Ethernet type field + * @daddr: destination address (NULL leave destination address) + * @saddr: source address (NULL use device source address) + * @len: packet length (<= skb->len) + * + * + * Set the protocol type. For a packet of type ETH_P_802_3 we put the length + * in here instead. It is up to the 802.2 layer to carry protocol information. + */ +int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, + void *daddr, void *saddr, unsigned len) +{ + struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN); + + if (type != ETH_P_802_3) + eth->h_proto = htons(type); + else + eth->h_proto = htons(len); + + /* + * Set the source hardware address. + */ + + if (!saddr) + saddr = dev->dev_addr; + memcpy(eth->h_source, saddr, dev->addr_len); + + if (daddr) { + memcpy(eth->h_dest, daddr, dev->addr_len); + return ETH_HLEN; + } + + /* + * Anyway, the loopback-device should never use this function... + */ + + if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) { + memset(eth->h_dest, 0, dev->addr_len); + return ETH_HLEN; + } + + return -ETH_HLEN; +} + +EXPORT_SYMBOL(eth_header); + +/* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h + * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ + +/** + * eth_rebuild_header- rebuild the Ethernet MAC header. + * @skb: socket buffer to update + * + * This is called after an ARP or IPV6 ndisc it's resolution on this + * sk_buff. We now let protocol (ARP) fill in the other fields. + * + * This routine CANNOT use cached dst->neigh! + * Really, it is used only when dst->neigh is wrong. + */ +int eth_rebuild_header(struct sk_buff *skb) +{ + struct ethhdr *eth = (struct ethhdr *)skb->data; + struct net_device *dev = skb->dev; + + switch (eth->h_proto) { +#ifdef CONFIG_INET + case __constant_htons(ETH_P_IP): + return arp_find(eth->h_dest, skb); +#endif + default: + printk(KERN_DEBUG + "%s: unable to resolve type %X addresses.\n", + dev->name, (int)eth->h_proto); + + memcpy(eth->h_source, dev->dev_addr, ETH_ALEN); + break; + } + + return 0; +} +EXPORT_SYMBOL(eth_rebuild_header); + +/* 2.6.24 will introduce struct pci_dev is_pcie bit. To help + * with the compatibility code (compat.diff) being smaller, we provide a helper + * so in cases where that will be used we can simply slap ifdefs with this + * routine. Use compat_ prefex to not pollute namespace. */ +int compat_is_pcie(struct pci_dev *pdev) +{ + int cap; + cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); + return cap ? 1 : 0; +} +EXPORT_SYMBOL(compat_is_pcie); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) */ + diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c new file mode 100644 index 00000000..e872447a --- /dev/null +++ b/compat/compat-2.6.25.c @@ -0,0 +1,378 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.25. + */ + +#include + +/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) + +/* Backport work for QoS dependencies (kernel/pm_qos_params.c) + * ipw2100 now makes use of + * pm_qos_add_requirement(), + * pm_qos_update_requirement() and + * pm_qos_remove_requirement() from it + * + * */ + +/* + * locking rule: all changes to target_value or requirements or notifiers lists + * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock + * held, taken with _irqsave. One lock to rule them all + */ +struct requirement_list { + struct list_head list; + union { + s32 value; + s32 usec; + s32 kbps; + }; + char *name; +}; + +static s32 max_compare(s32 v1, s32 v2); +static s32 min_compare(s32 v1, s32 v2); + +struct pm_qos_object { + struct requirement_list requirements; + struct blocking_notifier_head *notifiers; + struct miscdevice pm_qos_power_miscdev; + char *name; + s32 default_value; + s32 target_value; + s32 (*comparitor)(s32, s32); +}; + +static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); +static struct pm_qos_object cpu_dma_pm_qos = { + .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, + .notifiers = &cpu_dma_lat_notifier, + .name = "cpu_dma_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + +static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); +static struct pm_qos_object network_lat_pm_qos = { + .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, + .notifiers = &network_lat_notifier, + .name = "network_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + + +static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); +static struct pm_qos_object network_throughput_pm_qos = { + .requirements = + {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, + .notifiers = &network_throughput_notifier, + .name = "network_throughput", + .default_value = 0, + .target_value = 0, + .comparitor = max_compare +}; + + +static struct pm_qos_object *pm_qos_array[] = { + &null_pm_qos, + &cpu_dma_pm_qos, + &network_lat_pm_qos, + &network_throughput_pm_qos +}; + +static DEFINE_SPINLOCK(pm_qos_lock); + +/* static helper functions */ +static s32 max_compare(s32 v1, s32 v2) +{ + return max(v1, v2); +} + +static s32 min_compare(s32 v1, s32 v2) +{ + return min(v1, v2); +} + +static void update_target(int target) +{ + s32 extreme_value; + struct requirement_list *node; + unsigned long flags; + int call_notifier = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + extreme_value = pm_qos_array[target]->default_value; + list_for_each_entry(node, + &pm_qos_array[target]->requirements.list, list) { + extreme_value = pm_qos_array[target]->comparitor( + extreme_value, node->value); + } + if (pm_qos_array[target]->target_value != extreme_value) { + call_notifier = 1; + pm_qos_array[target]->target_value = extreme_value; + pr_debug(KERN_ERR "new target for qos %d is %d\n", target, + pm_qos_array[target]->target_value); + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + + if (call_notifier) + blocking_notifier_call_chain(pm_qos_array[target]->notifiers, + (unsigned long) extreme_value, NULL); +} + + +/** + * pm_qos_add_requirement - inserts new qos request into the list + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * This function inserts a new entry in the pm_qos_class list of requested qos + * performance charactoistics. It recomputes the agregate QoS expectations for + * the pm_qos_class of parrameters. + */ +int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) +{ + struct requirement_list *dep; + unsigned long flags; + + dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); + if (dep) { + if (value == PM_QOS_DEFAULT_VALUE) + dep->value = pm_qos_array[pm_qos_class]->default_value; + else + dep->value = value; + dep->name = kstrdup(name, GFP_KERNEL); + if (!dep->name) + goto cleanup; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_add(&dep->list, + &pm_qos_array[pm_qos_class]->requirements.list); + spin_unlock_irqrestore(&pm_qos_lock, flags); + update_target(pm_qos_class); + + return 0; + } + +cleanup: + kfree(dep); + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(pm_qos_add_requirement); + +/** + * pm_qos_update_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * Updates an existing qos requierement for the pm_qos_class of parameters along + * with updating the target pm_qos_class value. + * + * If the named request isn't in the lest then no change is made. + */ +int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + if (new_value == PM_QOS_DEFAULT_VALUE) + node->value = + pm_qos_array[pm_qos_class]->default_value; + else + node->value = new_value; + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); + + return 0; +} +EXPORT_SYMBOL_GPL(pm_qos_update_requirement); + +/** + * pm_qos_remove_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * + * Will remove named qos request from pm_qos_class list of parrameters and + * recompute the current target value for the pm_qos_class. + */ +void pm_qos_remove_requirement(int pm_qos_class, char *name) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + kfree(node->name); + list_del(&node->list); + kfree(node); + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); +} +EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); + + +/** + * The following things are out of ./lib/vsprintf.c + * The new iwlwifi driver is using them. + */ + +/** + * strict_strtoul - convert a string to an unsigned long strictly + * @cp: The string to be converted + * @base: The number base to use + * @res: The converted result value + * + * strict_strtoul converts a string to an unsigned long only if the + * string is really an unsigned long string, any string containing + * any invalid char at the tail will be rejected and -EINVAL is returned, + * only a newline char at the tail is acceptible because people generally + * change a module parameter in the following way: + * + * echo 1024 > /sys/module/e1000/parameters/copybreak + * + * echo will append a newline to the tail. + * + * It returns 0 if conversion is successful and *res is set to the converted + * value, otherwise it returns -EINVAL and *res is set to 0. + * + * simple_strtoul just ignores the successive invalid characters and + * return the converted value of prefix part of the string. + */ +int strict_strtoul(const char *cp, unsigned int base, unsigned long *res); + +/** + * strict_strtol - convert a string to a long strictly + * @cp: The string to be converted + * @base: The number base to use + * @res: The converted result value + * + * strict_strtol is similiar to strict_strtoul, but it allows the first + * character of a string is '-'. + * + * It returns 0 if conversion is successful and *res is set to the converted + * value, otherwise it returns -EINVAL and *res is set to 0. + */ +int strict_strtol(const char *cp, unsigned int base, long *res); + +#define define_strict_strtoux(type, valtype) \ +int strict_strtou##type(const char *cp, unsigned int base, valtype *res)\ +{ \ + char *tail; \ + valtype val; \ + size_t len; \ + \ + *res = 0; \ + len = strlen(cp); \ + if (len == 0) \ + return -EINVAL; \ + \ + val = simple_strtou##type(cp, &tail, base); \ + if ((*tail == '\0') || \ + ((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {\ + *res = val; \ + return 0; \ + } \ + \ + return -EINVAL; \ +} \ + +#define define_strict_strtox(type, valtype) \ +int strict_strto##type(const char *cp, unsigned int base, valtype *res) \ +{ \ + int ret; \ + if (*cp == '-') { \ + ret = strict_strtou##type(cp+1, base, res); \ + if (!ret) \ + *res = -(*res); \ + } else \ + ret = strict_strtou##type(cp, base, res); \ + \ + return ret; \ +} \ + +define_strict_strtoux(l, unsigned long) +define_strict_strtox(l, long) + +EXPORT_SYMBOL(strict_strtoul); +EXPORT_SYMBOL(strict_strtol); + +int __dev_addr_sync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + int err = 0; + + da = *from; + while (da != NULL) { + next = da->next; + if (!da->da_synced) { + err = __dev_addr_add(to, to_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_synced = 1; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + return err; +} +EXPORT_SYMBOL_GPL(__dev_addr_sync); + +void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + + da = *from; + while (da != NULL) { + next = da->next; + if (da->da_synced) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + da->da_synced = 0; + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } +} +EXPORT_SYMBOL_GPL(__dev_addr_unsync); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ + diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c new file mode 100644 index 00000000..960a79a1 --- /dev/null +++ b/compat/compat-2.6.26.c @@ -0,0 +1,69 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.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 + +/* All things not in 2.6.25 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) + + +/** + * 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); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ + diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c new file mode 100644 index 00000000..7fffe8e0 --- /dev/null +++ b/compat/compat-2.6.27.c @@ -0,0 +1,207 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.27 + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) + +#include +#include +#include +#include +#include + +/* rfkill notification chain */ +#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill + switch has changed */ + +/* + * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external, + * it was defined internally, some drivers want access to this information. + * + * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so + * we have to call the PCI routines directly. + */ + +/** + * pci_pme_capable - check the capability of PCI device to generate PME# + * @dev: PCI device to handle. + * @state: PCI state from which device will issue PME#. + * + * This is the backport code for older kernels for compat-wireless, we read stuff + * from the initialization stuff from pci_pm_init(). + */ +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) +{ + int pm; + u16 pmc = 0; + u16 pme_support; /* as from the pci dev */ + /* find PCI PM capability in list */ + pm = pci_find_capability(dev, PCI_CAP_ID_PM); + if (!pm) + return false; + + if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { + dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", + pmc & PCI_PM_CAP_VER_MASK); + return false; + } + + pmc &= PCI_PM_CAP_PME_MASK; + + if (!pmc) + return false; + + pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; + + /* Check device's ability to generate PME# */ + + return !!(pme_support & (1 << state)); +} +EXPORT_SYMBOL(pci_pme_capable); + +/** + * mmc_align_data_size - pads a transfer size to a more optimal value + * @card: the MMC card associated with the data transfer + * @sz: original transfer size + * + * Pads the original data size with a number of extra bytes in + * order to avoid controller bugs and/or performance hits + * (e.g. some controllers revert to PIO for certain sizes). + * + * Returns the improved size, which might be unmodified. + * + * Note that this function is only relevant when issuing a + * single scatter gather entry. + */ +unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) +{ + /* + * FIXME: We don't have a system for the controller to tell + * the core about its problems yet, so for now we just 32-bit + * align the size. + */ + sz = ((sz + 3) / 4) * 4; + + return sz; +} +EXPORT_SYMBOL(mmc_align_data_size); + +/* + * Calculate the maximum byte mode transfer size + */ +static inline unsigned int sdio_max_byte_size(struct sdio_func *func) +{ + unsigned int mval = (unsigned int) min(func->card->host->max_seg_size, + func->card->host->max_blk_size); + mval = min(mval, func->max_blksize); + return min(mval, 512u); /* maximum size for byte mode */ +} + +/** + * sdio_align_size - pads a transfer size to a more optimal value + * @func: SDIO function + * @sz: original transfer size + * + * Pads the original data size with a number of extra bytes in + * order to avoid controller bugs and/or performance hits + * (e.g. some controllers revert to PIO for certain sizes). + * + * If possible, it will also adjust the size so that it can be + * handled in just a single request. + * + * Returns the improved size, which might be unmodified. + */ +unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) +{ + unsigned int orig_sz; + unsigned int blk_sz, byte_sz; + unsigned chunk_sz; + + orig_sz = sz; + + /* + * Do a first check with the controller, in case it + * wants to increase the size up to a point where it + * might need more than one block. + */ + sz = mmc_align_data_size(func->card, sz); + + /* + * If we can still do this with just a byte transfer, then + * we're done. + */ + if (sz <= sdio_max_byte_size(func)) + return sz; + + if (func->card->cccr.multi_block) { + /* + * Check if the transfer is already block aligned + */ + if ((sz % func->cur_blksize) == 0) + return sz; + + /* + * Realign it so that it can be done with one request, + * and recheck if the controller still likes it. + */ + blk_sz = ((sz + func->cur_blksize - 1) / + func->cur_blksize) * func->cur_blksize; + blk_sz = mmc_align_data_size(func->card, blk_sz); + + /* + * This value is only good if it is still just + * one request. + */ + if ((blk_sz % func->cur_blksize) == 0) + return blk_sz; + + /* + * We failed to do one request, but at least try to + * pad the remainder properly. + */ + byte_sz = mmc_align_data_size(func->card, + sz % func->cur_blksize); + if (byte_sz <= sdio_max_byte_size(func)) { + blk_sz = sz / func->cur_blksize; + return blk_sz * func->cur_blksize + byte_sz; + } + } else { + /* + * We need multiple requests, so first check that the + * controller can handle the chunk size; + */ + chunk_sz = mmc_align_data_size(func->card, + sdio_max_byte_size(func)); + if (chunk_sz == sdio_max_byte_size(func)) { + /* + * Fix up the size of the remainder (if any) + */ + byte_sz = orig_sz % chunk_sz; + if (byte_sz) { + byte_sz = mmc_align_data_size(func->card, + byte_sz); + } + + return (orig_sz / chunk_sz) * chunk_sz + byte_sz; + } + } + + /* + * The controller is simply incapable of transferring the size + * we want in decent manner, so just return the original size. + */ + return orig_sz; +} +EXPORT_SYMBOL_GPL(sdio_align_size); + + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ + diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c new file mode 100644 index 00000000..959a4294 --- /dev/null +++ b/compat/compat-2.6.28.c @@ -0,0 +1,363 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.28. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) + +#include + +/* 2.6.28 compat code goes here */ + +/* + * Compat-wireless notes for USB backport stuff: + * + * urb->reject exists on 2.6.27, the poison/unpoison helpers + * did not though. The anchor poison does not exist so we cannot use them. + * + * USB anchor poising seems to exist to prevent future driver sumbissions + * of usb_anchor_urb() to an anchor marked as poisoned. For older kernels + * we cannot use that, so new usb_anchor_urb()s will be anchored. The down + * side to this should be submission of URBs will continue being anchored + * on an anchor instead of having them being rejected immediately when the + * driver realized we needed to stop. For ar9170 we poison URBs upon the + * ar9170 mac80211 stop callback(), don't think this should be so bad. + * It mean there is period of time in older kernels for which we continue + * to anchor new URBs to a known stopped anchor. We have two anchors + * (TX, and RX) + */ + +#if 0 +/** + * usb_poison_urb - reliably kill a transfer and prevent further use of an URB + * @urb: pointer to URB describing a previously submitted request, + * may be NULL + * + * This routine cancels an in-progress request. It is guaranteed that + * upon return all completion handlers will have finished and the URB + * will be totally idle and cannot be reused. These features make + * this an ideal way to stop I/O in a disconnect() callback. + * If the request has not already finished or been unlinked + * the completion handler will see urb->status == -ENOENT. + * + * After and while the routine runs, attempts to resubmit the URB will fail + * with error -EPERM. Thus even if the URB's completion handler always + * tries to resubmit, it will not succeed and the URB will become idle. + * + * This routine may not be used in an interrupt context (such as a bottom + * half or a completion handler), or when holding a spinlock, or in other + * situations where the caller can't schedule(). + * + * This routine should not be called by a driver after its disconnect + * method has returned. + */ +void usb_poison_urb(struct urb *urb) +{ + might_sleep(); + if (!(urb && urb->dev && urb->ep)) + return; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_lock_irq(&usb_reject_lock); +#endif + ++urb->reject; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_unlock_irq(&usb_reject_lock); +#endif + /* + * XXX: usb_hcd_unlink_urb() needs backporting... this is defined + * on usb hcd.c but urb.c gets access to it. That is, older kernels + * have usb_hcd_unlink_urb() but its not exported, nor can we + * re-implement it exactly. This essentially dequeues the urb from + * hw, we need to figure out a way to backport this. + */ + //usb_hcd_unlink_urb(urb, -ENOENT); + + wait_event(usb_kill_urb_queue, atomic_read(&urb->use_count) == 0); +} +EXPORT_SYMBOL_GPL(usb_poison_urb); +#endif + +#include +struct pcmcia_cfg_mem { + tuple_t tuple; + cisparse_t parse; + u8 buf[256]; + cistpl_cftable_entry_t dflt; +}; +/** + * pcmcia_loop_config() - loop over configuration options + * @p_dev: the struct pcmcia_device which we need to loop for. + * @conf_check: function to call for each configuration option. + * It gets passed the struct pcmcia_device, the CIS data + * describing the configuration option, and private data + * being passed to pcmcia_loop_config() + * @priv_data: private data to be passed to the conf_check function. + * + * pcmcia_loop_config() loops over all configuration options, and calls + * the driver-specific conf_check() for each one, checking whether + * it is a valid one. Returns 0 on success or errorcode otherwise. + */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + unsigned int vcc, + void *priv_data), + void *priv_data) +{ + struct pcmcia_cfg_mem *cfg_mem; + + tuple_t *tuple; + int ret; + unsigned int vcc; + + cfg_mem = kzalloc(sizeof(struct pcmcia_cfg_mem), GFP_KERNEL); + if (cfg_mem == NULL) + return -ENOMEM; + + /* get the current Vcc setting */ + vcc = p_dev->socket->socket.Vcc; + + tuple = &cfg_mem->tuple; + tuple->TupleData = cfg_mem->buf; + tuple->TupleDataMax = 255; + tuple->TupleOffset = 0; + tuple->DesiredTuple = CISTPL_CFTABLE_ENTRY; + tuple->Attributes = 0; + + ret = pcmcia_get_first_tuple(p_dev, tuple); + while (!ret) { + cistpl_cftable_entry_t *cfg = &cfg_mem->parse.cftable_entry; + + if (pcmcia_get_tuple_data(p_dev, tuple)) + goto next_entry; + + if (pcmcia_parse_tuple(tuple, &cfg_mem->parse)) + goto next_entry; + + /* default values */ + p_dev->conf.ConfigIndex = cfg->index; + if (cfg->flags & CISTPL_CFTABLE_DEFAULT) + cfg_mem->dflt = *cfg; + + ret = conf_check(p_dev, cfg, &cfg_mem->dflt, vcc, priv_data); + if (!ret) + break; + +next_entry: + ret = pcmcia_get_next_tuple(p_dev, tuple); + } + + return ret; +} +EXPORT_SYMBOL(pcmcia_loop_config); + +void usb_unpoison_urb(struct urb *urb) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + unsigned long flags; +#endif + + if (!urb) + return; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_lock_irqsave(&usb_reject_lock, flags); +#endif + --urb->reject; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) + spin_unlock_irqrestore(&usb_reject_lock, flags); +#endif +} +EXPORT_SYMBOL_GPL(usb_unpoison_urb); + + +#if 0 +/** + * usb_poison_anchored_urbs - cease all traffic from an anchor + * @anchor: anchor the requests are bound to + * + * this allows all outstanding URBs to be poisoned starting + * from the back of the queue. Newly added URBs will also be + * poisoned + * + * This routine should not be called by a driver after its disconnect + * method has returned. + */ +void usb_poison_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + + spin_lock_irq(&anchor->lock); + // anchor->poisoned = 1; /* XXX: Cannot backport */ + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + /* we must make sure the URB isn't freed before we kill it*/ + usb_get_urb(victim); + spin_unlock_irq(&anchor->lock); + /* this will unanchor the URB */ + usb_poison_urb(victim); + usb_put_urb(victim); + spin_lock_irq(&anchor->lock); + } + spin_unlock_irq(&anchor->lock); +} +EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); +#endif + +/** + * usb_get_from_anchor - get an anchor's oldest urb + * @anchor: the anchor whose urb you want + * + * this will take the oldest urb from an anchor, + * unanchor and return it + */ +struct urb *usb_get_from_anchor(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + if (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.next, struct urb, + anchor_list); + usb_get_urb(victim); + spin_unlock_irqrestore(&anchor->lock, flags); + usb_unanchor_urb(victim); + } else { + spin_unlock_irqrestore(&anchor->lock, flags); + victim = NULL; + } + + return victim; +} + +EXPORT_SYMBOL_GPL(usb_get_from_anchor); + +/** + * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs + * @anchor: the anchor whose urbs you want to unanchor + * + * use this to get rid of all an anchor's urbs + */ +void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + usb_get_urb(victim); + spin_unlock_irqrestore(&anchor->lock, flags); + /* this may free the URB */ + usb_unanchor_urb(victim); + usb_put_urb(victim); + spin_lock_irqsave(&anchor->lock, flags); + } + spin_unlock_irqrestore(&anchor->lock, flags); +} + +EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); + +/** + * usb_anchor_empty - is an anchor empty + * @anchor: the anchor you want to query + * + * returns 1 if the anchor has no urbs associated with it + */ +int usb_anchor_empty(struct usb_anchor *anchor) +{ + return list_empty(&anchor->urb_list); +} + +EXPORT_SYMBOL_GPL(usb_anchor_empty); + + +void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) +{ + /* + * Make sure the BAR is actually a memory resource, not an IO resource + */ + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { + WARN_ON(1); + return NULL; + } + return ioremap_nocache(pci_resource_start(pdev, bar), + pci_resource_len(pdev, bar)); +} +EXPORT_SYMBOL_GPL(pci_ioremap_bar); + +static unsigned long round_jiffies_common(unsigned long j, int cpu, + bool force_up) +{ + int rem; + unsigned long original = j; + + /* + * We don't want all cpus firing their timers at once hitting the + * same lock or cachelines, so we skew each extra cpu with an extra + * 3 jiffies. This 3 jiffies came originally from the mm/ code which + * already did this. + * The skew is done by adding 3*cpunr, then round, then subtract this + * extra offset again. + */ + j += cpu * 3; + + rem = j % HZ; + + /* + * If the target jiffie is just after a whole second (which can happen + * due to delays of the timer irq, long irq off times etc etc) then + * we should round down to the whole second, not up. Use 1/4th second + * as cutoff for this rounding as an extreme upper bound for this. + * But never round down if @force_up is set. + */ + if (rem < HZ/4 && !force_up) /* round down */ + j = j - rem; + else /* round up */ + j = j - rem + HZ; + + /* now that we have rounded, subtract the extra skew again */ + j -= cpu * 3; + + if (j <= jiffies) /* rounding ate our timeout entirely; */ + return original; + return j; +} + +/** + * round_jiffies_up - function to round jiffies up to a full second + * @j: the time in (absolute) jiffies that should be rounded + * + * This is the same as round_jiffies() except that it will never + * round down. This is useful for timeouts for which the exact time + * of firing does not matter too much, as long as they don't fire too + * early. + */ +unsigned long round_jiffies_up(unsigned long j) +{ + return round_jiffies_common(j, raw_smp_processor_id(), true); +} +EXPORT_SYMBOL_GPL(round_jiffies_up); + +void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, + int size) +{ + skb_fill_page_desc(skb, i, page, off, size); + skb->len += size; + skb->data_len += size; + skb->truesize += size; +} +EXPORT_SYMBOL(skb_add_rx_frag); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c new file mode 100644 index 00000000..669ad350 --- /dev/null +++ b/compat/compat-2.6.29.c @@ -0,0 +1,40 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.29. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) + +#include + +/** + * usb_unpoison_anchored_urbs - let an anchor be used successfully again + * @anchor: anchor the requests are bound to + * + * Reverses the effect of usb_poison_anchored_urbs + * the anchor can be used normally after it returns + */ +void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) +{ + unsigned long flags; + struct urb *lazarus; + + spin_lock_irqsave(&anchor->lock, flags); + list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { + usb_unpoison_urb(lazarus); + } + //anchor->poisoned = 0; /* XXX: cannot backport */ + spin_unlock_irqrestore(&anchor->lock, flags); +} +EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); + + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ + diff --git a/compat/compat-2.6.30.c b/compat/compat-2.6.30.c new file mode 100644 index 00000000..f8219189 --- /dev/null +++ b/compat/compat-2.6.30.c @@ -0,0 +1,18 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.30. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) + +/* 2.6.30 compat code goes here */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ + diff --git a/compat/compat-2.6.31.c b/compat/compat-2.6.31.c new file mode 100644 index 00000000..dc8588fe --- /dev/null +++ b/compat/compat-2.6.31.c @@ -0,0 +1,64 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.31. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) + +#include + +/** + * genl_register_family_with_ops - register a generic netlink family + * @family: generic netlink family + * @ops: operations to be registered + * @n_ops: number of elements to register + * + * Registers the specified family and operations from the specified table. + * Only one family may be registered with the same family name or identifier. + * + * The family id may equal GENL_ID_GENERATE causing an unique id to + * be automatically generated and assigned. + * + * Either a doit or dumpit callback must be specified for every registered + * operation or the function will fail. Only one operation structure per + * command identifier may be registered. + * + * See include/net/genetlink.h for more documenation on the operations + * structure. + * + * This is equivalent to calling genl_register_family() followed by + * genl_register_ops() for every operation entry in the table taking + * care to unregister the family on error path. + * + * Return 0 on success or a negative error code. + */ +int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops) +{ + int err, i; + + err = genl_register_family(family); + if (err) + return err; + + for (i = 0; i < n_ops; ++i, ++ops) { + err = genl_register_ops(family, ops); + if (err) + goto err_out; + } + return 0; +err_out: + genl_unregister_family(family); + return err; +} +EXPORT_SYMBOL(genl_register_family_with_ops); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + diff --git a/compat/compat-2.6.32.c b/compat/compat-2.6.32.c new file mode 100644 index 00000000..22c2c197 --- /dev/null +++ b/compat/compat-2.6.32.c @@ -0,0 +1,124 @@ +/* + * Copyright 2007 Luis R. Rodriguez + * + * 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.32. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) + +#include + +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kzalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} + +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} + +int __dev_addr_sync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + int err = 0; + + da = *from; + while (da != NULL) { + next = da->next; + if (!da->da_synced) { + err = __dev_addr_add(to, to_count, + da->da_addr, da->da_addrlen, 0); + if (err < 0) + break; + da->da_synced = 1; + da->da_users++; + } else if (da->da_users == 1) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } + return err; +} +EXPORT_SYMBOL_GPL(__dev_addr_sync); + +void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, + struct dev_addr_list **from, int *from_count) +{ + struct dev_addr_list *da, *next; + + da = *from; + while (da != NULL) { + next = da->next; + if (da->da_synced) { + __dev_addr_delete(to, to_count, + da->da_addr, da->da_addrlen, 0); + da->da_synced = 0; + __dev_addr_delete(from, from_count, + da->da_addr, da->da_addrlen, 0); + } + da = next; + } +} +EXPORT_SYMBOL_GPL(__dev_addr_unsync); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ + diff --git a/compat/main.c b/compat/main.c new file mode 100644 index 00000000..390278db --- /dev/null +++ b/compat/main.c @@ -0,0 +1,18 @@ +#include + +MODULE_AUTHOR("Luis R. Rodriguez"); +MODULE_DESCRIPTION("Kernel compatibility module"); +MODULE_LICENSE("GPL"); + +static int __init compat_init(void) +{ + return 0; +} +module_init(compat_init); + +static void __exit compat_exit(void) +{ + return; +} +module_exit(compat_exit); + diff --git a/include/linux/compat-2.6.14.h b/include/linux/compat-2.6.14.h new file mode 100644 index 00000000..22e7e319 --- /dev/null +++ b/include/linux/compat-2.6.14.h @@ -0,0 +1,14 @@ +#ifndef LINUX_26_14_COMPAT_H +#define LINUX_26_14_COMPAT_H + +#include +#include + +/* Compat work for 2.6.14 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) + +typedef unsigned int gfp_t; + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) */ + +#endif /* LINUX_26_14_COMPAT_H */ diff --git a/include/linux/compat-2.6.18.h b/include/linux/compat-2.6.18.h new file mode 100644 index 00000000..3245c42c --- /dev/null +++ b/include/linux/compat-2.6.18.h @@ -0,0 +1,14 @@ +#ifndef LINUX_26_18_COMPAT_H +#define LINUX_26_18_COMPAT_H + +#include +#include + +/* Compat work for 2.6.18 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) + +#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) */ + +#endif /* LINUX_26_18_COMPAT_H */ diff --git a/include/linux/compat-2.6.19.h b/include/linux/compat-2.6.19.h new file mode 100644 index 00000000..017044cf --- /dev/null +++ b/include/linux/compat-2.6.19.h @@ -0,0 +1,25 @@ +#ifndef LINUX_26_19_COMPAT_H +#define LINUX_26_19_COMPAT_H + +#include +#include + +/* Compat work for 2.6.19 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)) + +#include + +static inline int +compat_kmem_cache_destroy(struct kmem_cache *cachep) +{ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) + return kmem_cache_destroy(cachep); +#else + kmem_cache_destroy(cachep); + return 0; +#endif +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) */ + +#endif /* LINUX_26_19_COMPAT_H */ diff --git a/include/linux/compat-2.6.21.h b/include/linux/compat-2.6.21.h new file mode 100644 index 00000000..263ebd2f --- /dev/null +++ b/include/linux/compat-2.6.21.h @@ -0,0 +1,19 @@ +#ifndef LINUX_26_21_COMPAT_H +#define LINUX_26_21_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) + +#include + +#define register_sysctl_table(table) \ + ({ \ + register_sysctl_table((table), 0); \ + }) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) */ + +#endif /* LINUX_26_21_COMPAT_H */ diff --git a/include/linux/compat-2.6.22.h b/include/linux/compat-2.6.22.h new file mode 100644 index 00000000..85cd9d56 --- /dev/null +++ b/include/linux/compat-2.6.22.h @@ -0,0 +1,105 @@ +#ifndef LINUX_26_22_COMPAT_H +#define LINUX_26_22_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) + +#include +#include + +/* reuse ax25_ptr */ +#define ieee80211_ptr ax25_ptr + +#ifdef CONFIG_AX25 +#error Compat reuses the AX.25 pointer so that may not be enabled! +#endif + +static inline unsigned char *skb_mac_header(const struct sk_buff *skb) +{ + return skb->mac.raw; +} + +static inline void skb_set_mac_header(struct sk_buff *skb, int offset) +{ + skb->mac.raw = skb->data + offset; +} + +static inline void skb_reset_mac_header(struct sk_buff *skb) +{ + skb->mac.raw = skb->data; +} + +static inline void skb_reset_network_header(struct sk_buff *skb) +{ + skb->nh.raw = skb->data; +} + +static inline void skb_set_network_header(struct sk_buff *skb, int offset) +{ + skb->nh.raw = skb->data + offset; +} + +static inline void skb_set_transport_header(struct sk_buff *skb, int offset) +{ + skb->h.raw = skb->data + offset; +} + +static inline unsigned char *skb_transport_header(struct sk_buff *skb) +{ + return skb->h.raw; +} + +static inline unsigned char *skb_network_header(const struct sk_buff *skb) +{ + return skb->nh.raw; +} + +static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb) +{ + return skb->tail; +} + +static inline struct iphdr *ip_hdr(const struct sk_buff *skb) +{ + return (struct iphdr *)skb_network_header(skb); +} + +static inline void skb_copy_from_linear_data(const struct sk_buff *skb, + void *to, + const unsigned int len) +{ + memcpy(to, skb->data, len); +} + +static inline void skb_copy_from_linear_data_offset(const struct sk_buff *skb, + const int offset, void *to, + const unsigned int len) +{ + memcpy(to, skb->data + offset, len); +} + +#define __maybe_unused __attribute__((unused)) + +#define uninitialized_var(x) x = x + +/* This will lead to very weird behaviour... */ +#define NLA_BINARY NLA_STRING + +static inline int pci_set_mwi(struct pci_dev *dev) +{ + return -ENOSYS; +} + +static inline void pci_clear_mwi(struct pci_dev *dev) +{ +} + +#define list_first_entry(ptr, type, member) \ + list_entry((ptr)->next, type, member) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) */ + +#endif /* LINUX_26_22_COMPAT_H */ diff --git a/include/linux/compat-2.6.23.h b/include/linux/compat-2.6.23.h new file mode 100644 index 00000000..c36f90d4 --- /dev/null +++ b/include/linux/compat-2.6.23.h @@ -0,0 +1,136 @@ +#ifndef LINUX_26_23_COMPAT_H +#define LINUX_26_23_COMPAT_H + +#include +#include + +/* Compat work for < 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) + +#include +#include +#include +#include + +/* + * Tell gcc if a function is cold. The compiler will assume any path + * directly leading to the call is unlikely. + */ + +#if !(__GNUC__ == 4 && __GNUC_MINOR__ < 3) +/* Mark functions as cold. gcc will assume any path leading to a call + * to them will be unlikely. This means a lot of manual unlikely()s + * are unnecessary now for any paths leading to the usual suspects + * like BUG(), printk(), panic() etc. [but let's keep them for now for + * older compilers] + * + * Early snapshots of gcc 4.3 don't support this and we can't detect this + * in the preprocessor, but we can live with this because they're unreleased. + * Maketime probing would be overkill here. + * + * gcc also has a __attribute__((__hot__)) to move hot functions into + * a special section, but I don't see any sense in this right now in + * the kernel context */ +#define __cold __attribute__((__cold__)) +#endif /* gcc 4.3 check */ + +#ifndef __cold +#define __cold +#endif + +/* Added as of 2.6.23 in include/linux/netdevice.h */ +#define alloc_netdev_mq(sizeof_priv, name, setup, queue) \ + alloc_netdev(sizeof_priv, name, setup) +#define NETIF_F_MULTI_QUEUE 16384 + +/* Added as of 2.6.23 on include/linux/netdevice.h */ +static inline int netif_is_multiqueue(const struct net_device *dev) +{ + return (!!(NETIF_F_MULTI_QUEUE & dev->features)); +} + +/* 2.6.23 fixed a bug in tcf_destroy_chain and the parameter changed */ +static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) +{ + struct tcf_proto *tp; + + while ((tp = *fl) != NULL) { + *fl = tp->next; + tp->ops->destroy(tp); + module_put(tp->ops->owner); + kfree(tp); + } +} + +/* dev_mc_list was replaced with dev_addr_list as of 2.6.23, + * only new member added is da_synced. */ +#define dev_addr_list dev_mc_list +#define da_addr dmi_addr +#define da_addrlen dmi_addrlen +#define da_users dmi_users +#define da_gusers dmi_gusers + +/* dev_set_promiscuity() was moved to __dev_set_promiscuity() on 2.6.23 and + * dev_set_promiscuity() became a wrapper. */ +#define __dev_set_promiscuity dev_set_promiscuity + +/* Our own 2.6.22 port on compat.c */ +extern void dev_mc_unsync(struct net_device *to, struct net_device *from); +extern int dev_mc_sync(struct net_device *to, struct net_device *from); + +/* Our own 2.6.22 port on compat.c */ +extern void __dev_set_rx_mode(struct net_device *dev); + +/* Simple to add this */ +extern int cancel_delayed_work_sync(struct delayed_work *work); + +#define cancel_delayed_work_sync cancel_rearming_delayed_work + +#define debugfs_rename(a, b, c, d) 1 + +/* nl80211 requires multicast group support which is new and added on + * 2.6.23. We can't add support for it for older kernels to support it + * genl_family structure was changed. Lets just let through the + * genl_register_mc_group call. This means no multicast group suppport */ + +#define genl_register_mc_group(a, b) 0 + +/** + * struct genl_multicast_group - generic netlink multicast group + * @name: name of the multicast group, names are per-family + * @id: multicast group ID, assigned by the core, to use with + * genlmsg_multicast(). + * @list: list entry for linking + * @family: pointer to family, need not be set before registering + */ +struct genl_multicast_group +{ + struct genl_family *family; /* private */ + struct list_head list; /* private */ + char name[GENL_NAMSIZ]; + u32 id; +}; + + +/* Added as of 2.6.23 */ +int pci_try_set_mwi(struct pci_dev *dev); + +/* Added as of 2.6.23 */ +#ifdef CONFIG_PM_SLEEP +/* + * Tell the freezer that the current task should be frozen by it + */ +static inline void set_freezable(void) +{ + current->flags &= ~PF_NOFREEZE; +} + +#else +static inline void set_freezable(void) {} +#endif /* CONFIG_PM_SLEEP */ + +#else +#define tcf_destroy_chain_compat tcf_destroy_chain +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ + +#endif /* LINUX_26_23_COMPAT_H */ diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h new file mode 100644 index 00000000..43e63022 --- /dev/null +++ b/include/linux/compat-2.6.24.h @@ -0,0 +1,202 @@ +#ifndef LINUX_26_24_COMPAT_H +#define LINUX_26_24_COMPAT_H + +#include +#include + +/* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) + +/* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ +typedef unsigned long uintptr_t; + +/* From include/linux/net.h */ +enum sock_shutdown_cmd { + SHUT_RD = 0, + SHUT_WR = 1, + SHUT_RDWR = 2, +}; + +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) /* Local check */ +/* Added as of 2.6.24 in include/linux/skbuff.h. + * + * Although 2.6.23 does support for CONFIG_NETDEVICES_MULTIQUEUE + * this helper was not added until 2.6.24. This implementation + * is exactly as it is on newer kernels. + * + * For older kernels we use the an internal mac80211 hack. + * For details see changes to include/net/mac80211.h through + * compat.diff and compat/mq_compat.h */ +static inline u16 skb_get_queue_mapping(struct sk_buff *skb) +{ +#ifdef CONFIG_NETDEVICES_MULTIQUEUE + return skb->queue_mapping; +#else + return 0; +#endif +} +#endif /* Local 2.6.23 check */ + +/* On older kernels we handle this a bit differently, so we yield to that + * code for its implementation in mq_compat.h as we want to make + * use of the internal mac80211 __ieee80211_queue_stopped() which itself + * uses internal mac80211 data structure hacks. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* Local check */ +/** + * netif_subqueue_stopped - test status of subqueue + * @dev: network device + * @queue_index: sub queue index + * + * Check individual transmit queue of a device with multiple transmit queues. + */ +static inline int __netif_subqueue_stopped(const struct net_device *dev, + u16 queue_index) +{ +#ifdef CONFIG_NETDEVICES_MULTIQUEUE + return test_bit(__LINK_STATE_XOFF, + &dev->egress_subqueue[queue_index].state); +#else + return 0; +#endif +} + +/* Note: although the backport implementation for netif_subqueue_stopped + * on older kernels is identical to upstream __netif_subqueue_stopped() + * (except for a const qualifier) we implement netif_subqueue_stopped() + * as part of mac80211 as it relies on internal mac80211 structures we + * use for MQ support. We this implement it in mq_compat.h */ + +#endif /* Local 2.6.23 check */ + +/* + * Force link bug if constructor is used, can't be done compatibly + * because constructor arguments were swapped since then! + */ +extern void __incompatible_kmem_cache_create(void); + +/* 2.6.21 and 2.6.22 kmem_cache_create() takes 6 arguments */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +#define kmem_cache_create(name, objsize, align, flags, ctor) \ + ({ \ + if (ctor) __incompatible_kmem_cache_create(); \ + kmem_cache_create((name), (objsize), (align), \ + (flags), NULL, NULL); \ + }) +#endif + +/* 2.6.23 kmem_cache_create() takes 5 arguments */ +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,23)) +#define kmem_cache_create(name, objsize, align, flags, ctor) \ + ({ \ + if (ctor) __incompatible_kmem_cache_create(); \ + kmem_cache_create((name), (objsize), (align), \ + (flags), NULL); \ + }) +#endif + +/* From include/linux/mod_devicetable.h */ + +/* SSB core, see drivers/ssb/ */ +#ifndef SSB_DEVICE +struct ssb_device_id { + __u16 vendor; + __u16 coreid; + __u8 revision; +}; +#define SSB_DEVICE(_vendor, _coreid, _revision) \ + { .vendor = _vendor, .coreid = _coreid, .revision = _revision, } +#define SSB_DEVTABLE_END \ + { 0, }, + +#define SSB_ANY_VENDOR 0xFFFF +#define SSB_ANY_ID 0xFFFF +#define SSB_ANY_REV 0xFF +#endif + + +/* Namespace stuff, introduced on 2.6.24 */ +#define dev_get_by_index(a, b) dev_get_by_index(b) +#define __dev_get_by_index(a, b) __dev_get_by_index(b) + +/* + * Display a 6 byte device address (MAC) in a readable format. + */ +#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" +extern char *print_mac(char *buf, const u8 *addr); +#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused + +extern int eth_header(struct sk_buff *skb, struct net_device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len); +extern int eth_rebuild_header(struct sk_buff *skb); +extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, + unsigned char * haddr); +extern int eth_header_cache(struct neighbour *neigh, + struct hh_cache *hh); + +/* This structure is simply not present on 2.6.22 and 2.6.23 */ +struct header_ops { + int (*create) (struct sk_buff *skb, struct net_device *dev, + unsigned short type, void *daddr, + void *saddr, unsigned len); + int (*parse)(const struct sk_buff *skb, unsigned char *haddr); + int (*rebuild)(struct sk_buff *skb); + #define HAVE_HEADER_CACHE + int (*cache)(struct neighbour *neigh, struct hh_cache *hh); + void (*cache_update)(struct hh_cache *hh, + struct net_device *dev, + unsigned char *haddr); +}; + +/* net/ieee80211/ieee80211_crypt_tkip uses sg_init_table. This was added on + * 2.6.24. CONFIG_DEBUG_SG was added in 2.6.24 as well, so lets just ignore + * the debug stuff. Note that adding this required changes to the struct + * scatterlist on include/asm/scatterlist*, so the right way to port this + * is to simply ignore the new structure changes and zero the scatterlist + * array. We lave the kdoc intact for reference. + */ + +/** + * sg_mark_end - Mark the end of the scatterlist + * @sg: SG entryScatterlist + * + * Description: + * Marks the passed in sg entry as the termination point for the sg + * table. A call to sg_next() on this entry will return NULL. + * + **/ +static inline void sg_mark_end(struct scatterlist *sg) +{ +} + +/** + * sg_init_table - Initialize SG table + * @sgl: The SG table + * @nents: Number of entries in table + * + * Notes: + * If this is part of a chained sg table, sg_mark_end() should be + * used only on the last table part. + * + **/ +{ + memset(sgl, 0, sizeof(*sgl) * nents); +} + +/** + * usb_endpoint_num - get the endpoint's number + * @epd: endpoint to be checked + * + * Returns @epd's number: 0 to 15. + */ +static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) +{ + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; +} + +/* Helper to make struct pci_dev is_pcie compatibility code smaller */ +int compat_is_pcie(struct pci_dev *pdev); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */ + +#endif /* LINUX_26_24_COMPAT_H */ diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h new file mode 100644 index 00000000..23cf4876 --- /dev/null +++ b/include/linux/compat-2.6.25.h @@ -0,0 +1,112 @@ +#ifndef LINUX_26_25_COMPAT_H +#define LINUX_26_25_COMPAT_H + +#include +#include + +/* Compat work for 2.6.24 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) + +#include +#include +#include +#include +#include +#include +#include + +#define __WARN(foo) dump_stack() + +#define dev_emerg(dev, format, arg...) \ + dev_printk(KERN_EMERG , dev , format , ## arg) +#define dev_alert(dev, format, arg...) \ + dev_printk(KERN_ALERT , dev , format , ## arg) +#define dev_crit(dev, format, arg...) \ + dev_printk(KERN_CRIT , dev , format , ## arg) + +extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); +extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); + +#define seq_file_net &init_net; + +enum nf_inet_hooks { + NF_INET_PRE_ROUTING = 0, + NF_INET_LOCAL_IN = 1, + NF_INET_FORWARD = 2, + NF_INET_LOCAL_OUT = 3, + NF_INET_POST_ROUTING = 4, + NF_INET_NUMHOOKS = 5 +}; + +/* The patch: + * commit 8b5f6883683c91ad7e1af32b7ceeb604d68e2865 + * Author: Marcin Slusarz + * Date: Fri Feb 8 04:20:12 2008 -0800 + * + * byteorder: move le32_add_cpu & friends from OCFS2 to core + * + * moves le*_add_cpu and be*_add_cpu functions from OCFS2 to core + * header (1st) and converted some existing code to it. We port + * it here as later kernels will most likely use it. + */ +static inline void le16_add_cpu(__le16 *var, u16 val) +{ + *var = cpu_to_le16(le16_to_cpu(*var) + val); +} + +static inline void le32_add_cpu(__le32 *var, u32 val) +{ + *var = cpu_to_le32(le32_to_cpu(*var) + val); +} + +static inline void le64_add_cpu(__le64 *var, u64 val) +{ + *var = cpu_to_le64(le64_to_cpu(*var) + val); +} + +static inline void be16_add_cpu(__be16 *var, u16 val) +{ + u16 v = be16_to_cpu(*var); + *var = cpu_to_be16(v + val); +} + +static inline void be32_add_cpu(__be32 *var, u32 val) +{ + u32 v = be32_to_cpu(*var); + *var = cpu_to_be32(v + val); +} + +static inline void be64_add_cpu(__be64 *var, u64 val) +{ + u64 v = be64_to_cpu(*var); + *var = cpu_to_be64(v + val); +} + +/* 2.6.25 changes hwrng_unregister()'s behaviour by supporting + * suspend of its parent device (the misc device, which is itself the + * hardware random number generator). It does this by passing a parameter to + * unregister_miscdev() which is not supported in older kernels. The suspend + * parameter allows us to enable access to the device's hardware + * number generator during suspend. As far as wireless is concerned this means + * if a driver goes to suspend it you won't have the HNR available in + * older kernels. */ +static inline void __hwrng_unregister(struct hwrng *rng, bool suspended) +{ + hwrng_unregister(rng); +} + +static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) +{ + led_classdev_unregister(lcd); +} + +/** + * The following things are out of ./include/linux/kernel.h + * The new iwlwifi driver is using them. + */ +extern int strict_strtoul(const char *, unsigned int, unsigned long *); +extern int strict_strtol(const char *, unsigned int, long *); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ + +#endif /* LINUX_26_25_COMPAT_H */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h new file mode 100644 index 00000000..b7c3b057 --- /dev/null +++ b/include/linux/compat-2.6.26.h @@ -0,0 +1,377 @@ +#ifndef LINUX_26_26_COMPAT_H +#define LINUX_26_26_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) + +#include +#include +#include +#include +#include +#include + +/* These jiffie helpers added as of 2.6.26 */ + +/* + * These four macros compare jiffies and 'a' for convenience. + */ + +/* time_is_before_jiffies(a) return true if a is before jiffies */ +#define time_is_before_jiffies(a) time_after(jiffies, a) + +/* time_is_after_jiffies(a) return true if a is after jiffies */ +#define time_is_after_jiffies(a) time_before(jiffies, a) + +/* time_is_before_eq_jiffies(a) return true if a is before or equal to jiffies*/ +#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a) + +/* time_is_after_eq_jiffies(a) return true if a is after or equal to jiffies*/ +#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a) + +/* This comes from include/linux/input.h */ +#define SW_RFKILL_ALL 0x03 /* rfkill master switch, type "any" + set = radio enabled */ + +/* From 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, + struct device *parent, + dev_t devt, + void *drvdata, + const char *fmt, ...) +__attribute__((format(printf, 5, 6))); + +/* This is from include/linux/list.h */ + +/** + * list_is_singular - tests whether a list has just one entry. + * @head: the list to test. + */ +static inline int list_is_singular(const struct list_head *head) +{ + return !list_empty(head) && (head->next == head->prev); +} + +/* This is from include/linux/device.h, which was added as of 2.6.26 */ +static inline const char *dev_name(struct device *dev) +{ + /* will be changed into kobject_name(&dev->kobj) in the near future */ + return dev->bus_id; +} + +/* This is from include/linux/kernel.h, which was added as of 2.6.26 */ + +/** + * clamp_val - return a value clamped to a given range using val's type + * @val: current value + * @min: minimum allowable value + * @max: maximum allowable value + * + * This macro does no typechecking and uses temporary variables of whatever + * type the input argument 'val' is. This is useful when val is an unsigned + * type and min and max are literals that will otherwise be assigned a signed + * integer type. + */ + +#define clamp_val(val, min, max) ({ \ + typeof(val) __val = (val); \ + typeof(val) __min = (min); \ + typeof(val) __max = (max); \ + __val = __val < __min ? __min: __val; \ + __val > __max ? __max: __val; }) + +/* This comes from include/net/net_namespace.h */ + +#ifdef CONFIG_NET_NS +static inline +int net_eq(const struct net *net1, const struct net *net2) +{ + return net1 == net2; +} +#else +static inline +int net_eq(const struct net *net1, const struct net *net2) +{ + return 1; +} +#endif + +static inline +void dev_net_set(struct net_device *dev, struct net *net) +{ +#ifdef CONFIG_NET_NS + release_net(dev->nd_net); + dev->nd_net = hold_net(net); +#endif +} + +static inline +struct net *sock_net(const struct sock *sk) +{ +#ifdef CONFIG_NET_NS + return sk->sk_net; +#else + return &init_net; +#endif +} + +/* This comes from include/linux/netdevice.h */ + +/* + * Net namespace inlines + */ +static inline +struct net *dev_net(const struct net_device *dev) +{ +#ifdef CONFIG_NET_NS + /* + * compat-wirelss backport note: + * For older kernels we may just need to always return init_net, + * not sure when we added dev->nd_net. + */ + return dev->nd_net; +#else + return &init_net; +#endif +} + + +/* + * 2.6.26 added its own unaligned API which the + * new drivers can use. Lets port it here by including it in older + * kernels and also deal with the architecture handling here. + */ + +#ifdef CONFIG_ALPHA + +#include +#include +#include + +#endif /* alpha */ +#ifdef CONFIG_ARM + +/* arm */ +#include +#include +#include + +#endif /* arm */ +#ifdef CONFIG_AVR32 + +/* + * AVR32 can handle some unaligned accesses, depending on the + * implementation. The AVR32 AP implementation can handle unaligned + * words, but halfwords must be halfword-aligned, and doublewords must + * be word-aligned. + * + * However, swapped word loads must be word-aligned so we can't + * optimize word loads in general. + */ + +#include +#include +#include + +#endif +#ifdef CONFIG_BLACKFIN + +#include +#include +#include + +#endif /* blackfin */ +#ifdef CONFIG_CRIS + +/* + * CRIS can do unaligned accesses itself. + */ +#include +#include + +#endif /* cris */ +#ifdef CONFIG_FRV + +#include +#include +#include + +#endif /* frv */ +#ifdef CONFIG_H8300 + +#include +#include +#include + +#endif /* h8300 */ +#ifdef CONFIG_IA64 + +#include +#include +#include + +#endif /* ia64 */ +#ifdef CONFIG_M32R + +#if defined(__LITTLE_ENDIAN__) +# include +# include +# include +#else +# include +# include +# include +#endif + +#endif /* m32r */ +#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */ + +#ifdef CONFIG_COLDFIRE +#include +#include +#include +#else + +/* + * The m68k can do unaligned accesses itself. + */ +#include +#include +#endif + +#endif /* m68k and m68knommu */ +#ifdef CONFIG_MIPS + +#if defined(__MIPSEB__) +# include +# include +# include +# define get_unaligned __get_unaligned_be +# define put_unaligned __put_unaligned_be +#elif defined(__MIPSEL__) +# include +# include +# include +#endif + +#endif /* mips */ +#ifdef CONFIG_MN10300 + +#include +#include + +#endif /* mn10300 */ +#ifdef CONFIG_PARISC + +#include +#include +#include + +#endif /* parisc */ +#ifdef CONFIG_PPC +/* + * The PowerPC can do unaligned accesses itself in big endian mode. + */ +#include +#include + +#endif /* ppc */ +#ifdef CONFIG_S390 + +/* + * The S390 can do unaligned accesses itself. + */ +#include +#include + +#endif /* s390 */ +#ifdef CONFIG_SUPERH + +/* SH can't handle unaligned accesses. */ +#ifdef __LITTLE_ENDIAN__ +# include +# include +# include +#else +# include +# include +# include +#endif + +#endif /* sh - SUPERH */ +#ifdef CONFIG_SPARC + +/* sparc and sparc64 */ +#include +#include +#include + +#endif /* sparc */ +#ifdef CONFIG_UML + +#include "asm/arch/unaligned.h" + +#endif /* um - uml */ +#ifdef CONFIG_V850 + +#include +#include +#include + +#endif /* v850 */ +#ifdef CONFIG_X86 +/* + * The x86 can do unaligned accesses itself. + */ +#include +#include + +#endif /* x86 */ +#ifdef CONFIG_XTENSA + +#ifdef __XTENSA_EL__ +# include +# include +# include +#elif defined(__XTENSA_EB__) +# include +# include +# include +#else +# error processor byte order undefined! +#endif + +#endif /* xtensa */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ + +#endif /* LINUX_26_26_COMPAT_H */ diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h new file mode 100644 index 00000000..ed10a6c4 --- /dev/null +++ b/include/linux/compat-2.6.27.h @@ -0,0 +1,183 @@ +#ifndef LINUX_26_27_COMPAT_H +#define LINUX_26_27_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PCI_PM_CAP_PME_SHIFT 11 + +/* I can't find a more suitable replacement... */ +#define flush_work(work) cancel_work_sync(work) + +/* + * On older kernels we do not have net_device Multi Queue support, but + * since we no longer use MQ on mac80211 we can simply use the 0 queue. + * Note that if other fullmac drivers make use of this they then need + * to be backported somehow or deal with just 1 queueue from MQ. + */ +static inline void netif_tx_wake_all_queues(struct net_device *dev) +{ + netif_wake_queue(dev); +} +static inline void netif_tx_start_all_queues(struct net_device *dev) +{ + netif_start_queue(dev); +} +static inline void netif_tx_stop_all_queues(struct net_device *dev) +{ + netif_stop_queue(dev); +} + +bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); + +/* + * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck + */ +#define netif_addr_lock_bh +#define netif_addr_unlock_bh + +/* + * To port this properly we'd have to port warn_slowpath_null(), + * which I'm lazy to do so just do a regular print for now. If you + * want to port this read kernel/panic.c + */ +#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) + +/* This is ported directly as-is on newer kernels */ +#ifndef WARN +#define WARN(condition, format...) ({ \ + int __ret_warn_on = !!(condition); \ + if (unlikely(__ret_warn_on)) \ + __WARN_printf(format); \ + unlikely(__ret_warn_on); \ +}) +#endif + +/* On 2.6.27 a second argument was added, on older kernels we ignore it */ +#define dma_mapping_error(pdev, dma_addr) dma_mapping_error(dma_addr) +#define pci_dma_mapping_error(pdev, dma_addr) dma_mapping_error(pdev, dma_addr) + +/* This is from include/linux/ieee80211.h */ +#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 + +/* New link list changes added as of 2.6.27, needed for ath9k */ + +static inline void __list_cut_position(struct list_head *list, + struct list_head *head, struct list_head *entry) +{ + struct list_head *new_first = entry->next; + list->next = head->next; + list->next->prev = list; + list->prev = entry; + entry->next = list; + head->next = new_first; + new_first->prev = head; +} + +/** + * list_cut_position - cut a list into two + * @list: a new list to add all removed entries + * @head: a list with entries + * @entry: an entry within head, could be the head itself + * and if so we won't cut the list + * + * This helper moves the initial part of @head, up to and + * including @entry, from @head to @list. You should + * pass on @entry an element you know is on @head. @list + * should be an empty list or a list you do not care about + * losing its data. + * + */ +static inline void list_cut_position(struct list_head *list, + struct list_head *head, struct list_head *entry) +{ + if (list_empty(head)) + return; + if (list_is_singular(head) && + (head->next != entry && head != entry)) + return; + if (entry == head) + INIT_LIST_HEAD(list); + else + __list_cut_position(list, head, entry); +} + + +/* __list_splice as re-implemented on 2.6.27, we backport it */ +static inline void __compat_list_splice_new_27(const struct list_head *list, + struct list_head *prev, + struct list_head *next) +{ + struct list_head *first = list->next; + struct list_head *last = list->prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +/** + * list_splice_tail - join two lists, each list being a queue + * @list: the new list to add. + * @head: the place to add it in the first list. + */ +static inline void list_splice_tail(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) + __compat_list_splice_new_27(list, head->prev, head); +} + +/** + * list_splice_tail_init - join two lists and reinitialise the emptied list + * @list: the new list to add. + * @head: the place to add it in the first list. + * + * Each of the lists is a queue. + * The list at @list is reinitialised + */ +static inline void list_splice_tail_init(struct list_head *list, + struct list_head *head) +{ + if (!list_empty(list)) { + __compat_list_splice_new_27(list, head->prev, head); + INIT_LIST_HEAD(list); + } +} + +extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); +extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); + +#define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len) +#define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra) +#define iwe_stream_add_event(info, stream, ends, iwe, event_len) iwe_stream_add_event(stream, ends, iwe, event_len) + +/* Flags available in struct iw_request_info */ +#define IW_REQUEST_FLAG_COMPAT 0x0001 /* Compat ioctl call */ + +static inline int iwe_stream_lcp_len(struct iw_request_info *info) +{ +#ifdef CONFIG_COMPAT + if (info->flags & IW_REQUEST_FLAG_COMPAT) + return IW_EV_COMPAT_LCP_LEN; +#endif + return IW_EV_LCP_LEN; +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ + +#endif /* LINUX_26_27_COMPAT_H */ diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h new file mode 100644 index 00000000..8f90edc6 --- /dev/null +++ b/include/linux/compat-2.6.28.h @@ -0,0 +1,209 @@ +#ifndef LINUX_26_28_COMPAT_H +#define LINUX_26_28_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) + +#include +#include +#include + +#ifndef ETH_P_PAE +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#endif + +#include + +#ifndef WARN_ONCE +#define WARN_ONCE(condition, format...) ({ \ + static int __warned; \ + int __ret_warn_once = !!(condition); \ + \ + if (unlikely(__ret_warn_once)) \ + if (WARN(!__warned, format)) \ + __warned = 1; \ + unlikely(__ret_warn_once); \ +}) +#endif /* From include/asm-generic/bug.h */ + +#include +#include +#include +#ifdef pcmcia_parse_tuple +#undef pcmcia_parse_tuple +#define pcmcia_parse_tuple(tuple, parse) pccard_parse_tuple(tuple, parse) +#endif + +/* From : include/pcmcia/ds.h */ +/* loop CIS entries for valid configuration */ +int pcmcia_loop_config(struct pcmcia_device *p_dev, + int (*conf_check) (struct pcmcia_device *p_dev, + cistpl_cftable_entry_t *cfg, + cistpl_cftable_entry_t *dflt, + unsigned int vcc, + void *priv_data), + void *priv_data); + +#if 0 +extern void usb_poison_urb(struct urb *urb); +#endif +extern void usb_unpoison_urb(struct urb *urb); + +#if 0 +extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); +#endif + +extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); +extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); +extern int usb_anchor_empty(struct usb_anchor *anchor); + + +void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); + +/** + * skb_queue_is_last - check if skb is the last entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the last buffer on the list. + */ +static inline bool skb_queue_is_last(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->next == (struct sk_buff *) list); +} + +/** + * skb_queue_next - return the next packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the next packet in @list after @skb. It is only valid to + * call this if skb_queue_is_last() evaluates to false. + */ +static inline struct sk_buff *skb_queue_next(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_last(list, skb)); + return skb->next; +} + +/** + * __skb_queue_head_init - initialize non-spinlock portions of sk_buff_head + * @list: queue to initialize + * + * This initializes only the list and queue length aspects of + * an sk_buff_head object. This allows to initialize the list + * aspects of an sk_buff_head without reinitializing things like + * the spinlock. It can also be used for on-stack sk_buff_head + * objects where the spinlock is known to not be used. + */ +static inline void __skb_queue_head_init(struct sk_buff_head *list) +{ + list->prev = list->next = (struct sk_buff *)list; + list->qlen = 0; +} + +static inline void __skb_queue_splice(const struct sk_buff_head *list, + struct sk_buff *prev, + struct sk_buff *next) +{ + struct sk_buff *first = list->next; + struct sk_buff *last = list->prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +/** + * skb_queue_splice - join two skb lists, this is designed for stacks + * @list: the new list to add + * @head: the place to add it in the first list + */ +static inline void skb_queue_splice(const struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, (struct sk_buff *) head, head->next); + head->qlen += list->qlen; + } +} + +/** + * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list + * @list: the new list to add + * @head: the place to add it in the first list + * + * Each of the lists is a queue. + * The list at @list is reinitialised + */ +static inline void skb_queue_splice_tail_init(struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, head->prev, (struct sk_buff *) head); + head->qlen += list->qlen; + __skb_queue_head_init(list); + } +} /* From include/linux/skbuff.h */ + +/** + * skb_queue_splice_tail - join two skb lists, each list being a queue + * @list: the new list to add + * @head: the place to add it in the first list + */ +static inline void skb_queue_splice_tail(const struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, head->prev, (struct sk_buff *) head); + head->qlen += list->qlen; + } +} + +#ifndef DECLARE_TRACE + +#define TP_PROTO(args...) args +#define TP_ARGS(args...) args + +#define DECLARE_TRACE(name, proto, args) \ + static inline void _do_trace_##name(struct tracepoint *tp, proto) \ + { } \ + static inline void trace_##name(proto) \ + { } \ + static inline int register_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline int unregister_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } + +#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) +#define EXPORT_TRACEPOINT_SYMBOL(name) + + +#endif + +/* openSuse includes round_jiffies_up in it's kernel 2.6.27. + * This is needed to prevent conflicts with the openSuse definition. + */ +#define round_jiffies_up backport_round_jiffies_up + +unsigned long round_jiffies_up(unsigned long j); + +extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, + int off, int size); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ + +#endif /* LINUX_26_28_COMPAT_H */ diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h new file mode 100644 index 00000000..cad5e6b4 --- /dev/null +++ b/include/linux/compat-2.6.29.h @@ -0,0 +1,61 @@ +#ifndef LINUX_26_29_COMPAT_H +#define LINUX_26_29_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) + +#include +#include +#include + +/** + * skb_queue_is_first - check if skb is the first entry in the queue + * @list: queue head + * @skb: buffer + * + * Returns true if @skb is the first buffer on the list. + */ +static inline bool skb_queue_is_first(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + return (skb->prev == (struct sk_buff *) list); +} + +/** + * skb_queue_prev - return the prev packet in the queue + * @list: queue head + * @skb: current buffer + * + * Return the prev packet in @list before @skb. It is only valid to + * call this if skb_queue_is_first() evaluates to false. + */ +static inline struct sk_buff *skb_queue_prev(const struct sk_buff_head *list, + const struct sk_buff *skb) +{ + /* This BUG_ON may seem severe, but if we just return then we + * are going to dereference garbage. + */ + BUG_ON(skb_queue_is_first(list, skb)); + return skb->prev; +} + + +static inline struct net_device_stats *dev_get_stats(struct net_device *dev) +{ + return dev->get_stats(dev); +} + +extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); + +#define DIV_ROUND_CLOSEST(x, divisor)( \ +{ \ + typeof(divisor) __divisor = divisor; \ + (((x) + ((__divisor) / 2)) / (__divisor)); \ +} \ +) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ + +#endif /* LINUX_26_29_COMPAT_H */ diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h new file mode 100644 index 00000000..2ff1d691 --- /dev/null +++ b/include/linux/compat-2.6.30.h @@ -0,0 +1,29 @@ +#ifndef LINUX_26_30_COMPAT_H +#define LINUX_26_30_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) + +#ifndef TP_PROTO +#define TP_PROTO(args...) TPPROTO(args) +#endif +#ifndef TP_ARGS +#define TP_ARGS(args...) TPARGS(args) +#endif + +#define IRQ_WAKE_THREAD (2) + +/* From : include/linux/pm.h */ +/* How to reorder dpm_list after device_move() */ +enum dpm_order { + DPM_ORDER_NONE, + DPM_ORDER_DEV_AFTER_PARENT, + DPM_ORDER_PARENT_BEFORE_DEV, + DPM_ORDER_DEV_LAST, +}; + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ + +#endif /* LINUX_26_30_COMPAT_H */ diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h new file mode 100644 index 00000000..27dc6a1d --- /dev/null +++ b/include/linux/compat-2.6.31.h @@ -0,0 +1,198 @@ +#ifndef LINUX_26_31_COMPAT_H +#define LINUX_26_31_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) + +#include +#include +#include +#include +#include +#include + +/* + * These macros allow us to backport rfkill without any + * changes on cfg80211 through compat.diff. Note that this + * file will be included by rfkill_backport.h so we must + * not conflict with things there. + */ +#define rfkill_get_led_trigger_name backport_rfkill_get_led_trigger_name +#define rfkill_set_led_trigger_name backport_rfkill_set_led_trigger_name +#define rfkill_set_hw_state backport_rfkill_set_hw_state +#define rfkill_set_sw_state backport_rfkill_set_sw_state +#define rfkill_init_sw_state backport_rfkill_init_sw_state +#define rfkill_set_states backport_rfkill_set_states +#define rfkill_pause_polling backport_rfkill_pause_polling +#define rfkill_resume_polling backport_rfkill_resume_polling +#define rfkill_blocked backport_rfkill_blocked +#define rfkill_alloc backport_rfkill_alloc +#define rfkill_register backport_rfkill_register +#define rfkill_unregister backport_rfkill_unregister +#define rfkill_destroy backport_rfkill_destroy + +#ifndef ERFKILL +#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC) +#define ERFKILL 132 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_ALPHA +#define ERFKILL 138 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_MIPS +#define ERFKILL 167 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_PARISC +#define ERFKILL 256 /* Operation not possible due to RF-kill */ +#endif +#ifdef CONFIG_SPARC +#define ERFKILL 134 /* Operation not possible due to RF-kill */ +#endif +#endif + +#ifndef NETDEV_PRE_UP +#define NETDEV_PRE_UP 0x000D +#endif + +#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN +#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104 +#endif + +struct compat_threaded_irq { + unsigned int irq; + irq_handler_t handler; + irq_handler_t thread_fn; + void *dev_id; + char wq_name[64]; + struct workqueue_struct *wq; + struct work_struct work; +}; + +/* + * kmemleak was introduced on 2.6.31, since older kernels do not have + * we simply ignore its tuning. + */ +static inline void kmemleak_ignore(const void *ptr) +{ + return; +} + +static inline void kmemleak_not_leak(const void *ptr) +{ + return; +} + +static inline void kmemleak_no_scan(const void *ptr) +{ + return; +} + +/* + * Added via adf30907d63893e4208dfe3f5c88ae12bc2f25d5 + * + * There is no _sk_dst on older kernels, so just set the + * old dst to NULL and release it directly. + */ +static inline void skb_dst_drop(struct sk_buff *skb) +{ + dst_release(skb->dst); + skb->dst = NULL; +} + +static inline struct dst_entry *skb_dst(const struct sk_buff *skb) +{ + return (struct dst_entry *)skb->dst; +} + +static inline void skb_dst_set(struct sk_buff *skb, struct dst_entry *dst) +{ + skb->dst = dst; +} + +static inline struct rtable *skb_rtable(const struct sk_buff *skb) +{ + return (struct rtable *)skb_dst(skb); +} + +extern int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops); + + +/* Backport threaded IRQ support */ + +static inline +void compat_irq_work(struct work_struct *work) +{ + struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work); + comp->thread_fn(comp->irq, comp->dev_id); +} + +static inline +irqreturn_t compat_irq_dispatcher(int irq, void *dev_id) +{ + struct compat_threaded_irq *comp = dev_id; + irqreturn_t res; + + res = comp->handler(irq, comp->dev_id); + if (res == IRQ_WAKE_THREAD) { + queue_work(comp->wq, &comp->work); + res = IRQ_HANDLED; + } + + return res; +} + +static inline +int compat_request_threaded_irq(struct compat_threaded_irq *comp, + unsigned int irq, + irq_handler_t handler, + irq_handler_t thread_fn, + unsigned long flags, + const char *name, + void *dev_id) +{ + comp->irq = irq; + comp->handler = handler; + comp->thread_fn = thread_fn; + comp->dev_id = dev_id; + INIT_WORK(&comp->work, compat_irq_work); + + if (!comp->wq) { + snprintf(comp->wq_name, sizeof(comp->wq_name), + "compirq/%u-%s", irq, name); + comp->wq = create_singlethread_workqueue(comp->wq_name); + if (!comp->wq) { + printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n", + comp->wq_name); + return -ENOMEM; + } + } + return request_irq(irq, compat_irq_dispatcher, flags, name, comp); +} + +static inline +void compat_free_threaded_irq(struct compat_threaded_irq *comp) +{ + free_irq(comp->irq, comp); +} + +static inline +void compat_destroy_threaded_irq(struct compat_threaded_irq *comp) +{ + if (comp->wq) + destroy_workqueue(comp->wq); + comp->wq = NULL; +} + +static inline +void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) +{ + synchronize_irq(comp->irq); + cancel_work_sync(&comp->work); +} + + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + +#endif /* LINUX_26_31_COMPAT_H */ diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h new file mode 100644 index 00000000..3e8725a1 --- /dev/null +++ b/include/linux/compat-2.6.32.h @@ -0,0 +1,76 @@ +#ifndef LINUX_26_32_COMPAT_H +#define LINUX_26_32_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) + +#include +#include + +#define SDIO_VENDOR_ID_INTEL 0x0089 +#define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 +#define SDIO_DEVICE_ID_INTEL_IWMC3200WIFI 0x1403 +#define SDIO_DEVICE_ID_INTEL_IWMC3200TOP 0x1404 +#define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405 +#define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406 + +/* + * struct genl_multicast_group was made netns aware through + * patch "genetlink: make netns aware" by johannes, we just + * force this to always use the default init_net + */ +#define genl_info_net(x) &init_net +/* Just use init_net for older kernels */ +#define get_net_ns_by_pid(x) &init_net + +/* net namespace is lost */ +#define genlmsg_multicast_netns(a, b, c, d, e) genlmsg_multicast(b, c, d, e) +#define genlmsg_multicast_allns(a, b, c, d) genlmsg_multicast(a, b, c, d) + +#define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP) + +#define SET_NETDEV_DEVTYPE(netdev, type) + +#ifdef __KERNEL__ +/* Driver transmit return codes */ +enum netdev_tx { + BACKPORT_NETDEV_TX_OK = NETDEV_TX_OK, /* driver took care of packet */ + BACKPORT_NETDEV_TX_BUSY = NETDEV_TX_BUSY, /* driver tx path was busy*/ + BACKPORT_NETDEV_TX_LOCKED = NETDEV_TX_LOCKED, /* driver tx lock was already taken */ +}; +typedef enum netdev_tx netdev_tx_t; +#endif /* __KERNEL__ */ + +/* + * dev_pm_ops is only available on kernels >= 2.6.29, for + * older kernels we rely on reverting the work to old + * power management style stuff. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) +/* + * Use this if you want to use the same suspend and resume callbacks for suspend + * to RAM and hibernation. + */ +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ +struct dev_pm_ops name = { \ + .suspend = suspend_fn, \ + .resume = resume_fn, \ + .freeze = suspend_fn, \ + .thaw = resume_fn, \ + .poweroff = suspend_fn, \ + .restore = resume_fn, \ +} +#else +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) +#endif /* >= 2.6.29 */ + +#define wireless_send_event(a, b, c, d) wireless_send_event(a, b, c, (char * ) d) + +/* The export symbol in changed in compat/patches/15-symbol-export-conflicts.patch */ +#define ieee80211_rx(hw, skb) mac80211_ieee80211_rx(hw, skb) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ + +#endif /* LINUX_26_32_COMPAT_H */ diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h new file mode 100644 index 00000000..528627ea --- /dev/null +++ b/include/linux/compat-2.6.33.h @@ -0,0 +1,15 @@ +#ifndef LINUX_26_33_COMPAT_H +#define LINUX_26_33_COMPAT_H + +#include +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) + +#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ +/* source: include/linux/if.h */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ + +#endif /* LINUX_26_33_COMPAT_H */ diff --git a/include/linux/compat.h b/include/linux/compat.h new file mode 100644 index 00000000..bea00c99 --- /dev/null +++ b/include/linux/compat.h @@ -0,0 +1,26 @@ +#ifndef LINUX_26_COMPAT_H +#define LINUX_26_COMPAT_H + +#include +#include +#include + +/* + * Each compat file represents compatibility code for new kernel + * code introduced for *that* kernel revision. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat_autoconf.h b/include/linux/compat_autoconf.h new file mode 100644 index 00000000..813755c6 --- /dev/null +++ b/include/linux/compat_autoconf.h @@ -0,0 +1,37 @@ +#ifndef COMPAT_AUTOCONF_INCLUDED +#define COMPAT_AUTOCONF_INCLUDED + +/* + * This is an example of a compat autconf header file that gets + * automatically generated by your projet. You will only need this + * if you are working with a lot of config options. + * + * Your project will likely just override this, or leave this as-is. + */ + +/* + * Example automatically generated C config: don't edit + * Thu Dec 10 10:34:11 PST 2009 + * compat-wireless-2.6: master-2009-11-19-5-gb4fd4dd + * linux-2.6: next-20091208 + */ +//#define COMPAT_PROJECT_FOO_RELEASE "master-2009-11-19-5-gb4fd4dd" +//#define COMPAT_UPSTREAM_FOO_KERNEL_RELEASE "next-20091208" + +/* Example kernel version minimum requirement */ +//#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) +//#error Compat-wireless requirement: Linux >= 2,6,10 +//#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) */ + +/* Example hard requirement */ +//#error Compat-wireless requirement: CONFIG_WIRELESS_EXT must be enabled in your kernel +//#endif /* CONFIG_WIRELESS_EXT */ + +/* + * Example of how to match your external modules kconfig options into this. + * You'll need something to generate this for you. + */ +//#ifndef CONFIG_FOO_BAR +//#define CONFIG_FOO_BAR 1 + +#endif /* COMPAT_AUTOCONF_INCLUDED */ diff --git a/main.c b/main.c deleted file mode 100644 index 390278db..00000000 --- a/main.c +++ /dev/null @@ -1,18 +0,0 @@ -#include - -MODULE_AUTHOR("Luis R. Rodriguez"); -MODULE_DESCRIPTION("Kernel compatibility module"); -MODULE_LICENSE("GPL"); - -static int __init compat_init(void) -{ - return 0; -} -module_init(compat_init); - -static void __exit compat_exit(void) -{ - return; -} -module_exit(compat_exit); - -- cgit v1.2.3 From 2e6e7db7df95d819ccfc67beeb328b8d3574e624 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 15:30:14 -0800 Subject: Fix 2.6.31 build: iw_handler needs asm/compat.h Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 3e8725a1..54f7cb09 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -7,6 +7,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) #include +#include #include #define SDIO_VENDOR_ID_INTEL 0x0089 -- cgit v1.2.3 From 0dca48d4a634d64075cdf2ae247249a2b0a3ef60 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 22:20:43 -0800 Subject: Rename compat.h to compat-2.6.h As include/linux/compat.h is already taken upstream. Signed-off-by: Luis R. Rodriguez --- Makefile | 6 +++--- include/linux/compat-2.6.h | 26 ++++++++++++++++++++++++++ include/linux/compat.h | 26 -------------------------- 3 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 include/linux/compat-2.6.h delete mode 100644 include/linux/compat.h diff --git a/Makefile b/Makefile index 0433a14d..0d4bd66d 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) COMPAT_LATEST_VERSION = 32 KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_$(ver)=y)) +$(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) endif obj-y += compat/ @@ -23,7 +23,7 @@ obj-y += compat/ # This hack lets us put our include path first than the kernel's # when building our compat modules. Your own makefile would look # the same. -NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat.h $(CFLAGS) +NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat-2.6.h $(CFLAGS) modules: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules @@ -35,4 +35,4 @@ clean: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean all: modules -clean-files := Module.symvers modules.order Module.markers +clean-files := Module.symvers modules.order Module.markers compat/modules.order diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h new file mode 100644 index 00000000..bea00c99 --- /dev/null +++ b/include/linux/compat-2.6.h @@ -0,0 +1,26 @@ +#ifndef LINUX_26_COMPAT_H +#define LINUX_26_COMPAT_H + +#include +#include +#include + +/* + * Each compat file represents compatibility code for new kernel + * code introduced for *that* kernel revision. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat.h b/include/linux/compat.h deleted file mode 100644 index bea00c99..00000000 --- a/include/linux/compat.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef LINUX_26_COMPAT_H -#define LINUX_26_COMPAT_H - -#include -#include -#include - -/* - * Each compat file represents compatibility code for new kernel - * code introduced for *that* kernel revision. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From 416dea1cc82b74ffb0bf2782c24fc0557170b8cb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 10 Dec 2009 23:30:08 -0800 Subject: Add some new 2.6.33 backport code for networking Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 528627ea..8ac44e59 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -10,6 +10,12 @@ #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ +#define kparam_block_sysfs_write(a) +#define kparam_unblock_sysfs_write(a) + +/* this will never happen on older kernels */ +#define NETDEV_POST_INIT 0xffff + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 5d3ff43a5c8b251a9dabb06a03783b1d53f516f6 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 11 Dec 2009 15:36:16 -0800 Subject: Add a backport for flush_delayed_work() We can't really *flush* per se, see the code for more details but we can at least delete and synch the timer. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 54f7cb09..727ac71d 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -9,6 +9,7 @@ #include #include #include +#include #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 @@ -17,6 +18,24 @@ #define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405 #define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406 +static inline void flush_delayed_work(struct delayed_work *dwork) +{ + if (del_timer_sync(&dwork->timer)) { + /* + * This is what would happen on 2.6.32 but since we don't have + * access to the singlethread_cpu we can't really backport this, + * so avoid really *flush*ing the work... Oh well. Any better ideas? + + struct cpu_workqueue_struct *cwq; + cwq = wq_per_cpu(keventd_wq, get_cpu()); + __queue_work(cwq, &dwork->work); + put_cpu(); + + */ + } + flush_work(&dwork->work); +} + /* * struct genl_multicast_group was made netns aware through * patch "genetlink: make netns aware" by johannes, we just -- cgit v1.2.3 From 46c10c1254bd98fd0c8be4c557c5db3a9be6af3d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 11 Dec 2009 21:33:41 -0800 Subject: Backport netdev_alloc_skb_ip_align Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 8ac44e59..0942baf1 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -7,6 +7,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) +#include + #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ @@ -16,6 +18,16 @@ /* this will never happen on older kernels */ #define NETDEV_POST_INIT 0xffff +static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length) +{ + struct sk_buff *skb = netdev_alloc_skb(dev, length + NET_IP_ALIGN); + + if (NET_IP_ALIGN && skb) + skb_reserve(skb, NET_IP_ALIGN); + return skb; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From c7ef0678c7fc485c47c00ce93602d95352b1140d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 22 Dec 2009 16:20:00 +0100 Subject: compat: Backport pcmcia from 2.6.33 This backports the pcmcia_loop_tuple function and change the signature of pcmcia_request_window and pcmcia_map_mem_page as needed for older kernels. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-2.6.33.c | 130 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.33.h | 21 +++++++ 3 files changed, 152 insertions(+) create mode 100644 compat/compat-2.6.33.c diff --git a/compat/Makefile b/compat/Makefile index 20d80e2d..fd2f99fe 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -19,3 +19,4 @@ compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o +compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c new file mode 100644 index 00000000..052c6099 --- /dev/null +++ b/compat/compat-2.6.33.c @@ -0,0 +1,130 @@ +/* + * Copyright 2009 Hauke Mehrtens + * + * 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.33. + */ + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) + + +/** + * pccard_loop_tuple() - loop over tuples in the CIS + * @s: the struct pcmcia_socket where the card is inserted + * @function: the device function we loop for + * @code: which CIS code shall we look for? + * @parse: buffer where the tuple shall be parsed (or NULL, if no parse) + * @priv_data: private data to be passed to the loop_tuple function. + * @loop_tuple: function to call for each CIS entry of type @function. IT + * gets passed the raw tuple, the paresed tuple (if @parse is + * set) and @priv_data. + * + * pccard_loop_tuple() loops over all CIS entries of type @function, and + * calls the @loop_tuple function for each entry. If the call to @loop_tuple + * returns 0, the loop exits. Returns 0 on success or errorcode otherwise. + */ +int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, + cisdata_t code, cisparse_t *parse, void *priv_data, + int (*loop_tuple) (tuple_t *tuple, + cisparse_t *parse, + void *priv_data)) +{ + tuple_t tuple; + cisdata_t *buf; + int ret; + + buf = kzalloc(256, GFP_KERNEL); + if (buf == NULL) { + dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n"); + return -ENOMEM; + } + + tuple.TupleData = buf; + tuple.TupleDataMax = 255; + tuple.TupleOffset = 0; + tuple.DesiredTuple = code; + tuple.Attributes = 0; + + ret = pccard_get_first_tuple(s, function, &tuple); + while (!ret) { + if (pccard_get_tuple_data(s, &tuple)) + goto next_entry; + + if (parse) + if (pcmcia_parse_tuple(&tuple, parse)) + goto next_entry; + + ret = loop_tuple(&tuple, parse, priv_data); + if (!ret) + break; + +next_entry: + ret = pccard_get_next_tuple(s, function, &tuple); + } + + kfree(buf); + return ret; +} +EXPORT_SYMBOL(pccard_loop_tuple); +/* Source: drivers/pcmcia/cistpl.c */ + + +struct pcmcia_loop_mem { + struct pcmcia_device *p_dev; + void *priv_data; + int (*loop_tuple) (struct pcmcia_device *p_dev, + tuple_t *tuple, + void *priv_data); +}; + +/** + * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config() + * + * pcmcia_do_loop_tuple() is the internal callback for the call from + * pcmcia_loop_tuple() to pccard_loop_tuple(). Data is transferred + * by a struct pcmcia_cfg_mem. + */ +static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv) +{ + struct pcmcia_loop_mem *loop = priv; + + return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data); +}; + +/** + * pcmcia_loop_tuple() - loop over tuples in the CIS + * @p_dev: the struct pcmcia_device which we need to loop for. + * @code: which CIS code shall we look for? + * @priv_data: private data to be passed to the loop_tuple function. + * @loop_tuple: function to call for each CIS entry of type @function. IT + * gets passed the raw tuple and @priv_data. + * + * pcmcia_loop_tuple() loops over all CIS entries of type @function, and + * calls the @loop_tuple function for each entry. If the call to @loop_tuple + * returns 0, the loop exits. Returns 0 on success or errorcode otherwise. + */ +int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, + int (*loop_tuple) (struct pcmcia_device *p_dev, + tuple_t *tuple, + void *priv_data), + void *priv_data) +{ + struct pcmcia_loop_mem loop = { + .p_dev = p_dev, + .loop_tuple = loop_tuple, + .priv_data = priv_data}; + + return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, + &loop, pcmcia_do_loop_tuple); +} +EXPORT_SYMBOL(pcmcia_loop_tuple); +/* Source: drivers/pcmcia/pcmcia_resource.c */ + + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ + diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 0942baf1..5367cd99 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -8,6 +8,9 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) #include +#include +#include +#include #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ @@ -28,6 +31,24 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, return skb; } +#define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c) + +#define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c) + +/* loop over CIS entries */ +int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, + int (*loop_tuple) (struct pcmcia_device *p_dev, + tuple_t *tuple, + void *priv_data), + void *priv_data); + +/* loop over CIS entries */ +int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, + cisdata_t code, cisparse_t *parse, void *priv_data, + int (*loop_tuple) (tuple_t *tuple, + cisparse_t *parse, + void *priv_data)); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 67e42ae9944837d0787a66c9ced00ceaa86d4a43 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 26 Dec 2009 22:44:34 +0100 Subject: compat: backport kfifo for libertas Second part of the kfifo backport. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 5367cd99..68f0e2ca 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -11,6 +11,7 @@ #include #include #include +#include #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ @@ -49,6 +50,13 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, cisparse_t *parse, void *priv_data)); +/* Backport for kfifo + * kfifo_alloc and kfifo_free must be backported manually + */ +#define kfifo_in(a, b, c) __kfifo_put(*a, b, c) +#define kfifo_out(a, b, c) __kfifo_get(*a, b, c) +#define kfifo_len(a) __kfifo_len(*a) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 5dc40f3a780ef81b818cd55871c556eb6f24b0ad Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 26 Dec 2009 22:44:35 +0100 Subject: compat: Backport eth_mac_addr eth_mac_addr is needed by net/mac80211/iface.c Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.29.c | 24 ++++++++++++++++++++++++ include/linux/compat-2.6.29.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 669ad350..ea2a9919 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -13,6 +13,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) #include +#include /** * usb_unpoison_anchored_urbs - let an anchor be used successfully again @@ -35,6 +36,29 @@ void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) } EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); +/** + * eth_mac_addr - set new Ethernet hardware address + * @dev: network device + * @p: socket address + * Change hardware address of device. + * + * This doesn't change hardware matching, so needs to be overridden + * for most real devices. + */ +int eth_mac_addr(struct net_device *dev, void *p) +{ + struct sockaddr *addr = p; + + if (netif_running(dev)) + return -EBUSY; + if (!is_valid_ether_addr(addr->sa_data)) + return -EADDRNOTAVAIL; + memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + return 0; +} +EXPORT_SYMBOL(eth_mac_addr); +/* Source: net/ethernet/eth.c */ + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index cad5e6b4..b31a58c9 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -56,6 +56,8 @@ extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); } \ ) +extern int eth_mac_addr(struct net_device *dev, void *p); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ #endif /* LINUX_26_29_COMPAT_H */ -- cgit v1.2.3 From 1ce9a1070be5e447e1574ea7a627d7ccc1495a05 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 09:48:04 -0800 Subject: Add missing headers for 2.6.24 and 2.6.25 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 2 ++ include/linux/compat-2.6.24.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index e872447a..bd2afefa 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -13,6 +13,8 @@ /* All things not in 2.6.22, 2.6.23 and 2.6.24 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) +#include + /* Backport work for QoS dependencies (kernel/pm_qos_params.c) * ipw2100 now makes use of * pm_qos_add_requirement(), diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 43e63022..091b7eab 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -7,6 +7,8 @@ /* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include + /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; -- cgit v1.2.3 From 3f72956504fbcccda61ed875501eeee0f6e4618d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 09:56:43 -0800 Subject: Add few missing misc defines for compilation on 2.6.25 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 23cf4876..d876be82 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -13,8 +13,21 @@ #include #include #include +#include #include +/* + * 2.6.25 adds PM_EVENT_HIBERNATE as well here but + * we don't have this on <= 2.6.23) + */ +#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND) + +/* Although we don't care about wimax this is needed for rfkill input stuff */ +#define KEY_WIMAX 246 + +/* Although pm_qos stuff is not implemented on <= 2.6.24 lets keep the define */ +#define PM_QOS_DEFAULT_VALUE -1 + #define __WARN(foo) dump_stack() #define dev_emerg(dev, format, arg...) \ -- cgit v1.2.3 From 2d7c39a08265fb4a45e1686476959b9281092894 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 5 Jan 2010 18:00:04 -0800 Subject: Make kobject_set_name_vargs() do nothing on <= 2.6.24 The struct kobject does not have a name member on older kernels so naming something naming a kobject will be futile. This implies dev_set_name() won't be able to rename the kobject. This may actually bust 2.6.24, I believe we discussed this particular issue on the linux-wireless mailing list at some point with a person trying 2.6.24. If there is an issue with this patch we can go back and check the list. I'm offline rigtt now though so trying to get compilation to work at least. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.26.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index 960a79a1..d591eb0a 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -20,6 +20,9 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) +/* 2.6.24 does not have the struct kobject with a name */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) + /** * kobject_set_name_vargs - Set the name of an kobject * @kobj: struct kobject to set the name of @@ -47,6 +50,14 @@ int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, kfree(old_name); return 0; } +#else +static +int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, + va_list vargs) +{ + return 0; +} +#endif /** * dev_set_name - set a device name -- cgit v1.2.3 From 88d8bae287c48096d3c33ac5774383d68a5a39aa Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 5 Jan 2010 18:07:33 -0800 Subject: Remove duplicate __dev_addr_sync() and __dev_addr_sync() for older kernels These were implemented eons ago for 2.6.25 backport work but now 2.6.32 exported these again implemented in the exact same way so just use that. 2.6.24 now compiles with ath9k. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index bd2afefa..19ecdd28 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -328,53 +328,5 @@ define_strict_strtox(l, long) EXPORT_SYMBOL(strict_strtoul); EXPORT_SYMBOL(strict_strtol); -int __dev_addr_sync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - int err = 0; - - da = *from; - while (da != NULL) { - next = da->next; - if (!da->da_synced) { - err = __dev_addr_add(to, to_count, - da->da_addr, da->da_addrlen, 0); - if (err < 0) - break; - da->da_synced = 1; - da->da_users++; - } else if (da->da_users == 1) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } - return err; -} -EXPORT_SYMBOL_GPL(__dev_addr_sync); - -void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - - da = *from; - while (da != NULL) { - next = da->next; - if (da->da_synced) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - da->da_synced = 0; - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } -} -EXPORT_SYMBOL_GPL(__dev_addr_unsync); - #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ -- cgit v1.2.3 From 0cc2fce3ad6c0ed3a852d107b0244121118fb26b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 5 Jan 2010 18:42:35 -0800 Subject: Fix compilation warning on iface.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes this compilation warning: 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:392: warning: statement with no effect /home/mcgrof/devel/compat-wireless-2.6/net/mac80211/iface.c:397: warning: statement with no effect Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.27.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index ed10a6c4..3b29294c 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -45,8 +45,8 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); /* * The net_device has a spin_lock on newer kernels, on older kernels we're out of luck */ -#define netif_addr_lock_bh -#define netif_addr_unlock_bh +#define netif_addr_lock_bh(dev) +#define netif_addr_unlock_bh(dev) /* * To port this properly we'd have to port warn_slowpath_null(), -- cgit v1.2.3 From d9ac575676a8c26aef9577dca512cc7ab7076eb9 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 11:24:27 -0800 Subject: Backport pm-qos for kernels <= 2.6.24 pm-qos is used by mac80211 and ipw2100. mac80211 uses it for the dynamic power save to see if to enable it or not upon recalculation for dynamic ps. It takes the latency registered to the kernel into account. Since older kernels do not have pm-qos we simply initialize pm-qos stuff durng the compat module probe treating pm-qos as if it were a feature of the compat module. We carry the header file include/linux/pm_qos_params.h as part of this package, external kernel drivers just need to ensure they also make use of the NOSTDINC_FLAGS flag as we do on the top level Makefile to be able to benefit from a direct port and let external drivers also inlcude include/linux/pm_qos_params.h as it if it were in their older kernels. Cc: Mark Gross Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 178 +++++++++++++++++++++++++++++++++++++++++- compat/main.c | 3 + include/linux/compat-2.6.25.h | 12 +++ include/linux/pm_qos_params.h | 26 ++++++ 4 files changed, 216 insertions(+), 3 deletions(-) create mode 100644 include/linux/pm_qos_params.h diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 19ecdd28..32845725 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Luis R. Rodriguez + * Copyright 2007-2010 Luis R. Rodriguez * * 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 @@ -15,13 +15,23 @@ #include -/* Backport work for QoS dependencies (kernel/pm_qos_params.c) +/* + * Backport work for QoS dependencies (kernel/pm_qos_params.c) + * pm-qos stuff written by mark gross mgross@linux.intel.com. + * * ipw2100 now makes use of * pm_qos_add_requirement(), * pm_qos_update_requirement() and * pm_qos_remove_requirement() from it * - * */ + * mac80211 uses the network latency to determine if to enable or not + * dynamic PS. mac80211 also and registers a notifier for when + * the latency changes. Since older kernels do no thave pm-qos stuff + * we just implement it completley here and register it upon cfg80211 + * init. I haven't tested ipw2100 on 2.6.24 though. + * + * This is copied from the kernel written by mark gross mgross@linux.intel.com + */ /* * locking rule: all changes to target_value or requirements or notifiers lists @@ -94,6 +104,17 @@ static struct pm_qos_object *pm_qos_array[] = { static DEFINE_SPINLOCK(pm_qos_lock); +static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos); +static int pm_qos_power_open(struct inode *inode, struct file *filp); +static int pm_qos_power_release(struct inode *inode, struct file *filp); + +static const struct file_operations pm_qos_power_fops = { + .write = pm_qos_power_write, + .open = pm_qos_power_open, + .release = pm_qos_power_release, +}; + /* static helper functions */ static s32 max_compare(s32 v1, s32 v2) { @@ -132,6 +153,46 @@ static void update_target(int target) (unsigned long) extreme_value, NULL); } +static int register_pm_qos_misc(struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + + return misc_register(&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor(int minor) +{ + int pm_qos_class; + + for (pm_qos_class = 0; + pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { + if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) + return pm_qos_class; + } + return -1; +} + +/** + * pm_qos_requirement - returns current system wide qos expectation + * @pm_qos_class: identification of which qos value is requested + * + * This function returns the current target value in an atomic manner. + */ +int pm_qos_requirement(int pm_qos_class) +{ + int ret_val; + unsigned long flags; + + spin_lock_irqsave(&pm_qos_lock, flags); + ret_val = pm_qos_array[pm_qos_class]->target_value; + spin_unlock_irqrestore(&pm_qos_lock, flags); + + return ret_val; +} +EXPORT_SYMBOL_GPL(pm_qos_requirement); /** * pm_qos_add_requirement - inserts new qos request into the list @@ -242,6 +303,117 @@ void pm_qos_remove_requirement(int pm_qos_class, char *name) } EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); +/** + * pm_qos_add_notifier - sets notification entry for changes to target value + * @pm_qos_class: identifies which qos target changes should be notified. + * @notifier: notifier block managed by caller. + * + * will register the notifier into a notification chain that gets called + * uppon changes to the pm_qos_class target value. + */ + int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) +{ + int retval; + + retval = blocking_notifier_chain_register( + pm_qos_array[pm_qos_class]->notifiers, notifier); + + return retval; +} +EXPORT_SYMBOL_GPL(pm_qos_add_notifier); + +/** + * pm_qos_remove_notifier - deletes notification entry from chain. + * @pm_qos_class: identifies which qos target changes are notified. + * @notifier: notifier block to be removed. + * + * will remove the notifier from the notification chain that gets called + * uppon changes to the pm_qos_class target value. + */ +int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) +{ + int retval; + + retval = blocking_notifier_chain_unregister( + pm_qos_array[pm_qos_class]->notifiers, notifier); + + return retval; +} +EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); + +#define PID_NAME_LEN sizeof("process_1234567890") +static char name[PID_NAME_LEN]; + +static int pm_qos_power_open(struct inode *inode, struct file *filp) +{ + int ret; + long pm_qos_class; + + pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); + if (pm_qos_class >= 0) { + filp->private_data = (void *)pm_qos_class; + sprintf(name, "process_%d", current->pid); + ret = pm_qos_add_requirement(pm_qos_class, name, + PM_QOS_DEFAULT_VALUE); + if (ret >= 0) + return 0; + } + + return -EPERM; +} + +static int pm_qos_power_release(struct inode *inode, struct file *filp) +{ + int pm_qos_class; + + pm_qos_class = (long)filp->private_data; + sprintf(name, "process_%d", current->pid); + pm_qos_remove_requirement(pm_qos_class, name); + + return 0; +} + +static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos) +{ + s32 value; + int pm_qos_class; + + pm_qos_class = (long)filp->private_data; + if (count != sizeof(s32)) + return -EINVAL; + if (copy_from_user(&value, buf, sizeof(s32))) + return -EFAULT; + sprintf(name, "process_%d", current->pid); + pm_qos_update_requirement(pm_qos_class, name, value); + + return sizeof(s32); +} + +/* + * This initializes pm-qos for older kernels. + */ +int compat_pm_qos_power_init(void) +{ + int ret = 0; + + ret = register_pm_qos_misc(&cpu_dma_pm_qos); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&network_lat_pm_qos); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: network_latency setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&network_throughput_pm_qos); + if (ret < 0) + printk(KERN_ERR + "pm_qos_param: network_throughput setup failed\n"); + + return ret; +} /** * The following things are out of ./lib/vsprintf.c diff --git a/compat/main.c b/compat/main.c index 390278db..251ba43c 100644 --- a/compat/main.c +++ b/compat/main.c @@ -6,6 +6,9 @@ MODULE_LICENSE("GPL"); static int __init compat_init(void) { + /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ + compat_pm_qos_power_init(); + return 0; } module_init(compat_init); diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index d876be82..054b3e59 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -15,6 +15,9 @@ #include #include #include +#include + +int compat_pm_qos_power_init(void); /* * 2.6.25 adds PM_EVENT_HIBERNATE as well here but @@ -120,6 +123,15 @@ static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) extern int strict_strtoul(const char *, unsigned int, unsigned long *); extern int strict_strtol(const char *, unsigned int, long *); +#else +/* + * Kernels >= 2.6.25 have pm-qos and its initialized as part of + * the bootup process + */ +static inline int compat_pm_qos_power_init(void) +{ + return; +} #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ #endif /* LINUX_26_25_COMPAT_H */ diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h new file mode 100644 index 00000000..091c13c7 --- /dev/null +++ b/include/linux/pm_qos_params.h @@ -0,0 +1,26 @@ +/* interface for the pm_qos_power infrastructure of the linux kernel. + * + * Mark Gross + */ +#include +#include +#include + +#define PM_QOS_RESERVED 0 +#define PM_QOS_CPU_DMA_LATENCY 1 +#define PM_QOS_NETWORK_LATENCY 2 +#define PM_QOS_NETWORK_THROUGHPUT 3 +#define PM_QOS_SYSTEM_BUS_FREQ 4 + +#define PM_QOS_NUM_CLASSES 5 +#define PM_QOS_DEFAULT_VALUE -1 + +int pm_qos_add_requirement(int qos, char *name, s32 value); +int pm_qos_update_requirement(int qos, char *name, s32 new_value); +void pm_qos_remove_requirement(int qos, char *name); + +int pm_qos_requirement(int qos); + +int pm_qos_add_notifier(int qos, struct notifier_block *notifier); +int pm_qos_remove_notifier(int qos, struct notifier_block *notifier); + -- cgit v1.2.3 From 4c69b272d698765be2f614ed900e866c64dab0ab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 11:27:07 -0800 Subject: Simple compile warning fix for pm-qos return 0 on newer kernels. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 054b3e59..a4d5c908 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -130,7 +130,7 @@ extern int strict_strtol(const char *, unsigned int, long *); */ static inline int compat_pm_qos_power_init(void) { - return; + return 0; } #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ -- cgit v1.2.3 From b01d80cc389a805c2cf2be1051ab52352e4a9903 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 11:49:33 -0800 Subject: include arp.h, required for 2.6.23 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.24.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index 977eb45e..e496236e 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -13,6 +13,8 @@ /* All things not in 2.6.22 and 2.6.23 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include + /* Part of net/ethernet/eth.c as of 2.6.24 */ char *print_mac(char *buf, const u8 *addr) { -- cgit v1.2.3 From 050e4900331f5d34e077bed4b2deb2f2d82aca86 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 12:08:54 -0800 Subject: Remove duplicate __dev_addr_delete() This is already implemented on compat-2.6.32.c Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.24.c | 61 -------------------------------------------------- 1 file changed, 61 deletions(-) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index e496236e..347f6f7d 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -24,67 +24,6 @@ char *print_mac(char *buf, const u8 *addr) } EXPORT_SYMBOL(print_mac); -/* On net/core/dev.c as of 2.6.24 */ -int __dev_addr_delete(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (; (da = *list) != NULL; list = &da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - alen == da->da_addrlen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 0; - if (old_glbl == 0) - break; - } - if (--da->da_users) - return 0; - - *list = da->next; - kfree(da); - (*count)--; - return 0; - } - } - return -ENOENT; -} - -/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but - * might as well add it */ -int __dev_addr_add(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (da = *list; da != NULL; da = da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - da->da_addrlen == alen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 1; - if (old_glbl) - return 0; - } - da->da_users++; - return 0; - } - } - - da = kmalloc(sizeof(*da), GFP_ATOMIC); - if (da == NULL) - return -ENOMEM; - memcpy(da->da_addr, addr, alen); - da->da_addrlen = alen; - da->da_users = 1; - da->da_gusers = glbl ? 1 : 0; - da->next = *list; - *list = da; - (*count)++; - return 0; -} - /* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ -- cgit v1.2.3 From 009d808ca18e10685321e28d3293bd54f115b9bf Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 12:11:43 -0800 Subject: Fix compilation for 2.6.23 due to missing declaration of sg_init_table() Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.24.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 091b7eab..287b14c3 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -181,6 +181,7 @@ static inline void sg_mark_end(struct scatterlist *sg) * used only on the last table part. * **/ +static inline void sg_init_table(struct scatterlist *sgl, unsigned int nents) { memset(sgl, 0, sizeof(*sgl) * nents); } -- cgit v1.2.3 From 819330bf6c14af584b494e590df68cbca388a921 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 12:18:59 -0800 Subject: Skip MMC/SDIO backport for kernels <= 2.6.23 This allows compilation of compat for 2.6.23 for builds that do not require MMC/SDIO. Anyone interested in MMC/SDIO backport support should look to see if its possible to backport/add MMC/SDIO support to older kernels. That's likeley a project on its own though, not sure. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.27.c | 4 ++++ include/linux/compat-2.6.27.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index 7fffe8e0..4fef36ab 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -13,10 +13,12 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #include #include #include +#endif /* rfkill notification chain */ #define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill @@ -67,6 +69,7 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) } EXPORT_SYMBOL(pci_pme_capable); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) /** * mmc_align_data_size - pads a transfer size to a more optimal value * @card: the MMC card associated with the data transfer @@ -201,6 +204,7 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) return orig_sz; } EXPORT_SYMBOL_GPL(sdio_align_size); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 3b29294c..3e5e661c 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -9,8 +9,10 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #include +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ #include #include #include @@ -159,8 +161,10 @@ static inline void list_splice_tail_init(struct list_head *list, } } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ #define iwe_stream_add_value(info, event, value, ends, iwe, event_len) iwe_stream_add_value(event, value, ends, iwe, event_len) #define iwe_stream_add_point(info, stream, ends, iwe, extra) iwe_stream_add_point(stream, ends, iwe, extra) -- cgit v1.2.3 From 339afd76afe046098ebb2242825b760f529a3782 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 14:38:40 -0800 Subject: Add missing headers for 2.6.24 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.24.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 287b14c3..90a0cd4d 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -7,7 +7,12 @@ /* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) +#include +#include #include +#include +#include +#include /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; -- cgit v1.2.3 From d6160fd5d2404dc5c9d72a441f3373d4636eec9c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 15:43:19 -0800 Subject: Copy over a few headers from the latest kernel These header files are used regularly by new Linux driver. Instead of backporting those headers just copy the headers over. This is typically not recommended unless you know what you are doing. In this case we do -- we ensure structs don't change for usage of certain subystems and when they do change we port the entire subsystem ourselves. In this case we only copy over bit operations, unaligned helpers. The only subystem related header we copy over is the wireless header for which we use to backport the entire 802.11 subsystem using compat-wireless, and compat-wireless uses this compat module. We'll synch these on each kernel release. Signed-off-by: Luis R. Rodriguez --- include/linux/bitops.h | 194 ++++++ include/linux/compat-2.6.27.h | 1 + include/linux/unaligned/access_ok.h | 67 ++ include/linux/unaligned/be_byteshift.h | 70 ++ include/linux/unaligned/be_memmove.h | 36 + include/linux/unaligned/be_struct.h | 36 + include/linux/unaligned/generic.h | 68 ++ include/linux/unaligned/le_byteshift.h | 70 ++ include/linux/unaligned/le_memmove.h | 36 + include/linux/unaligned/le_struct.h | 36 + include/linux/unaligned/memmove.h | 45 ++ include/linux/unaligned/packed_struct.h | 46 ++ include/linux/wireless.h | 1160 +++++++++++++++++++++++++++++++ 13 files changed, 1865 insertions(+) create mode 100644 include/linux/bitops.h create mode 100644 include/linux/unaligned/access_ok.h create mode 100644 include/linux/unaligned/be_byteshift.h create mode 100644 include/linux/unaligned/be_memmove.h create mode 100644 include/linux/unaligned/be_struct.h create mode 100644 include/linux/unaligned/generic.h create mode 100644 include/linux/unaligned/le_byteshift.h create mode 100644 include/linux/unaligned/le_memmove.h create mode 100644 include/linux/unaligned/le_struct.h create mode 100644 include/linux/unaligned/memmove.h create mode 100644 include/linux/unaligned/packed_struct.h create mode 100644 include/linux/wireless.h diff --git a/include/linux/bitops.h b/include/linux/bitops.h new file mode 100644 index 00000000..c05a29cb --- /dev/null +++ b/include/linux/bitops.h @@ -0,0 +1,194 @@ +#ifndef _LINUX_BITOPS_H +#define _LINUX_BITOPS_H +#include + +#ifdef __KERNEL__ +#define BIT(nr) (1UL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS_PER_BYTE 8 +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) +#endif + +/* + * Include this here because some architectures need generic_ffs/fls in + * scope + */ +#include + +#define for_each_bit(bit, addr, size) \ + for ((bit) = find_first_bit((addr), (size)); \ + (bit) < (size); \ + (bit) = find_next_bit((addr), (size), (bit) + 1)) + + +static __inline__ int get_bitmask_order(unsigned int count) +{ + int order; + + order = fls(count); + return order; /* We could be slightly more clever with -1 here... */ +} + +static __inline__ int get_count_order(unsigned int count) +{ + int order; + + order = fls(count) - 1; + if (count & (count - 1)) + order++; + return order; +} + +static inline unsigned long hweight_long(unsigned long w) +{ + return sizeof(w) == 4 ? hweight32(w) : hweight64(w); +} + +/** + * rol32 - rotate a 32-bit value left + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u32 rol32(__u32 word, unsigned int shift) +{ + return (word << shift) | (word >> (32 - shift)); +} + +/** + * ror32 - rotate a 32-bit value right + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u32 ror32(__u32 word, unsigned int shift) +{ + return (word >> shift) | (word << (32 - shift)); +} + +/** + * rol16 - rotate a 16-bit value left + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u16 rol16(__u16 word, unsigned int shift) +{ + return (word << shift) | (word >> (16 - shift)); +} + +/** + * ror16 - rotate a 16-bit value right + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u16 ror16(__u16 word, unsigned int shift) +{ + return (word >> shift) | (word << (16 - shift)); +} + +/** + * rol8 - rotate an 8-bit value left + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u8 rol8(__u8 word, unsigned int shift) +{ + return (word << shift) | (word >> (8 - shift)); +} + +/** + * ror8 - rotate an 8-bit value right + * @word: value to rotate + * @shift: bits to roll + */ +static inline __u8 ror8(__u8 word, unsigned int shift) +{ + return (word >> shift) | (word << (8 - shift)); +} + +static inline unsigned fls_long(unsigned long l) +{ + if (sizeof(l) == 4) + return fls(l); + return fls64(l); +} + +/** + * __ffs64 - find first set bit in a 64 bit word + * @word: The 64 bit word + * + * On 64 bit arches this is a synomyn for __ffs + * The result is not defined if no bits are set, so check that @word + * is non-zero before calling this. + */ +static inline unsigned long __ffs64(u64 word) +{ +#if BITS_PER_LONG == 32 + if (((u32)word) == 0UL) + return __ffs((u32)(word >> 32)) + 32; +#elif BITS_PER_LONG != 64 +#error BITS_PER_LONG not 32 or 64 +#endif + return __ffs((unsigned long)word); +} + +#ifdef __KERNEL__ +#ifdef CONFIG_GENERIC_FIND_FIRST_BIT + +/** + * find_first_bit - find the first set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit. + */ +extern unsigned long find_first_bit(const unsigned long *addr, + unsigned long size); + +/** + * find_first_zero_bit - find the first cleared bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first cleared bit. + */ +extern unsigned long find_first_zero_bit(const unsigned long *addr, + unsigned long size); +#endif /* CONFIG_GENERIC_FIND_FIRST_BIT */ + +#ifdef CONFIG_GENERIC_FIND_LAST_BIT +/** + * find_last_bit - find the last set bit in a memory region + * @addr: The address to start the search at + * @size: The maximum size to search + * + * Returns the bit number of the first set bit, or size. + */ +extern unsigned long find_last_bit(const unsigned long *addr, + unsigned long size); +#endif /* CONFIG_GENERIC_FIND_LAST_BIT */ + +#ifdef CONFIG_GENERIC_FIND_NEXT_BIT + +/** + * find_next_bit - find the next set bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ +extern unsigned long find_next_bit(const unsigned long *addr, + unsigned long size, unsigned long offset); + +/** + * find_next_zero_bit - find the next cleared bit in a memory region + * @addr: The address to base the search on + * @offset: The bitnumber to start searching at + * @size: The bitmap size in bits + */ + +extern unsigned long find_next_zero_bit(const unsigned long *addr, + unsigned long size, + unsigned long offset); + +#endif /* CONFIG_GENERIC_FIND_NEXT_BIT */ +#endif /* __KERNEL__ */ +#endif diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 3e5e661c..3e471d09 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -17,6 +17,7 @@ #include #include #include +#include #define PCI_PM_CAP_PME_SHIFT 11 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h new file mode 100644 index 00000000..99c1b4d2 --- /dev/null +++ b/include/linux/unaligned/access_ok.h @@ -0,0 +1,67 @@ +#ifndef _LINUX_UNALIGNED_ACCESS_OK_H +#define _LINUX_UNALIGNED_ACCESS_OK_H + +#include +#include + +static inline u16 get_unaligned_le16(const void *p) +{ + return le16_to_cpup((__le16 *)p); +} + +static inline u32 get_unaligned_le32(const void *p) +{ + return le32_to_cpup((__le32 *)p); +} + +static inline u64 get_unaligned_le64(const void *p) +{ + return le64_to_cpup((__le64 *)p); +} + +static inline u16 get_unaligned_be16(const void *p) +{ + return be16_to_cpup((__be16 *)p); +} + +static inline u32 get_unaligned_be32(const void *p) +{ + return be32_to_cpup((__be32 *)p); +} + +static inline u64 get_unaligned_be64(const void *p) +{ + return be64_to_cpup((__be64 *)p); +} + +static inline void put_unaligned_le16(u16 val, void *p) +{ + *((__le16 *)p) = cpu_to_le16(val); +} + +static inline void put_unaligned_le32(u32 val, void *p) +{ + *((__le32 *)p) = cpu_to_le32(val); +} + +static inline void put_unaligned_le64(u64 val, void *p) +{ + *((__le64 *)p) = cpu_to_le64(val); +} + +static inline void put_unaligned_be16(u16 val, void *p) +{ + *((__be16 *)p) = cpu_to_be16(val); +} + +static inline void put_unaligned_be32(u32 val, void *p) +{ + *((__be32 *)p) = cpu_to_be32(val); +} + +static inline void put_unaligned_be64(u64 val, void *p) +{ + *((__be64 *)p) = cpu_to_be64(val); +} + +#endif /* _LINUX_UNALIGNED_ACCESS_OK_H */ diff --git a/include/linux/unaligned/be_byteshift.h b/include/linux/unaligned/be_byteshift.h new file mode 100644 index 00000000..9356b242 --- /dev/null +++ b/include/linux/unaligned/be_byteshift.h @@ -0,0 +1,70 @@ +#ifndef _LINUX_UNALIGNED_BE_BYTESHIFT_H +#define _LINUX_UNALIGNED_BE_BYTESHIFT_H + +#include + +static inline u16 __get_unaligned_be16(const u8 *p) +{ + return p[0] << 8 | p[1]; +} + +static inline u32 __get_unaligned_be32(const u8 *p) +{ + return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; +} + +static inline u64 __get_unaligned_be64(const u8 *p) +{ + return (u64)__get_unaligned_be32(p) << 32 | + __get_unaligned_be32(p + 4); +} + +static inline void __put_unaligned_be16(u16 val, u8 *p) +{ + *p++ = val >> 8; + *p++ = val; +} + +static inline void __put_unaligned_be32(u32 val, u8 *p) +{ + __put_unaligned_be16(val >> 16, p); + __put_unaligned_be16(val, p + 2); +} + +static inline void __put_unaligned_be64(u64 val, u8 *p) +{ + __put_unaligned_be32(val >> 32, p); + __put_unaligned_be32(val, p + 4); +} + +static inline u16 get_unaligned_be16(const void *p) +{ + return __get_unaligned_be16((const u8 *)p); +} + +static inline u32 get_unaligned_be32(const void *p) +{ + return __get_unaligned_be32((const u8 *)p); +} + +static inline u64 get_unaligned_be64(const void *p) +{ + return __get_unaligned_be64((const u8 *)p); +} + +static inline void put_unaligned_be16(u16 val, void *p) +{ + __put_unaligned_be16(val, p); +} + +static inline void put_unaligned_be32(u32 val, void *p) +{ + __put_unaligned_be32(val, p); +} + +static inline void put_unaligned_be64(u64 val, void *p) +{ + __put_unaligned_be64(val, p); +} + +#endif /* _LINUX_UNALIGNED_BE_BYTESHIFT_H */ diff --git a/include/linux/unaligned/be_memmove.h b/include/linux/unaligned/be_memmove.h new file mode 100644 index 00000000..c2a76c5c --- /dev/null +++ b/include/linux/unaligned/be_memmove.h @@ -0,0 +1,36 @@ +#ifndef _LINUX_UNALIGNED_BE_MEMMOVE_H +#define _LINUX_UNALIGNED_BE_MEMMOVE_H + +#include + +static inline u16 get_unaligned_be16(const void *p) +{ + return __get_unaligned_memmove16((const u8 *)p); +} + +static inline u32 get_unaligned_be32(const void *p) +{ + return __get_unaligned_memmove32((const u8 *)p); +} + +static inline u64 get_unaligned_be64(const void *p) +{ + return __get_unaligned_memmove64((const u8 *)p); +} + +static inline void put_unaligned_be16(u16 val, void *p) +{ + __put_unaligned_memmove16(val, p); +} + +static inline void put_unaligned_be32(u32 val, void *p) +{ + __put_unaligned_memmove32(val, p); +} + +static inline void put_unaligned_be64(u64 val, void *p) +{ + __put_unaligned_memmove64(val, p); +} + +#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ diff --git a/include/linux/unaligned/be_struct.h b/include/linux/unaligned/be_struct.h new file mode 100644 index 00000000..13241583 --- /dev/null +++ b/include/linux/unaligned/be_struct.h @@ -0,0 +1,36 @@ +#ifndef _LINUX_UNALIGNED_BE_STRUCT_H +#define _LINUX_UNALIGNED_BE_STRUCT_H + +#include + +static inline u16 get_unaligned_be16(const void *p) +{ + return __get_unaligned_cpu16((const u8 *)p); +} + +static inline u32 get_unaligned_be32(const void *p) +{ + return __get_unaligned_cpu32((const u8 *)p); +} + +static inline u64 get_unaligned_be64(const void *p) +{ + return __get_unaligned_cpu64((const u8 *)p); +} + +static inline void put_unaligned_be16(u16 val, void *p) +{ + __put_unaligned_cpu16(val, p); +} + +static inline void put_unaligned_be32(u32 val, void *p) +{ + __put_unaligned_cpu32(val, p); +} + +static inline void put_unaligned_be64(u64 val, void *p) +{ + __put_unaligned_cpu64(val, p); +} + +#endif /* _LINUX_UNALIGNED_BE_STRUCT_H */ diff --git a/include/linux/unaligned/generic.h b/include/linux/unaligned/generic.h new file mode 100644 index 00000000..02d97ff3 --- /dev/null +++ b/include/linux/unaligned/generic.h @@ -0,0 +1,68 @@ +#ifndef _LINUX_UNALIGNED_GENERIC_H +#define _LINUX_UNALIGNED_GENERIC_H + +/* + * Cause a link-time error if we try an unaligned access other than + * 1,2,4 or 8 bytes long + */ +extern void __bad_unaligned_access_size(void); + +#define __get_unaligned_le(ptr) ((__force typeof(*(ptr)))({ \ + __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ + __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_le16((ptr)), \ + __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_le32((ptr)), \ + __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_le64((ptr)), \ + __bad_unaligned_access_size())))); \ + })) + +#define __get_unaligned_be(ptr) ((__force typeof(*(ptr)))({ \ + __builtin_choose_expr(sizeof(*(ptr)) == 1, *(ptr), \ + __builtin_choose_expr(sizeof(*(ptr)) == 2, get_unaligned_be16((ptr)), \ + __builtin_choose_expr(sizeof(*(ptr)) == 4, get_unaligned_be32((ptr)), \ + __builtin_choose_expr(sizeof(*(ptr)) == 8, get_unaligned_be64((ptr)), \ + __bad_unaligned_access_size())))); \ + })) + +#define __put_unaligned_le(val, ptr) ({ \ + void *__gu_p = (ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(u8 *)__gu_p = (__force u8)(val); \ + break; \ + case 2: \ + put_unaligned_le16((__force u16)(val), __gu_p); \ + break; \ + case 4: \ + put_unaligned_le32((__force u32)(val), __gu_p); \ + break; \ + case 8: \ + put_unaligned_le64((__force u64)(val), __gu_p); \ + break; \ + default: \ + __bad_unaligned_access_size(); \ + break; \ + } \ + (void)0; }) + +#define __put_unaligned_be(val, ptr) ({ \ + void *__gu_p = (ptr); \ + switch (sizeof(*(ptr))) { \ + case 1: \ + *(u8 *)__gu_p = (__force u8)(val); \ + break; \ + case 2: \ + put_unaligned_be16((__force u16)(val), __gu_p); \ + break; \ + case 4: \ + put_unaligned_be32((__force u32)(val), __gu_p); \ + break; \ + case 8: \ + put_unaligned_be64((__force u64)(val), __gu_p); \ + break; \ + default: \ + __bad_unaligned_access_size(); \ + break; \ + } \ + (void)0; }) + +#endif /* _LINUX_UNALIGNED_GENERIC_H */ diff --git a/include/linux/unaligned/le_byteshift.h b/include/linux/unaligned/le_byteshift.h new file mode 100644 index 00000000..be376fb7 --- /dev/null +++ b/include/linux/unaligned/le_byteshift.h @@ -0,0 +1,70 @@ +#ifndef _LINUX_UNALIGNED_LE_BYTESHIFT_H +#define _LINUX_UNALIGNED_LE_BYTESHIFT_H + +#include + +static inline u16 __get_unaligned_le16(const u8 *p) +{ + return p[0] | p[1] << 8; +} + +static inline u32 __get_unaligned_le32(const u8 *p) +{ + return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; +} + +static inline u64 __get_unaligned_le64(const u8 *p) +{ + return (u64)__get_unaligned_le32(p + 4) << 32 | + __get_unaligned_le32(p); +} + +static inline void __put_unaligned_le16(u16 val, u8 *p) +{ + *p++ = val; + *p++ = val >> 8; +} + +static inline void __put_unaligned_le32(u32 val, u8 *p) +{ + __put_unaligned_le16(val >> 16, p + 2); + __put_unaligned_le16(val, p); +} + +static inline void __put_unaligned_le64(u64 val, u8 *p) +{ + __put_unaligned_le32(val >> 32, p + 4); + __put_unaligned_le32(val, p); +} + +static inline u16 get_unaligned_le16(const void *p) +{ + return __get_unaligned_le16((const u8 *)p); +} + +static inline u32 get_unaligned_le32(const void *p) +{ + return __get_unaligned_le32((const u8 *)p); +} + +static inline u64 get_unaligned_le64(const void *p) +{ + return __get_unaligned_le64((const u8 *)p); +} + +static inline void put_unaligned_le16(u16 val, void *p) +{ + __put_unaligned_le16(val, p); +} + +static inline void put_unaligned_le32(u32 val, void *p) +{ + __put_unaligned_le32(val, p); +} + +static inline void put_unaligned_le64(u64 val, void *p) +{ + __put_unaligned_le64(val, p); +} + +#endif /* _LINUX_UNALIGNED_LE_BYTESHIFT_H */ diff --git a/include/linux/unaligned/le_memmove.h b/include/linux/unaligned/le_memmove.h new file mode 100644 index 00000000..269849be --- /dev/null +++ b/include/linux/unaligned/le_memmove.h @@ -0,0 +1,36 @@ +#ifndef _LINUX_UNALIGNED_LE_MEMMOVE_H +#define _LINUX_UNALIGNED_LE_MEMMOVE_H + +#include + +static inline u16 get_unaligned_le16(const void *p) +{ + return __get_unaligned_memmove16((const u8 *)p); +} + +static inline u32 get_unaligned_le32(const void *p) +{ + return __get_unaligned_memmove32((const u8 *)p); +} + +static inline u64 get_unaligned_le64(const void *p) +{ + return __get_unaligned_memmove64((const u8 *)p); +} + +static inline void put_unaligned_le16(u16 val, void *p) +{ + __put_unaligned_memmove16(val, p); +} + +static inline void put_unaligned_le32(u32 val, void *p) +{ + __put_unaligned_memmove32(val, p); +} + +static inline void put_unaligned_le64(u64 val, void *p) +{ + __put_unaligned_memmove64(val, p); +} + +#endif /* _LINUX_UNALIGNED_LE_MEMMOVE_H */ diff --git a/include/linux/unaligned/le_struct.h b/include/linux/unaligned/le_struct.h new file mode 100644 index 00000000..088c4572 --- /dev/null +++ b/include/linux/unaligned/le_struct.h @@ -0,0 +1,36 @@ +#ifndef _LINUX_UNALIGNED_LE_STRUCT_H +#define _LINUX_UNALIGNED_LE_STRUCT_H + +#include + +static inline u16 get_unaligned_le16(const void *p) +{ + return __get_unaligned_cpu16((const u8 *)p); +} + +static inline u32 get_unaligned_le32(const void *p) +{ + return __get_unaligned_cpu32((const u8 *)p); +} + +static inline u64 get_unaligned_le64(const void *p) +{ + return __get_unaligned_cpu64((const u8 *)p); +} + +static inline void put_unaligned_le16(u16 val, void *p) +{ + __put_unaligned_cpu16(val, p); +} + +static inline void put_unaligned_le32(u32 val, void *p) +{ + __put_unaligned_cpu32(val, p); +} + +static inline void put_unaligned_le64(u64 val, void *p) +{ + __put_unaligned_cpu64(val, p); +} + +#endif /* _LINUX_UNALIGNED_LE_STRUCT_H */ diff --git a/include/linux/unaligned/memmove.h b/include/linux/unaligned/memmove.h new file mode 100644 index 00000000..eeb5a779 --- /dev/null +++ b/include/linux/unaligned/memmove.h @@ -0,0 +1,45 @@ +#ifndef _LINUX_UNALIGNED_MEMMOVE_H +#define _LINUX_UNALIGNED_MEMMOVE_H + +#include +#include + +/* Use memmove here, so gcc does not insert a __builtin_memcpy. */ + +static inline u16 __get_unaligned_memmove16(const void *p) +{ + u16 tmp; + memmove(&tmp, p, 2); + return tmp; +} + +static inline u32 __get_unaligned_memmove32(const void *p) +{ + u32 tmp; + memmove(&tmp, p, 4); + return tmp; +} + +static inline u64 __get_unaligned_memmove64(const void *p) +{ + u64 tmp; + memmove(&tmp, p, 8); + return tmp; +} + +static inline void __put_unaligned_memmove16(u16 val, void *p) +{ + memmove(p, &val, 2); +} + +static inline void __put_unaligned_memmove32(u32 val, void *p) +{ + memmove(p, &val, 4); +} + +static inline void __put_unaligned_memmove64(u64 val, void *p) +{ + memmove(p, &val, 8); +} + +#endif /* _LINUX_UNALIGNED_MEMMOVE_H */ diff --git a/include/linux/unaligned/packed_struct.h b/include/linux/unaligned/packed_struct.h new file mode 100644 index 00000000..2498bb9f --- /dev/null +++ b/include/linux/unaligned/packed_struct.h @@ -0,0 +1,46 @@ +#ifndef _LINUX_UNALIGNED_PACKED_STRUCT_H +#define _LINUX_UNALIGNED_PACKED_STRUCT_H + +#include + +struct __una_u16 { u16 x __attribute__((packed)); }; +struct __una_u32 { u32 x __attribute__((packed)); }; +struct __una_u64 { u64 x __attribute__((packed)); }; + +static inline u16 __get_unaligned_cpu16(const void *p) +{ + const struct __una_u16 *ptr = (const struct __una_u16 *)p; + return ptr->x; +} + +static inline u32 __get_unaligned_cpu32(const void *p) +{ + const struct __una_u32 *ptr = (const struct __una_u32 *)p; + return ptr->x; +} + +static inline u64 __get_unaligned_cpu64(const void *p) +{ + const struct __una_u64 *ptr = (const struct __una_u64 *)p; + return ptr->x; +} + +static inline void __put_unaligned_cpu16(u16 val, void *p) +{ + struct __una_u16 *ptr = (struct __una_u16 *)p; + ptr->x = val; +} + +static inline void __put_unaligned_cpu32(u32 val, void *p) +{ + struct __una_u32 *ptr = (struct __una_u32 *)p; + ptr->x = val; +} + +static inline void __put_unaligned_cpu64(u64 val, void *p) +{ + struct __una_u64 *ptr = (struct __una_u64 *)p; + ptr->x = val; +} + +#endif /* _LINUX_UNALIGNED_PACKED_STRUCT_H */ diff --git a/include/linux/wireless.h b/include/linux/wireless.h new file mode 100644 index 00000000..5b4c6c77 --- /dev/null +++ b/include/linux/wireless.h @@ -0,0 +1,1160 @@ +/* + * This file define a set of standard wireless extensions + * + * Version : 22 16.3.07 + * + * Authors : Jean Tourrilhes - HPL - + * Copyright (c) 1997-2007 Jean Tourrilhes, All Rights Reserved. + */ + +#ifndef _LINUX_WIRELESS_H +#define _LINUX_WIRELESS_H + +/************************** DOCUMENTATION **************************/ +/* + * Initial APIs (1996 -> onward) : + * ----------------------------- + * Basically, the wireless extensions are for now a set of standard ioctl + * call + /proc/net/wireless + * + * The entry /proc/net/wireless give statistics and information on the + * driver. + * This is better than having each driver having its entry because + * its centralised and we may remove the driver module safely. + * + * Ioctl are used to configure the driver and issue commands. This is + * better than command line options of insmod because we may want to + * change dynamically (while the driver is running) some parameters. + * + * The ioctl mechanimsm are copied from standard devices ioctl. + * We have the list of command plus a structure descibing the + * data exchanged... + * Note that to add these ioctl, I was obliged to modify : + * # net/core/dev.c (two place + add include) + * # net/ipv4/af_inet.c (one place + add include) + * + * /proc/net/wireless is a copy of /proc/net/dev. + * We have a structure for data passed from the driver to /proc/net/wireless + * Too add this, I've modified : + * # net/core/dev.c (two other places) + * # include/linux/netdevice.h (one place) + * # include/linux/proc_fs.h (one place) + * + * New driver API (2002 -> onward) : + * ------------------------------- + * This file is only concerned with the user space API and common definitions. + * The new driver API is defined and documented in : + * # include/net/iw_handler.h + * + * Note as well that /proc/net/wireless implementation has now moved in : + * # net/core/wireless.c + * + * Wireless Events (2002 -> onward) : + * -------------------------------- + * Events are defined at the end of this file, and implemented in : + * # net/core/wireless.c + * + * Other comments : + * -------------- + * Do not add here things that are redundant with other mechanisms + * (drivers init, ifconfig, /proc/net/dev, ...) and with are not + * wireless specific. + * + * These wireless extensions are not magic : each driver has to provide + * support for them... + * + * IMPORTANT NOTE : As everything in the kernel, this is very much a + * work in progress. Contact me if you have ideas of improvements... + */ + +/***************************** INCLUDES *****************************/ + +#include /* for __u* and __s* typedefs */ +#include /* for "struct sockaddr" et al */ +#include /* for IFNAMSIZ and co... */ + +/***************************** VERSION *****************************/ +/* + * This constant is used to know the availability of the wireless + * extensions and to know which version of wireless extensions it is + * (there is some stuff that will be added in the future...) + * I just plan to increment with each new version. + */ +#define WIRELESS_EXT 22 + +/* + * Changes : + * + * V2 to V3 + * -------- + * Alan Cox start some incompatibles changes. I've integrated a bit more. + * - Encryption renamed to Encode to avoid US regulation problems + * - Frequency changed from float to struct to avoid problems on old 386 + * + * V3 to V4 + * -------- + * - Add sensitivity + * + * V4 to V5 + * -------- + * - Missing encoding definitions in range + * - Access points stuff + * + * V5 to V6 + * -------- + * - 802.11 support (ESSID ioctls) + * + * V6 to V7 + * -------- + * - define IW_ESSID_MAX_SIZE and IW_MAX_AP + * + * V7 to V8 + * -------- + * - Changed my e-mail address + * - More 802.11 support (nickname, rate, rts, frag) + * - List index in frequencies + * + * V8 to V9 + * -------- + * - Support for 'mode of operation' (ad-hoc, managed...) + * - Support for unicast and multicast power saving + * - Change encoding to support larger tokens (>64 bits) + * - Updated iw_params (disable, flags) and use it for NWID + * - Extracted iw_point from iwreq for clarity + * + * V9 to V10 + * --------- + * - Add PM capability to range structure + * - Add PM modifier : MAX/MIN/RELATIVE + * - Add encoding option : IW_ENCODE_NOKEY + * - Add TxPower ioctls (work like TxRate) + * + * V10 to V11 + * ---------- + * - Add WE version in range (help backward/forward compatibility) + * - Add retry ioctls (work like PM) + * + * V11 to V12 + * ---------- + * - Add SIOCSIWSTATS to get /proc/net/wireless programatically + * - Add DEV PRIVATE IOCTL to avoid collisions in SIOCDEVPRIVATE space + * - Add new statistics (frag, retry, beacon) + * - Add average quality (for user space calibration) + * + * V12 to V13 + * ---------- + * - Document creation of new driver API. + * - Extract union iwreq_data from struct iwreq (for new driver API). + * - Rename SIOCSIWNAME as SIOCSIWCOMMIT + * + * V13 to V14 + * ---------- + * - Wireless Events support : define struct iw_event + * - Define additional specific event numbers + * - Add "addr" and "param" fields in union iwreq_data + * - AP scanning stuff (SIOCSIWSCAN and friends) + * + * V14 to V15 + * ---------- + * - Add IW_PRIV_TYPE_ADDR for struct sockaddr private arg + * - Make struct iw_freq signed (both m & e), add explicit padding + * - Add IWEVCUSTOM for driver specific event/scanning token + * - Add IW_MAX_GET_SPY for driver returning a lot of addresses + * - Add IW_TXPOW_RANGE for range of Tx Powers + * - Add IWEVREGISTERED & IWEVEXPIRED events for Access Points + * - Add IW_MODE_MONITOR for passive monitor + * + * V15 to V16 + * ---------- + * - Increase the number of bitrates in iw_range to 32 (for 802.11g) + * - Increase the number of frequencies in iw_range to 32 (for 802.11b+a) + * - Reshuffle struct iw_range for increases, add filler + * - Increase IW_MAX_AP to 64 for driver returning a lot of addresses + * - Remove IW_MAX_GET_SPY because conflict with enhanced spy support + * - Add SIOCSIWTHRSPY/SIOCGIWTHRSPY and "struct iw_thrspy" + * - Add IW_ENCODE_TEMP and iw_range->encoding_login_index + * + * V16 to V17 + * ---------- + * - Add flags to frequency -> auto/fixed + * - Document (struct iw_quality *)->updated, add new flags (INVALID) + * - Wireless Event capability in struct iw_range + * - Add support for relative TxPower (yick !) + * + * V17 to V18 (From Jouni Malinen ) + * ---------- + * - Add support for WPA/WPA2 + * - Add extended encoding configuration (SIOCSIWENCODEEXT and + * SIOCGIWENCODEEXT) + * - Add SIOCSIWGENIE/SIOCGIWGENIE + * - Add SIOCSIWMLME + * - Add SIOCSIWPMKSA + * - Add struct iw_range bit field for supported encoding capabilities + * - Add optional scan request parameters for SIOCSIWSCAN + * - Add SIOCSIWAUTH/SIOCGIWAUTH for setting authentication and WPA + * related parameters (extensible up to 4096 parameter values) + * - Add wireless events: IWEVGENIE, IWEVMICHAELMICFAILURE, + * IWEVASSOCREQIE, IWEVASSOCRESPIE, IWEVPMKIDCAND + * + * V18 to V19 + * ---------- + * - Remove (struct iw_point *)->pointer from events and streams + * - Remove header includes to help user space + * - Increase IW_ENCODING_TOKEN_MAX from 32 to 64 + * - Add IW_QUAL_ALL_UPDATED and IW_QUAL_ALL_INVALID macros + * - Add explicit flag to tell stats are in dBm : IW_QUAL_DBM + * - Add IW_IOCTL_IDX() and IW_EVENT_IDX() macros + * + * V19 to V20 + * ---------- + * - RtNetlink requests support (SET/GET) + * + * V20 to V21 + * ---------- + * - Remove (struct net_device *)->get_wireless_stats() + * - Change length in ESSID and NICK to strlen() instead of strlen()+1 + * - Add IW_RETRY_SHORT/IW_RETRY_LONG retry modifiers + * - Power/Retry relative values no longer * 100000 + * - Add explicit flag to tell stats are in 802.11k RCPI : IW_QUAL_RCPI + * + * V21 to V22 + * ---------- + * - Prevent leaking of kernel space in stream on 64 bits. + */ + +/**************************** CONSTANTS ****************************/ + +/* -------------------------- IOCTL LIST -------------------------- */ + +/* Wireless Identification */ +#define SIOCSIWCOMMIT 0x8B00 /* Commit pending changes to driver */ +#define SIOCGIWNAME 0x8B01 /* get name == wireless protocol */ +/* SIOCGIWNAME is used to verify the presence of Wireless Extensions. + * Common values : "IEEE 802.11-DS", "IEEE 802.11-FH", "IEEE 802.11b"... + * Don't put the name of your driver there, it's useless. */ + +/* Basic operations */ +#define SIOCSIWNWID 0x8B02 /* set network id (pre-802.11) */ +#define SIOCGIWNWID 0x8B03 /* get network id (the cell) */ +#define SIOCSIWFREQ 0x8B04 /* set channel/frequency (Hz) */ +#define SIOCGIWFREQ 0x8B05 /* get channel/frequency (Hz) */ +#define SIOCSIWMODE 0x8B06 /* set operation mode */ +#define SIOCGIWMODE 0x8B07 /* get operation mode */ +#define SIOCSIWSENS 0x8B08 /* set sensitivity (dBm) */ +#define SIOCGIWSENS 0x8B09 /* get sensitivity (dBm) */ + +/* Informative stuff */ +#define SIOCSIWRANGE 0x8B0A /* Unused */ +#define SIOCGIWRANGE 0x8B0B /* Get range of parameters */ +#define SIOCSIWPRIV 0x8B0C /* Unused */ +#define SIOCGIWPRIV 0x8B0D /* get private ioctl interface info */ +#define SIOCSIWSTATS 0x8B0E /* Unused */ +#define SIOCGIWSTATS 0x8B0F /* Get /proc/net/wireless stats */ +/* SIOCGIWSTATS is strictly used between user space and the kernel, and + * is never passed to the driver (i.e. the driver will never see it). */ + +/* Spy support (statistics per MAC address - used for Mobile IP support) */ +#define SIOCSIWSPY 0x8B10 /* set spy addresses */ +#define SIOCGIWSPY 0x8B11 /* get spy info (quality of link) */ +#define SIOCSIWTHRSPY 0x8B12 /* set spy threshold (spy event) */ +#define SIOCGIWTHRSPY 0x8B13 /* get spy threshold */ + +/* Access Point manipulation */ +#define SIOCSIWAP 0x8B14 /* set access point MAC addresses */ +#define SIOCGIWAP 0x8B15 /* get access point MAC addresses */ +#define SIOCGIWAPLIST 0x8B17 /* Deprecated in favor of scanning */ +#define SIOCSIWSCAN 0x8B18 /* trigger scanning (list cells) */ +#define SIOCGIWSCAN 0x8B19 /* get scanning results */ + +/* 802.11 specific support */ +#define SIOCSIWESSID 0x8B1A /* set ESSID (network name) */ +#define SIOCGIWESSID 0x8B1B /* get ESSID */ +#define SIOCSIWNICKN 0x8B1C /* set node name/nickname */ +#define SIOCGIWNICKN 0x8B1D /* get node name/nickname */ +/* As the ESSID and NICKN are strings up to 32 bytes long, it doesn't fit + * within the 'iwreq' structure, so we need to use the 'data' member to + * point to a string in user space, like it is done for RANGE... */ + +/* Other parameters useful in 802.11 and some other devices */ +#define SIOCSIWRATE 0x8B20 /* set default bit rate (bps) */ +#define SIOCGIWRATE 0x8B21 /* get default bit rate (bps) */ +#define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */ +#define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */ +#define SIOCSIWFRAG 0x8B24 /* set fragmentation thr (bytes) */ +#define SIOCGIWFRAG 0x8B25 /* get fragmentation thr (bytes) */ +#define SIOCSIWTXPOW 0x8B26 /* set transmit power (dBm) */ +#define SIOCGIWTXPOW 0x8B27 /* get transmit power (dBm) */ +#define SIOCSIWRETRY 0x8B28 /* set retry limits and lifetime */ +#define SIOCGIWRETRY 0x8B29 /* get retry limits and lifetime */ + +/* Encoding stuff (scrambling, hardware security, WEP...) */ +#define SIOCSIWENCODE 0x8B2A /* set encoding token & mode */ +#define SIOCGIWENCODE 0x8B2B /* get encoding token & mode */ +/* Power saving stuff (power management, unicast and multicast) */ +#define SIOCSIWPOWER 0x8B2C /* set Power Management settings */ +#define SIOCGIWPOWER 0x8B2D /* get Power Management settings */ + +/* WPA : Generic IEEE 802.11 informatiom element (e.g., for WPA/RSN/WMM). + * This ioctl uses struct iw_point and data buffer that includes IE id and len + * fields. More than one IE may be included in the request. Setting the generic + * IE to empty buffer (len=0) removes the generic IE from the driver. Drivers + * are allowed to generate their own WPA/RSN IEs, but in these cases, drivers + * are required to report the used IE as a wireless event, e.g., when + * associating with an AP. */ +#define SIOCSIWGENIE 0x8B30 /* set generic IE */ +#define SIOCGIWGENIE 0x8B31 /* get generic IE */ + +/* WPA : IEEE 802.11 MLME requests */ +#define SIOCSIWMLME 0x8B16 /* request MLME operation; uses + * struct iw_mlme */ +/* WPA : Authentication mode parameters */ +#define SIOCSIWAUTH 0x8B32 /* set authentication mode params */ +#define SIOCGIWAUTH 0x8B33 /* get authentication mode params */ + +/* WPA : Extended version of encoding configuration */ +#define SIOCSIWENCODEEXT 0x8B34 /* set encoding token & mode */ +#define SIOCGIWENCODEEXT 0x8B35 /* get encoding token & mode */ + +/* WPA2 : PMKSA cache management */ +#define SIOCSIWPMKSA 0x8B36 /* PMKSA cache operation */ + +/* -------------------- DEV PRIVATE IOCTL LIST -------------------- */ + +/* These 32 ioctl are wireless device private, for 16 commands. + * Each driver is free to use them for whatever purpose it chooses, + * however the driver *must* export the description of those ioctls + * with SIOCGIWPRIV and *must* use arguments as defined below. + * If you don't follow those rules, DaveM is going to hate you (reason : + * it make mixed 32/64bit operation impossible). + */ +#define SIOCIWFIRSTPRIV 0x8BE0 +#define SIOCIWLASTPRIV 0x8BFF +/* Previously, we were using SIOCDEVPRIVATE, but we now have our + * separate range because of collisions with other tools such as + * 'mii-tool'. + * We now have 32 commands, so a bit more space ;-). + * Also, all 'even' commands are only usable by root and don't return the + * content of ifr/iwr to user (but you are not obliged to use the set/get + * convention, just use every other two command). More details in iwpriv.c. + * And I repeat : you are not forced to use them with iwpriv, but you + * must be compliant with it. + */ + +/* ------------------------- IOCTL STUFF ------------------------- */ + +/* The first and the last (range) */ +#define SIOCIWFIRST 0x8B00 +#define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */ +#define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST) + +/* Odd : get (world access), even : set (root access) */ +#define IW_IS_SET(cmd) (!((cmd) & 0x1)) +#define IW_IS_GET(cmd) ((cmd) & 0x1) + +/* ----------------------- WIRELESS EVENTS ----------------------- */ +/* Those are *NOT* ioctls, do not issue request on them !!! */ +/* Most events use the same identifier as ioctl requests */ + +#define IWEVTXDROP 0x8C00 /* Packet dropped to excessive retry */ +#define IWEVQUAL 0x8C01 /* Quality part of statistics (scan) */ +#define IWEVCUSTOM 0x8C02 /* Driver specific ascii string */ +#define IWEVREGISTERED 0x8C03 /* Discovered a new node (AP mode) */ +#define IWEVEXPIRED 0x8C04 /* Expired a node (AP mode) */ +#define IWEVGENIE 0x8C05 /* Generic IE (WPA, RSN, WMM, ..) + * (scan results); This includes id and + * length fields. One IWEVGENIE may + * contain more than one IE. Scan + * results may contain one or more + * IWEVGENIE events. */ +#define IWEVMICHAELMICFAILURE 0x8C06 /* Michael MIC failure + * (struct iw_michaelmicfailure) + */ +#define IWEVASSOCREQIE 0x8C07 /* IEs used in (Re)Association Request. + * The data includes id and length + * fields and may contain more than one + * IE. This event is required in + * Managed mode if the driver + * generates its own WPA/RSN IE. This + * should be sent just before + * IWEVREGISTERED event for the + * association. */ +#define IWEVASSOCRESPIE 0x8C08 /* IEs used in (Re)Association + * Response. The data includes id and + * length fields and may contain more + * than one IE. This may be sent + * between IWEVASSOCREQIE and + * IWEVREGISTERED events for the + * association. */ +#define IWEVPMKIDCAND 0x8C09 /* PMKID candidate for RSN + * pre-authentication + * (struct iw_pmkid_cand) */ + +#define IWEVFIRST 0x8C00 +#define IW_EVENT_IDX(cmd) ((cmd) - IWEVFIRST) + +/* ------------------------- PRIVATE INFO ------------------------- */ +/* + * The following is used with SIOCGIWPRIV. It allow a driver to define + * the interface (name, type of data) for its private ioctl. + * Privates ioctl are SIOCIWFIRSTPRIV -> SIOCIWLASTPRIV + */ + +#define IW_PRIV_TYPE_MASK 0x7000 /* Type of arguments */ +#define IW_PRIV_TYPE_NONE 0x0000 +#define IW_PRIV_TYPE_BYTE 0x1000 /* Char as number */ +#define IW_PRIV_TYPE_CHAR 0x2000 /* Char as character */ +#define IW_PRIV_TYPE_INT 0x4000 /* 32 bits int */ +#define IW_PRIV_TYPE_FLOAT 0x5000 /* struct iw_freq */ +#define IW_PRIV_TYPE_ADDR 0x6000 /* struct sockaddr */ + +#define IW_PRIV_SIZE_FIXED 0x0800 /* Variable or fixed number of args */ + +#define IW_PRIV_SIZE_MASK 0x07FF /* Max number of those args */ + +/* + * Note : if the number of args is fixed and the size < 16 octets, + * instead of passing a pointer we will put args in the iwreq struct... + */ + +/* ----------------------- OTHER CONSTANTS ----------------------- */ + +/* Maximum frequencies in the range struct */ +#define IW_MAX_FREQUENCIES 32 +/* Note : if you have something like 80 frequencies, + * don't increase this constant and don't fill the frequency list. + * The user will be able to set by channel anyway... */ + +/* Maximum bit rates in the range struct */ +#define IW_MAX_BITRATES 32 + +/* Maximum tx powers in the range struct */ +#define IW_MAX_TXPOWER 8 +/* Note : if you more than 8 TXPowers, just set the max and min or + * a few of them in the struct iw_range. */ + +/* Maximum of address that you may set with SPY */ +#define IW_MAX_SPY 8 + +/* Maximum of address that you may get in the + list of access points in range */ +#define IW_MAX_AP 64 + +/* Maximum size of the ESSID and NICKN strings */ +#define IW_ESSID_MAX_SIZE 32 + +/* Modes of operation */ +#define IW_MODE_AUTO 0 /* Let the driver decides */ +#define IW_MODE_ADHOC 1 /* Single cell network */ +#define IW_MODE_INFRA 2 /* Multi cell network, roaming, ... */ +#define IW_MODE_MASTER 3 /* Synchronisation master or Access Point */ +#define IW_MODE_REPEAT 4 /* Wireless Repeater (forwarder) */ +#define IW_MODE_SECOND 5 /* Secondary master/repeater (backup) */ +#define IW_MODE_MONITOR 6 /* Passive monitor (listen only) */ +#define IW_MODE_MESH 7 /* Mesh (IEEE 802.11s) network */ + +/* Statistics flags (bitmask in updated) */ +#define IW_QUAL_QUAL_UPDATED 0x01 /* Value was updated since last read */ +#define IW_QUAL_LEVEL_UPDATED 0x02 +#define IW_QUAL_NOISE_UPDATED 0x04 +#define IW_QUAL_ALL_UPDATED 0x07 +#define IW_QUAL_DBM 0x08 /* Level + Noise are dBm */ +#define IW_QUAL_QUAL_INVALID 0x10 /* Driver doesn't provide value */ +#define IW_QUAL_LEVEL_INVALID 0x20 +#define IW_QUAL_NOISE_INVALID 0x40 +#define IW_QUAL_RCPI 0x80 /* Level + Noise are 802.11k RCPI */ +#define IW_QUAL_ALL_INVALID 0x70 + +/* Frequency flags */ +#define IW_FREQ_AUTO 0x00 /* Let the driver decides */ +#define IW_FREQ_FIXED 0x01 /* Force a specific value */ + +/* Maximum number of size of encoding token available + * they are listed in the range structure */ +#define IW_MAX_ENCODING_SIZES 8 + +/* Maximum size of the encoding token in bytes */ +#define IW_ENCODING_TOKEN_MAX 64 /* 512 bits (for now) */ + +/* Flags for encoding (along with the token) */ +#define IW_ENCODE_INDEX 0x00FF /* Token index (if needed) */ +#define IW_ENCODE_FLAGS 0xFF00 /* Flags defined below */ +#define IW_ENCODE_MODE 0xF000 /* Modes defined below */ +#define IW_ENCODE_DISABLED 0x8000 /* Encoding disabled */ +#define IW_ENCODE_ENABLED 0x0000 /* Encoding enabled */ +#define IW_ENCODE_RESTRICTED 0x4000 /* Refuse non-encoded packets */ +#define IW_ENCODE_OPEN 0x2000 /* Accept non-encoded packets */ +#define IW_ENCODE_NOKEY 0x0800 /* Key is write only, so not present */ +#define IW_ENCODE_TEMP 0x0400 /* Temporary key */ + +/* Power management flags available (along with the value, if any) */ +#define IW_POWER_ON 0x0000 /* No details... */ +#define IW_POWER_TYPE 0xF000 /* Type of parameter */ +#define IW_POWER_PERIOD 0x1000 /* Value is a period/duration of */ +#define IW_POWER_TIMEOUT 0x2000 /* Value is a timeout (to go asleep) */ +#define IW_POWER_MODE 0x0F00 /* Power Management mode */ +#define IW_POWER_UNICAST_R 0x0100 /* Receive only unicast messages */ +#define IW_POWER_MULTICAST_R 0x0200 /* Receive only multicast messages */ +#define IW_POWER_ALL_R 0x0300 /* Receive all messages though PM */ +#define IW_POWER_FORCE_S 0x0400 /* Force PM procedure for sending unicast */ +#define IW_POWER_REPEATER 0x0800 /* Repeat broadcast messages in PM period */ +#define IW_POWER_MODIFIER 0x000F /* Modify a parameter */ +#define IW_POWER_MIN 0x0001 /* Value is a minimum */ +#define IW_POWER_MAX 0x0002 /* Value is a maximum */ +#define IW_POWER_RELATIVE 0x0004 /* Value is not in seconds/ms/us */ + +/* Transmit Power flags available */ +#define IW_TXPOW_TYPE 0x00FF /* Type of value */ +#define IW_TXPOW_DBM 0x0000 /* Value is in dBm */ +#define IW_TXPOW_MWATT 0x0001 /* Value is in mW */ +#define IW_TXPOW_RELATIVE 0x0002 /* Value is in arbitrary units */ +#define IW_TXPOW_RANGE 0x1000 /* Range of value between min/max */ + +/* Retry limits and lifetime flags available */ +#define IW_RETRY_ON 0x0000 /* No details... */ +#define IW_RETRY_TYPE 0xF000 /* Type of parameter */ +#define IW_RETRY_LIMIT 0x1000 /* Maximum number of retries*/ +#define IW_RETRY_LIFETIME 0x2000 /* Maximum duration of retries in us */ +#define IW_RETRY_MODIFIER 0x00FF /* Modify a parameter */ +#define IW_RETRY_MIN 0x0001 /* Value is a minimum */ +#define IW_RETRY_MAX 0x0002 /* Value is a maximum */ +#define IW_RETRY_RELATIVE 0x0004 /* Value is not in seconds/ms/us */ +#define IW_RETRY_SHORT 0x0010 /* Value is for short packets */ +#define IW_RETRY_LONG 0x0020 /* Value is for long packets */ + +/* Scanning request flags */ +#define IW_SCAN_DEFAULT 0x0000 /* Default scan of the driver */ +#define IW_SCAN_ALL_ESSID 0x0001 /* Scan all ESSIDs */ +#define IW_SCAN_THIS_ESSID 0x0002 /* Scan only this ESSID */ +#define IW_SCAN_ALL_FREQ 0x0004 /* Scan all Frequencies */ +#define IW_SCAN_THIS_FREQ 0x0008 /* Scan only this Frequency */ +#define IW_SCAN_ALL_MODE 0x0010 /* Scan all Modes */ +#define IW_SCAN_THIS_MODE 0x0020 /* Scan only this Mode */ +#define IW_SCAN_ALL_RATE 0x0040 /* Scan all Bit-Rates */ +#define IW_SCAN_THIS_RATE 0x0080 /* Scan only this Bit-Rate */ +/* struct iw_scan_req scan_type */ +#define IW_SCAN_TYPE_ACTIVE 0 +#define IW_SCAN_TYPE_PASSIVE 1 +/* Maximum size of returned data */ +#define IW_SCAN_MAX_DATA 4096 /* In bytes */ + +/* Scan capability flags - in (struct iw_range *)->scan_capa */ +#define IW_SCAN_CAPA_NONE 0x00 +#define IW_SCAN_CAPA_ESSID 0x01 +#define IW_SCAN_CAPA_BSSID 0x02 +#define IW_SCAN_CAPA_CHANNEL 0x04 +#define IW_SCAN_CAPA_MODE 0x08 +#define IW_SCAN_CAPA_RATE 0x10 +#define IW_SCAN_CAPA_TYPE 0x20 +#define IW_SCAN_CAPA_TIME 0x40 + +/* Max number of char in custom event - use multiple of them if needed */ +#define IW_CUSTOM_MAX 256 /* In bytes */ + +/* Generic information element */ +#define IW_GENERIC_IE_MAX 1024 + +/* MLME requests (SIOCSIWMLME / struct iw_mlme) */ +#define IW_MLME_DEAUTH 0 +#define IW_MLME_DISASSOC 1 +#define IW_MLME_AUTH 2 +#define IW_MLME_ASSOC 3 + +/* SIOCSIWAUTH/SIOCGIWAUTH struct iw_param flags */ +#define IW_AUTH_INDEX 0x0FFF +#define IW_AUTH_FLAGS 0xF000 +/* SIOCSIWAUTH/SIOCGIWAUTH parameters (0 .. 4095) + * (IW_AUTH_INDEX mask in struct iw_param flags; this is the index of the + * parameter that is being set/get to; value will be read/written to + * struct iw_param value field) */ +#define IW_AUTH_WPA_VERSION 0 +#define IW_AUTH_CIPHER_PAIRWISE 1 +#define IW_AUTH_CIPHER_GROUP 2 +#define IW_AUTH_KEY_MGMT 3 +#define IW_AUTH_TKIP_COUNTERMEASURES 4 +#define IW_AUTH_DROP_UNENCRYPTED 5 +#define IW_AUTH_80211_AUTH_ALG 6 +#define IW_AUTH_WPA_ENABLED 7 +#define IW_AUTH_RX_UNENCRYPTED_EAPOL 8 +#define IW_AUTH_ROAMING_CONTROL 9 +#define IW_AUTH_PRIVACY_INVOKED 10 +#define IW_AUTH_CIPHER_GROUP_MGMT 11 +#define IW_AUTH_MFP 12 + +/* IW_AUTH_WPA_VERSION values (bit field) */ +#define IW_AUTH_WPA_VERSION_DISABLED 0x00000001 +#define IW_AUTH_WPA_VERSION_WPA 0x00000002 +#define IW_AUTH_WPA_VERSION_WPA2 0x00000004 + +/* IW_AUTH_PAIRWISE_CIPHER, IW_AUTH_GROUP_CIPHER, and IW_AUTH_CIPHER_GROUP_MGMT + * values (bit field) */ +#define IW_AUTH_CIPHER_NONE 0x00000001 +#define IW_AUTH_CIPHER_WEP40 0x00000002 +#define IW_AUTH_CIPHER_TKIP 0x00000004 +#define IW_AUTH_CIPHER_CCMP 0x00000008 +#define IW_AUTH_CIPHER_WEP104 0x00000010 +#define IW_AUTH_CIPHER_AES_CMAC 0x00000020 + +/* IW_AUTH_KEY_MGMT values (bit field) */ +#define IW_AUTH_KEY_MGMT_802_1X 1 +#define IW_AUTH_KEY_MGMT_PSK 2 + +/* IW_AUTH_80211_AUTH_ALG values (bit field) */ +#define IW_AUTH_ALG_OPEN_SYSTEM 0x00000001 +#define IW_AUTH_ALG_SHARED_KEY 0x00000002 +#define IW_AUTH_ALG_LEAP 0x00000004 + +/* IW_AUTH_ROAMING_CONTROL values */ +#define IW_AUTH_ROAMING_ENABLE 0 /* driver/firmware based roaming */ +#define IW_AUTH_ROAMING_DISABLE 1 /* user space program used for roaming + * control */ + +/* IW_AUTH_MFP (management frame protection) values */ +#define IW_AUTH_MFP_DISABLED 0 /* MFP disabled */ +#define IW_AUTH_MFP_OPTIONAL 1 /* MFP optional */ +#define IW_AUTH_MFP_REQUIRED 2 /* MFP required */ + +/* SIOCSIWENCODEEXT definitions */ +#define IW_ENCODE_SEQ_MAX_SIZE 8 +/* struct iw_encode_ext ->alg */ +#define IW_ENCODE_ALG_NONE 0 +#define IW_ENCODE_ALG_WEP 1 +#define IW_ENCODE_ALG_TKIP 2 +#define IW_ENCODE_ALG_CCMP 3 +#define IW_ENCODE_ALG_PMK 4 +#define IW_ENCODE_ALG_AES_CMAC 5 +/* struct iw_encode_ext ->ext_flags */ +#define IW_ENCODE_EXT_TX_SEQ_VALID 0x00000001 +#define IW_ENCODE_EXT_RX_SEQ_VALID 0x00000002 +#define IW_ENCODE_EXT_GROUP_KEY 0x00000004 +#define IW_ENCODE_EXT_SET_TX_KEY 0x00000008 + +/* IWEVMICHAELMICFAILURE : struct iw_michaelmicfailure ->flags */ +#define IW_MICFAILURE_KEY_ID 0x00000003 /* Key ID 0..3 */ +#define IW_MICFAILURE_GROUP 0x00000004 +#define IW_MICFAILURE_PAIRWISE 0x00000008 +#define IW_MICFAILURE_STAKEY 0x00000010 +#define IW_MICFAILURE_COUNT 0x00000060 /* 1 or 2 (0 = count not supported) + */ + +/* Bit field values for enc_capa in struct iw_range */ +#define IW_ENC_CAPA_WPA 0x00000001 +#define IW_ENC_CAPA_WPA2 0x00000002 +#define IW_ENC_CAPA_CIPHER_TKIP 0x00000004 +#define IW_ENC_CAPA_CIPHER_CCMP 0x00000008 +#define IW_ENC_CAPA_4WAY_HANDSHAKE 0x00000010 + +/* Event capability macros - in (struct iw_range *)->event_capa + * Because we have more than 32 possible events, we use an array of + * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */ +#define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \ + (cmd - SIOCIWFIRSTPRIV + 0x60) : \ + (cmd - SIOCSIWCOMMIT)) +#define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5) +#define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F)) +/* Event capability constants - event autogenerated by the kernel + * This list is valid for most 802.11 devices, customise as needed... */ +#define IW_EVENT_CAPA_K_0 (IW_EVENT_CAPA_MASK(0x8B04) | \ + IW_EVENT_CAPA_MASK(0x8B06) | \ + IW_EVENT_CAPA_MASK(0x8B1A)) +#define IW_EVENT_CAPA_K_1 (IW_EVENT_CAPA_MASK(0x8B2A)) +/* "Easy" macro to set events in iw_range (less efficient) */ +#define IW_EVENT_CAPA_SET(event_capa, cmd) (event_capa[IW_EVENT_CAPA_INDEX(cmd)] |= IW_EVENT_CAPA_MASK(cmd)) +#define IW_EVENT_CAPA_SET_KERNEL(event_capa) {event_capa[0] |= IW_EVENT_CAPA_K_0; event_capa[1] |= IW_EVENT_CAPA_K_1; } + + +/****************************** TYPES ******************************/ + +/* --------------------------- SUBTYPES --------------------------- */ +/* + * Generic format for most parameters that fit in an int + */ +struct iw_param +{ + __s32 value; /* The value of the parameter itself */ + __u8 fixed; /* Hardware should not use auto select */ + __u8 disabled; /* Disable the feature */ + __u16 flags; /* Various specifc flags (if any) */ +}; + +/* + * For all data larger than 16 octets, we need to use a + * pointer to memory allocated in user space. + */ +struct iw_point +{ + void __user *pointer; /* Pointer to the data (in user space) */ + __u16 length; /* number of fields or size in bytes */ + __u16 flags; /* Optional params */ +}; + +#ifdef __KERNEL__ +#ifdef CONFIG_COMPAT + +#include + +struct compat_iw_point { + compat_caddr_t pointer; + __u16 length; + __u16 flags; +}; +#endif +#endif + +/* + * A frequency + * For numbers lower than 10^9, we encode the number in 'm' and + * set 'e' to 0 + * For number greater than 10^9, we divide it by the lowest power + * of 10 to get 'm' lower than 10^9, with 'm'= f / (10^'e')... + * The power of 10 is in 'e', the result of the division is in 'm'. + */ +struct iw_freq +{ + __s32 m; /* Mantissa */ + __s16 e; /* Exponent */ + __u8 i; /* List index (when in range struct) */ + __u8 flags; /* Flags (fixed/auto) */ +}; + +/* + * Quality of the link + */ +struct iw_quality +{ + __u8 qual; /* link quality (%retries, SNR, + %missed beacons or better...) */ + __u8 level; /* signal level (dBm) */ + __u8 noise; /* noise level (dBm) */ + __u8 updated; /* Flags to know if updated */ +}; + +/* + * Packet discarded in the wireless adapter due to + * "wireless" specific problems... + * Note : the list of counter and statistics in net_device_stats + * is already pretty exhaustive, and you should use that first. + * This is only additional stats... + */ +struct iw_discarded +{ + __u32 nwid; /* Rx : Wrong nwid/essid */ + __u32 code; /* Rx : Unable to code/decode (WEP) */ + __u32 fragment; /* Rx : Can't perform MAC reassembly */ + __u32 retries; /* Tx : Max MAC retries num reached */ + __u32 misc; /* Others cases */ +}; + +/* + * Packet/Time period missed in the wireless adapter due to + * "wireless" specific problems... + */ +struct iw_missed +{ + __u32 beacon; /* Missed beacons/superframe */ +}; + +/* + * Quality range (for spy threshold) + */ +struct iw_thrspy +{ + struct sockaddr addr; /* Source address (hw/mac) */ + struct iw_quality qual; /* Quality of the link */ + struct iw_quality low; /* Low threshold */ + struct iw_quality high; /* High threshold */ +}; + +/* + * Optional data for scan request + * + * Note: these optional parameters are controlling parameters for the + * scanning behavior, these do not apply to getting scan results + * (SIOCGIWSCAN). Drivers are expected to keep a local BSS table and + * provide a merged results with all BSSes even if the previous scan + * request limited scanning to a subset, e.g., by specifying an SSID. + * Especially, scan results are required to include an entry for the + * current BSS if the driver is in Managed mode and associated with an AP. + */ +struct iw_scan_req +{ + __u8 scan_type; /* IW_SCAN_TYPE_{ACTIVE,PASSIVE} */ + __u8 essid_len; + __u8 num_channels; /* num entries in channel_list; + * 0 = scan all allowed channels */ + __u8 flags; /* reserved as padding; use zero, this may + * be used in the future for adding flags + * to request different scan behavior */ + struct sockaddr bssid; /* ff:ff:ff:ff:ff:ff for broadcast BSSID or + * individual address of a specific BSS */ + + /* + * Use this ESSID if IW_SCAN_THIS_ESSID flag is used instead of using + * the current ESSID. This allows scan requests for specific ESSID + * without having to change the current ESSID and potentially breaking + * the current association. + */ + __u8 essid[IW_ESSID_MAX_SIZE]; + + /* + * Optional parameters for changing the default scanning behavior. + * These are based on the MLME-SCAN.request from IEEE Std 802.11. + * TU is 1.024 ms. If these are set to 0, driver is expected to use + * reasonable default values. min_channel_time defines the time that + * will be used to wait for the first reply on each channel. If no + * replies are received, next channel will be scanned after this. If + * replies are received, total time waited on the channel is defined by + * max_channel_time. + */ + __u32 min_channel_time; /* in TU */ + __u32 max_channel_time; /* in TU */ + + struct iw_freq channel_list[IW_MAX_FREQUENCIES]; +}; + +/* ------------------------- WPA SUPPORT ------------------------- */ + +/* + * Extended data structure for get/set encoding (this is used with + * SIOCSIWENCODEEXT/SIOCGIWENCODEEXT. struct iw_point and IW_ENCODE_* + * flags are used in the same way as with SIOCSIWENCODE/SIOCGIWENCODE and + * only the data contents changes (key data -> this structure, including + * key data). + * + * If the new key is the first group key, it will be set as the default + * TX key. Otherwise, default TX key index is only changed if + * IW_ENCODE_EXT_SET_TX_KEY flag is set. + * + * Key will be changed with SIOCSIWENCODEEXT in all cases except for + * special "change TX key index" operation which is indicated by setting + * key_len = 0 and ext_flags |= IW_ENCODE_EXT_SET_TX_KEY. + * + * tx_seq/rx_seq are only used when respective + * IW_ENCODE_EXT_{TX,RX}_SEQ_VALID flag is set in ext_flags. Normal + * TKIP/CCMP operation is to set RX seq with SIOCSIWENCODEEXT and start + * TX seq from zero whenever key is changed. SIOCGIWENCODEEXT is normally + * used only by an Authenticator (AP or an IBSS station) to get the + * current TX sequence number. Using TX_SEQ_VALID for SIOCSIWENCODEEXT and + * RX_SEQ_VALID for SIOCGIWENCODEEXT are optional, but can be useful for + * debugging/testing. + */ +struct iw_encode_ext +{ + __u32 ext_flags; /* IW_ENCODE_EXT_* */ + __u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + __u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ + struct sockaddr addr; /* ff:ff:ff:ff:ff:ff for broadcast/multicast + * (group) keys or unicast address for + * individual keys */ + __u16 alg; /* IW_ENCODE_ALG_* */ + __u16 key_len; + __u8 key[0]; +}; + +/* SIOCSIWMLME data */ +struct iw_mlme +{ + __u16 cmd; /* IW_MLME_* */ + __u16 reason_code; + struct sockaddr addr; +}; + +/* SIOCSIWPMKSA data */ +#define IW_PMKSA_ADD 1 +#define IW_PMKSA_REMOVE 2 +#define IW_PMKSA_FLUSH 3 + +#define IW_PMKID_LEN 16 + +struct iw_pmksa +{ + __u32 cmd; /* IW_PMKSA_* */ + struct sockaddr bssid; + __u8 pmkid[IW_PMKID_LEN]; +}; + +/* IWEVMICHAELMICFAILURE data */ +struct iw_michaelmicfailure +{ + __u32 flags; + struct sockaddr src_addr; + __u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; /* LSB first */ +}; + +/* IWEVPMKIDCAND data */ +#define IW_PMKID_CAND_PREAUTH 0x00000001 /* RNS pre-authentication enabled */ +struct iw_pmkid_cand +{ + __u32 flags; /* IW_PMKID_CAND_* */ + __u32 index; /* the smaller the index, the higher the + * priority */ + struct sockaddr bssid; +}; + +/* ------------------------ WIRELESS STATS ------------------------ */ +/* + * Wireless statistics (used for /proc/net/wireless) + */ +struct iw_statistics +{ + __u16 status; /* Status + * - device dependent for now */ + + struct iw_quality qual; /* Quality of the link + * (instant/mean/max) */ + struct iw_discarded discard; /* Packet discarded counts */ + struct iw_missed miss; /* Packet missed counts */ +}; + +/* ------------------------ IOCTL REQUEST ------------------------ */ +/* + * This structure defines the payload of an ioctl, and is used + * below. + * + * Note that this structure should fit on the memory footprint + * of iwreq (which is the same as ifreq), which mean a max size of + * 16 octets = 128 bits. Warning, pointers might be 64 bits wide... + * You should check this when increasing the structures defined + * above in this file... + */ +union iwreq_data +{ + /* Config - generic */ + char name[IFNAMSIZ]; + /* Name : used to verify the presence of wireless extensions. + * Name of the protocol/provider... */ + + struct iw_point essid; /* Extended network name */ + struct iw_param nwid; /* network id (or domain - the cell) */ + struct iw_freq freq; /* frequency or channel : + * 0-1000 = channel + * > 1000 = frequency in Hz */ + + struct iw_param sens; /* signal level threshold */ + struct iw_param bitrate; /* default bit rate */ + struct iw_param txpower; /* default transmit power */ + struct iw_param rts; /* RTS threshold threshold */ + struct iw_param frag; /* Fragmentation threshold */ + __u32 mode; /* Operation mode */ + struct iw_param retry; /* Retry limits & lifetime */ + + struct iw_point encoding; /* Encoding stuff : tokens */ + struct iw_param power; /* PM duration/timeout */ + struct iw_quality qual; /* Quality part of statistics */ + + struct sockaddr ap_addr; /* Access point address */ + struct sockaddr addr; /* Destination address (hw/mac) */ + + struct iw_param param; /* Other small parameters */ + struct iw_point data; /* Other large parameters */ +}; + +/* + * The structure to exchange data for ioctl. + * This structure is the same as 'struct ifreq', but (re)defined for + * convenience... + * Do I need to remind you about structure size (32 octets) ? + */ +struct iwreq +{ + union + { + char ifrn_name[IFNAMSIZ]; /* if name, e.g. "eth0" */ + } ifr_ifrn; + + /* Data part (defined just above) */ + union iwreq_data u; +}; + +/* -------------------------- IOCTL DATA -------------------------- */ +/* + * For those ioctl which want to exchange mode data that what could + * fit in the above structure... + */ + +/* + * Range of parameters + */ + +struct iw_range +{ + /* Informative stuff (to choose between different interface) */ + __u32 throughput; /* To give an idea... */ + /* In theory this value should be the maximum benchmarked + * TCP/IP throughput, because with most of these devices the + * bit rate is meaningless (overhead an co) to estimate how + * fast the connection will go and pick the fastest one. + * I suggest people to play with Netperf or any benchmark... + */ + + /* NWID (or domain id) */ + __u32 min_nwid; /* Minimal NWID we are able to set */ + __u32 max_nwid; /* Maximal NWID we are able to set */ + + /* Old Frequency (backward compat - moved lower ) */ + __u16 old_num_channels; + __u8 old_num_frequency; + + /* Scan capabilities */ + __u8 scan_capa; /* IW_SCAN_CAPA_* bit field */ + + /* Wireless event capability bitmasks */ + __u32 event_capa[6]; + + /* signal level threshold range */ + __s32 sensitivity; + + /* Quality of link & SNR stuff */ + /* Quality range (link, level, noise) + * If the quality is absolute, it will be in the range [0 ; max_qual], + * if the quality is dBm, it will be in the range [max_qual ; 0]. + * Don't forget that we use 8 bit arithmetics... */ + struct iw_quality max_qual; /* Quality of the link */ + /* This should contain the average/typical values of the quality + * indicator. This should be the threshold between a "good" and + * a "bad" link (example : monitor going from green to orange). + * Currently, user space apps like quality monitors don't have any + * way to calibrate the measurement. With this, they can split + * the range between 0 and max_qual in different quality level + * (using a geometric subdivision centered on the average). + * I expect that people doing the user space apps will feedback + * us on which value we need to put in each driver... */ + struct iw_quality avg_qual; /* Quality of the link */ + + /* Rates */ + __u8 num_bitrates; /* Number of entries in the list */ + __s32 bitrate[IW_MAX_BITRATES]; /* list, in bps */ + + /* RTS threshold */ + __s32 min_rts; /* Minimal RTS threshold */ + __s32 max_rts; /* Maximal RTS threshold */ + + /* Frag threshold */ + __s32 min_frag; /* Minimal frag threshold */ + __s32 max_frag; /* Maximal frag threshold */ + + /* Power Management duration & timeout */ + __s32 min_pmp; /* Minimal PM period */ + __s32 max_pmp; /* Maximal PM period */ + __s32 min_pmt; /* Minimal PM timeout */ + __s32 max_pmt; /* Maximal PM timeout */ + __u16 pmp_flags; /* How to decode max/min PM period */ + __u16 pmt_flags; /* How to decode max/min PM timeout */ + __u16 pm_capa; /* What PM options are supported */ + + /* Encoder stuff */ + __u16 encoding_size[IW_MAX_ENCODING_SIZES]; /* Different token sizes */ + __u8 num_encoding_sizes; /* Number of entry in the list */ + __u8 max_encoding_tokens; /* Max number of tokens */ + /* For drivers that need a "login/passwd" form */ + __u8 encoding_login_index; /* token index for login token */ + + /* Transmit power */ + __u16 txpower_capa; /* What options are supported */ + __u8 num_txpower; /* Number of entries in the list */ + __s32 txpower[IW_MAX_TXPOWER]; /* list, in bps */ + + /* Wireless Extension version info */ + __u8 we_version_compiled; /* Must be WIRELESS_EXT */ + __u8 we_version_source; /* Last update of source */ + + /* Retry limits and lifetime */ + __u16 retry_capa; /* What retry options are supported */ + __u16 retry_flags; /* How to decode max/min retry limit */ + __u16 r_time_flags; /* How to decode max/min retry life */ + __s32 min_retry; /* Minimal number of retries */ + __s32 max_retry; /* Maximal number of retries */ + __s32 min_r_time; /* Minimal retry lifetime */ + __s32 max_r_time; /* Maximal retry lifetime */ + + /* Frequency */ + __u16 num_channels; /* Number of channels [0; num - 1] */ + __u8 num_frequency; /* Number of entry in the list */ + struct iw_freq freq[IW_MAX_FREQUENCIES]; /* list */ + /* Note : this frequency list doesn't need to fit channel numbers, + * because each entry contain its channel index */ + + __u32 enc_capa; /* IW_ENC_CAPA_* bit field */ +}; + +/* + * Private ioctl interface information + */ + +struct iw_priv_args +{ + __u32 cmd; /* Number of the ioctl to issue */ + __u16 set_args; /* Type and number of args */ + __u16 get_args; /* Type and number of args */ + char name[IFNAMSIZ]; /* Name of the extension */ +}; + +/* ----------------------- WIRELESS EVENTS ----------------------- */ +/* + * Wireless events are carried through the rtnetlink socket to user + * space. They are encapsulated in the IFLA_WIRELESS field of + * a RTM_NEWLINK message. + */ + +/* + * A Wireless Event. Contains basically the same data as the ioctl... + */ +struct iw_event +{ + __u16 len; /* Real length of this stuff */ + __u16 cmd; /* Wireless IOCTL */ + union iwreq_data u; /* IOCTL fixed payload */ +}; + +/* Size of the Event prefix (including padding and alignement junk) */ +#define IW_EV_LCP_LEN (sizeof(struct iw_event) - sizeof(union iwreq_data)) +/* Size of the various events */ +#define IW_EV_CHAR_LEN (IW_EV_LCP_LEN + IFNAMSIZ) +#define IW_EV_UINT_LEN (IW_EV_LCP_LEN + sizeof(__u32)) +#define IW_EV_FREQ_LEN (IW_EV_LCP_LEN + sizeof(struct iw_freq)) +#define IW_EV_PARAM_LEN (IW_EV_LCP_LEN + sizeof(struct iw_param)) +#define IW_EV_ADDR_LEN (IW_EV_LCP_LEN + sizeof(struct sockaddr)) +#define IW_EV_QUAL_LEN (IW_EV_LCP_LEN + sizeof(struct iw_quality)) + +/* iw_point events are special. First, the payload (extra data) come at + * the end of the event, so they are bigger than IW_EV_POINT_LEN. Second, + * we omit the pointer, so start at an offset. */ +#define IW_EV_POINT_OFF (((char *) &(((struct iw_point *) NULL)->length)) - \ + (char *) NULL) +#define IW_EV_POINT_LEN (IW_EV_LCP_LEN + sizeof(struct iw_point) - \ + IW_EV_POINT_OFF) + +#ifdef __KERNEL__ +#ifdef CONFIG_COMPAT +struct __compat_iw_event { + __u16 len; /* Real length of this stuff */ + __u16 cmd; /* Wireless IOCTL */ + compat_caddr_t pointer; +}; +#define IW_EV_COMPAT_LCP_LEN offsetof(struct __compat_iw_event, pointer) +#define IW_EV_COMPAT_POINT_OFF offsetof(struct compat_iw_point, length) + +/* Size of the various events for compat */ +#define IW_EV_COMPAT_CHAR_LEN (IW_EV_COMPAT_LCP_LEN + IFNAMSIZ) +#define IW_EV_COMPAT_UINT_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(__u32)) +#define IW_EV_COMPAT_FREQ_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_freq)) +#define IW_EV_COMPAT_PARAM_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_param)) +#define IW_EV_COMPAT_ADDR_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct sockaddr)) +#define IW_EV_COMPAT_QUAL_LEN (IW_EV_COMPAT_LCP_LEN + sizeof(struct iw_quality)) +#define IW_EV_COMPAT_POINT_LEN \ + (IW_EV_COMPAT_LCP_LEN + sizeof(struct compat_iw_point) - \ + IW_EV_COMPAT_POINT_OFF) +#endif +#endif + +/* Size of the Event prefix when packed in stream */ +#define IW_EV_LCP_PK_LEN (4) +/* Size of the various events when packed in stream */ +#define IW_EV_CHAR_PK_LEN (IW_EV_LCP_PK_LEN + IFNAMSIZ) +#define IW_EV_UINT_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(__u32)) +#define IW_EV_FREQ_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_freq)) +#define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param)) +#define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr)) +#define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality)) +#define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4) + +#endif /* _LINUX_WIRELESS_H */ -- cgit v1.2.3 From 88aea8e23db0708416411f534e099e6a0f623fab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 15:56:12 -0800 Subject: Add missing input key definitions Newer rfkill implementations makes use of this. rfkill for newer kernels has been backported for older kernels through compat-wireless. Maybe we should bring that in here? Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.24.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 90a0cd4d..f3eaec3a 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -14,6 +14,10 @@ #include #include +#define KEY_BLUETOOTH 237 +#define KEY_WLAN 238 +#define KEY_UWB 239 + /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; -- cgit v1.2.3 From 1fdde09ff7195dd421d831d4aa51c4413927269e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 15:57:52 -0800 Subject: Add DMA_BIT_MASK() for older kernels Old kernels do not have this declared. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.24.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index f3eaec3a..ac9489f7 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -18,6 +18,8 @@ #define KEY_WLAN 238 #define KEY_UWB 239 +#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) + /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; -- cgit v1.2.3 From a312e00197ea4876bba541121f32b676bc92b829 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 16:17:04 -0800 Subject: Add initial backport support for network namespaces We simply declare the overly used init_net sprinkled all over the kernel, and declare its. All other code should that uses network namespaces should be ifdef'd for now as well as inclusion of net/net_namespace.h as we do not backport the network namespace implemetnation at all, we simply try to nullify its effect. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.24.c | 7 +++++++ include/linux/compat-2.6.24.h | 31 +++++++++++++++++++++++++++++++ include/linux/compat-2.6.26.h | 2 ++ 3 files changed, 40 insertions(+) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index 347f6f7d..31a9212f 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -15,6 +15,13 @@ #include +/* + * We simply won't use it though, just declare it for our wrappers and + * for usage with tons of code that makes mention to it. + */ +struct net init_net; +EXPORT_SYMBOL(init_net); + /* Part of net/ethernet/eth.c as of 2.6.24 */ char *print_mac(char *buf, const u8 *addr) { diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index ac9489f7..246156c2 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -20,6 +20,37 @@ #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) +struct proc_dir_entry; +struct net_device; +struct net { + atomic_t count; /* To decided when the network + * namespace should be freed. + */ + atomic_t use_count; /* To track references we + * destroy on demand + */ + struct list_head list; /* list of network namespaces */ + struct work_struct work; /* work struct for freeing */ + + struct proc_dir_entry *proc_net; + struct proc_dir_entry *proc_net_stat; + struct proc_dir_entry *proc_net_root; + + struct net_device *loopback_dev; /* The loopback */ + + struct list_head dev_base_head; + struct hlist_head *dev_name_head; + struct hlist_head *dev_index_head; +}; + +#ifdef CONFIG_NET +/* Init's network namespace */ +extern struct net init_net; +#define INIT_NET_NS(net_ns) .net_ns = &init_net, +#else +#define INIT_NET_NS(net_ns) +#endif + /* Added on 2.6.24 in include/linux/types.h by Al viro on commit 142956af */ typedef unsigned long uintptr_t; diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index b7c3b057..0ea99b15 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,7 +11,9 @@ #include #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include +#endif /* These jiffie helpers added as of 2.6.26 */ -- cgit v1.2.3 From cd96ca22f449eaea5c5d5ab11433b4ae98906d38 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 16:24:09 -0800 Subject: Only define BITS_TO_LONGS if not defined This removes this nagging complaint on older kernels: CC [M] /home/mcgrof/compat/compat/compat-2.6.32.o In file included from include/asm-i386/cpufeature.h:11, from include/asm/cpufeature.h:10, from include/asm/alternative.h:43, from include/asm/atomic.h:4, from /home/mcgrof/compat/include/linux/compat-2.6.24.h:10, from /home/mcgrof/compat/include/linux/compat-2.6.h:15, from :0: /home/mcgrof/compat/include/linux/bitops.h:10:1: warning: "BITS_TO_LONGS" redefined In file included from include/asm/alternative.h:6, from include/asm/atomic.h:4, from /home/mcgrof/compat/include/linux/compat-2.6.24.h:10, from /home/mcgrof/compat/include/linux/compat-2.6.h:15, from :0: include/linux/types.h:6:1: warning: this is the location of the previous definition In file included from include/asm-i386/cpufeature.h:11, from include/asm/cpufeature.h:10, from include/asm/alternative.h:43, from include/asm/atomic.h:4, from /home/mcgrof/compat/include/linux/compat-2.6.24.h:10, from /home/mcgrof/compat/include/linux/compat-2.6.h:15, from :0: Note that this means we'll have to keep include/linux/bitops.h up to date on our tree now. Shouldn't be an issue but just worth noting. Signed-off-by: Luis R. Rodriguez --- include/linux/bitops.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index c05a29cb..8469d353 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -7,8 +7,10 @@ #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) #define BITS_PER_BYTE 8 +#ifndef BITS_TO_LONGS /* Older kernels define this already */ #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #endif +#endif /* * Include this here because some architectures need generic_ffs/fls in -- cgit v1.2.3 From 5e4b4b6ae384d543c2067aad5fe5c58ed9106c63 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 16:40:14 -0800 Subject: Add the new system bus frequency pm-qos object for older kernels This adds the new system_bus_freq_pm_qos for older kernels. This also fixes a compile warning on possible array out of bounds access on pm-qos, this was due to the fact that the pm-qos implementation we had on code was out of synch with the header we were copying over. This synchs up the array to what is in linux-next as of linux-next tag next-20100111 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 32845725..e1a81aeb 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -94,12 +94,24 @@ static struct pm_qos_object network_throughput_pm_qos = { .comparitor = max_compare }; +static BLOCKING_NOTIFIER_HEAD(system_bus_freq_notifier); +static struct pm_qos_object system_bus_freq_pm_qos = { + .requirements = + {LIST_HEAD_INIT(system_bus_freq_pm_qos.requirements.list)}, + .notifiers = &system_bus_freq_notifier, + .name = "system_bus_freq", + .default_value = 0, + .target_value = 0, + .comparitor = max_compare +}; + static struct pm_qos_object *pm_qos_array[] = { &null_pm_qos, &cpu_dma_pm_qos, &network_lat_pm_qos, - &network_throughput_pm_qos + &network_throughput_pm_qos, + &system_bus_freq_pm_qos, }; static DEFINE_SPINLOCK(pm_qos_lock); @@ -408,9 +420,17 @@ int compat_pm_qos_power_init(void) return ret; } ret = register_pm_qos_misc(&network_throughput_pm_qos); - if (ret < 0) + if (ret < 0) { printk(KERN_ERR "pm_qos_param: network_throughput setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&system_bus_freq_pm_qos); + if (ret < 0) { + printk(KERN_ERR + "pm_qos_param: network_throughput setup failed\n"); + return ret; + } return ret; } -- cgit v1.2.3 From a52301d8fcc3dae6dfe7f3065566a7e55f2c904d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 16:44:06 -0800 Subject: Updates the pm-qos array indexes to match upstream This style is used now upstream for the pm-qos object array declaration. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index e1a81aeb..7ce42326 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -107,11 +107,11 @@ static struct pm_qos_object system_bus_freq_pm_qos = { static struct pm_qos_object *pm_qos_array[] = { - &null_pm_qos, - &cpu_dma_pm_qos, - &network_lat_pm_qos, - &network_throughput_pm_qos, - &system_bus_freq_pm_qos, + [PM_QOS_RESERVED] = &null_pm_qos, + [PM_QOS_CPU_DMA_LATENCY] = &cpu_dma_pm_qos, + [PM_QOS_NETWORK_LATENCY] = &network_lat_pm_qos, + [PM_QOS_NETWORK_THROUGHPUT] = &network_throughput_pm_qos, + [PM_QOS_SYSTEM_BUS_FREQ] = &system_bus_freq_pm_qos, }; static DEFINE_SPINLOCK(pm_qos_lock); -- cgit v1.2.3 From 5bb94c3921ab7935a5846c15548bd22caa3c6452 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 17:07:28 -0800 Subject: Extract pm-qos code into compat/pm_qos_params.c This should make it easier to synch with later version of kernel/pm_qos_params.c Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 6 +- compat/compat-2.6.25.c | 422 ------------------------------------------------ compat/pm_qos_params.c | 428 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 433 insertions(+), 423 deletions(-) create mode 100644 compat/pm_qos_params.c diff --git a/compat/Makefile b/compat/Makefile index fd2f99fe..d950f47f 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -10,7 +10,11 @@ compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o -compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o + +compat-$(CONFIG_COMPAT_KERNEL_24) += \ + compat-2.6.24.o \ + pm_qos_params.o + compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 7ce42326..75468210 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -8,433 +8,11 @@ * Compatibility file for Linux wireless for kernels 2.6.25. */ -#include - /* All things not in 2.6.22, 2.6.23 and 2.6.24 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) #include -/* - * Backport work for QoS dependencies (kernel/pm_qos_params.c) - * pm-qos stuff written by mark gross mgross@linux.intel.com. - * - * ipw2100 now makes use of - * pm_qos_add_requirement(), - * pm_qos_update_requirement() and - * pm_qos_remove_requirement() from it - * - * mac80211 uses the network latency to determine if to enable or not - * dynamic PS. mac80211 also and registers a notifier for when - * the latency changes. Since older kernels do no thave pm-qos stuff - * we just implement it completley here and register it upon cfg80211 - * init. I haven't tested ipw2100 on 2.6.24 though. - * - * This is copied from the kernel written by mark gross mgross@linux.intel.com - */ - -/* - * locking rule: all changes to target_value or requirements or notifiers lists - * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock - * held, taken with _irqsave. One lock to rule them all - */ -struct requirement_list { - struct list_head list; - union { - s32 value; - s32 usec; - s32 kbps; - }; - char *name; -}; - -static s32 max_compare(s32 v1, s32 v2); -static s32 min_compare(s32 v1, s32 v2); - -struct pm_qos_object { - struct requirement_list requirements; - struct blocking_notifier_head *notifiers; - struct miscdevice pm_qos_power_miscdev; - char *name; - s32 default_value; - s32 target_value; - s32 (*comparitor)(s32, s32); -}; - -static struct pm_qos_object null_pm_qos; -static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); -static struct pm_qos_object cpu_dma_pm_qos = { - .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, - .notifiers = &cpu_dma_lat_notifier, - .name = "cpu_dma_latency", - .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, - .comparitor = min_compare -}; - -static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); -static struct pm_qos_object network_lat_pm_qos = { - .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, - .notifiers = &network_lat_notifier, - .name = "network_latency", - .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, - .comparitor = min_compare -}; - - -static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); -static struct pm_qos_object network_throughput_pm_qos = { - .requirements = - {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, - .notifiers = &network_throughput_notifier, - .name = "network_throughput", - .default_value = 0, - .target_value = 0, - .comparitor = max_compare -}; - -static BLOCKING_NOTIFIER_HEAD(system_bus_freq_notifier); -static struct pm_qos_object system_bus_freq_pm_qos = { - .requirements = - {LIST_HEAD_INIT(system_bus_freq_pm_qos.requirements.list)}, - .notifiers = &system_bus_freq_notifier, - .name = "system_bus_freq", - .default_value = 0, - .target_value = 0, - .comparitor = max_compare -}; - - -static struct pm_qos_object *pm_qos_array[] = { - [PM_QOS_RESERVED] = &null_pm_qos, - [PM_QOS_CPU_DMA_LATENCY] = &cpu_dma_pm_qos, - [PM_QOS_NETWORK_LATENCY] = &network_lat_pm_qos, - [PM_QOS_NETWORK_THROUGHPUT] = &network_throughput_pm_qos, - [PM_QOS_SYSTEM_BUS_FREQ] = &system_bus_freq_pm_qos, -}; - -static DEFINE_SPINLOCK(pm_qos_lock); - -static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, - size_t count, loff_t *f_pos); -static int pm_qos_power_open(struct inode *inode, struct file *filp); -static int pm_qos_power_release(struct inode *inode, struct file *filp); - -static const struct file_operations pm_qos_power_fops = { - .write = pm_qos_power_write, - .open = pm_qos_power_open, - .release = pm_qos_power_release, -}; - -/* static helper functions */ -static s32 max_compare(s32 v1, s32 v2) -{ - return max(v1, v2); -} - -static s32 min_compare(s32 v1, s32 v2) -{ - return min(v1, v2); -} - -static void update_target(int target) -{ - s32 extreme_value; - struct requirement_list *node; - unsigned long flags; - int call_notifier = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - extreme_value = pm_qos_array[target]->default_value; - list_for_each_entry(node, - &pm_qos_array[target]->requirements.list, list) { - extreme_value = pm_qos_array[target]->comparitor( - extreme_value, node->value); - } - if (pm_qos_array[target]->target_value != extreme_value) { - call_notifier = 1; - pm_qos_array[target]->target_value = extreme_value; - pr_debug(KERN_ERR "new target for qos %d is %d\n", target, - pm_qos_array[target]->target_value); - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - - if (call_notifier) - blocking_notifier_call_chain(pm_qos_array[target]->notifiers, - (unsigned long) extreme_value, NULL); -} - -static int register_pm_qos_misc(struct pm_qos_object *qos) -{ - qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR; - qos->pm_qos_power_miscdev.name = qos->name; - qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; - - return misc_register(&qos->pm_qos_power_miscdev); -} - -static int find_pm_qos_object_by_minor(int minor) -{ - int pm_qos_class; - - for (pm_qos_class = 0; - pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { - if (minor == - pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) - return pm_qos_class; - } - return -1; -} - -/** - * pm_qos_requirement - returns current system wide qos expectation - * @pm_qos_class: identification of which qos value is requested - * - * This function returns the current target value in an atomic manner. - */ -int pm_qos_requirement(int pm_qos_class) -{ - int ret_val; - unsigned long flags; - - spin_lock_irqsave(&pm_qos_lock, flags); - ret_val = pm_qos_array[pm_qos_class]->target_value; - spin_unlock_irqrestore(&pm_qos_lock, flags); - - return ret_val; -} -EXPORT_SYMBOL_GPL(pm_qos_requirement); - -/** - * pm_qos_add_requirement - inserts new qos request into the list - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * @value: defines the qos request - * - * This function inserts a new entry in the pm_qos_class list of requested qos - * performance charactoistics. It recomputes the agregate QoS expectations for - * the pm_qos_class of parrameters. - */ -int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) -{ - struct requirement_list *dep; - unsigned long flags; - - dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); - if (dep) { - if (value == PM_QOS_DEFAULT_VALUE) - dep->value = pm_qos_array[pm_qos_class]->default_value; - else - dep->value = value; - dep->name = kstrdup(name, GFP_KERNEL); - if (!dep->name) - goto cleanup; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_add(&dep->list, - &pm_qos_array[pm_qos_class]->requirements.list); - spin_unlock_irqrestore(&pm_qos_lock, flags); - update_target(pm_qos_class); - - return 0; - } - -cleanup: - kfree(dep); - return -ENOMEM; -} -EXPORT_SYMBOL_GPL(pm_qos_add_requirement); - -/** - * pm_qos_update_requirement - modifies an existing qos request - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * @value: defines the qos request - * - * Updates an existing qos requierement for the pm_qos_class of parameters along - * with updating the target pm_qos_class value. - * - * If the named request isn't in the lest then no change is made. - */ -int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) -{ - unsigned long flags; - struct requirement_list *node; - int pending_update = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_for_each_entry(node, - &pm_qos_array[pm_qos_class]->requirements.list, list) { - if (strcmp(node->name, name) == 0) { - if (new_value == PM_QOS_DEFAULT_VALUE) - node->value = - pm_qos_array[pm_qos_class]->default_value; - else - node->value = new_value; - pending_update = 1; - break; - } - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - if (pending_update) - update_target(pm_qos_class); - - return 0; -} -EXPORT_SYMBOL_GPL(pm_qos_update_requirement); - -/** - * pm_qos_remove_requirement - modifies an existing qos request - * @pm_qos_class: identifies which list of qos request to us - * @name: identifies the request - * - * Will remove named qos request from pm_qos_class list of parrameters and - * recompute the current target value for the pm_qos_class. - */ -void pm_qos_remove_requirement(int pm_qos_class, char *name) -{ - unsigned long flags; - struct requirement_list *node; - int pending_update = 0; - - spin_lock_irqsave(&pm_qos_lock, flags); - list_for_each_entry(node, - &pm_qos_array[pm_qos_class]->requirements.list, list) { - if (strcmp(node->name, name) == 0) { - kfree(node->name); - list_del(&node->list); - kfree(node); - pending_update = 1; - break; - } - } - spin_unlock_irqrestore(&pm_qos_lock, flags); - if (pending_update) - update_target(pm_qos_class); -} -EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); - -/** - * pm_qos_add_notifier - sets notification entry for changes to target value - * @pm_qos_class: identifies which qos target changes should be notified. - * @notifier: notifier block managed by caller. - * - * will register the notifier into a notification chain that gets called - * uppon changes to the pm_qos_class target value. - */ - int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) -{ - int retval; - - retval = blocking_notifier_chain_register( - pm_qos_array[pm_qos_class]->notifiers, notifier); - - return retval; -} -EXPORT_SYMBOL_GPL(pm_qos_add_notifier); - -/** - * pm_qos_remove_notifier - deletes notification entry from chain. - * @pm_qos_class: identifies which qos target changes are notified. - * @notifier: notifier block to be removed. - * - * will remove the notifier from the notification chain that gets called - * uppon changes to the pm_qos_class target value. - */ -int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) -{ - int retval; - - retval = blocking_notifier_chain_unregister( - pm_qos_array[pm_qos_class]->notifiers, notifier); - - return retval; -} -EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); - -#define PID_NAME_LEN sizeof("process_1234567890") -static char name[PID_NAME_LEN]; - -static int pm_qos_power_open(struct inode *inode, struct file *filp) -{ - int ret; - long pm_qos_class; - - pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); - if (pm_qos_class >= 0) { - filp->private_data = (void *)pm_qos_class; - sprintf(name, "process_%d", current->pid); - ret = pm_qos_add_requirement(pm_qos_class, name, - PM_QOS_DEFAULT_VALUE); - if (ret >= 0) - return 0; - } - - return -EPERM; -} - -static int pm_qos_power_release(struct inode *inode, struct file *filp) -{ - int pm_qos_class; - - pm_qos_class = (long)filp->private_data; - sprintf(name, "process_%d", current->pid); - pm_qos_remove_requirement(pm_qos_class, name); - - return 0; -} - -static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, - size_t count, loff_t *f_pos) -{ - s32 value; - int pm_qos_class; - - pm_qos_class = (long)filp->private_data; - if (count != sizeof(s32)) - return -EINVAL; - if (copy_from_user(&value, buf, sizeof(s32))) - return -EFAULT; - sprintf(name, "process_%d", current->pid); - pm_qos_update_requirement(pm_qos_class, name, value); - - return sizeof(s32); -} - -/* - * This initializes pm-qos for older kernels. - */ -int compat_pm_qos_power_init(void) -{ - int ret = 0; - - ret = register_pm_qos_misc(&cpu_dma_pm_qos); - if (ret < 0) { - printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n"); - return ret; - } - ret = register_pm_qos_misc(&network_lat_pm_qos); - if (ret < 0) { - printk(KERN_ERR "pm_qos_param: network_latency setup failed\n"); - return ret; - } - ret = register_pm_qos_misc(&network_throughput_pm_qos); - if (ret < 0) { - printk(KERN_ERR - "pm_qos_param: network_throughput setup failed\n"); - return ret; - } - ret = register_pm_qos_misc(&system_bus_freq_pm_qos); - if (ret < 0) { - printk(KERN_ERR - "pm_qos_param: network_throughput setup failed\n"); - return ret; - } - - return ret; -} - /** * The following things are out of ./lib/vsprintf.c * The new iwlwifi driver is using them. diff --git a/compat/pm_qos_params.c b/compat/pm_qos_params.c new file mode 100644 index 00000000..da93e957 --- /dev/null +++ b/compat/pm_qos_params.c @@ -0,0 +1,428 @@ +#include + +/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) + +#include + +/* + * Backport work for QoS dependencies (kernel/pm_qos_params.c) + * pm-qos stuff written by mark gross mgross@linux.intel.com. + * + * ipw2100 now makes use of + * pm_qos_add_requirement(), + * pm_qos_update_requirement() and + * pm_qos_remove_requirement() from it + * + * mac80211 uses the network latency to determine if to enable or not + * dynamic PS. mac80211 also and registers a notifier for when + * the latency changes. Since older kernels do no thave pm-qos stuff + * we just implement it completley here and register it upon cfg80211 + * init. I haven't tested ipw2100 on 2.6.24 though. + * + * This is copied from the kernel written by mark gross mgross@linux.intel.com + */ + +/* + * locking rule: all changes to target_value or requirements or notifiers lists + * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock + * held, taken with _irqsave. One lock to rule them all + */ +struct requirement_list { + struct list_head list; + union { + s32 value; + s32 usec; + s32 kbps; + }; + char *name; +}; + +static s32 max_compare(s32 v1, s32 v2); +static s32 min_compare(s32 v1, s32 v2); + +struct pm_qos_object { + struct requirement_list requirements; + struct blocking_notifier_head *notifiers; + struct miscdevice pm_qos_power_miscdev; + char *name; + s32 default_value; + s32 target_value; + s32 (*comparitor)(s32, s32); +}; + +static struct pm_qos_object null_pm_qos; +static BLOCKING_NOTIFIER_HEAD(cpu_dma_lat_notifier); +static struct pm_qos_object cpu_dma_pm_qos = { + .requirements = {LIST_HEAD_INIT(cpu_dma_pm_qos.requirements.list)}, + .notifiers = &cpu_dma_lat_notifier, + .name = "cpu_dma_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + +static BLOCKING_NOTIFIER_HEAD(network_lat_notifier); +static struct pm_qos_object network_lat_pm_qos = { + .requirements = {LIST_HEAD_INIT(network_lat_pm_qos.requirements.list)}, + .notifiers = &network_lat_notifier, + .name = "network_latency", + .default_value = 2000 * USEC_PER_SEC, + .target_value = 2000 * USEC_PER_SEC, + .comparitor = min_compare +}; + + +static BLOCKING_NOTIFIER_HEAD(network_throughput_notifier); +static struct pm_qos_object network_throughput_pm_qos = { + .requirements = + {LIST_HEAD_INIT(network_throughput_pm_qos.requirements.list)}, + .notifiers = &network_throughput_notifier, + .name = "network_throughput", + .default_value = 0, + .target_value = 0, + .comparitor = max_compare +}; + +static BLOCKING_NOTIFIER_HEAD(system_bus_freq_notifier); +static struct pm_qos_object system_bus_freq_pm_qos = { + .requirements = + {LIST_HEAD_INIT(system_bus_freq_pm_qos.requirements.list)}, + .notifiers = &system_bus_freq_notifier, + .name = "system_bus_freq", + .default_value = 0, + .target_value = 0, + .comparitor = max_compare +}; + + +static struct pm_qos_object *pm_qos_array[] = { + [PM_QOS_RESERVED] = &null_pm_qos, + [PM_QOS_CPU_DMA_LATENCY] = &cpu_dma_pm_qos, + [PM_QOS_NETWORK_LATENCY] = &network_lat_pm_qos, + [PM_QOS_NETWORK_THROUGHPUT] = &network_throughput_pm_qos, + [PM_QOS_SYSTEM_BUS_FREQ] = &system_bus_freq_pm_qos, +}; + +static DEFINE_SPINLOCK(pm_qos_lock); + +static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos); +static int pm_qos_power_open(struct inode *inode, struct file *filp); +static int pm_qos_power_release(struct inode *inode, struct file *filp); + +static const struct file_operations pm_qos_power_fops = { + .write = pm_qos_power_write, + .open = pm_qos_power_open, + .release = pm_qos_power_release, +}; + +/* static helper functions */ +static s32 max_compare(s32 v1, s32 v2) +{ + return max(v1, v2); +} + +static s32 min_compare(s32 v1, s32 v2) +{ + return min(v1, v2); +} + +static void update_target(int target) +{ + s32 extreme_value; + struct requirement_list *node; + unsigned long flags; + int call_notifier = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + extreme_value = pm_qos_array[target]->default_value; + list_for_each_entry(node, + &pm_qos_array[target]->requirements.list, list) { + extreme_value = pm_qos_array[target]->comparitor( + extreme_value, node->value); + } + if (pm_qos_array[target]->target_value != extreme_value) { + call_notifier = 1; + pm_qos_array[target]->target_value = extreme_value; + pr_debug(KERN_ERR "new target for qos %d is %d\n", target, + pm_qos_array[target]->target_value); + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + + if (call_notifier) + blocking_notifier_call_chain(pm_qos_array[target]->notifiers, + (unsigned long) extreme_value, NULL); +} + +static int register_pm_qos_misc(struct pm_qos_object *qos) +{ + qos->pm_qos_power_miscdev.minor = MISC_DYNAMIC_MINOR; + qos->pm_qos_power_miscdev.name = qos->name; + qos->pm_qos_power_miscdev.fops = &pm_qos_power_fops; + + return misc_register(&qos->pm_qos_power_miscdev); +} + +static int find_pm_qos_object_by_minor(int minor) +{ + int pm_qos_class; + + for (pm_qos_class = 0; + pm_qos_class < PM_QOS_NUM_CLASSES; pm_qos_class++) { + if (minor == + pm_qos_array[pm_qos_class]->pm_qos_power_miscdev.minor) + return pm_qos_class; + } + return -1; +} + +/** + * pm_qos_requirement - returns current system wide qos expectation + * @pm_qos_class: identification of which qos value is requested + * + * This function returns the current target value in an atomic manner. + */ +int pm_qos_requirement(int pm_qos_class) +{ + int ret_val; + unsigned long flags; + + spin_lock_irqsave(&pm_qos_lock, flags); + ret_val = pm_qos_array[pm_qos_class]->target_value; + spin_unlock_irqrestore(&pm_qos_lock, flags); + + return ret_val; +} +EXPORT_SYMBOL_GPL(pm_qos_requirement); + +/** + * pm_qos_add_requirement - inserts new qos request into the list + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * This function inserts a new entry in the pm_qos_class list of requested qos + * performance charactoistics. It recomputes the agregate QoS expectations for + * the pm_qos_class of parrameters. + */ +int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) +{ + struct requirement_list *dep; + unsigned long flags; + + dep = kzalloc(sizeof(struct requirement_list), GFP_KERNEL); + if (dep) { + if (value == PM_QOS_DEFAULT_VALUE) + dep->value = pm_qos_array[pm_qos_class]->default_value; + else + dep->value = value; + dep->name = kstrdup(name, GFP_KERNEL); + if (!dep->name) + goto cleanup; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_add(&dep->list, + &pm_qos_array[pm_qos_class]->requirements.list); + spin_unlock_irqrestore(&pm_qos_lock, flags); + update_target(pm_qos_class); + + return 0; + } + +cleanup: + kfree(dep); + return -ENOMEM; +} +EXPORT_SYMBOL_GPL(pm_qos_add_requirement); + +/** + * pm_qos_update_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * @value: defines the qos request + * + * Updates an existing qos requierement for the pm_qos_class of parameters along + * with updating the target pm_qos_class value. + * + * If the named request isn't in the lest then no change is made. + */ +int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + if (new_value == PM_QOS_DEFAULT_VALUE) + node->value = + pm_qos_array[pm_qos_class]->default_value; + else + node->value = new_value; + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); + + return 0; +} +EXPORT_SYMBOL_GPL(pm_qos_update_requirement); + +/** + * pm_qos_remove_requirement - modifies an existing qos request + * @pm_qos_class: identifies which list of qos request to us + * @name: identifies the request + * + * Will remove named qos request from pm_qos_class list of parrameters and + * recompute the current target value for the pm_qos_class. + */ +void pm_qos_remove_requirement(int pm_qos_class, char *name) +{ + unsigned long flags; + struct requirement_list *node; + int pending_update = 0; + + spin_lock_irqsave(&pm_qos_lock, flags); + list_for_each_entry(node, + &pm_qos_array[pm_qos_class]->requirements.list, list) { + if (strcmp(node->name, name) == 0) { + kfree(node->name); + list_del(&node->list); + kfree(node); + pending_update = 1; + break; + } + } + spin_unlock_irqrestore(&pm_qos_lock, flags); + if (pending_update) + update_target(pm_qos_class); +} +EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); + +/** + * pm_qos_add_notifier - sets notification entry for changes to target value + * @pm_qos_class: identifies which qos target changes should be notified. + * @notifier: notifier block managed by caller. + * + * will register the notifier into a notification chain that gets called + * uppon changes to the pm_qos_class target value. + */ + int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) +{ + int retval; + + retval = blocking_notifier_chain_register( + pm_qos_array[pm_qos_class]->notifiers, notifier); + + return retval; +} +EXPORT_SYMBOL_GPL(pm_qos_add_notifier); + +/** + * pm_qos_remove_notifier - deletes notification entry from chain. + * @pm_qos_class: identifies which qos target changes are notified. + * @notifier: notifier block to be removed. + * + * will remove the notifier from the notification chain that gets called + * uppon changes to the pm_qos_class target value. + */ +int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) +{ + int retval; + + retval = blocking_notifier_chain_unregister( + pm_qos_array[pm_qos_class]->notifiers, notifier); + + return retval; +} +EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); + +#define PID_NAME_LEN sizeof("process_1234567890") +static char name[PID_NAME_LEN]; + +static int pm_qos_power_open(struct inode *inode, struct file *filp) +{ + int ret; + long pm_qos_class; + + pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); + if (pm_qos_class >= 0) { + filp->private_data = (void *)pm_qos_class; + sprintf(name, "process_%d", current->pid); + ret = pm_qos_add_requirement(pm_qos_class, name, + PM_QOS_DEFAULT_VALUE); + if (ret >= 0) + return 0; + } + + return -EPERM; +} + +static int pm_qos_power_release(struct inode *inode, struct file *filp) +{ + int pm_qos_class; + + pm_qos_class = (long)filp->private_data; + sprintf(name, "process_%d", current->pid); + pm_qos_remove_requirement(pm_qos_class, name); + + return 0; +} + +static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, + size_t count, loff_t *f_pos) +{ + s32 value; + int pm_qos_class; + + pm_qos_class = (long)filp->private_data; + if (count != sizeof(s32)) + return -EINVAL; + if (copy_from_user(&value, buf, sizeof(s32))) + return -EFAULT; + sprintf(name, "process_%d", current->pid); + pm_qos_update_requirement(pm_qos_class, name, value); + + return sizeof(s32); +} + +/* + * This initializes pm-qos for older kernels. + */ +int compat_pm_qos_power_init(void) +{ + int ret = 0; + + ret = register_pm_qos_misc(&cpu_dma_pm_qos); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: cpu_dma_latency setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&network_lat_pm_qos); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: network_latency setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&network_throughput_pm_qos); + if (ret < 0) { + printk(KERN_ERR + "pm_qos_param: network_throughput setup failed\n"); + return ret; + } + ret = register_pm_qos_misc(&system_bus_freq_pm_qos); + if (ret < 0) { + printk(KERN_ERR + "pm_qos_param: network_throughput setup failed\n"); + return ret; + } + + return ret; +} + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ -- cgit v1.2.3 From a54e30dc4493d84f95d63f03b6511ae96fdd5df5 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 17:13:31 -0800 Subject: Move pm-qos backport comments to 2.6.25 compat header We'll be synching the pm-qos implementation to match upstream pm-qos on linux-next. Signed-off-by: Luis R. Rodriguez --- compat/pm_qos_params.c | 18 ------------------ include/linux/compat-2.6.25.h | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/compat/pm_qos_params.c b/compat/pm_qos_params.c index da93e957..5ce3d0b1 100644 --- a/compat/pm_qos_params.c +++ b/compat/pm_qos_params.c @@ -5,24 +5,6 @@ #include -/* - * Backport work for QoS dependencies (kernel/pm_qos_params.c) - * pm-qos stuff written by mark gross mgross@linux.intel.com. - * - * ipw2100 now makes use of - * pm_qos_add_requirement(), - * pm_qos_update_requirement() and - * pm_qos_remove_requirement() from it - * - * mac80211 uses the network latency to determine if to enable or not - * dynamic PS. mac80211 also and registers a notifier for when - * the latency changes. Since older kernels do no thave pm-qos stuff - * we just implement it completley here and register it upon cfg80211 - * init. I haven't tested ipw2100 on 2.6.24 though. - * - * This is copied from the kernel written by mark gross mgross@linux.intel.com - */ - /* * locking rule: all changes to target_value or requirements or notifiers lists * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index a4d5c908..c188f369 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -17,6 +17,28 @@ #include #include +/* + * Backport work for QoS dependencies (kernel/pm_qos_params.c) + * pm-qos stuff written by mark gross mgross@linux.intel.com. + * + * ipw2100 now makes use of: + * + * pm_qos_add_requirement(), + * pm_qos_update_requirement() and + * pm_qos_remove_requirement() from it + * + * mac80211 uses the network latency to determine if to enable or not + * dynamic PS. mac80211 also and registers a notifier for when + * the latency changes. Since older kernels do no thave pm-qos stuff + * we just implement it completley here and register it upon cfg80211 + * init. I haven't tested ipw2100 on 2.6.24 though. + * + * This pm-qos implementation is copied verbatim from the kernel + * written by mark gross mgross@linux.intel.com. You don't have + * to do anythinig to use pm-qos except use the same exported + * routines as used in newer kernels. The compat_pm_qos_power_init() + * defned below is used by the compat module to initialize pm-qos. + */ int compat_pm_qos_power_init(void); /* -- cgit v1.2.3 From 08ec0d36c10a745bdf37d72cde73c5e048a23152 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 17:26:03 -0800 Subject: Synch up pm-qos implementation completely with linux-next next-20100111 This should be easier to keep track of and backport now for older kernels. As we move along each new kernel release will get a branch and have its own pm-qos implementation, the master tag will always keep backporting the latest bleedinge edge (from linux-next). Signed-off-by: Luis R. Rodriguez --- compat/pm_qos_params.c | 116 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 41 deletions(-) diff --git a/compat/pm_qos_params.c b/compat/pm_qos_params.c index 5ce3d0b1..30aeddf8 100644 --- a/compat/pm_qos_params.c +++ b/compat/pm_qos_params.c @@ -1,12 +1,53 @@ #include -/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ +/* This is the backport of pm-qos params for kernels <= 2.6.25 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) +/* + * This module exposes the interface to kernel space for specifying + * QoS dependencies. It provides infrastructure for registration of: + * + * Dependents on a QoS value : register requirements + * Watchers of QoS value : get notified when target QoS value changes + * + * This QoS design is best effort based. Dependents register their QoS needs. + * Watchers register to keep track of the current QoS needs of the system. + * + * There are 3 basic classes of QoS parameter: latency, timeout, throughput + * each have defined units: + * latency: usec + * timeout: usec <-- currently not used. + * throughput: kbs (kilo byte / sec) + * + * There are lists of pm_qos_objects each one wrapping requirements, notifiers + * + * User mode requirements on a QOS parameter register themselves to the + * subsystem by opening the device node /dev/... and writing there request to + * the node. As long as the process holds a file handle open to the node the + * client continues to be accounted for. Upon file release the usermode + * requirement is removed and a new qos target is computed. This way when the + * requirement that the application has is cleaned up when closes the file + * pointer or exits the pm_qos_object will get an opportunity to clean up. + * + * Mark Gross + */ + +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include + +#include /* - * locking rule: all changes to target_value or requirements or notifiers lists + * locking rule: all changes to requirements or notifiers lists * or pm_qos_object list and pm_qos_objects need to happen with pm_qos_lock * held, taken with _irqsave. One lock to rule them all */ @@ -29,7 +70,7 @@ struct pm_qos_object { struct miscdevice pm_qos_power_miscdev; char *name; s32 default_value; - s32 target_value; + atomic_t target_value; s32 (*comparitor)(s32, s32); }; @@ -40,7 +81,7 @@ static struct pm_qos_object cpu_dma_pm_qos = { .notifiers = &cpu_dma_lat_notifier, .name = "cpu_dma_latency", .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, + .target_value = ATOMIC_INIT(2000 * USEC_PER_SEC), .comparitor = min_compare }; @@ -50,7 +91,7 @@ static struct pm_qos_object network_lat_pm_qos = { .notifiers = &network_lat_notifier, .name = "network_latency", .default_value = 2000 * USEC_PER_SEC, - .target_value = 2000 * USEC_PER_SEC, + .target_value = ATOMIC_INIT(2000 * USEC_PER_SEC), .comparitor = min_compare }; @@ -62,7 +103,7 @@ static struct pm_qos_object network_throughput_pm_qos = { .notifiers = &network_throughput_notifier, .name = "network_throughput", .default_value = 0, - .target_value = 0, + .target_value = ATOMIC_INIT(0), .comparitor = max_compare }; @@ -73,12 +114,12 @@ static struct pm_qos_object system_bus_freq_pm_qos = { .notifiers = &system_bus_freq_notifier, .name = "system_bus_freq", .default_value = 0, - .target_value = 0, + .target_value = ATOMIC_INIT(0), .comparitor = max_compare }; -static struct pm_qos_object *pm_qos_array[] = { +static struct pm_qos_object *pm_qos_array[PM_QOS_NUM_CLASSES] = { [PM_QOS_RESERVED] = &null_pm_qos, [PM_QOS_CPU_DMA_LATENCY] = &cpu_dma_pm_qos, [PM_QOS_NETWORK_LATENCY] = &network_lat_pm_qos, @@ -94,9 +135,9 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp); static int pm_qos_power_release(struct inode *inode, struct file *filp); static const struct file_operations pm_qos_power_fops = { - .write = pm_qos_power_write, - .open = pm_qos_power_open, - .release = pm_qos_power_release, + .write = pm_qos_power_write, + .open = pm_qos_power_open, + .release = pm_qos_power_release, }; /* static helper functions */ @@ -110,6 +151,7 @@ static s32 min_compare(s32 v1, s32 v2) return min(v1, v2); } + static void update_target(int target) { s32 extreme_value; @@ -124,11 +166,11 @@ static void update_target(int target) extreme_value = pm_qos_array[target]->comparitor( extreme_value, node->value); } - if (pm_qos_array[target]->target_value != extreme_value) { + if (atomic_read(&pm_qos_array[target]->target_value) != extreme_value) { call_notifier = 1; - pm_qos_array[target]->target_value = extreme_value; + atomic_set(&pm_qos_array[target]->target_value, extreme_value); pr_debug(KERN_ERR "new target for qos %d is %d\n", target, - pm_qos_array[target]->target_value); + atomic_read(&pm_qos_array[target]->target_value)); } spin_unlock_irqrestore(&pm_qos_lock, flags); @@ -167,14 +209,7 @@ static int find_pm_qos_object_by_minor(int minor) */ int pm_qos_requirement(int pm_qos_class) { - int ret_val; - unsigned long flags; - - spin_lock_irqsave(&pm_qos_lock, flags); - ret_val = pm_qos_array[pm_qos_class]->target_value; - spin_unlock_irqrestore(&pm_qos_lock, flags); - - return ret_val; + return atomic_read(&pm_qos_array[pm_qos_class]->target_value); } EXPORT_SYMBOL_GPL(pm_qos_requirement); @@ -185,8 +220,8 @@ EXPORT_SYMBOL_GPL(pm_qos_requirement); * @value: defines the qos request * * This function inserts a new entry in the pm_qos_class list of requested qos - * performance charactoistics. It recomputes the agregate QoS expectations for - * the pm_qos_class of parrameters. + * performance characteristics. It recomputes the aggregate QoS expectations + * for the pm_qos_class of parameters. */ int pm_qos_add_requirement(int pm_qos_class, char *name, s32 value) { @@ -224,10 +259,10 @@ EXPORT_SYMBOL_GPL(pm_qos_add_requirement); * @name: identifies the request * @value: defines the qos request * - * Updates an existing qos requierement for the pm_qos_class of parameters along + * Updates an existing qos requirement for the pm_qos_class of parameters along * with updating the target pm_qos_class value. * - * If the named request isn't in the lest then no change is made. + * If the named request isn't in the list then no change is made. */ int pm_qos_update_requirement(int pm_qos_class, char *name, s32 new_value) { @@ -261,7 +296,7 @@ EXPORT_SYMBOL_GPL(pm_qos_update_requirement); * @pm_qos_class: identifies which list of qos request to us * @name: identifies the request * - * Will remove named qos request from pm_qos_class list of parrameters and + * Will remove named qos request from pm_qos_class list of parameters and * recompute the current target value for the pm_qos_class. */ void pm_qos_remove_requirement(int pm_qos_class, char *name) @@ -293,9 +328,9 @@ EXPORT_SYMBOL_GPL(pm_qos_remove_requirement); * @notifier: notifier block managed by caller. * * will register the notifier into a notification chain that gets called - * uppon changes to the pm_qos_class target value. + * upon changes to the pm_qos_class target value. */ - int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) +int pm_qos_add_notifier(int pm_qos_class, struct notifier_block *notifier) { int retval; @@ -312,7 +347,7 @@ EXPORT_SYMBOL_GPL(pm_qos_add_notifier); * @notifier: notifier block to be removed. * * will remove the notifier from the notification chain that gets called - * uppon changes to the pm_qos_class target value. + * upon changes to the pm_qos_class target value. */ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) { @@ -325,33 +360,33 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier) } EXPORT_SYMBOL_GPL(pm_qos_remove_notifier); -#define PID_NAME_LEN sizeof("process_1234567890") -static char name[PID_NAME_LEN]; +#define PID_NAME_LEN 32 static int pm_qos_power_open(struct inode *inode, struct file *filp) { int ret; long pm_qos_class; + char name[PID_NAME_LEN]; pm_qos_class = find_pm_qos_object_by_minor(iminor(inode)); if (pm_qos_class >= 0) { filp->private_data = (void *)pm_qos_class; - sprintf(name, "process_%d", current->pid); + snprintf(name, PID_NAME_LEN, "process_%d", current->pid); ret = pm_qos_add_requirement(pm_qos_class, name, PM_QOS_DEFAULT_VALUE); if (ret >= 0) return 0; } - return -EPERM; } static int pm_qos_power_release(struct inode *inode, struct file *filp) { int pm_qos_class; + char name[PID_NAME_LEN]; pm_qos_class = (long)filp->private_data; - sprintf(name, "process_%d", current->pid); + snprintf(name, PID_NAME_LEN, "process_%d", current->pid); pm_qos_remove_requirement(pm_qos_class, name); return 0; @@ -362,18 +397,20 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, { s32 value; int pm_qos_class; + char name[PID_NAME_LEN]; pm_qos_class = (long)filp->private_data; if (count != sizeof(s32)) return -EINVAL; if (copy_from_user(&value, buf, sizeof(s32))) return -EFAULT; - sprintf(name, "process_%d", current->pid); + snprintf(name, PID_NAME_LEN, "process_%d", current->pid); pm_qos_update_requirement(pm_qos_class, name, value); return sizeof(s32); } + /* * This initializes pm-qos for older kernels. */ @@ -398,13 +435,10 @@ int compat_pm_qos_power_init(void) return ret; } ret = register_pm_qos_misc(&system_bus_freq_pm_qos); - if (ret < 0) { + if (ret < 0) printk(KERN_ERR - "pm_qos_param: network_throughput setup failed\n"); - return ret; - } + "pm_qos_param: system_bus_freq setup failed\n"); return ret; } - #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ -- cgit v1.2.3 From 91a46cccd8df3e08eeeaeefae15f27ef212685a1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 17:52:30 -0800 Subject: Add initial 2.6.22 support Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.28.c | 2 ++ compat/compat-2.6.29.c | 2 ++ include/linux/compat-2.6.23.h | 1 + include/linux/compat-2.6.24.h | 11 +++++++++++ include/linux/compat-2.6.28.h | 3 +++ include/linux/compat-2.6.29.h | 2 ++ 6 files changed, 21 insertions(+) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 959a4294..87ad2d58 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -16,6 +16,7 @@ /* 2.6.28 compat code goes here */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /* * Compat-wireless notes for USB backport stuff: * @@ -281,6 +282,7 @@ int usb_anchor_empty(struct usb_anchor *anchor) } EXPORT_SYMBOL_GPL(usb_anchor_empty); +#endif void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index ea2a9919..50100d9a 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -15,6 +15,7 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) /** * usb_unpoison_anchored_urbs - let an anchor be used successfully again * @anchor: anchor the requests are bound to @@ -35,6 +36,7 @@ void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) spin_unlock_irqrestore(&anchor->lock, flags); } EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); +#endif /** * eth_mac_addr - set new Ethernet hardware address diff --git a/include/linux/compat-2.6.23.h b/include/linux/compat-2.6.23.h index c36f90d4..57b0642e 100644 --- a/include/linux/compat-2.6.23.h +++ b/include/linux/compat-2.6.23.h @@ -11,6 +11,7 @@ #include #include #include +#include /* * Tell gcc if a function is cold. The compiler will assume any path diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 246156c2..7b161300 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -13,6 +13,7 @@ #include #include #include +#include #define KEY_BLUETOOTH 237 #define KEY_WLAN 238 @@ -211,6 +212,16 @@ struct header_ops { **/ static inline void sg_mark_end(struct scatterlist *sg) { +#ifdef CONFIG_DEBUG_SG + BUG_ON(sg->sg_magic != SG_MAGIC); +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) + /* + * Set termination bit, clear potential chain bit + */ + sg->page_link |= 0x02; + sg->page_link &= ~0x01; +#endif } /** diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 8f90edc6..02297578 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -46,6 +46,8 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, void *priv_data), void *priv_data); +/* USB anchors were added as of 2.6.23 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if 0 extern void usb_poison_urb(struct urb *urb); #endif @@ -58,6 +60,7 @@ extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); extern int usb_anchor_empty(struct usb_anchor *anchor); +#endif void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index b31a58c9..a1a956a3 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -47,7 +47,9 @@ static inline struct net_device_stats *dev_get_stats(struct net_device *dev) return dev->get_stats(dev); } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); +#endif #define DIV_ROUND_CLOSEST(x, divisor)( \ { \ -- cgit v1.2.3 From 4e981e75b58ee17a2253b83aeadfbb840f8563df Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 11 Jan 2010 18:13:16 -0800 Subject: Adds __dev_addr_delete() and __dev_addr_add() for 2.6.22 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not sure how to port this yet though: CC [M] /home/mcgrof/compat/compat/compat-2.6.32.o /home/mcgrof/compat/compat/compat-2.6.32.c: In function ā€˜__dev_addr_syncā€™: /home/mcgrof/compat/compat/compat-2.6.32.c:84: error: ā€˜struct dev_mc_listā€™ has no member named ā€˜da_syncedā€™ /home/mcgrof/compat/compat/compat-2.6.32.c:89: error: ā€˜struct dev_mc_listā€™ has no member named ā€˜da_syncedā€™ /home/mcgrof/compat/compat/compat-2.6.32.c: In function ā€˜__dev_addr_unsyncā€™: /home/mcgrof/compat/compat/compat-2.6.32.c:111: error: ā€˜struct dev_mc_listā€™ has no member named ā€˜da_syncedā€™ /home/mcgrof/compat/compat/compat-2.6.32.c:114: error: ā€˜struct dev_mc_listā€™ has no member named ā€˜da_syncedā€™ make[3]: *** [/home/mcgrof/compat/compat/compat-2.6.32.o] Error 1 Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.23.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index d232b1aa..136d9499 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -13,6 +13,70 @@ /* All things not in 2.6.22 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) +/* On net/core/dev.c as of 2.6.24 */ +int __dev_addr_delete(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (; (da = *list) != NULL; list = &da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + alen == da->da_addrlen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 0; + if (old_glbl == 0) + break; + } + if (--da->da_users) + return 0; + + *list = da->next; + kfree(da); + (*count)--; + return 0; + } + } + return -ENOENT; +} +EXPORT_SYMBOL(__dev_addr_delete); + +/* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but + * might as well add it */ +int __dev_addr_add(struct dev_addr_list **list, int *count, + void *addr, int alen, int glbl) +{ + struct dev_addr_list *da; + + for (da = *list; da != NULL; da = da->next) { + if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && + da->da_addrlen == alen) { + if (glbl) { + int old_glbl = da->da_gusers; + da->da_gusers = 1; + if (old_glbl) + return 0; + } + da->da_users++; + return 0; + } + } + + da = kmalloc(sizeof(*da), GFP_ATOMIC); + if (da == NULL) + return -ENOMEM; + memcpy(da->da_addr, addr, alen); + da->da_addrlen = alen; + da->da_users = 1; + da->da_gusers = glbl ? 1 : 0; + da->next = *list; + *list = da; + (*count)++; + return 0; +} +EXPORT_SYMBOL(__dev_addr_add); + + /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. * Since da->da_synced is not part of 2.6.22 we need to take longer route when * syncing */ -- cgit v1.2.3 From bf830a1a67416b21623b6ba45862699664de5409 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 12 Jan 2010 16:31:23 -0800 Subject: Backport DEFINE_PCI_DEVICE_TABLE for kernels < 2.6.25 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index c188f369..4804977f 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -16,6 +16,19 @@ #include #include #include +#include + +/* The macro below uses a const upstream, this differs */ + +/** + * DEFINE_PCI_DEVICE_TABLE - macro used to describe a pci device table + * @_table: device table name + * + * This macro is used to create a struct pci_device_id array (a device table) + * in a generic manner. + */ +#define DEFINE_PCI_DEVICE_TABLE(_table) \ + struct pci_device_id _table[] __devinitdata /* * Backport work for QoS dependencies (kernel/pm_qos_params.c) -- cgit v1.2.3 From 7d2b68df6301937a8299bca8bef135ae951b569c Mon Sep 17 00:00:00 2001 From: Senthil Balasubramanian Date: Tue, 12 Jan 2010 16:50:52 -0800 Subject: Fix cfg80211 panic caused by backported pm-qos support pm-qos needs to be deregistered upon module unload. Signed-off-by: Senthil Balasubramanian Signed-off-by: Luis R. Rodriguez --- compat/main.c | 2 ++ compat/pm_qos_params.c | 33 +++++++++++++++++++++++++++++++++ include/linux/compat-2.6.25.h | 6 ++++++ 3 files changed, 41 insertions(+) diff --git a/compat/main.c b/compat/main.c index 251ba43c..76e571a7 100644 --- a/compat/main.c +++ b/compat/main.c @@ -15,6 +15,8 @@ module_init(compat_init); static void __exit compat_exit(void) { + compat_pm_qos_power_deinit(); + return; } module_exit(compat_exit); diff --git a/compat/pm_qos_params.c b/compat/pm_qos_params.c index 30aeddf8..833d98c5 100644 --- a/compat/pm_qos_params.c +++ b/compat/pm_qos_params.c @@ -441,4 +441,37 @@ int compat_pm_qos_power_init(void) return ret; } + +int compat_pm_qos_power_deinit(void) +{ + int ret = 0; + + ret = misc_deregister(&cpu_dma_pm_qos.pm_qos_power_miscdev); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: cpu_dma_latency deinit failed\n"); + return ret; + } + + ret = misc_deregister(&network_lat_pm_qos.pm_qos_power_miscdev); + if (ret < 0) { + printk(KERN_ERR "pm_qos_param: network_latency deinit failed\n"); + return ret; + } + + ret = misc_deregister(&network_throughput_pm_qos.pm_qos_power_miscdev); + if (ret < 0) { + printk(KERN_ERR + "pm_qos_param: network_throughput deinit failed\n"); + return ret; + } + + ret = misc_deregister(&system_bus_freq_pm_qos.pm_qos_power_miscdev); + if (ret < 0) { + printk(KERN_ERR + "pm_qos_param: system_bus_freq deinit failed\n"); + return ret; + } + + return ret; +} #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 4804977f..e0dfdf3a 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -53,6 +53,7 @@ * defned below is used by the compat module to initialize pm-qos. */ int compat_pm_qos_power_init(void); +int compat_pm_qos_power_deinit(void); /* * 2.6.25 adds PM_EVENT_HIBERNATE as well here but @@ -167,6 +168,11 @@ static inline int compat_pm_qos_power_init(void) { return 0; } + +static inline int int compat_pm_qos_power_deinit(void) +{ + return 0; +} #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) */ #endif /* LINUX_26_25_COMPAT_H */ -- cgit v1.2.3 From 60cd75a310b0e9815b942581ba515a5cacf5596f Mon Sep 17 00:00:00 2001 From: Senthil Balasubramanian Date: Tue, 12 Jan 2010 16:21:02 +0530 Subject: Fix dev_set_name() for kernel 2.6.23 Signed-off-by: Senthil Balasubramanian --- compat/compat-2.6.26.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index d591eb0a..668d658e 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -55,6 +55,19 @@ static int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, va_list vargs) { + struct device *dev; + unsigned int len; + va_list aq; + + dev = container_of(kobj, struct device, kobj); + + va_copy(aq, vargs); + len = vsnprintf(NULL, 0, fmt, aq); + va_end(aq); + + len = len < BUS_ID_SIZE ? (len + 1) : BUS_ID_SIZE; + + vsnprintf(dev->bus_id, len, fmt, vargs); return 0; } #endif -- cgit v1.2.3 From 33719df7ae4e1e6f03164d2365a74025c061d7a1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 09:50:36 -0800 Subject: Add module load print to know where we backported from For stable kernels this will be more important. I'll soon start a branch based on new kernel releases so if anyone wants to base their code only up to a specific point release they can use that. Signed-off-by: Luis R. Rodriguez --- compat/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/main.c b/compat/main.c index 76e571a7..1570f6f7 100644 --- a/compat/main.c +++ b/compat/main.c @@ -8,6 +8,8 @@ static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); + printk(KERN_INFO "Generic kernel compatibility enabled based on " + "linux-next next-20100112\n"); return 0; } -- cgit v1.2.3 From c67ff24ace9fe1ce0656a3fcfeb2545ae134209e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 12:36:32 -0800 Subject: Add notes about why debugfs_remove_recursive() cannot be backported You should just disable debugging for older kernels if this is used. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.26.c | 113 +++++++++++++++++++++++++++++++++++++++++- include/linux/compat-2.6.26.h | 13 +++++ 2 files changed, 125 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index 668d658e..c20ddd5d 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Luis R. Rodriguez + * Copyright 2007-2010 Luis R. Rodriguez * * 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 @@ -89,5 +89,116 @@ int dev_set_name(struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL_GPL(dev_set_name); +#if 0 +/* + * Below was an attempt to backport debugfs_remove_recursive() but as + * can be seen if enabled it cannot be backported since it relies on + * two static variables from fs/debugfs/inode.c . If you need backport + * this consider instead just disabling debugfs for drivers that use + * this for kernels < 2.6.26 + */ +static inline int debugfs_positive(struct dentry *dentry) +{ + return dentry->d_inode && !d_unhashed(dentry); +} + +static void __debugfs_remove(struct dentry *dentry, struct dentry *parent) +{ + int ret = 0; + + if (debugfs_positive(dentry)) { + if (dentry->d_inode) { + dget(dentry); + switch (dentry->d_inode->i_mode & S_IFMT) { + case S_IFDIR: + ret = simple_rmdir(parent->d_inode, dentry); + break; + case S_IFLNK: + kfree(dentry->d_inode->i_private); + /* fall through */ + default: + simple_unlink(parent->d_inode, dentry); + break; + } + if (!ret) + d_delete(dentry); + dput(dentry); + } + } +} + +/** + * debugfs_remove_recursive - recursively removes a directory + * @dentry: a pointer to a the dentry of the directory to be removed. + * + * This function recursively removes a directory tree in debugfs that + * was previously created with a call to another debugfs function + * (like debugfs_create_file() or variants thereof.) + * + * This function is required to be called in order for the file to be + * removed, no automatic cleanup of files will happen when a module is + * removed, you are responsible here. + */ +void debugfs_remove_recursive(struct dentry *dentry) +{ + struct dentry *child; + struct dentry *parent; + + if (!dentry) + return; + + parent = dentry->d_parent; + if (!parent || !parent->d_inode) + return; + + parent = dentry; + mutex_lock(&parent->d_inode->i_mutex); + + while (1) { + /* + * When all dentries under "parent" has been removed, + * walk up the tree until we reach our starting point. + */ + if (list_empty(&parent->d_subdirs)) { + mutex_unlock(&parent->d_inode->i_mutex); + if (parent == dentry) + break; + parent = parent->d_parent; + mutex_lock(&parent->d_inode->i_mutex); + } + child = list_entry(parent->d_subdirs.next, struct dentry, + d_u.d_child); + + /* + * If "child" isn't empty, walk down the tree and + * remove all its descendants first. + */ + if (!list_empty(&child->d_subdirs)) { + mutex_unlock(&parent->d_inode->i_mutex); + parent = child; + mutex_lock(&parent->d_inode->i_mutex); + continue; + } + __debugfs_remove(child, parent); + if (parent->d_subdirs.next == &child->d_u.d_child) { + /* + * Avoid infinite loop if we fail to remove + * one dentry. + */ + mutex_unlock(&parent->d_inode->i_mutex); + break; + } + simple_release_fs(&debugfs_mount, &debugfs_mount_count); + } + + parent = dentry->d_parent; + mutex_lock(&parent->d_inode->i_mutex); + __debugfs_remove(dentry, parent); + mutex_unlock(&parent->d_inode->i_mutex); + simple_release_fs(&debugfs_mount, &debugfs_mount_count); + } +EXPORT_SYMBOL_GPL(debugfs_remove_recursive); +#endif + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 0ea99b15..96459e0b 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,9 +11,22 @@ #include #include #include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #endif +#include +#include + +#if 0 +/* This cannot be backported :( */ +#if defined(CONFIG_DEBUG_FS) +void debugfs_remove_recursive(struct dentry *dentry); +#else +static inline void debugfs_remove_recursive(struct dentry *dentry) +{ } +#endif +#endif /* These jiffie helpers added as of 2.6.26 */ -- cgit v1.2.3 From 814951a2215835620577fbf40ddd7c434a28d119 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Jan 2010 22:20:17 +0100 Subject: compat: fix two return types This fixes a build error introduced in 7d2b68df6301937a8299bca8bef135ae951b569c: /include/linux/compat-2.6.25.h:172: error: two or more data types in declaration specifiers Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.25.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index e0dfdf3a..7188b8c1 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -169,7 +169,7 @@ static inline int compat_pm_qos_power_init(void) return 0; } -static inline int int compat_pm_qos_power_deinit(void) +static inline int compat_pm_qos_power_deinit(void) { return 0; } -- cgit v1.2.3 From f384ddbe0435fb9cf159ec7135a8ee108d83749c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Jan 2010 22:20:18 +0100 Subject: compat: autoconf.h moved from linux/ to generated/ with kernel 2.6.33 Changed the headers, because autoconf.h moved from linux/ into generated/ All compat-2.6.XX.h files are included by compat-2.6.h, so only compat-2.6.h needs to include autoconf.h. There is no situation known to me where you want to include any compat-2.6.XX.h file directly. This fixes build with kernel 2.6.33, without it complains about a missing import: /include/linux/compat-2.6.h:4:28: error: linux/autoconf.h: No such file or directory Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.14.h | 1 - include/linux/compat-2.6.18.h | 1 - include/linux/compat-2.6.19.h | 1 - include/linux/compat-2.6.21.h | 1 - include/linux/compat-2.6.22.h | 1 - include/linux/compat-2.6.23.h | 1 - include/linux/compat-2.6.24.h | 1 - include/linux/compat-2.6.25.h | 1 - include/linux/compat-2.6.26.h | 1 - include/linux/compat-2.6.27.h | 1 - include/linux/compat-2.6.28.h | 1 - include/linux/compat-2.6.29.h | 1 - include/linux/compat-2.6.30.h | 1 - include/linux/compat-2.6.31.h | 1 - include/linux/compat-2.6.32.h | 1 - include/linux/compat-2.6.33.h | 2 -- include/linux/compat-2.6.h | 6 +++++- 17 files changed, 5 insertions(+), 18 deletions(-) diff --git a/include/linux/compat-2.6.14.h b/include/linux/compat-2.6.14.h index 22e7e319..1f19f7fe 100644 --- a/include/linux/compat-2.6.14.h +++ b/include/linux/compat-2.6.14.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_14_COMPAT_H #define LINUX_26_14_COMPAT_H -#include #include /* Compat work for 2.6.14 */ diff --git a/include/linux/compat-2.6.18.h b/include/linux/compat-2.6.18.h index 3245c42c..5e0182b1 100644 --- a/include/linux/compat-2.6.18.h +++ b/include/linux/compat-2.6.18.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_18_COMPAT_H #define LINUX_26_18_COMPAT_H -#include #include /* Compat work for 2.6.18 */ diff --git a/include/linux/compat-2.6.19.h b/include/linux/compat-2.6.19.h index 017044cf..1e648c0a 100644 --- a/include/linux/compat-2.6.19.h +++ b/include/linux/compat-2.6.19.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_19_COMPAT_H #define LINUX_26_19_COMPAT_H -#include #include /* Compat work for 2.6.19 */ diff --git a/include/linux/compat-2.6.21.h b/include/linux/compat-2.6.21.h index 263ebd2f..89ed6d9a 100644 --- a/include/linux/compat-2.6.21.h +++ b/include/linux/compat-2.6.21.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_21_COMPAT_H #define LINUX_26_21_COMPAT_H -#include #include /* Compat work for 2.6.21 */ diff --git a/include/linux/compat-2.6.22.h b/include/linux/compat-2.6.22.h index 85cd9d56..7ca1b18e 100644 --- a/include/linux/compat-2.6.22.h +++ b/include/linux/compat-2.6.22.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_22_COMPAT_H #define LINUX_26_22_COMPAT_H -#include #include /* Compat work for 2.6.21 */ diff --git a/include/linux/compat-2.6.23.h b/include/linux/compat-2.6.23.h index 57b0642e..fbfb470d 100644 --- a/include/linux/compat-2.6.23.h +++ b/include/linux/compat-2.6.23.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_23_COMPAT_H #define LINUX_26_23_COMPAT_H -#include #include /* Compat work for < 2.6.23 */ diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 7b161300..f9c777ca 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_24_COMPAT_H #define LINUX_26_24_COMPAT_H -#include #include /* Compat work for 2.6.21, 2.6.22 and 2.6.23 */ diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 7188b8c1..f62a096f 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_25_COMPAT_H #define LINUX_26_25_COMPAT_H -#include #include /* Compat work for 2.6.24 */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 96459e0b..360f8e02 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_26_COMPAT_H #define LINUX_26_26_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 3e471d09..6d6bd881 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_27_COMPAT_H #define LINUX_26_27_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 02297578..bc260860 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_28_COMPAT_H #define LINUX_26_28_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index a1a956a3..318cdf43 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_29_COMPAT_H #define LINUX_26_29_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h index 2ff1d691..f997d862 100644 --- a/include/linux/compat-2.6.30.h +++ b/include/linux/compat-2.6.30.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_30_COMPAT_H #define LINUX_26_30_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 27dc6a1d..54ddefdc 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_31_COMPAT_H #define LINUX_26_31_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 727ac71d..c3e4dbec 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -1,7 +1,6 @@ #ifndef LINUX_26_32_COMPAT_H #define LINUX_26_32_COMPAT_H -#include #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 68f0e2ca..81239148 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -1,9 +1,7 @@ #ifndef LINUX_26_33_COMPAT_H #define LINUX_26_33_COMPAT_H -#include #include -#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index bea00c99..81224deb 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -1,8 +1,12 @@ #ifndef LINUX_26_COMPAT_H #define LINUX_26_COMPAT_H -#include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) +#include +#else +#include +#endif #include /* -- cgit v1.2.3 From d6eed2e4d67106228f6e717f7712c1975dbebaa1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Jan 2010 22:20:19 +0100 Subject: compat: build pccard and pcmcia condituinaly If the kernel does not include pcmcia, compat.o should not relay on methods provided by it. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.28.c | 4 ++++ compat/compat-2.6.33.c | 7 +++++++ include/linux/compat-2.6.28.h | 4 ++++ include/linux/compat-2.6.33.h | 8 ++++++++ 4 files changed, 23 insertions(+) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 87ad2d58..e3f3a1be 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -85,6 +85,8 @@ void usb_poison_urb(struct urb *urb) EXPORT_SYMBOL_GPL(usb_poison_urb); #endif +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) + #include struct pcmcia_cfg_mem { tuple_t tuple; @@ -160,6 +162,8 @@ next_entry: } EXPORT_SYMBOL(pcmcia_loop_config); +#endif /* CONFIG_PCMCIA */ + void usb_unpoison_urb(struct urb *urb) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 052c6099..055082e7 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -12,6 +12,9 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) +#include + +#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) /** * pccard_loop_tuple() - loop over tuples in the CIS @@ -73,6 +76,7 @@ next_entry: EXPORT_SYMBOL(pccard_loop_tuple); /* Source: drivers/pcmcia/cistpl.c */ +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) struct pcmcia_loop_mem { struct pcmcia_device *p_dev; @@ -125,6 +129,9 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, EXPORT_SYMBOL(pcmcia_loop_tuple); /* Source: drivers/pcmcia/pcmcia_resource.c */ +#endif /* CONFIG_PCMCIA */ + +#endif /* CONFIG_PCCARD */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index bc260860..c7dcb798 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -27,6 +27,8 @@ }) #endif /* From include/asm-generic/bug.h */ +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) + #include #include #include @@ -45,6 +47,8 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, void *priv_data), void *priv_data); +#endif /* CONFIG_PCMCIA */ + /* USB anchors were added as of 2.6.23 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if 0 diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 81239148..da5821b8 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -30,6 +30,10 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, return skb; } +#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) + +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) + #define pcmcia_request_window(a, b, c) pcmcia_request_window(&a, b, c) #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c) @@ -41,6 +45,8 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, void *priv_data), void *priv_data); +#endif /* CONFIG_PCMCIA */ + /* loop over CIS entries */ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, cisparse_t *parse, void *priv_data, @@ -48,6 +54,8 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, cisparse_t *parse, void *priv_data)); +#endif /* CONFIG_PCCARD */ + /* Backport for kfifo * kfifo_alloc and kfifo_free must be backported manually */ -- cgit v1.2.3 From 4644b4c664038ef9384b05d92e3d31f42d5c221f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 15:13:41 -0800 Subject: Update for next-20100113 Signed-off-by: Luis R. Rodriguez --- compat/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/main.c b/compat/main.c index 1570f6f7..d7f713da 100644 --- a/compat/main.c +++ b/compat/main.c @@ -9,7 +9,7 @@ static int __init compat_init(void) /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); printk(KERN_INFO "Generic kernel compatibility enabled based on " - "linux-next next-20100112\n"); + "linux-next next-20100113\n"); return 0; } -- cgit v1.2.3 From 8355d9993b4dc87089b7e947a9c1011d2f945378 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 17:09:24 -0800 Subject: Backport the new firmware_class from > 2.6.33 down to 2.6.23 My main concern with this backport was the usage of the core driver "base.h" but as it turns out firmware_class doesn't even need it. This allowed the backport to go through. This new backport allows drivers which use the new modified firmware API request_firmware_nowait() on older kernels. You should not need to chagne the your request_firmware_nowait() calls at all; the compat-2.6.32.h header ensures that your calls get mapped to compat_request_firmware_nowait() Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 2 + compat/compat_firmware_class.c | 726 +++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.27.h | 6 + include/linux/compat-2.6.32.h | 34 ++ 4 files changed, 768 insertions(+) create mode 100644 compat/compat_firmware_class.c diff --git a/compat/Makefile b/compat/Makefile index d950f47f..e3560a7b 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -1,6 +1,8 @@ obj-m += compat.o #compat-objs := +obj-m += compat_firmware_class.o + compat-y += main.o # Compat kernel compatibility code diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c new file mode 100644 index 00000000..2c1159aa --- /dev/null +++ b/compat/compat_firmware_class.c @@ -0,0 +1,726 @@ +/* + * firmware_class.c - Multi purpose firmware loading support + * + * Copyright (c) 2003 Manuel Estrada Sainz + * + * Please see Documentation/firmware_class/ for more information. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define to_dev(obj) container_of(obj, struct device, kobj) + +MODULE_AUTHOR("Manuel Estrada Sainz"); +MODULE_DESCRIPTION("Multi purpose firmware loading support"); +MODULE_LICENSE("GPL"); + +enum { + FW_STATUS_LOADING, + FW_STATUS_DONE, + FW_STATUS_ABORT, +}; + +static int loading_timeout = 60; /* In seconds */ + +/* fw_lock could be moved to 'struct firmware_priv' but since it is just + * guarding for corner cases a global lock should be OK */ +static DEFINE_MUTEX(fw_lock); + +struct firmware_priv { + char *fw_id; + struct completion completion; + struct bin_attribute attr_data; + struct firmware *fw; + unsigned long status; + struct page **pages; + int nr_pages; + int page_array_size; + const char *vdata; + struct timer_list timeout; +}; + +//#ifdef CONFIG_FW_LOADER +#if 0 +extern struct builtin_fw __start_builtin_fw[]; +extern struct builtin_fw __end_builtin_fw[]; +#else /* Module case. Avoid ifdefs later; it'll all optimise out */ +static struct builtin_fw *__start_builtin_fw; +static struct builtin_fw *__end_builtin_fw; +#endif + +static void +fw_load_abort(struct firmware_priv *fw_priv) +{ + set_bit(FW_STATUS_ABORT, &fw_priv->status); + wmb(); + complete(&fw_priv->completion); +} + +static ssize_t +firmware_timeout_show(struct class *class, char *buf) +{ + return sprintf(buf, "%d\n", loading_timeout); +} + +/** + * firmware_timeout_store - set number of seconds to wait for firmware + * @class: device class pointer + * @buf: buffer to scan for timeout value + * @count: number of bytes in @buf + * + * Sets the number of seconds to wait for the firmware. Once + * this expires an error will be returned to the driver and no + * firmware will be provided. + * + * Note: zero means 'wait forever'. + **/ +static ssize_t +firmware_timeout_store(struct class *class, const char *buf, size_t count) +{ + loading_timeout = simple_strtol(buf, NULL, 10); + if (loading_timeout < 0) + loading_timeout = 0; + return count; +} + +static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); + +static void fw_dev_release(struct device *dev); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) +static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + + if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id)) + return -ENOMEM; + if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) + return -ENOMEM; + + return 0; +} +#else +static int firmware_uevent(struct device *dev, char **envp, + int num_envp, char *buf, int size) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + int error, len = 0, i = 0; + + error = add_uevent_var(envp, num_envp, &i, + buf, size, &len, + "FIRMWARE=%s", fw_priv->fw_id); + if (error) + goto exit; + + error = add_uevent_var(envp, num_envp, &i, + buf, size, &len, + "TIMEOUT=%i", loading_timeout); + if (error) + goto exit; + + return 0; +exit: + envp[i] = NULL; + return error; +} +#endif + +static struct class firmware_class = { + .name = "firmware", + .dev_uevent = firmware_uevent, + .dev_release = fw_dev_release, +}; + +static ssize_t firmware_loading_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); + return sprintf(buf, "%d\n", loading); +} + +/* Some architectures don't have PAGE_KERNEL_RO */ +#ifndef PAGE_KERNEL_RO +#define PAGE_KERNEL_RO PAGE_KERNEL +#endif +/** + * firmware_loading_store - set value in the 'loading' control file + * @dev: device pointer + * @attr: device attribute pointer + * @buf: buffer to scan for loading control value + * @count: number of bytes in @buf + * + * The relevant values are: + * + * 1: Start a load, discarding any previous partial load. + * 0: Conclude the load and hand the data to the driver code. + * -1: Conclude the load with an error and discard any written data. + **/ +static ssize_t firmware_loading_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + int loading = simple_strtol(buf, NULL, 10); + int i; + + switch (loading) { + case 1: + mutex_lock(&fw_lock); + if (!fw_priv->fw) { + mutex_unlock(&fw_lock); + break; + } + vfree(fw_priv->fw->data); + fw_priv->fw->data = NULL; + for (i = 0; i < fw_priv->nr_pages; i++) + __free_page(fw_priv->pages[i]); + kfree(fw_priv->pages); + fw_priv->pages = NULL; + fw_priv->page_array_size = 0; + fw_priv->nr_pages = 0; + fw_priv->fw->size = 0; + set_bit(FW_STATUS_LOADING, &fw_priv->status); + mutex_unlock(&fw_lock); + break; + case 0: + if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { + vfree(fw_priv->fw->data); + fw_priv->fw->data = vmap(fw_priv->pages, + fw_priv->nr_pages, + 0, PAGE_KERNEL_RO); + if (!fw_priv->fw->data) { + dev_err(dev, "%s: vmap() failed\n", __func__); + goto err; + } + /* Pages will be freed by vfree() */ + fw_priv->page_array_size = 0; + fw_priv->nr_pages = 0; + complete(&fw_priv->completion); + clear_bit(FW_STATUS_LOADING, &fw_priv->status); + break; + } + /* fallthrough */ + default: + dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading); + /* fallthrough */ + case -1: + err: + fw_load_abort(fw_priv); + break; + } + + return count; +} + +static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); + +static ssize_t +firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) +{ + struct device *dev = to_dev(kobj); + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware *fw; + ssize_t ret_count; + + mutex_lock(&fw_lock); + fw = fw_priv->fw; + if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { + ret_count = -ENODEV; + goto out; + } + if (offset > fw->size) { + ret_count = 0; + goto out; + } + if (count > fw->size - offset) + count = fw->size - offset; + + ret_count = count; + + while (count) { + void *page_data; + int page_nr = offset >> PAGE_SHIFT; + int page_ofs = offset & (PAGE_SIZE-1); + int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count); + + page_data = kmap(fw_priv->pages[page_nr]); + + memcpy(buffer, page_data + page_ofs, page_cnt); + + kunmap(fw_priv->pages[page_nr]); + buffer += page_cnt; + offset += page_cnt; + count -= page_cnt; + } +out: + mutex_unlock(&fw_lock); + return ret_count; +} + +static int +fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) +{ + int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; + + /* If the array of pages is too small, grow it... */ + if (fw_priv->page_array_size < pages_needed) { + int new_array_size = max(pages_needed, + fw_priv->page_array_size * 2); + struct page **new_pages; + + new_pages = kmalloc(new_array_size * sizeof(void *), + GFP_KERNEL); + if (!new_pages) { + fw_load_abort(fw_priv); + return -ENOMEM; + } + memcpy(new_pages, fw_priv->pages, + fw_priv->page_array_size * sizeof(void *)); + memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) * + (new_array_size - fw_priv->page_array_size)); + kfree(fw_priv->pages); + fw_priv->pages = new_pages; + fw_priv->page_array_size = new_array_size; + } + + while (fw_priv->nr_pages < pages_needed) { + fw_priv->pages[fw_priv->nr_pages] = + alloc_page(GFP_KERNEL | __GFP_HIGHMEM); + + if (!fw_priv->pages[fw_priv->nr_pages]) { + fw_load_abort(fw_priv); + return -ENOMEM; + } + fw_priv->nr_pages++; + } + return 0; +} + +/** + * firmware_data_write - write method for firmware + * @kobj: kobject for the device + * @bin_attr: bin_attr structure + * @buffer: buffer being written + * @offset: buffer offset for write in total data store area + * @count: buffer size + * + * Data written to the 'data' attribute will be later handed to + * the driver as a firmware image. + **/ +static ssize_t +firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) +{ + struct device *dev = to_dev(kobj); + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware *fw; + ssize_t retval; + + if (!capable(CAP_SYS_RAWIO)) + return -EPERM; + + mutex_lock(&fw_lock); + fw = fw_priv->fw; + if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { + retval = -ENODEV; + goto out; + } + retval = fw_realloc_buffer(fw_priv, offset + count); + if (retval) + goto out; + + retval = count; + + while (count) { + void *page_data; + int page_nr = offset >> PAGE_SHIFT; + int page_ofs = offset & (PAGE_SIZE - 1); + int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count); + + page_data = kmap(fw_priv->pages[page_nr]); + + memcpy(page_data + page_ofs, buffer, page_cnt); + + kunmap(fw_priv->pages[page_nr]); + buffer += page_cnt; + offset += page_cnt; + count -= page_cnt; + } + + fw->size = max_t(size_t, offset, fw->size); +out: + mutex_unlock(&fw_lock); + return retval; +} + +static struct bin_attribute firmware_attr_data_tmpl = { + .attr = {.name = "data", .mode = 0644}, + .size = 0, + .read = firmware_data_read, + .write = firmware_data_write, +}; + +static void fw_dev_release(struct device *dev) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + int i; + + for (i = 0; i < fw_priv->nr_pages; i++) + __free_page(fw_priv->pages[i]); + kfree(fw_priv->pages); + kfree(fw_priv->fw_id); + kfree(fw_priv); + kfree(dev); + + module_put(THIS_MODULE); +} + +static void +firmware_class_timeout(u_long data) +{ + struct firmware_priv *fw_priv = (struct firmware_priv *) data; + fw_load_abort(fw_priv); +} + +static int fw_register_device(struct device **dev_p, const char *fw_name, + struct device *device) +{ + int retval; + struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), + GFP_KERNEL); + struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); + + *dev_p = NULL; + + if (!fw_priv || !f_dev) { + dev_err(device, "%s: kmalloc failed\n", __func__); + retval = -ENOMEM; + goto error_kfree; + } + + init_completion(&fw_priv->completion); + fw_priv->attr_data = firmware_attr_data_tmpl; + fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); + if (!fw_priv->fw_id) { + dev_err(device, "%s: Firmware name allocation failed\n", + __func__); + retval = -ENOMEM; + goto error_kfree; + } + + fw_priv->timeout.function = firmware_class_timeout; + fw_priv->timeout.data = (u_long) fw_priv; + init_timer(&fw_priv->timeout); + + dev_set_name(f_dev, "%s", dev_name(device)); + f_dev->parent = device; + f_dev->class = &firmware_class; + dev_set_drvdata(f_dev, fw_priv); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) + dev_set_uevent_suppress(f_dev, 1); +#endif + retval = device_register(f_dev); + if (retval) { + dev_err(device, "%s: device_register failed\n", __func__); + put_device(f_dev); + return retval; + } + *dev_p = f_dev; + return 0; + +error_kfree: + kfree(f_dev); + kfree(fw_priv); + return retval; +} + +static int fw_setup_device(struct firmware *fw, struct device **dev_p, + const char *fw_name, struct device *device, + int uevent) +{ + struct device *f_dev; + struct firmware_priv *fw_priv; + int retval; + + *dev_p = NULL; + retval = fw_register_device(&f_dev, fw_name, device); + if (retval) + goto out; + + /* Need to pin this module until class device is destroyed */ + __module_get(THIS_MODULE); + + fw_priv = dev_get_drvdata(f_dev); + + fw_priv->fw = fw; + retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); + if (retval) { + dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); + goto error_unreg; + } + + retval = device_create_file(f_dev, &dev_attr_loading); + if (retval) { + dev_err(device, "%s: device_create_file failed\n", __func__); + goto error_unreg; + } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) + if (uevent) + dev_set_uevent_suppress(f_dev, 0); +#endif + *dev_p = f_dev; + goto out; + +error_unreg: + device_unregister(f_dev); +out: + return retval; +} + +static int +_request_firmware(const struct firmware **firmware_p, const char *name, + struct device *device, int uevent) +{ + struct device *f_dev; + struct firmware_priv *fw_priv; + struct firmware *firmware; + struct builtin_fw *builtin; + int retval; + + if (!firmware_p) + return -EINVAL; + + *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); + if (!firmware) { + dev_err(device, "%s: kmalloc(struct firmware) failed\n", + __func__); + retval = -ENOMEM; + goto out; + } + + for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; + builtin++) { + if (strcmp(name, builtin->name)) + continue; + dev_info(device, "firmware: using built-in firmware %s\n", + name); + firmware->size = builtin->size; + firmware->data = builtin->data; + return 0; + } + + if (uevent) + dev_info(device, "firmware: requesting %s\n", name); + + retval = fw_setup_device(firmware, &f_dev, name, device, uevent); + if (retval) + goto error_kfree_fw; + + fw_priv = dev_get_drvdata(f_dev); + + if (uevent) { + if (loading_timeout > 0) { + fw_priv->timeout.expires = jiffies + loading_timeout * HZ; + add_timer(&fw_priv->timeout); + } + + kobject_uevent(&f_dev->kobj, KOBJ_ADD); + wait_for_completion(&fw_priv->completion); + set_bit(FW_STATUS_DONE, &fw_priv->status); + del_timer_sync(&fw_priv->timeout); + } else + wait_for_completion(&fw_priv->completion); + + mutex_lock(&fw_lock); + if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) { + retval = -ENOENT; + release_firmware(fw_priv->fw); + *firmware_p = NULL; + } + fw_priv->fw = NULL; + mutex_unlock(&fw_lock); + device_unregister(f_dev); + goto out; + +error_kfree_fw: + kfree(firmware); + *firmware_p = NULL; +out: + return retval; +} + +/** + * request_firmware: - send firmware request and wait for it + * @firmware_p: pointer to firmware image + * @name: name of firmware file + * @device: device for which firmware is being loaded + * + * @firmware_p will be used to return a firmware image by the name + * of @name for device @device. + * + * Should be called from user context where sleeping is allowed. + * + * @name will be used as $FIRMWARE in the uevent environment and + * should be distinctive enough not to be confused with any other + * firmware image for this or any other device. + **/ +int +request_firmware(const struct firmware **firmware_p, const char *name, + struct device *device) +{ + int uevent = 1; + return _request_firmware(firmware_p, name, device, uevent); +} + +/** + * release_firmware: - release the resource associated with a firmware image + * @fw: firmware resource to release + **/ +void +release_firmware(const struct firmware *fw) +{ + struct builtin_fw *builtin; + + if (fw) { + for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; + builtin++) { + if (fw->data == builtin->data) + goto free_fw; + } + vfree(fw->data); + free_fw: + kfree(fw); + } +} + +/* Async support */ +struct firmware_work { + struct work_struct work; + struct module *module; + const char *name; + struct device *device; + void *context; + void (*cont)(const struct firmware *fw, void *context); + int uevent; +}; + +static int +request_firmware_work_func(void *arg) +{ + struct firmware_work *fw_work = arg; + const struct firmware *fw; + int ret; + if (!arg) { + WARN_ON(1); + return 0; + } + ret = _request_firmware(&fw, fw_work->name, fw_work->device, + fw_work->uevent); + + fw_work->cont(fw, fw_work->context); + + module_put(fw_work->module); + kfree(fw_work); + return ret; +} + +/** + * request_firmware_nowait: asynchronous version of request_firmware + * @module: module requesting the firmware + * @uevent: sends uevent to copy the firmware image if this flag + * is non-zero else the firmware copy must be done manually. + * @name: name of firmware file + * @device: device for which firmware is being loaded + * @gfp: allocation flags + * @context: will be passed over to @cont, and + * @fw may be %NULL if firmware request fails. + * @cont: function will be called asynchronously when the firmware + * request is over. + * + * Asynchronous variant of request_firmware() for user contexts where + * it is not possible to sleep for long time. It can't be called + * in atomic contexts. + **/ +int +request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, gfp_t gfp, void *context, + void (*cont)(const struct firmware *fw, void *context)) +{ + struct task_struct *task; + struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work), + gfp); + + if (!fw_work) + return -ENOMEM; + if (!try_module_get(module)) { + kfree(fw_work); + return -EFAULT; + } + + *fw_work = (struct firmware_work) { + .module = module, + .name = name, + .device = device, + .context = context, + .cont = cont, + .uevent = uevent, + }; + + task = kthread_run(request_firmware_work_func, fw_work, + "firmware/%s", name); + + if (IS_ERR(task)) { + fw_work->cont(NULL, fw_work->context); + module_put(fw_work->module); + kfree(fw_work); + return PTR_ERR(task); + } + return 0; +} + +static int __init +firmware_class_init(void) +{ + int error; + error = class_register(&firmware_class); + if (error) { + printk(KERN_ERR "%s: class_register failed\n", __func__); + return error; + } + error = class_create_file(&firmware_class, &class_attr_timeout); + if (error) { + printk(KERN_ERR "%s: class_create_file failed\n", + __func__); + class_unregister(&firmware_class); + } + return error; + +} +static void __exit +firmware_class_exit(void) +{ + class_unregister(&firmware_class); +} + +fs_initcall(firmware_class_init); +module_exit(firmware_class_exit); + +EXPORT_SYMBOL(release_firmware); +EXPORT_SYMBOL(request_firmware); +EXPORT_SYMBOL(request_firmware_nowait); diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 6d6bd881..657cba06 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -23,6 +23,12 @@ /* I can't find a more suitable replacement... */ #define flush_work(work) cancel_work_sync(work) +struct builtin_fw { + char *name; + void *data; + unsigned long size; +}; + /* * On older kernels we do not have net_device Multi Queue support, but * since we no longer use MQ on mac80211 we can simply use the 0 queue. diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index c3e4dbec..fbdde527 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -9,6 +9,40 @@ #include #include #include +#include + +#define release_firmware compat_release_firmware +#define request_firmware compat_request_firmware +#define request_firmware_nowait compat_request_firmware_nowait + +#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) +int compat_request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int compat_request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, gfp_t gfp, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void compat_release_firmware(const struct firmware *fw); +#else +static inline int compat_request_firmware(const struct firmware **fw, + const char *name, + struct device *device) +{ + return -EINVAL; +} +static inline int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, gfp_t gfp, void *context, + void (*cont)(const struct firmware *fw, void *context)) +{ + return -EINVAL; +} + +static inline void compat_release_firmware(const struct firmware *fw) +{ +} +#endif #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 -- cgit v1.2.3 From 8bab166decfbaf87e5052bc24b96f238becffe0e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 17:35:29 -0800 Subject: Enable the compat_firmware_class to be built only on < 2.6.32 Signed-off-by: Luis R. Rodriguez --- Makefile | 5 +++++ compat/Makefile | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 0d4bd66d..06983c9e 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,11 @@ COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNE $(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) endif +ifeq ($(CONFIG_COMPAT_KERNEL_33),y) + CONFIG_COMPAT_FIRMWARE_CLASS=m + $(error "poo") +endif + obj-y += compat/ # This hack lets us put our include path first than the kernel's diff --git a/compat/Makefile b/compat/Makefile index e3560a7b..9441ff9f 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -1,7 +1,7 @@ obj-m += compat.o #compat-objs := -obj-m += compat_firmware_class.o +obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o compat-y += main.o -- cgit v1.2.3 From 97afd216312a5befde2ee7c05de19cf652d1f4fe Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 17:37:08 -0800 Subject: Enable 2.6.33 compatibility Signed-off-by: Luis R. Rodriguez --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 06983c9e..d71a369d 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ export PWD := $(shell pwd) # This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for # each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) -COMPAT_LATEST_VERSION = 32 +COMPAT_LATEST_VERSION = 33 KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) $(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) @@ -20,7 +20,6 @@ endif ifeq ($(CONFIG_COMPAT_KERNEL_33),y) CONFIG_COMPAT_FIRMWARE_CLASS=m - $(error "poo") endif obj-y += compat/ -- cgit v1.2.3 From 837e69ccc9736b2964decf1d2452fdcf9c226400 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Jan 2010 17:38:45 -0800 Subject: Export CONFIG_COMPAT_FIRMWARE_CLASS Signed-off-by: Luis R. Rodriguez --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index d71a369d..48438694 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ $(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) endif ifeq ($(CONFIG_COMPAT_KERNEL_33),y) - CONFIG_COMPAT_FIRMWARE_CLASS=m + export CONFIG_COMPAT_FIRMWARE_CLASS=m endif obj-y += compat/ -- cgit v1.2.3 From 8619c684837478a6e3abb987b0cc0b06bbd7bba4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Jan 2010 16:09:27 -0800 Subject: Fix loading of compat_firmware_class due to class name conflict This fixes this warning: [ 869.248771] ------------[ cut here ]------------ [ 869.248779] WARNING: at fs/sysfs/dir.c:463 sysfs_add_one+0x51/0x60() [ 869.248784] sysfs: duplicate filename 'firmware' can not be created [ 869.248788] Modules linked in: compat_firmware_class(+) aes_generic binfmt_misc ppdev i915 drm snd_hda_intel snd_pcm_oss snd_mixer_oss snd_pcm snd_page_alloc snd_hwdep snd_seq_dummy snd_seq_oss snd_seq_midi rfcomm snd_rawmidi sco arc4 snd_seq_midi_event bridge stp snd_seq bnep mac80211 snd_timer pcmcia l2cap ath snd_seq_device btusb iptable_filter yenta_socket bluetooth cfg80211 psmouse snd thinkpad_acpi rfkill_backport ip_tables rsrc_nonstatic video serio_raw compat soundcore output x_tables nvram pcmcia_core led_class joydev lp parport usbhid ohci1394 ieee1394 e1000e intel_agp [last unloaded: ath5k] [ 869.248885] Pid: 6096, comm: modprobe Not tainted 2.6.27.41 #1 [ 869.248890] [ 869.248892] Call Trace: [ 869.248902] [] warn_slowpath+0x98/0xd0 [ 869.248912] [] ? idr_get_empty_slot+0x108/0x2c0 [ 869.248920] [] ? ida_get_new_above+0xb0/0x220 [ 869.248927] [] ? sysfs_ilookup_test+0x9/0x20 [ 869.248934] [] ? find_inode+0x54/0xa0 [ 869.248940] [] ? sysfs_ilookup_test+0x0/0x20 [ 869.248948] [] ? __iget+0x9/0x70 [ 869.248954] [] ? sysfs_find_dirent+0x35/0x50 [ 869.248961] [] sysfs_add_one+0x51/0x60 [ 869.248967] [] create_dir+0x68/0xb0 [ 869.248975] [] sysfs_create_dir+0x39/0x50 [ 869.248982] [] ? kobject_get+0x1a/0x30 [ 869.248989] [] kobject_add_internal+0xb6/0x200 [ 869.248998] [] kset_register+0x2f/0x60 [ 869.249009] [] __class_register+0xcf/0x1b0 [ 869.249020] [] ? firmware_class_init+0x0/0x7e [compat_firmware_class] [ 869.249029] [] firmware_class_init+0x21/0x7e [compat_firmware_class] [ 869.249038] [] do_one_initcall+0x41/0x170 [ 869.249047] [] ? __blocking_notifier_call_chain+0x21/0x80 [ 869.249059] [] sys_init_module+0xaf/0x1e0 [ 869.249068] [] system_call_fastpath+0x16/0x1b [ 869.249072] [ 869.249075] ---[ end trace c1a363c5ede5a470 ]--- [ 869.249082] kobject_add_internal failed for firmware with -EEXIST, don't try to register things with the same name in the same directory. [ 869.249092] Pid: 6096, comm: modprobe Tainted: G W 2.6.27.41 #1 [ 869.249096] [ 869.249097] Call Trace: [ 869.249104] [] kobject_add_internal+0x15d/0x200 [ 869.249112] [] kset_register+0x2f/0x60 [ 869.249120] [] __class_register+0xcf/0x1b0 [ 869.249130] [] ? firmware_class_init+0x0/0x7e [compat_firmware_class] [ 869.249139] [] firmware_class_init+0x21/0x7e [compat_firmware_class] [ 869.249146] [] do_one_initcall+0x41/0x170 [ 869.249153] [] ? __blocking_notifier_call_chain+0x21/0x80 [ 869.249163] [] sys_init_module+0xaf/0x1e0 [ 869.249170] [] system_call_fastpath+0x16/0x1b [ 869.249174] [ 869.249178] firmware_class_init: class_register failed Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 2c1159aa..ce937a35 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -138,7 +138,7 @@ exit: #endif static struct class firmware_class = { - .name = "firmware", + .name = "compat_firmware", .dev_uevent = firmware_uevent, .dev_release = fw_dev_release, }; -- cgit v1.2.3 From 4eabb039841a50b3c89b9f535357ae4dfd1a186c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Tue, 19 Jan 2010 11:19:07 -0800 Subject: compat: fix firmware class compile on linux 2.6.32 The firmware class API change happened after 2.6.32, so move the compat code to the 2.6.33 header file. Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.32.h | 34 ---------------------------------- include/linux/compat-2.6.33.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index fbdde527..c3e4dbec 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -9,40 +9,6 @@ #include #include #include -#include - -#define release_firmware compat_release_firmware -#define request_firmware compat_request_firmware -#define request_firmware_nowait compat_request_firmware_nowait - -#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) -int compat_request_firmware(const struct firmware **fw, const char *name, - struct device *device); -int compat_request_firmware_nowait( - struct module *module, int uevent, - const char *name, struct device *device, gfp_t gfp, void *context, - void (*cont)(const struct firmware *fw, void *context)); - -void compat_release_firmware(const struct firmware *fw); -#else -static inline int compat_request_firmware(const struct firmware **fw, - const char *name, - struct device *device) -{ - return -EINVAL; -} -static inline int request_firmware_nowait( - struct module *module, int uevent, - const char *name, struct device *device, gfp_t gfp, void *context, - void (*cont)(const struct firmware *fw, void *context)) -{ - return -EINVAL; -} - -static inline void compat_release_firmware(const struct firmware *fw) -{ -} -#endif #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index da5821b8..73fc91c8 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -10,6 +10,40 @@ #include #include #include +#include + +#define release_firmware compat_release_firmware +#define request_firmware compat_request_firmware +#define request_firmware_nowait compat_request_firmware_nowait + +#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) +int compat_request_firmware(const struct firmware **fw, const char *name, + struct device *device); +int compat_request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, gfp_t gfp, void *context, + void (*cont)(const struct firmware *fw, void *context)); + +void compat_release_firmware(const struct firmware *fw); +#else +static inline int compat_request_firmware(const struct firmware **fw, + const char *name, + struct device *device) +{ + return -EINVAL; +} +static inline int request_firmware_nowait( + struct module *module, int uevent, + const char *name, struct device *device, gfp_t gfp, void *context, + void (*cont)(const struct firmware *fw, void *context)) +{ + return -EINVAL; +} + +static inline void compat_release_firmware(const struct firmware *fw) +{ +} +#endif #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ -- cgit v1.2.3 From 7b002e53ca662e415245a2c6e59c50291ff778bd Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Jan 2010 15:57:10 -0800 Subject: Only build compat_firmware_class if CONFIG_FW_LOADER was enabled This prevents bothering with building compat_firmware_class if your kernel lacks CONFIG_FW_LOADER support. Signed-off-by: Luis R. Rodriguez --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 48438694..be2fdc5e 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,10 @@ $(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) endif ifeq ($(CONFIG_COMPAT_KERNEL_33),y) +ifneq ($(CONFIG_FW_LOADER),) export CONFIG_COMPAT_FIRMWARE_CLASS=m endif +endif obj-y += compat/ -- cgit v1.2.3 From 7c3c8447d754525abd289533b9e471639f4d3dc3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Jan 2010 15:58:56 -0800 Subject: Fix build with CONFIG_PCMCIA disabled Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 73fc91c8..9559f21d 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -6,9 +6,13 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) #include +#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) #include #include #include +#endif +#endif #include #include -- cgit v1.2.3 From 80deffd6ba98f1a4a2825e2815dcffa339abfd6a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Jan 2010 15:59:13 -0800 Subject: Fix build with CONFIG_USB disabled Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.28.c | 6 +++++- compat/compat-2.6.29.c | 2 ++ include/linux/compat-2.6.28.h | 3 +++ include/linux/compat-2.6.29.h | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index e3f3a1be..a141859f 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -17,6 +17,7 @@ /* 2.6.28 compat code goes here */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) +#if defined(CONFIG_USB) /* * Compat-wireless notes for USB backport stuff: * @@ -84,6 +85,7 @@ void usb_poison_urb(struct urb *urb) } EXPORT_SYMBOL_GPL(usb_poison_urb); #endif +#endif /* CONFIG_USB */ #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) @@ -164,6 +166,8 @@ EXPORT_SYMBOL(pcmcia_loop_config); #endif /* CONFIG_PCMCIA */ +#if defined(CONFIG_USB) + void usb_unpoison_urb(struct urb *urb) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) @@ -286,9 +290,9 @@ int usb_anchor_empty(struct usb_anchor *anchor) } EXPORT_SYMBOL_GPL(usb_anchor_empty); +#endif /* CONFIG_USB */ #endif - void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) { /* diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 50100d9a..48e72a35 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -16,6 +16,7 @@ #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) +#if defined(CONFIG_USB) /** * usb_unpoison_anchored_urbs - let an anchor be used successfully again * @anchor: anchor the requests are bound to @@ -36,6 +37,7 @@ void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) spin_unlock_irqrestore(&anchor->lock, flags); } EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); +#endif /* CONFIG_USB */ #endif /** diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index c7dcb798..13a03674 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -51,6 +51,8 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, /* USB anchors were added as of 2.6.23 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) + +#if defined(CONFIG_USB) #if 0 extern void usb_poison_urb(struct urb *urb); #endif @@ -63,6 +65,7 @@ extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); extern int usb_anchor_empty(struct usb_anchor *anchor); +#endif /* CONFIG_USB */ #endif diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 318cdf43..27f13252 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -47,7 +47,9 @@ static inline struct net_device_stats *dev_get_stats(struct net_device *dev) } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) +#if defined(CONFIG_USB) extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); +#endif /* CONFIG_USB */ #endif #define DIV_ROUND_CLOSEST(x, divisor)( \ -- cgit v1.2.3 From 96c8b2c208fee5a33e9c7b7a1d8e129d1aefe21b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 20 Jan 2010 11:03:49 -0800 Subject: Install udev rules and scripts needed for compat_firmware_class If you are a distribution maintainer and your distribution has lsb_release and if you disagree with the way we handle the uknown case just go ahead and add a case for yourself in scripts/compat_firmware_install along with a directory and your own files. Signed-off-by: Luis R. Rodriguez --- Makefile | 1 + scripts/compat_firmware_install | 19 +++++++++++++++++++ udev/50-compat_firmware.rules | 4 ++++ udev/compat_firmware.sh | 35 +++++++++++++++++++++++++++++++++++ udev/ubuntu/50-compat_firmware.rules | 4 ++++ udev/ubuntu/compat_firmware.sh | 29 +++++++++++++++++++++++++++++ 6 files changed, 92 insertions(+) create mode 100755 scripts/compat_firmware_install create mode 100644 udev/50-compat_firmware.rules create mode 100755 udev/compat_firmware.sh create mode 100644 udev/ubuntu/50-compat_firmware.rules create mode 100755 udev/ubuntu/compat_firmware.sh diff --git a/Makefile b/Makefile index be2fdc5e..3692f966 100644 --- a/Makefile +++ b/Makefile @@ -37,6 +37,7 @@ install: modules $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \ modules_install depmod -a + @./scripts/compat_firmware_install clean: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean all: modules diff --git a/scripts/compat_firmware_install b/scripts/compat_firmware_install new file mode 100755 index 00000000..d92961a6 --- /dev/null +++ b/scripts/compat_firmware_install @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ -f /usr/bin/lsb_release ]; then + LSB_RED_ID=$(/usr/bin/lsb_release -i -s) +else + LSB_RED_ID="Unknown" +fi + +case $LSB_RED_ID in +"Ubuntu") + cp udev/ubuntu/compat_firmware.sh /lib/udev/ + cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +*) + cp udev/compat_firmware.sh /lib/udev/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ + ;; +esac + diff --git a/udev/50-compat_firmware.rules b/udev/50-compat_firmware.rules new file mode 100644 index 00000000..6473788e --- /dev/null +++ b/udev/50-compat_firmware.rules @@ -0,0 +1,4 @@ +# do not edit this file, it will be overwritten on update + +# compat_firmware-class requests, copies files into the kernel +SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh" diff --git a/udev/compat_firmware.sh b/udev/compat_firmware.sh new file mode 100755 index 00000000..ef609e71 --- /dev/null +++ b/udev/compat_firmware.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +# This is ported from Ubuntu but ubuntu uses these directories which +# other distributions don't care about: +# FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \ +# /lib/firmware/$(uname -r) /lib/firmware" +# If your distribution looks for firmware in other directories +# feel free to extend this and add your own directory here. +# +FIRMWARE_DIRS="/lib/firmware" + +err() { + echo "$@" >&2 + logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true +} + +if [ ! -e /sys$DEVPATH/loading ]; then + err "udev firmware loader misses sysfs directory" + exit 1 +fi + +for DIR in $FIRMWARE_DIRS; do + [ -e "$DIR/$FIRMWARE" ] || continue + echo 1 > /sys$DEVPATH/loading + cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data + echo 0 > /sys$DEVPATH/loading + exit 0 +done + +echo -1 > /sys$DEVPATH/loading +err "Cannot find firmware file '$FIRMWARE'" +mkdir -p /dev/.udev/firmware-missing +file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g') +ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file +exit 1 diff --git a/udev/ubuntu/50-compat_firmware.rules b/udev/ubuntu/50-compat_firmware.rules new file mode 100644 index 00000000..6473788e --- /dev/null +++ b/udev/ubuntu/50-compat_firmware.rules @@ -0,0 +1,4 @@ +# do not edit this file, it will be overwritten on update + +# compat_firmware-class requests, copies files into the kernel +SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh" diff --git a/udev/ubuntu/compat_firmware.sh b/udev/ubuntu/compat_firmware.sh new file mode 100755 index 00000000..9d4659a3 --- /dev/null +++ b/udev/ubuntu/compat_firmware.sh @@ -0,0 +1,29 @@ +#!/bin/sh -e + +FIRMWARE_DIRS="/lib/firmware/updates/$(uname -r) /lib/firmware/updates \ + /lib/firmware/$(uname -r) /lib/firmware" + +err() { + echo "$@" >&2 + logger -t "${0##*/}[$$]" "$@" 2>/dev/null || true +} + +if [ ! -e /sys$DEVPATH/loading ]; then + err "udev firmware loader misses sysfs directory" + exit 1 +fi + +for DIR in $FIRMWARE_DIRS; do + [ -e "$DIR/$FIRMWARE" ] || continue + echo 1 > /sys$DEVPATH/loading + cat "$DIR/$FIRMWARE" > /sys$DEVPATH/data + echo 0 > /sys$DEVPATH/loading + exit 0 +done + +echo -1 > /sys$DEVPATH/loading +err "Cannot find firmware file '$FIRMWARE'" +mkdir -p /dev/.udev/firmware-missing +file=$(echo "$FIRMWARE" | sed 's:/:\\x2f:g') +ln -s -f "$DEVPATH" /dev/.udev/firmware-missing/$file +exit 1 -- cgit v1.2.3 From 09bb5f3ad3868a66eb2fed3d3b279071b0550a1b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 20 Jan 2010 20:33:16 +0100 Subject: compat: fix build with CONFIG_USB=m The usb compat code was not build if usb was build as module in kernel. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.28.c | 4 ++-- compat/compat-2.6.29.c | 2 +- include/linux/compat-2.6.28.h | 2 +- include/linux/compat-2.6.29.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index a141859f..115bd23a 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -17,7 +17,7 @@ /* 2.6.28 compat code goes here */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) -#if defined(CONFIG_USB) +#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) /* * Compat-wireless notes for USB backport stuff: * @@ -166,7 +166,7 @@ EXPORT_SYMBOL(pcmcia_loop_config); #endif /* CONFIG_PCMCIA */ -#if defined(CONFIG_USB) +#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) void usb_unpoison_urb(struct urb *urb) { diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 48e72a35..c8e0183f 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -16,7 +16,7 @@ #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) -#if defined(CONFIG_USB) +#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) /** * usb_unpoison_anchored_urbs - let an anchor be used successfully again * @anchor: anchor the requests are bound to diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 13a03674..2cab3201 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -52,7 +52,7 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, /* USB anchors were added as of 2.6.23 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) -#if defined(CONFIG_USB) +#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) #if 0 extern void usb_poison_urb(struct urb *urb); #endif diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 27f13252..c3572a20 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -47,7 +47,7 @@ static inline struct net_device_stats *dev_get_stats(struct net_device *dev) } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) -#if defined(CONFIG_USB) +#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); #endif /* CONFIG_USB */ #endif -- cgit v1.2.3 From ce74eb41c7bfe5d83636284935bae6ede9bb4bb5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 21 Jan 2010 20:32:48 +0100 Subject: compat: fix build on arm ARM does not provided the include file asm/compat.h. Use linux/compat.h instead, it includes asm/compat.h if needed. This patch is from OpenWRT: https://dev.openwrt.org/browser/trunk/package/mac80211/patches/020-fix_compat_h.patch?rev=19063 Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index c3e4dbec..11060d86 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -6,7 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) #include -#include +#include #include #include -- cgit v1.2.3 From deee4e7e0247b9180f4f7f4b76d6c3efc45de2b2 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 16 Feb 2010 22:03:00 +0100 Subject: compat: backport genlmsg_unicast Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.32.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 11060d86..2f5013f2 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -9,6 +9,7 @@ #include #include #include +#include #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 @@ -47,6 +48,7 @@ static inline void flush_delayed_work(struct delayed_work *dwork) /* net namespace is lost */ #define genlmsg_multicast_netns(a, b, c, d, e) genlmsg_multicast(b, c, d, e) #define genlmsg_multicast_allns(a, b, c, d) genlmsg_multicast(a, b, c, d) +#define genlmsg_unicast(net, skb, pid) genlmsg_unicast(skb, pid) #define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP) -- cgit v1.2.3 From 2d736d0f494a4889266eb481b37284e9cbd74c9b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 16 Feb 2010 22:03:01 +0100 Subject: compat: backport some netdevice.h defs Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 70 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.h | 1 + 2 files changed, 71 insertions(+) create mode 100644 include/linux/compat-2.6.34.h diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h new file mode 100644 index 00000000..4229a22b --- /dev/null +++ b/include/linux/compat-2.6.34.h @@ -0,0 +1,70 @@ +#ifndef LINUX_26_34_COMPAT_H +#define LINUX_26_34_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) + +#include + +#define netdev_mc_count(dev) ((dev)->mc_count) +#define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) + +#define netdev_for_each_mc_addr(mclist, dev) \ + for (mclist = dev->mc_list; mclist; mclist = mclist->next) +/* source: include/linux/netdevice.h */ + + +/* Logging, debugging and troubleshooting/diagnostic helpers. */ + +/* netdev_printk helpers, similar to dev_printk */ + +static inline const char *netdev_name(const struct net_device *dev) +{ + if (dev->reg_state != NETREG_REGISTERED) + return "(unregistered net_device)"; + return dev->name; +} + +#define netdev_printk(level, netdev, format, args...) \ + dev_printk(level, (netdev)->dev.parent, \ + "%s: " format, \ + netdev_name(netdev), ##args) + +#define netdev_emerg(dev, format, args...) \ + netdev_printk(KERN_EMERG, dev, format, ##args) +#define netdev_alert(dev, format, args...) \ + netdev_printk(KERN_ALERT, dev, format, ##args) +#define netdev_crit(dev, format, args...) \ + netdev_printk(KERN_CRIT, dev, format, ##args) +#define netdev_err(dev, format, args...) \ + netdev_printk(KERN_ERR, dev, format, ##args) +#define netdev_warn(dev, format, args...) \ + netdev_printk(KERN_WARNING, dev, format, ##args) +#define netdev_notice(dev, format, args...) \ + netdev_printk(KERN_NOTICE, dev, format, ##args) +#define netdev_info(dev, format, args...) \ + netdev_printk(KERN_INFO, dev, format, ##args) + +#if defined(DEBUG) +#define netdev_dbg(__dev, format, args...) \ + netdev_printk(KERN_DEBUG, __dev, format, ##args) +#elif defined(CONFIG_DYNAMIC_DEBUG) +#define netdev_dbg(__dev, format, args...) \ +do { \ + dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \ + netdev_name(__dev), ##args); \ +} while (0) +#else +#define netdev_dbg(__dev, format, args...) \ +({ \ + if (0) \ + netdev_printk(KERN_DEBUG, __dev, format, ##args); \ + 0; \ +}) +#endif +/* source: include/linux/netdevice.h */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ + +#endif /* LINUX_26_34_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 81224deb..ceca9970 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -26,5 +26,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From ef968cbcfb8d08c94ea2349987808cfdbc4690e0 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 18 Feb 2010 09:34:36 -0800 Subject: compat: backport for ARM dma_sync_single_range_*() helpers This backports for ARM dma_sync_single_range_for_cpu() and dma_sync_single_range_for_device() needed by the b44 Ethernet driver. Signed-off-by: Pavel Roskin Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.27.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 657cba06..e9de41ee 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -188,6 +188,30 @@ static inline int iwe_stream_lcp_len(struct iw_request_info *info) return IW_EV_LCP_LEN; } +#ifdef CONFIG_ARM + +/* + * The caller asks to handle a range between offset and offset + size, + * but we process a larger range from 0 to offset + size due to lack of + * offset support. + */ + +static inline void dma_sync_single_range_for_cpu(struct device *dev, + dma_addr_t handle, unsigned long offset, size_t size, + enum dma_data_direction dir) +{ + dma_sync_single_for_cpu(dev, handle, offset + size, dir); +} + +static inline void dma_sync_single_range_for_device(struct device *dev, + dma_addr_t handle, unsigned long offset, size_t size, + enum dma_data_direction dir) +{ + dma_sync_single_for_device(dev, handle, offset + size, dir); +} + +#endif /* arm */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 5acb4d977a0c49411033414a8ba179e7b10cdb2b Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Thu, 18 Feb 2010 09:45:37 -0800 Subject: compat: backport debugfs_remove_recursive() This avoids using the internal globals by the internal kernel debugfs implementation. Signed-off-by: Pavel Roskin Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.26.c | 121 ++++++++---------------------------------- include/linux/compat-2.6.26.h | 4 +- 2 files changed, 22 insertions(+), 103 deletions(-) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index c20ddd5d..82134c21 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -89,116 +89,37 @@ int dev_set_name(struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL_GPL(dev_set_name); -#if 0 /* - * Below was an attempt to backport debugfs_remove_recursive() but as - * can be seen if enabled it cannot be backported since it relies on - * two static variables from fs/debugfs/inode.c . If you need backport - * this consider instead just disabling debugfs for drivers that use - * this for kernels < 2.6.26 - */ -static inline int debugfs_positive(struct dentry *dentry) -{ - return dentry->d_inode && !d_unhashed(dentry); -} - -static void __debugfs_remove(struct dentry *dentry, struct dentry *parent) -{ - int ret = 0; - - if (debugfs_positive(dentry)) { - if (dentry->d_inode) { - dget(dentry); - switch (dentry->d_inode->i_mode & S_IFMT) { - case S_IFDIR: - ret = simple_rmdir(parent->d_inode, dentry); - break; - case S_IFLNK: - kfree(dentry->d_inode->i_private); - /* fall through */ - default: - simple_unlink(parent->d_inode, dentry); - break; - } - if (!ret) - d_delete(dentry); - dput(dentry); - } - } -} - -/** - * debugfs_remove_recursive - recursively removes a directory - * @dentry: a pointer to a the dentry of the directory to be removed. - * - * This function recursively removes a directory tree in debugfs that - * was previously created with a call to another debugfs function - * (like debugfs_create_file() or variants thereof.) - * - * This function is required to be called in order for the file to be - * removed, no automatic cleanup of files will happen when a module is - * removed, you are responsible here. + * Backport of debugfs_remove_recursive() without using the internals globals + * which are used by the kernel's version with: + * simple_release_fs(&debugfs_mount, &debugfs_mount_count); */ void debugfs_remove_recursive(struct dentry *dentry) { - struct dentry *child; - struct dentry *parent; + struct dentry *last = NULL; - if (!dentry) + /* Sanity checks */ + if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode) return; - parent = dentry->d_parent; - if (!parent || !parent->d_inode) - return; + while (dentry != last) { + struct dentry *child = dentry; - parent = dentry; - mutex_lock(&parent->d_inode->i_mutex); - - while (1) { - /* - * When all dentries under "parent" has been removed, - * walk up the tree until we reach our starting point. - */ - if (list_empty(&parent->d_subdirs)) { - mutex_unlock(&parent->d_inode->i_mutex); - if (parent == dentry) - break; - parent = parent->d_parent; - mutex_lock(&parent->d_inode->i_mutex); - } - child = list_entry(parent->d_subdirs.next, struct dentry, - d_u.d_child); - - /* - * If "child" isn't empty, walk down the tree and - * remove all its descendants first. - */ - if (!list_empty(&child->d_subdirs)) { - mutex_unlock(&parent->d_inode->i_mutex); - parent = child; - mutex_lock(&parent->d_inode->i_mutex); - continue; - } - __debugfs_remove(child, parent); - if (parent->d_subdirs.next == &child->d_u.d_child) { - /* - * Avoid infinite loop if we fail to remove - * one dentry. - */ - mutex_unlock(&parent->d_inode->i_mutex); - break; - } - simple_release_fs(&debugfs_mount, &debugfs_mount_count); - } + /* Find a child without children */ + while (!list_empty(&child->d_subdirs)) + child = list_entry(child->d_subdirs.next, + struct dentry, + d_u.d_child); - parent = dentry->d_parent; - mutex_lock(&parent->d_inode->i_mutex); - __debugfs_remove(dentry, parent); - mutex_unlock(&parent->d_inode->i_mutex); - simple_release_fs(&debugfs_mount, &debugfs_mount_count); - } + /* Bail out if we already tried to remove that entry */ + if (child == last) + return; + + last = child; + debugfs_remove(child); + } +} EXPORT_SYMBOL_GPL(debugfs_remove_recursive); -#endif #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 360f8e02..498fe44c 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,21 +11,19 @@ #include #include #include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #endif #include #include -#if 0 -/* This cannot be backported :( */ #if defined(CONFIG_DEBUG_FS) void debugfs_remove_recursive(struct dentry *dentry); #else static inline void debugfs_remove_recursive(struct dentry *dentry) { } #endif -#endif /* These jiffie helpers added as of 2.6.26 */ -- cgit v1.2.3 From a9bf211db2574435fbed4c835dbff0ff10108ce1 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 19 Feb 2010 20:17:42 -0500 Subject: compat: move debugfs_remove_recursive() to compat-2.6.27 debugfs_remove_recursive() appeared in Linux 2.6.27, so it should be in compat-2.6.27, not in compat-2.6.26. Don't compile it if CONFIG_DEBUG_FS is disabled. Signed-off-by: Pavel Roskin --- compat/compat-2.6.26.c | 32 -------------------------------- compat/compat-2.6.27.c | 33 +++++++++++++++++++++++++++++++++ include/linux/compat-2.6.26.h | 8 -------- include/linux/compat-2.6.27.h | 8 ++++++++ 4 files changed, 41 insertions(+), 40 deletions(-) diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index 82134c21..b9bf9e76 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -89,37 +89,5 @@ int dev_set_name(struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL_GPL(dev_set_name); -/* - * Backport of debugfs_remove_recursive() without using the internals globals - * which are used by the kernel's version with: - * simple_release_fs(&debugfs_mount, &debugfs_mount_count); - */ -void debugfs_remove_recursive(struct dentry *dentry) -{ - struct dentry *last = NULL; - - /* Sanity checks */ - if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode) - return; - - while (dentry != last) { - struct dentry *child = dentry; - - /* Find a child without children */ - while (!list_empty(&child->d_subdirs)) - child = list_entry(child->d_subdirs.next, - struct dentry, - d_u.d_child); - - /* Bail out if we already tried to remove that entry */ - if (child == last) - return; - - last = child; - debugfs_remove(child); - } -} -EXPORT_SYMBOL_GPL(debugfs_remove_recursive); - #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index 4fef36ab..b78d4653 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -206,6 +206,39 @@ unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) EXPORT_SYMBOL_GPL(sdio_align_size); #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ +#ifdef CONFIG_DEBUG_FS +/* + * Backport of debugfs_remove_recursive() without using the internals globals + * which are used by the kernel's version with: + * simple_release_fs(&debugfs_mount, &debugfs_mount_count); + */ +void debugfs_remove_recursive(struct dentry *dentry) +{ + struct dentry *last = NULL; + + /* Sanity checks */ + if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode) + return; + + while (dentry != last) { + struct dentry *child = dentry; + + /* Find a child without children */ + while (!list_empty(&child->d_subdirs)) + child = list_entry(child->d_subdirs.next, + struct dentry, + d_u.d_child); + + /* Bail out if we already tried to remove that entry */ + if (child == last) + return; + + last = child; + debugfs_remove(child); + } +} +EXPORT_SYMBOL_GPL(debugfs_remove_recursive); +#endif /* CONFIG_DEBUG_FS */ #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 498fe44c..2bee30ec 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -11,20 +11,12 @@ #include #include #include -#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include #endif #include #include -#if defined(CONFIG_DEBUG_FS) -void debugfs_remove_recursive(struct dentry *dentry); -#else -static inline void debugfs_remove_recursive(struct dentry *dentry) -{ } -#endif - /* These jiffie helpers added as of 2.6.26 */ /* diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index e9de41ee..a690e2c4 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -5,6 +5,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) +#include #include #include #include @@ -212,6 +213,13 @@ static inline void dma_sync_single_range_for_device(struct device *dev, #endif /* arm */ +#if defined(CONFIG_DEBUG_FS) +void debugfs_remove_recursive(struct dentry *dentry); +#else +static inline void debugfs_remove_recursive(struct dentry *dentry) +{ } +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From e93c5ec72f81280e85250dfbb771e166f0193849 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 21 Feb 2010 15:32:18 +0100 Subject: compat: backport some more of the netdev debug printk Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 74 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 4229a22b..b5d19039 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -63,6 +63,80 @@ do { \ 0; \ }) #endif + +#if defined(VERBOSE_DEBUG) +#define netdev_vdbg netdev_dbg +#else + +#define netdev_vdbg(dev, format, args...) \ +({ \ + if (0) \ + netdev_printk(KERN_DEBUG, dev, format, ##args); \ + 0; \ +}) +#endif + +/* + * netdev_WARN() acts like dev_printk(), but with the key difference + * of using a WARN/WARN_ON to get the message out, including the + * file/line information and a backtrace. + */ +#define netdev_WARN(dev, format, args...) \ + WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args); + +/* netif printk helpers, similar to netdev_printk */ + +#define netif_printk(priv, type, level, dev, fmt, args...) \ +do { \ + if (netif_msg_##type(priv)) \ + netdev_printk(level, (dev), fmt, ##args); \ +} while (0) + +#define netif_emerg(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args) +#define netif_alert(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args) +#define netif_crit(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args) +#define netif_err(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_ERR, dev, fmt, ##args) +#define netif_warn(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args) +#define netif_notice(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args) +#define netif_info(priv, type, dev, fmt, args...) \ + netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args) + +#if defined(DEBUG) +#define netif_dbg(priv, type, dev, format, args...) \ + netif_printk(priv, type, KERN_DEBUG, dev, format, ##args) +#elif defined(CONFIG_DYNAMIC_DEBUG) +#define netif_dbg(priv, type, netdev, format, args...) \ +do { \ + if (netif_msg_##type(priv)) \ + dynamic_dev_dbg((netdev)->dev.parent, \ + "%s: " format, \ + netdev_name(netdev), ##args); \ +} while (0) +#else +#define netif_dbg(priv, type, dev, format, args...) \ +({ \ + if (0) \ + netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \ + 0; \ +}) +#endif + +#if defined(VERBOSE_DEBUG) +#define netif_vdbg netdev_dbg +#else +#define netif_vdbg(priv, type, dev, format, args...) \ +({ \ + if (0) \ + netif_printk(KERN_DEBUG, dev, format, ##args); \ + 0; \ +}) +#endif /* source: include/linux/netdevice.h */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ -- cgit v1.2.3 From 3db1495ad802808204b991bd4296bb4a3b71eb36 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 5 Mar 2010 15:58:25 -0500 Subject: compat: define KEY_RFKILL, which appeared in Linux 2.6.33 It is used in net/rfkill/input.c Signed-off-by: Pavel Roskin --- include/linux/compat-2.6.33.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 9559f21d..70e5f98f 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -49,6 +49,8 @@ static inline void compat_release_firmware(const struct firmware *fw) } #endif +#define KEY_RFKILL 247 /* Key that controls all radios */ + #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ -- cgit v1.2.3 From 2c567cf7ec8b3f4c774cb95e4815e843da4168ec Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 7 Mar 2010 11:20:40 +0100 Subject: compat: fix some build problems with kernel 2.6.24 Signed-off-by: Hauke Mehrtens --- compat/Makefile | 6 +++--- include/linux/compat-2.6.25.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index 9441ff9f..2005ff3a 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -12,12 +12,12 @@ compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o +compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o -compat-$(CONFIG_COMPAT_KERNEL_24) += \ - compat-2.6.24.o \ +compat-$(CONFIG_COMPAT_KERNEL_25) += \ + compat-2.6.25.o \ pm_qos_params.o -compat-$(CONFIG_COMPAT_KERNEL_25) += compat-2.6.25.o compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index f62a096f..8d329b33 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -27,7 +27,7 @@ * in a generic manner. */ #define DEFINE_PCI_DEVICE_TABLE(_table) \ - struct pci_device_id _table[] __devinitdata + const struct pci_device_id _table[] __devinitdata /* * Backport work for QoS dependencies (kernel/pm_qos_params.c) -- cgit v1.2.3 From ce1ce992988ba3ec6df8014a87b166134fdbafb0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 7 Mar 2010 11:20:41 +0100 Subject: compat: backport device_{lock,trylock,unlock} This fixes build of ar9170. CC: Gus Wirth Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index b5d19039..d189bee7 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -139,6 +139,22 @@ do { \ #endif /* source: include/linux/netdevice.h */ + +static inline void device_lock(struct device *dev) +{ + down(&dev->sem); +} + +static inline int device_trylock(struct device *dev) +{ + return down_trylock(&dev->sem); +} + +static inline void device_unlock(struct device *dev) +{ + up(&dev->sem); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 502ef4964e8cd19e7bd5089261811eec1bd6b18e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 11 Mar 2010 22:32:41 +0100 Subject: compat: update bitops.h Copy header from recent linux-next Signed-off-by: Hauke Mehrtens --- include/linux/bitops.h | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 8469d353..b62de8c5 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -18,16 +18,18 @@ */ #include -#define for_each_bit(bit, addr, size) \ +#define for_each_set_bit(bit, addr, size) \ for ((bit) = find_first_bit((addr), (size)); \ (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) +/* Temporary */ +#define for_each_bit(bit, addr, size) for_each_set_bit(bit, addr, size) static __inline__ int get_bitmask_order(unsigned int count) { int order; - + order = fls(count); return order; /* We could be slightly more clever with -1 here... */ } @@ -35,7 +37,7 @@ static __inline__ int get_bitmask_order(unsigned int count) static __inline__ int get_count_order(unsigned int count) { int order; - + order = fls(count) - 1; if (count & (count - 1)) order++; @@ -47,6 +49,31 @@ static inline unsigned long hweight_long(unsigned long w) return sizeof(w) == 4 ? hweight32(w) : hweight64(w); } +/* + * Clearly slow versions of the hweightN() functions, their benefit is + * of course compile time evaluation of constant arguments. + */ +#define HWEIGHT8(w) \ + ( BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + \ + (!!((w) & (1ULL << 0))) + \ + (!!((w) & (1ULL << 1))) + \ + (!!((w) & (1ULL << 2))) + \ + (!!((w) & (1ULL << 3))) + \ + (!!((w) & (1ULL << 4))) + \ + (!!((w) & (1ULL << 5))) + \ + (!!((w) & (1ULL << 6))) + \ + (!!((w) & (1ULL << 7))) ) + +#define HWEIGHT16(w) (HWEIGHT8(w) + HWEIGHT8((w) >> 8)) +#define HWEIGHT32(w) (HWEIGHT16(w) + HWEIGHT16((w) >> 16)) +#define HWEIGHT64(w) (HWEIGHT32(w) + HWEIGHT32((w) >> 32)) + +/* + * Type invariant version that simply casts things to the + * largest type. + */ +#define HWEIGHT(w) HWEIGHT64((u64)(w)) + /** * rol32 - rotate a 32-bit value left * @word: value to rotate -- cgit v1.2.3 From c2141ed115ab4fb82d9d082c10019e7239a21578 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 11 Mar 2010 22:32:43 +0100 Subject: compat: backport PCMCIA_DEVICE_PROD_ID3 Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index d189bee7..1cb3e06f 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -155,6 +155,13 @@ static inline void device_unlock(struct device *dev) up(&dev->sem); } +#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) +#define PCMCIA_DEVICE_PROD_ID3(v3, vh3) { \ + .match_flags = PCMCIA_DEV_ID_MATCH_PROD_ID3, \ + .prod_id = { NULL, NULL, (v3), NULL }, \ + .prod_id_hash = { 0, 0, (vh3), 0 }, } +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 44f4dc712df88e48b52e0c45e0e84df695b3731d Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 24 Mar 2010 17:23:37 -0400 Subject: compat: add compat-2.6.35.h and IW_HANDLER compat: add compat-2.6.35.h and IW_HANDLER Signed-off-by: Pavel Roskin --- include/linux/compat-2.6.35.h | 13 +++++++++++++ include/linux/compat-2.6.h | 1 + 2 files changed, 14 insertions(+) create mode 100644 include/linux/compat-2.6.35.h diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h new file mode 100644 index 00000000..7387c46f --- /dev/null +++ b/include/linux/compat-2.6.35.h @@ -0,0 +1,13 @@ +#ifndef LINUX_26_35_COMPAT_H +#define LINUX_26_35_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) + +#define IW_HANDLER(id, func) \ + [IW_IOCTL_IDX(id)] = func + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ + +#endif /* LINUX_26_35_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index ceca9970..6171cd9a 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -27,5 +27,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From fb3804188587b5a21fc9ce69b7333a4f857b0eac Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 24 Mar 2010 17:57:43 -0400 Subject: compat: add qdisc_all_tx_empty for Linux 2.6.26 and older --- include/linux/compat-2.6.27.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index a690e2c4..e27115bf 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -18,6 +18,8 @@ #include #include #include +#include +#include #define PCI_PM_CAP_PME_SHIFT 11 @@ -49,6 +51,12 @@ static inline void netif_tx_stop_all_queues(struct net_device *dev) netif_stop_queue(dev); } +/* Are all TX queues of the device empty? */ +static inline bool qdisc_all_tx_empty(const struct net_device *dev) +{ + return skb_queue_empty(&dev->qdisc->q); +} + bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); /* -- cgit v1.2.3 From 97da2ad6bfc2855bb6700f1c8ed000c332b9ce7d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 5 Apr 2010 23:02:38 +0200 Subject: compat: Backport clamp This is needed by the ath5k driver. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.26.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 2bee30ec..82511774 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -47,6 +47,24 @@ extern int dev_set_name(struct device *dev, const char *name, ...) __attribute__((format(printf, 2, 3))); +/** + * clamp - return a value clamped to a given range with strict typechecking + * @val: current value + * @min: minimum allowable value + * @max: maximum allowable value + * + * This macro does strict typechecking of min/max to make sure they are of the + * same type as val. See the unnecessary pointer comparisons. + */ +#define clamp(val, min, max) ({ \ + typeof(val) __val = (val); \ + typeof(min) __min = (min); \ + typeof(max) __max = (max); \ + (void) (&__val == &__min); \ + (void) (&__val == &__max); \ + __val = __val < __min ? __min: __val; \ + __val > __max ? __max: __val; }) + /** * clamp_t - return a value clamped to a given range using a given type * @type: the type of variable to use -- cgit v1.2.3 From 00a299b0330de98b98e93f1442b54ee98bb88f2a Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 6 Apr 2010 18:41:09 -0400 Subject: compat: add device_create() implementation for Linux 2.6.26 and older This should make 25-device_create.patch in compat-wireless unnecessary. Signed-off-by: Pavel Roskin --- include/linux/compat-2.6.27.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index e27115bf..d667222a 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -228,6 +228,14 @@ static inline void debugfs_remove_recursive(struct dentry *dentry) { } #endif +#define device_create(cls, parent, devt, drvdata, fmt, ...) \ +({ \ + struct device *_dev; \ + _dev = (device_create)(cls, parent, devt, fmt, __VA_ARGS__); \ + dev_set_drvdata(_dev, drvdata); \ + _dev; \ +}) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 2d4e4f2df516b020d91bc39e15551b9eddf45c62 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Tue, 6 Apr 2010 18:41:15 -0400 Subject: compat: add stub headers linux/tracepoint.h and trace/define_trace.h This should make 13-trace.patch in compat-wireless unnecessary. Signed-off-by: Pavel Roskin --- include/linux/tracepoint.h | 8 ++++++++ include/trace/define_trace.h | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 include/linux/tracepoint.h create mode 100644 include/trace/define_trace.h diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h new file mode 100644 index 00000000..7484716f --- /dev/null +++ b/include/linux/tracepoint.h @@ -0,0 +1,8 @@ +#ifndef _COMPAT_LINUX_TRACEPOINT_H +#define _COMPAT_LINUX_TRACEPOINT_H 1 + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */ + +#endif /* _COMPAT_LINUX_TRACEPOINT_H */ diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h new file mode 100644 index 00000000..f5c01de4 --- /dev/null +++ b/include/trace/define_trace.h @@ -0,0 +1,8 @@ +#ifndef _COMPAT_TRACE_DEFINE_TRACE_H +#define _COMPAT_TRACE_DEFINE_TRACE_H 1 + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) */ + +#endif /* _COMPAT_TRACE_DEFINE_TRACE_H */ -- cgit v1.2.3 From b797c6841708d033a2937a61515e4abe39614301 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 7 Apr 2010 01:26:52 -0400 Subject: compat: add net/net_namespace.h stub for Linux 2.6.23 and older This obviates a good part of 06-header-changes.patch in compat-wireless. Signed-off-by: Pavel Roskin --- include/net/net_namespace.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 include/net/net_namespace.h diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h new file mode 100644 index 00000000..206c0c15 --- /dev/null +++ b/include/net/net_namespace.h @@ -0,0 +1,8 @@ +#ifndef _COMPAT_NET_NET_NAMESPACE_H +#define _COMPAT_NET_NET_NAMESPACE_H 1 + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) */ + +#endif /* _COMPAT_NET_NET_NAMESPACE_H */ -- cgit v1.2.3 From ee8938922962ea5a162351dffb4c588490f807bc Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 9 Apr 2010 19:50:22 +0200 Subject: compat: add rcu_dereference_check Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.34.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 1cb3e06f..736a2f08 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -162,6 +162,8 @@ static inline void device_unlock(struct device *dev) .prod_id_hash = { 0, 0, (vh3), 0 }, } #endif +#define rcu_dereference_check(p, c) rcu_dereference(p) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 26c30be706748b6beea1a062354fcc86c71b9611 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 18 Apr 2010 15:37:56 +0200 Subject: compat: Add definitions needed for libertas sdio driver. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 7387c46f..964e8dc6 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -8,6 +8,9 @@ #define IW_HANDLER(id, func) \ [IW_IOCTL_IDX(id)] = func +#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */ +#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From bb189141906cb3ed0d5bf240616c27b3dd67369c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 18 Apr 2010 15:37:57 +0200 Subject: compat: Add linux/version.h include before using it. This causes problems if theses header files are used without including linux/compat-2.6.h Signed-off-by: Hauke Mehrtens --- include/linux/tracepoint.h | 2 ++ include/net/net_namespace.h | 2 ++ include/trace/define_trace.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 7484716f..9f5add1c 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -1,6 +1,8 @@ #ifndef _COMPAT_LINUX_TRACEPOINT_H #define _COMPAT_LINUX_TRACEPOINT_H 1 +#include + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) #include_next #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */ diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 206c0c15..0f74944b 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h @@ -1,6 +1,8 @@ #ifndef _COMPAT_NET_NET_NAMESPACE_H #define _COMPAT_NET_NET_NAMESPACE_H 1 +#include + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) #include_next #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)) */ diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index f5c01de4..a31105a4 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h @@ -1,6 +1,8 @@ #ifndef _COMPAT_TRACE_DEFINE_TRACE_H #define _COMPAT_TRACE_DEFINE_TRACE_H 1 +#include + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) #include_next #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) */ -- cgit v1.2.3 From 11e5145f98cab97af2af2f4552dbce96751796b0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 19 Apr 2010 22:06:55 +0200 Subject: compat: backport convert multicast list to list_head. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 964e8dc6..4d3483a3 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -4,6 +4,7 @@ #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) +#include #define IW_HANDLER(id, func) \ [IW_IOCTL_IDX(id)] = func @@ -11,6 +12,8 @@ #define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */ +#define netdev_hw_addr dev_mc_list + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 524449c0184d44773d4947db8cd3bfd98a0a215f Mon Sep 17 00:00:00 2001 From: Grazvydas Ignotas Date: Thu, 22 Apr 2010 16:54:02 +0300 Subject: compat: fix uevent_suppress on 2.6.29 or older kernels Missing uevent_suppress is causing two uevents instead of one, which is confusing udev and sometimes causing firmware load to fail due to race condition, so let's add it. Signed-off-by: Grazvydas Ignotas --- compat/compat_firmware_class.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index ce937a35..54ee8b91 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -432,6 +432,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, dev_set_drvdata(f_dev, fw_priv); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) dev_set_uevent_suppress(f_dev, 1); +#else + f_dev->uevent_suppress = 1; #endif retval = device_register(f_dev); if (retval) { @@ -479,9 +481,11 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, goto error_unreg; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) if (uevent) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) dev_set_uevent_suppress(f_dev, 0); +#else + f_dev->uevent_suppress = 0; #endif *dev_p = f_dev; goto out; -- cgit v1.2.3 From 8eca4cf0648fad100bd44a0779328f13e6b7d4ca Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Apr 2010 23:28:11 +0200 Subject: compat: update compat_firmware_class.c to new version Signed-off-by: Hauke Mehrtens --- compat/compat_firmware_class.c | 191 +++++++++++++++++++++-------------------- include/linux/compat-2.6.30.h | 7 ++ include/linux/compat-2.6.34.h | 33 +++++++ 3 files changed, 140 insertions(+), 91 deletions(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 54ee8b91..02f38a25 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -19,6 +19,7 @@ #include #include #include +#include #define to_dev(obj) container_of(obj, struct device, kobj) @@ -26,6 +27,53 @@ MODULE_AUTHOR("Manuel Estrada Sainz"); MODULE_DESCRIPTION("Multi purpose firmware loading support"); MODULE_LICENSE("GPL"); +/* Builtin firmware support */ + +//#ifdef CONFIG_FW_LOADER +#if 0 + +extern struct builtin_fw __start_builtin_fw[]; +extern struct builtin_fw __end_builtin_fw[]; + +static bool fw_get_builtin_firmware(struct firmware *fw, const char *name) +{ + struct builtin_fw *b_fw; + + for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { + if (strcmp(name, b_fw->name) == 0) { + fw->size = b_fw->size; + fw->data = b_fw->data; + return true; + } + } + + return false; +} + +static bool fw_is_builtin_firmware(const struct firmware *fw) +{ + struct builtin_fw *b_fw; + + for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) + if (fw->data == b_fw->data) + return true; + + return false; +} + +#else /* Module case - no builtin firmware support */ + +static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name) +{ + return false; +} + +static inline bool fw_is_builtin_firmware(const struct firmware *fw) +{ + return false; +} +#endif + enum { FW_STATUS_LOADING, FW_STATUS_DONE, @@ -39,7 +87,6 @@ static int loading_timeout = 60; /* In seconds */ static DEFINE_MUTEX(fw_lock); struct firmware_priv { - char *fw_id; struct completion completion; struct bin_attribute attr_data; struct firmware *fw; @@ -47,19 +94,11 @@ struct firmware_priv { struct page **pages; int nr_pages; int page_array_size; - const char *vdata; struct timer_list timeout; + bool nowait; + char fw_id[]; }; -//#ifdef CONFIG_FW_LOADER -#if 0 -extern struct builtin_fw __start_builtin_fw[]; -extern struct builtin_fw __end_builtin_fw[]; -#else /* Module case. Avoid ifdefs later; it'll all optimise out */ -static struct builtin_fw *__start_builtin_fw; -static struct builtin_fw *__end_builtin_fw; -#endif - static void fw_load_abort(struct firmware_priv *fw_priv) { @@ -95,9 +134,25 @@ firmware_timeout_store(struct class *class, const char *buf, size_t count) return count; } -static CLASS_ATTR(timeout, 0644, firmware_timeout_show, firmware_timeout_store); +static struct class_attribute firmware_class_attrs[] = { + __ATTR(timeout, S_IWUSR | S_IRUGO, + firmware_timeout_show, firmware_timeout_store), + __ATTR_NULL +}; + +static void fw_dev_release(struct device *dev) +{ + struct firmware_priv *fw_priv = dev_get_drvdata(dev); + int i; + + for (i = 0; i < fw_priv->nr_pages; i++) + __free_page(fw_priv->pages[i]); + kfree(fw_priv->pages); + kfree(fw_priv); + kfree(dev); -static void fw_dev_release(struct device *dev); + module_put(THIS_MODULE); +} #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) @@ -108,6 +163,8 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) return -ENOMEM; if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) return -ENOMEM; + if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait)) + return -ENOMEM; return 0; } @@ -129,6 +186,11 @@ static int firmware_uevent(struct device *dev, char **envp, "TIMEOUT=%i", loading_timeout); if (error) goto exit; + error = add_uevent_var(envp, num_envp, &i, + buf, size, &len, + "ASYNC=%i", fw_priv->nowait); + if (error) + goto exit; return 0; exit: @@ -139,6 +201,7 @@ exit: static struct class firmware_class = { .name = "compat_firmware", + .class_attrs = firmware_class_attrs, .dev_uevent = firmware_uevent, .dev_release = fw_dev_release, }; @@ -374,21 +437,6 @@ static struct bin_attribute firmware_attr_data_tmpl = { .write = firmware_data_write, }; -static void fw_dev_release(struct device *dev) -{ - struct firmware_priv *fw_priv = dev_get_drvdata(dev); - int i; - - for (i = 0; i < fw_priv->nr_pages; i++) - __free_page(fw_priv->pages[i]); - kfree(fw_priv->pages); - kfree(fw_priv->fw_id); - kfree(fw_priv); - kfree(dev); - - module_put(THIS_MODULE); -} - static void firmware_class_timeout(u_long data) { @@ -400,8 +448,8 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, struct device *device) { int retval; - struct firmware_priv *fw_priv = kzalloc(sizeof(*fw_priv), - GFP_KERNEL); + struct firmware_priv *fw_priv = + kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); *dev_p = NULL; @@ -412,16 +460,9 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, goto error_kfree; } + strcpy(fw_priv->fw_id, fw_name); init_completion(&fw_priv->completion); fw_priv->attr_data = firmware_attr_data_tmpl; - fw_priv->fw_id = kstrdup(fw_name, GFP_KERNEL); - if (!fw_priv->fw_id) { - dev_err(device, "%s: Firmware name allocation failed\n", - __func__); - retval = -ENOMEM; - goto error_kfree; - } - fw_priv->timeout.function = firmware_class_timeout; fw_priv->timeout.data = (u_long) fw_priv; init_timer(&fw_priv->timeout); @@ -430,11 +471,7 @@ static int fw_register_device(struct device **dev_p, const char *fw_name, f_dev->parent = device; f_dev->class = &firmware_class; dev_set_drvdata(f_dev, fw_priv); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) dev_set_uevent_suppress(f_dev, 1); -#else - f_dev->uevent_suppress = 1; -#endif retval = device_register(f_dev); if (retval) { dev_err(device, "%s: device_register failed\n", __func__); @@ -452,7 +489,7 @@ error_kfree: static int fw_setup_device(struct firmware *fw, struct device **dev_p, const char *fw_name, struct device *device, - int uevent) + int uevent, bool nowait) { struct device *f_dev; struct firmware_priv *fw_priv; @@ -468,7 +505,10 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, fw_priv = dev_get_drvdata(f_dev); + fw_priv->nowait = nowait; + fw_priv->fw = fw; + sysfs_bin_attr_init(&fw_priv->attr_data); retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); if (retval) { dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); @@ -482,11 +522,7 @@ static int fw_setup_device(struct firmware *fw, struct device **dev_p, } if (uevent) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) dev_set_uevent_suppress(f_dev, 0); -#else - f_dev->uevent_suppress = 0; -#endif *dev_p = f_dev; goto out; @@ -498,12 +534,11 @@ out: static int _request_firmware(const struct firmware **firmware_p, const char *name, - struct device *device, int uevent) + struct device *device, int uevent, bool nowait) { struct device *f_dev; struct firmware_priv *fw_priv; struct firmware *firmware; - struct builtin_fw *builtin; int retval; if (!firmware_p) @@ -517,21 +552,16 @@ _request_firmware(const struct firmware **firmware_p, const char *name, goto out; } - for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; - builtin++) { - if (strcmp(name, builtin->name)) - continue; - dev_info(device, "firmware: using built-in firmware %s\n", - name); - firmware->size = builtin->size; - firmware->data = builtin->data; + if (fw_get_builtin_firmware(firmware, name)) { + dev_dbg(device, "firmware: using built-in firmware %s\n", name); return 0; } if (uevent) - dev_info(device, "firmware: requesting %s\n", name); + dev_dbg(device, "firmware: requesting %s\n", name); - retval = fw_setup_device(firmware, &f_dev, name, device, uevent); + retval = fw_setup_device(firmware, &f_dev, name, device, + uevent, nowait); if (retval) goto error_kfree_fw; @@ -588,26 +618,19 @@ request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) { int uevent = 1; - return _request_firmware(firmware_p, name, device, uevent); + return _request_firmware(firmware_p, name, device, uevent, false); } /** * release_firmware: - release the resource associated with a firmware image * @fw: firmware resource to release **/ -void -release_firmware(const struct firmware *fw) +void release_firmware(const struct firmware *fw) { - struct builtin_fw *builtin; - if (fw) { - for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; - builtin++) { - if (fw->data == builtin->data) - goto free_fw; - } - vfree(fw->data); - free_fw: + if (!fw_is_builtin_firmware(fw)) + vfree(fw->data); + kfree(fw); } } @@ -634,7 +657,7 @@ request_firmware_work_func(void *arg) return 0; } ret = _request_firmware(&fw, fw_work->name, fw_work->device, - fw_work->uevent); + fw_work->uevent, true); fw_work->cont(fw, fw_work->context); @@ -644,7 +667,7 @@ request_firmware_work_func(void *arg) } /** - * request_firmware_nowait: asynchronous version of request_firmware + * request_firmware_nowait - asynchronous version of request_firmware * @module: module requesting the firmware * @uevent: sends uevent to copy the firmware image if this flag * is non-zero else the firmware copy must be done manually. @@ -698,26 +721,12 @@ request_firmware_nowait( return 0; } -static int __init -firmware_class_init(void) +static int __init firmware_class_init(void) { - int error; - error = class_register(&firmware_class); - if (error) { - printk(KERN_ERR "%s: class_register failed\n", __func__); - return error; - } - error = class_create_file(&firmware_class, &class_attr_timeout); - if (error) { - printk(KERN_ERR "%s: class_create_file failed\n", - __func__); - class_unregister(&firmware_class); - } - return error; - + return class_register(&firmware_class); } -static void __exit -firmware_class_exit(void) + +static void __exit firmware_class_exit(void) { class_unregister(&firmware_class); } diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h index f997d862..eface8c2 100644 --- a/include/linux/compat-2.6.30.h +++ b/include/linux/compat-2.6.30.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) +#include + #ifndef TP_PROTO #define TP_PROTO(args...) TPPROTO(args) #endif @@ -23,6 +25,11 @@ enum dpm_order { DPM_ORDER_DEV_LAST, }; +static inline void dev_set_uevent_suppress(struct device *dev, int val) +{ + dev->uevent_suppress = val; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ #endif /* LINUX_26_30_COMPAT_H */ diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 736a2f08..18ae456c 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -164,6 +164,39 @@ static inline void device_unlock(struct device *dev) #define rcu_dereference_check(p, c) rcu_dereference(p) +/** + * sysfs_attr_init - initialize a dynamically allocated sysfs attribute + * @attr: struct attribute to initialize + * + * Initialize a dynamically allocated struct attribute so we can + * make lockdep happy. This is a new requirement for attributes + * and initially this is only needed when lockdep is enabled. + * Lockdep gives a nice error when your attribute is added to + * sysfs if you don't have this. + */ +#ifdef CONFIG_DEBUG_LOCK_ALLOC +#define sysfs_attr_init(attr) \ +do { \ + static struct lock_class_key __key; \ + \ + (attr)->key = &__key; \ +} while(0) +#else +#define sysfs_attr_init(attr) do {} while(0) +#endif + +/** + * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute + * @attr: struct bin_attribute to initialize + * + * Initialize a dynamically allocated struct bin_attribute so we + * can make lockdep happy. This is a new requirement for + * attributes and initially this is only needed when lockdep is + * enabled. Lockdep gives a nice error when your attribute is + * added to sysfs if you don't have this. + */ +#define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 089108ddebe7f12e8115e622bd4f7c1792067130 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Apr 2010 23:28:12 +0200 Subject: compat: backport sk_sleep Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 4d3483a3..9132ecbc 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -5,6 +5,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) #include +#include #define IW_HANDLER(id, func) \ [IW_IOCTL_IDX(id)] = func @@ -14,6 +15,11 @@ #define netdev_hw_addr dev_mc_list +static inline wait_queue_head_t *sk_sleep(struct sock *sk) +{ + return sk->sk_sleep; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 2ce27fe6b3a6a5060853fd3239fccf0bbe6d94be Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 3 May 2010 21:36:41 +0200 Subject: compat: backport usb_alloc_coherent() and usb_free_coherent() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 9132ecbc..9c6e6964 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -20,6 +20,9 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) return sk->sk_sleep; } +#define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) +#define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 7349fb77e7b24102f4539a8022e9fd75147b5012 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 May 2010 16:43:05 -0700 Subject: compat: add new way to backport the usage of net_device_ops We tend to #ifdef code that uses the new net_device_ops on kernels older than 2.6.29. This tends to create a burden on the upkeeping of the hunks. We can minimize our work by instead definining a new netdev_attach_ops() which will do our backport work for the older kernels and simply attach the ops for newer kernels. This should simplify backporting of network drivers considerably. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.29.c | 22 ++++- include/linux/compat-2.6.29.h | 195 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 215 insertions(+), 2 deletions(-) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index c8e0183f..c2a5f531 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Luis R. Rodriguez + * Copyright 2007-2010 Luis R. Rodriguez * * 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 @@ -15,6 +15,26 @@ #include #include +/* + * Expand this as drivers require more ops, for now this + * only sets the ones we need. + */ +void netdev_attach_ops(struct net_device *dev, + const struct net_device_ops *ops) +{ +#define SET_NETDEVOP(_op) (_op ? _op : NULL) + dev->open = SET_NETDEVOP(ops->ndo_open); + dev->stop = SET_NETDEVOP(ops->ndo_stop); + dev->hard_start_xmit = SET_NETDEVOP(ops->ndo_start_xmit); + dev->set_multicast_list = SET_NETDEVOP(ops->ndo_set_multicast_list); + dev->change_mtu = SET_NETDEVOP(ops->ndo_change_mtu); + dev->set_mac_address = SET_NETDEVOP(ops->ndo_set_mac_address); + dev->tx_timeout = SET_NETDEVOP(ops->ndo_tx_timeout); + dev->get_stats = SET_NETDEVOP(ops->ndo_get_stats); +#undef SET_NETDEVOP +} +EXPORT_SYMBOL(netdev_attach_ops); + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) /** diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index c3572a20..165b78c3 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -2,13 +2,199 @@ #define LINUX_26_29_COMPAT_H #include +#include +#include + +/* + * I kow this looks odd.. but 2.6.32 added the netdev_tx_t + * and we backport that there so inlcude that header first + * as we need it for the netdev ops. + */ +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) -#include #include #include +/* + * Older kernels do not have struct net_device_ops but what we can + * do is just define the data structure and use a caller to let us + * set the data structure's routines onto the old netdev, essentially + * doing it the old way. This avoids huge deltas on our backports. + */ + +/* + * This structure defines the management hooks for network devices. + * The following hooks can be defined; unless noted otherwise, they are + * optional and can be filled with a null pointer. + * + * int (*ndo_init)(struct net_device *dev); + * This function is called once when network device is registered. + * The network device can use this to any late stage initializaton + * or semantic validattion. It can fail with an error code which will + * be propogated back to register_netdev + * + * void (*ndo_uninit)(struct net_device *dev); + * This function is called when device is unregistered or when registration + * fails. It is not called if init fails. + * + * int (*ndo_open)(struct net_device *dev); + * This function is called when network device transistions to the up + * state. + * + * int (*ndo_stop)(struct net_device *dev); + * This function is called when network device transistions to the down + * state. + * + * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb, + * struct net_device *dev); + * Called when a packet needs to be transmitted. + * Must return NETDEV_TX_OK , NETDEV_TX_BUSY. + * (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX) + * Required can not be NULL. + * + * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb); + * Called to decide which queue to when device supports multiple + * transmit queues. + * + * void (*ndo_change_rx_flags)(struct net_device *dev, int flags); + * This function is called to allow device receiver to make + * changes to configuration when multicast or promiscious is enabled. + * + * void (*ndo_set_rx_mode)(struct net_device *dev); + * This function is called device changes address list filtering. + * + * void (*ndo_set_multicast_list)(struct net_device *dev); + * This function is called when the multicast address list changes. + * + * int (*ndo_set_mac_address)(struct net_device *dev, void *addr); + * This function is called when the Media Access Control address + * needs to be changed. If this interface is not defined, the + * mac address can not be changed. + * + * int (*ndo_validate_addr)(struct net_device *dev); + * Test if Media Access Control address is valid for the device. + * + * int (*ndo_do_ioctl)(struct net_device *dev, struct ifreq *ifr, int cmd); + * Called when a user request an ioctl which can't be handled by + * the generic interface code. If not defined ioctl's return + * not supported error code. + * + * int (*ndo_set_config)(struct net_device *dev, struct ifmap *map); + * Used to set network devices bus interface parameters. This interface + * is retained for legacy reason, new devices should use the bus + * interface (PCI) for low level management. + * + * int (*ndo_change_mtu)(struct net_device *dev, int new_mtu); + * Called when a user wants to change the Maximum Transfer Unit + * of a device. If not defined, any request to change MTU will + * will return an error. + * + * void (*ndo_tx_timeout)(struct net_device *dev); + * Callback uses when the transmitter has not made any progress + * for dev->watchdog ticks. + * + * struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); + * Called when a user wants to get the network device usage + * statistics. If not defined, the counters in dev->stats will + * be used. + * + * void (*ndo_vlan_rx_register)(struct net_device *dev, struct vlan_group *grp); + * If device support VLAN receive accleration + * (ie. dev->features & NETIF_F_HW_VLAN_RX), then this function is called + * when vlan groups for the device changes. Note: grp is NULL + * if no vlan's groups are being used. + * + * void (*ndo_vlan_rx_add_vid)(struct net_device *dev, unsigned short vid); + * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) + * this function is called when a VLAN id is registered. + * + * void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, unsigned short vid); + * If device support VLAN filtering (dev->features & NETIF_F_HW_VLAN_FILTER) + * this function is called when a VLAN id is unregistered. + * + * void (*ndo_poll_controller)(struct net_device *dev); + * + * SR-IOV management functions. + * int (*ndo_set_vf_mac)(struct net_device *dev, int vf, u8* mac); + * int (*ndo_set_vf_vlan)(struct net_device *dev, int vf, u16 vlan, u8 qos); + * int (*ndo_set_vf_tx_rate)(struct net_device *dev, int vf, int rate); + * int (*ndo_get_vf_config)(struct net_device *dev, + * int vf, struct ifla_vf_info *ivf); + */ +#define HAVE_NET_DEVICE_OPS +struct net_device_ops { + int (*ndo_init)(struct net_device *dev); + void (*ndo_uninit)(struct net_device *dev); + int (*ndo_open)(struct net_device *dev); + int (*ndo_stop)(struct net_device *dev); + netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb, + struct net_device *dev); + u16 (*ndo_select_queue)(struct net_device *dev, + struct sk_buff *skb); + void (*ndo_change_rx_flags)(struct net_device *dev, + int flags); + void (*ndo_set_rx_mode)(struct net_device *dev); + void (*ndo_set_multicast_list)(struct net_device *dev); + int (*ndo_set_mac_address)(struct net_device *dev, + void *addr); + int (*ndo_validate_addr)(struct net_device *dev); + int (*ndo_do_ioctl)(struct net_device *dev, + struct ifreq *ifr, int cmd); + int (*ndo_set_config)(struct net_device *dev, + struct ifmap *map); + int (*ndo_change_mtu)(struct net_device *dev, + int new_mtu); + int (*ndo_neigh_setup)(struct net_device *dev, + struct neigh_parms *); + void (*ndo_tx_timeout) (struct net_device *dev); + + struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); + + void (*ndo_vlan_rx_register)(struct net_device *dev, + struct vlan_group *grp); + void (*ndo_vlan_rx_add_vid)(struct net_device *dev, + unsigned short vid); + void (*ndo_vlan_rx_kill_vid)(struct net_device *dev, + unsigned short vid); +#ifdef CONFIG_NET_POLL_CONTROLLER + void (*ndo_poll_controller)(struct net_device *dev); +#endif + int (*ndo_set_vf_mac)(struct net_device *dev, + int queue, u8 *mac); + int (*ndo_set_vf_vlan)(struct net_device *dev, + int queue, u16 vlan, u8 qos); + int (*ndo_set_vf_tx_rate)(struct net_device *dev, + int vf, int rate); +/* + * The struct ifla_vf_info was added via b280da8d54b8d82b52f368a8703b7ada6c1744d5 + * on the v2.6.34-rc1~233^2~338 release + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) + int (*ndo_get_vf_config)(struct net_device *dev, + int vf, + struct ifla_vf_info *ivf); +#endif +#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) + int (*ndo_fcoe_enable)(struct net_device *dev); + int (*ndo_fcoe_disable)(struct net_device *dev); + int (*ndo_fcoe_ddp_setup)(struct net_device *dev, + u16 xid, + struct scatterlist *sgl, + unsigned int sgc); + int (*ndo_fcoe_ddp_done)(struct net_device *dev, + u16 xid); +#define NETDEV_FCOE_WWNN 0 +#define NETDEV_FCOE_WWPN 1 + int (*ndo_fcoe_get_wwn)(struct net_device *dev, + u64 *wwn, int type); +#endif +}; + +void netdev_attach_ops(struct net_device *dev, + const struct net_device_ops *ops); + /** * skb_queue_is_first - check if skb is the first entry in the queue * @list: queue head @@ -61,6 +247,13 @@ extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); extern int eth_mac_addr(struct net_device *dev, void *p); +#else + +static inline void netdev_attach_ops(struct net_device *dev, + const struct net_device_ops *ops) +{ + dev->netdev_ops = ops; +} #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ #endif /* LINUX_26_29_COMPAT_H */ -- cgit v1.2.3 From b2cd24d139ed8d9694a88abd53c73bd3d28075be Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 May 2010 17:14:39 -0700 Subject: compat: add the rest of the missing netdev_attach_ops() If you don't see your net_device_ops implemented on netdev_attach_ops() then you are shit out of luck and you must do the nasty ifdef magic. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.29.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index c2a5f531..8b3da339 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -16,8 +16,10 @@ #include /* - * Expand this as drivers require more ops, for now this - * only sets the ones we need. + * If you don't see your net_device_ops implemented on + * netdev_attach_ops() then you are shit out of luck and + * you must do the nasty ifdef magic, unless you figure + * out a way to squeze your hacks into this routine :) */ void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops) @@ -26,11 +28,21 @@ void netdev_attach_ops(struct net_device *dev, dev->open = SET_NETDEVOP(ops->ndo_open); dev->stop = SET_NETDEVOP(ops->ndo_stop); dev->hard_start_xmit = SET_NETDEVOP(ops->ndo_start_xmit); + dev->change_rx_flags = SET_NETDEVOP(ops->ndo_change_rx_flags); dev->set_multicast_list = SET_NETDEVOP(ops->ndo_set_multicast_list); + dev->validate_addr = SET_NETDEVOP(ops->ndo_validate_addr); + dev->do_ioctl = SET_NETDEVOP(ops->ndo_do_ioctl); + dev->set_config = SET_NETDEVOP(ops->ndo_set_config); dev->change_mtu = SET_NETDEVOP(ops->ndo_change_mtu); dev->set_mac_address = SET_NETDEVOP(ops->ndo_set_mac_address); dev->tx_timeout = SET_NETDEVOP(ops->ndo_tx_timeout); dev->get_stats = SET_NETDEVOP(ops->ndo_get_stats); + dev->vlan_rx_register = SET_NETDEVOP(ops->ndo_vlan_rx_register); + dev->vlan_rx_add_vid = SET_NETDEVOP(ops->ndo_vlan_rx_add_vid); + dev->vlan_rx_kill_vid = SET_NETDEVOP(ops->ndo_vlan_rx_kill_vid); +#ifdef CONFIG_NET_POLL_CONTROLLER + dev->poll_controller = SET_NETDEVOP(ops->ndo_poll_controller); +#endif #undef SET_NETDEVOP } EXPORT_SYMBOL(netdev_attach_ops); -- cgit v1.2.3 From bdf8c7203c35118d5d7b00f173ae6963fb496f49 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 May 2010 17:32:16 -0700 Subject: compat: add the ndo_select_queue for netdev_attach_ops() Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.29.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 8b3da339..5ee1e44c 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -43,6 +43,11 @@ void netdev_attach_ops(struct net_device *dev, #ifdef CONFIG_NET_POLL_CONTROLLER dev->poll_controller = SET_NETDEVOP(ops->ndo_poll_controller); #endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) + dev->select_queue = SET_NETDEVOP(ops->ndo_select_queue); +#endif + #undef SET_NETDEVOP } EXPORT_SYMBOL(netdev_attach_ops); -- cgit v1.2.3 From 53308ab1a7960306867a660b86bcfc2a5c872b73 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 6 May 2010 00:27:37 +0200 Subject: compat: backport eth_change_mtu and eth_validate_addr Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.29.c | 26 ++++++++++++++++++++++++++ include/linux/compat-2.6.29.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 5ee1e44c..8c725ee7 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -98,6 +98,32 @@ int eth_mac_addr(struct net_device *dev, void *p) return 0; } EXPORT_SYMBOL(eth_mac_addr); + +/** + * eth_change_mtu - set new MTU size + * @dev: network device + * @new_mtu: new Maximum Transfer Unit + * + * Allow changing MTU size. Needs to be overridden for devices + * supporting jumbo frames. + */ +int eth_change_mtu(struct net_device *dev, int new_mtu) +{ + if (new_mtu < 68 || new_mtu > ETH_DATA_LEN) + return -EINVAL; + dev->mtu = new_mtu; + return 0; +} +EXPORT_SYMBOL(eth_change_mtu); + +int eth_validate_addr(struct net_device *dev) +{ + if (!is_valid_ether_addr(dev->dev_addr)) + return -EADDRNOTAVAIL; + + return 0; +} +EXPORT_SYMBOL(eth_validate_addr); /* Source: net/ethernet/eth.c */ diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 165b78c3..f063e240 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -246,6 +246,8 @@ extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); ) extern int eth_mac_addr(struct net_device *dev, void *p); +extern int eth_change_mtu(struct net_device *dev, int new_mtu); +extern int eth_validate_addr(struct net_device *dev); #else -- cgit v1.2.3 From dae72d4eafdc6977dc15410e558eda14fe7290d4 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 10 May 2010 23:22:48 +0200 Subject: compat: move kparam_{block,unblock}_sysfs_write kparam_block_sysfs_write and kparam_unblock_sysfs_write will introduced in kernel 2.6.35 and not 2.6.33. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 3 --- include/linux/compat-2.6.35.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 70e5f98f..0b434fcf 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -54,9 +54,6 @@ static inline void compat_release_firmware(const struct firmware *fw) #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ -#define kparam_block_sysfs_write(a) -#define kparam_unblock_sysfs_write(a) - /* this will never happen on older kernels */ #define NETDEV_POST_INIT 0xffff diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 9c6e6964..278af5e3 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -23,6 +23,9 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) #define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) #define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) +#define kparam_block_sysfs_write(a) +#define kparam_unblock_sysfs_write(a) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 9fc43ef5dc218a82b0690198c01fd2084abc5a60 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 10 May 2010 23:22:49 +0200 Subject: compat: move usb_{alloc,free}_coherent usb_alloc_coherent and usb_free_coherent were introduced in kernel 2.6.34. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 3 +++ include/linux/compat-2.6.35.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 18ae456c..2870a3b8 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -197,6 +197,9 @@ do { \ */ #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) +#define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) +#define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 278af5e3..b850f8a7 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -20,9 +20,6 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) return sk->sk_sleep; } -#define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) -#define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) - #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) -- cgit v1.2.3 From 681b57755b37a544615caa4f23443a623be68e25 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 17 May 2010 11:55:06 -0700 Subject: compat: add compat_version read-only module parameter This will allow you to supply a version tag for the backport you use. Compat-wireless will re-use this and give it its own value based on the kernel we backport from. It will use either the linux-next git describe or the stable kernel git describe. Any delta on top of the git tree should also be reflected then in case of custom private trees/releases. Signed-off-by: Luis R. Rodriguez --- Makefile | 9 ++++++++- compat/main.c | 9 +++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3692f966..0f583bb4 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,10 @@ export KLIB_BUILD ?= $(KLIB)/build export PWD := $(shell pwd) +ifeq ($(KERNELRELEASE),) +export COMPAT_VERSION := $(shell git describe) +endif + # This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for # each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) @@ -29,7 +33,10 @@ obj-y += compat/ # This hack lets us put our include path first than the kernel's # when building our compat modules. Your own makefile would look # the same. -NOSTDINC_FLAGS := -I$(M)/include/ -include $(M)/include/linux/compat-2.6.h $(CFLAGS) +NOSTDINC_FLAGS := -I$(M)/include/ \ + -include $(M)/include/linux/compat-2.6.h \ + $(CFLAGS) \ + -DCOMPAT_VERSION=\"$(COMPAT_VERSION)\" modules: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules diff --git a/compat/main.c b/compat/main.c index d7f713da..35a5ae8d 100644 --- a/compat/main.c +++ b/compat/main.c @@ -4,6 +4,15 @@ MODULE_AUTHOR("Luis R. Rodriguez"); MODULE_DESCRIPTION("Kernel compatibility module"); MODULE_LICENSE("GPL"); +#ifndef COMPAT_VERSION +#error "You need a COMPAT_VERSION" +#endif + +static char *compat_version = COMPAT_VERSION; + +module_param(compat_version, charp, 0400); +MODULE_PARM_DESC(compat_version, "Version of the kernel compat backport"); + static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ -- cgit v1.2.3 From 0ca6e663d2bc18d8395bf7fc689c00d785da85a0 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 17 May 2010 12:04:06 -0700 Subject: Modify the compat print This uses the COMPAT_VERSION on the print Signed-off-by: Luis R. Rodriguez --- compat/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compat/main.c b/compat/main.c index 35a5ae8d..1a4ad6dd 100644 --- a/compat/main.c +++ b/compat/main.c @@ -17,8 +17,10 @@ static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); + printk(KERN_INFO "Generic kernel compatibility enabled based on " - "linux-next next-20100113\n"); + COMPAT_VERSION + "\n"); return 0; } -- cgit v1.2.3 From 4d9829dea12c504d6c0c53efed5830d6f75b3f27 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 17 May 2010 14:18:39 -0700 Subject: Add the COMPAT_BASE_TREE and COMPAT_BASE_TREE_VERSION These are to be used by projects using this tree for their own backport projects. Signed-off-by: Luis R. Rodriguez --- Makefile | 9 +++++++++ compat/main.c | 26 ++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 0f583bb4..838bf828 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,13 @@ export KLIB_BUILD ?= $(KLIB)/build export PWD := $(shell pwd) ifeq ($(KERNELRELEASE),) +export COMPAT_BASE_TREE := "linux-next.git" +# For this specific tree this is only relevant in +# terms of the last time we synched code up with upstream +# for internal stuff. For other compatability projects this +# would be the git describe of the base tree you are +# working with. +export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) endif @@ -36,6 +43,8 @@ obj-y += compat/ NOSTDINC_FLAGS := -I$(M)/include/ \ -include $(M)/include/linux/compat-2.6.h \ $(CFLAGS) \ + -DCOMPAT_BASE_TREE=\"$(COMPAT_BASE_TREE)\" \ + -DCOMPAT_BASE_TREE_VERSION=\"$(COMPAT_BASE_TREE_VERSION)\" \ -DCOMPAT_VERSION=\"$(COMPAT_VERSION)\" modules: diff --git a/compat/main.c b/compat/main.c index 1a4ad6dd..ef18516b 100644 --- a/compat/main.c +++ b/compat/main.c @@ -4,23 +4,45 @@ MODULE_AUTHOR("Luis R. Rodriguez"); MODULE_DESCRIPTION("Kernel compatibility module"); MODULE_LICENSE("GPL"); +#ifndef COMPAT_BASE_TREE +#error "You need a COMPAT_BASE_TREE" +#endif + +#ifndef COMPAT_BASE_TREE_VERSION +#error "You need a COMPAT_BASE_TREE_VERSION" +#endif + #ifndef COMPAT_VERSION #error "You need a COMPAT_VERSION" #endif +static char *compat_base_tree = COMPAT_BASE_TREE; +static char *compat_base_tree_version = COMPAT_BASE_TREE_VERSION; static char *compat_version = COMPAT_VERSION; +module_param(compat_base_tree, charp, 0400); +MODULE_PARM_DESC(compat_base_tree, + "The upstream tree used as base for this backport"); + +module_param(compat_base_tree_version, charp, 0400); +MODULE_PARM_DESC(compat_base_tree_version, + "The git-describe of the upstream base tree"); + module_param(compat_version, charp, 0400); -MODULE_PARM_DESC(compat_version, "Version of the kernel compat backport"); +MODULE_PARM_DESC(compat_version, + "Version of the kernel compat backport work"); static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); - printk(KERN_INFO "Generic kernel compatibility enabled based on " + printk(KERN_INFO "Kernel backport release: " COMPAT_VERSION "\n"); + printk(KERN_INFO "Backport based on " + COMPAT_BASE_TREE " " COMPAT_BASE_TREE_VERSION + "\n"); return 0; } -- cgit v1.2.3 From fc5c8fc1c1360f3fe62d02d9bb5796fed81b2352 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 17 May 2010 14:36:43 -0700 Subject: Add a COMPAT_PROJECT tag This will be used to identify the backport project only during initialization, there is no associated module parameter for this as there is no need for it. Signed-off-by: Luis R. Rodriguez --- Makefile | 1 + compat/main.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 838bf828..46fda21a 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,7 @@ NOSTDINC_FLAGS := -I$(M)/include/ \ $(CFLAGS) \ -DCOMPAT_BASE_TREE=\"$(COMPAT_BASE_TREE)\" \ -DCOMPAT_BASE_TREE_VERSION=\"$(COMPAT_BASE_TREE_VERSION)\" \ + -DCOMPAT_PROJECT="\"Generic kernel\"" \ -DCOMPAT_VERSION=\"$(COMPAT_VERSION)\" modules: diff --git a/compat/main.c b/compat/main.c index ef18516b..a1a48d01 100644 --- a/compat/main.c +++ b/compat/main.c @@ -37,7 +37,8 @@ static int __init compat_init(void) /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); - printk(KERN_INFO "Kernel backport release: " + printk(KERN_INFO + COMPAT_PROJECT " backport release: " COMPAT_VERSION "\n"); printk(KERN_INFO "Backport based on " -- cgit v1.2.3 From bd4fbdf07da8a1ff9c89e18221ffdafcd2ad9a69 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 17 May 2010 14:39:57 -0700 Subject: Fix the syntax for the defines passed for compat Spaces would not have worked without this. Signed-off-by: Luis R. Rodriguez --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 46fda21a..04877c54 100644 --- a/Makefile +++ b/Makefile @@ -43,10 +43,10 @@ obj-y += compat/ NOSTDINC_FLAGS := -I$(M)/include/ \ -include $(M)/include/linux/compat-2.6.h \ $(CFLAGS) \ - -DCOMPAT_BASE_TREE=\"$(COMPAT_BASE_TREE)\" \ - -DCOMPAT_BASE_TREE_VERSION=\"$(COMPAT_BASE_TREE_VERSION)\" \ + -DCOMPAT_BASE_TREE="\"$(COMPAT_BASE_TREE)\"" \ + -DCOMPAT_BASE_TREE_VERSION="\"$(COMPAT_BASE_TREE_VERSION)\"" \ -DCOMPAT_PROJECT="\"Generic kernel\"" \ - -DCOMPAT_VERSION=\"$(COMPAT_VERSION)\" + -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" modules: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules -- cgit v1.2.3 From 6a30ed4ed0aa74aef894ac88945f41fb34e4019d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 19 May 2010 15:31:51 -0700 Subject: Remove the stupid SET_NETDEVOP Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.29.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 8c725ee7..f94aed86 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -24,31 +24,28 @@ void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops) { -#define SET_NETDEVOP(_op) (_op ? _op : NULL) - dev->open = SET_NETDEVOP(ops->ndo_open); - dev->stop = SET_NETDEVOP(ops->ndo_stop); - dev->hard_start_xmit = SET_NETDEVOP(ops->ndo_start_xmit); - dev->change_rx_flags = SET_NETDEVOP(ops->ndo_change_rx_flags); - dev->set_multicast_list = SET_NETDEVOP(ops->ndo_set_multicast_list); - dev->validate_addr = SET_NETDEVOP(ops->ndo_validate_addr); - dev->do_ioctl = SET_NETDEVOP(ops->ndo_do_ioctl); - dev->set_config = SET_NETDEVOP(ops->ndo_set_config); - dev->change_mtu = SET_NETDEVOP(ops->ndo_change_mtu); - dev->set_mac_address = SET_NETDEVOP(ops->ndo_set_mac_address); - dev->tx_timeout = SET_NETDEVOP(ops->ndo_tx_timeout); - dev->get_stats = SET_NETDEVOP(ops->ndo_get_stats); - dev->vlan_rx_register = SET_NETDEVOP(ops->ndo_vlan_rx_register); - dev->vlan_rx_add_vid = SET_NETDEVOP(ops->ndo_vlan_rx_add_vid); - dev->vlan_rx_kill_vid = SET_NETDEVOP(ops->ndo_vlan_rx_kill_vid); + dev->open = ops->ndo_open; + dev->stop = ops->ndo_stop; + dev->hard_start_xmit = ops->ndo_start_xmit; + dev->change_rx_flags = ops->ndo_change_rx_flags; + dev->set_multicast_list = ops->ndo_set_multicast_list; + dev->validate_addr = ops->ndo_validate_addr; + dev->do_ioctl = ops->ndo_do_ioctl; + dev->set_config = ops->ndo_set_config; + dev->change_mtu = ops->ndo_change_mtu; + dev->set_mac_address = ops->ndo_set_mac_address; + dev->tx_timeout = ops->ndo_tx_timeout; + dev->get_stats = ops->ndo_get_stats; + dev->vlan_rx_register = ops->ndo_vlan_rx_register; + dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; + dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; #ifdef CONFIG_NET_POLL_CONTROLLER - dev->poll_controller = SET_NETDEVOP(ops->ndo_poll_controller); + dev->poll_controller = ops->ndo_poll_controller; #endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) - dev->select_queue = SET_NETDEVOP(ops->ndo_select_queue); + dev->select_queue = ops->ndo_select_queue; #endif - -#undef SET_NETDEVOP } EXPORT_SYMBOL(netdev_attach_ops); -- cgit v1.2.3 From 53956913c2f7e09fb5739158946c85dcd3f26a31 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 24 May 2010 09:52:22 -0700 Subject: compat: create the udev directories for compat_firmware file In case the directories are non existant create them. Reported-by: Jaroslav Fojtik Signed-off-by: Luis R. Rodriguez --- scripts/compat_firmware_install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/compat_firmware_install b/scripts/compat_firmware_install index d92961a6..33e4fde8 100755 --- a/scripts/compat_firmware_install +++ b/scripts/compat_firmware_install @@ -8,10 +8,12 @@ fi case $LSB_RED_ID in "Ubuntu") + mkdir -p /lib/udev/ /lib/udev/rules.d/ cp udev/ubuntu/compat_firmware.sh /lib/udev/ cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/ ;; *) + mkdir -p /lib/udev/ /lib/udev/rules.d/ cp udev/compat_firmware.sh /lib/udev/ cp udev/50-compat_firmware.rules /lib/udev/rules.d/ ;; -- cgit v1.2.3 From bcc837c4243e8de6598b8de0ea0be41eb69d0430 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 26 May 2010 20:01:52 -0700 Subject: compat: backport USHRT_MAX, SHRT_MAX and SHRT_MIN This backports this patch: Author: Alexey Dobriyan Date: Mon May 24 14:33:03 2010 -0700 kernel-wide: replace USHORT_MAX, SHORT_MAX and SHORT_MIN with USHRT_MAX, SHRT_MAX and SHRT_MIN - C99 knows about USHRT_MAX/SHRT_MAX/SHRT_MIN, not USHORT_MAX/SHORT_MAX/SHORT_MIN. - Make SHRT_MIN of type s16, not int, for consistency. [akpm@linux-foundation.org: fix drivers/dma/timb_dma.c] [akpm@linux-foundation.org: fix security/keys/keyring.c] Signed-off-by: Alexey Dobriyan Acked-by: WANG Cong Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.35.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index b850f8a7..7091f7cc 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -6,6 +6,12 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) #include #include +#include + +/* added on linux/kernel.h */ +#define USHRT_MAX ((u16)(~0U)) +#define SHRT_MAX ((s16)(USHRT_MAX>>1)) +#define SHRT_MIN ((s16)(-SHRT_MAX - 1)) #define IW_HANDLER(id, func) \ [IW_IOCTL_IDX(id)] = func -- cgit v1.2.3 From f4cb13ab60d343059725e2bed95116b036cdd4fc Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Jun 2010 11:12:24 +0200 Subject: compat: update bitops.h and wireless.h copy files from linux-next next-20100604 Signed-off-by: Hauke Mehrtens --- include/linux/bitops.h | 33 +++++---------------------------- include/linux/compat-2.6.35.h | 3 --- include/linux/wireless.h | 4 +++- 3 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index b62de8c5..679369be 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -12,6 +12,11 @@ #endif #endif +extern unsigned int __sw_hweight8(unsigned int w); +extern unsigned int __sw_hweight16(unsigned int w); +extern unsigned int __sw_hweight32(unsigned int w); +extern unsigned long __sw_hweight64(__u64 w); + /* * Include this here because some architectures need generic_ffs/fls in * scope @@ -23,9 +28,6 @@ (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) -/* Temporary */ -#define for_each_bit(bit, addr, size) for_each_set_bit(bit, addr, size) - static __inline__ int get_bitmask_order(unsigned int count) { int order; @@ -49,31 +51,6 @@ static inline unsigned long hweight_long(unsigned long w) return sizeof(w) == 4 ? hweight32(w) : hweight64(w); } -/* - * Clearly slow versions of the hweightN() functions, their benefit is - * of course compile time evaluation of constant arguments. - */ -#define HWEIGHT8(w) \ - ( BUILD_BUG_ON_ZERO(!__builtin_constant_p(w)) + \ - (!!((w) & (1ULL << 0))) + \ - (!!((w) & (1ULL << 1))) + \ - (!!((w) & (1ULL << 2))) + \ - (!!((w) & (1ULL << 3))) + \ - (!!((w) & (1ULL << 4))) + \ - (!!((w) & (1ULL << 5))) + \ - (!!((w) & (1ULL << 6))) + \ - (!!((w) & (1ULL << 7))) ) - -#define HWEIGHT16(w) (HWEIGHT8(w) + HWEIGHT8((w) >> 8)) -#define HWEIGHT32(w) (HWEIGHT16(w) + HWEIGHT16((w) >> 16)) -#define HWEIGHT64(w) (HWEIGHT32(w) + HWEIGHT32((w) >> 32)) - -/* - * Type invariant version that simply casts things to the - * largest type. - */ -#define HWEIGHT(w) HWEIGHT64((u64)(w)) - /** * rol32 - rotate a 32-bit value left * @word: value to rotate diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 7091f7cc..b38d6def 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -13,9 +13,6 @@ #define SHRT_MAX ((s16)(USHRT_MAX>>1)) #define SHRT_MIN ((s16)(-SHRT_MAX - 1)) -#define IW_HANDLER(id, func) \ - [IW_IOCTL_IDX(id)] = func - #define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */ #define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */ diff --git a/include/linux/wireless.h b/include/linux/wireless.h index 5b4c6c77..e6827eed 100644 --- a/include/linux/wireless.h +++ b/include/linux/wireless.h @@ -346,6 +346,8 @@ #define SIOCIWFIRST 0x8B00 #define SIOCIWLAST SIOCIWLASTPRIV /* 0x8BFF */ #define IW_IOCTL_IDX(cmd) ((cmd) - SIOCIWFIRST) +#define IW_HANDLER(id, func) \ + [IW_IOCTL_IDX(id)] = func /* Odd : get (world access), even : set (root access) */ #define IW_IS_SET(cmd) (!((cmd) & 0x1)) @@ -648,7 +650,7 @@ * 32 bit bitmasks. Note : 32 bits = 0x20 = 2^5. */ #define IW_EVENT_CAPA_BASE(cmd) ((cmd >= SIOCIWFIRSTPRIV) ? \ (cmd - SIOCIWFIRSTPRIV + 0x60) : \ - (cmd - SIOCSIWCOMMIT)) + (cmd - SIOCIWFIRST)) #define IW_EVENT_CAPA_INDEX(cmd) (IW_EVENT_CAPA_BASE(cmd) >> 5) #define IW_EVENT_CAPA_MASK(cmd) (1 << (IW_EVENT_CAPA_BASE(cmd) & 0x1F)) /* Event capability constants - event autogenerated by the kernel -- cgit v1.2.3 From 258303e08ec31bccd6f0f66a0421e6aa0f1b8815 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Jun 2010 11:12:25 +0200 Subject: compat: move kparam_{block,unblock}_sysfs_write kparam_block_sysfs_write and kparam_unblock_sysfs_write are not in kernel 2.6.35, move them to backport from kernel 2.6.36. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 3 --- include/linux/compat-2.6.36.h | 13 +++++++++++++ include/linux/compat-2.6.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 include/linux/compat-2.6.36.h diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index b38d6def..886815d5 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -23,9 +23,6 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) return sk->sk_sleep; } -#define kparam_block_sysfs_write(a) -#define kparam_unblock_sysfs_write(a) - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h new file mode 100644 index 00000000..03071080 --- /dev/null +++ b/include/linux/compat-2.6.36.h @@ -0,0 +1,13 @@ +#ifndef LINUX_26_36_COMPAT_H +#define LINUX_26_36_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) + +#define kparam_block_sysfs_write(a) +#define kparam_unblock_sysfs_write(a) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ + +#endif /* LINUX_26_36_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 6171cd9a..ef51195f 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -28,5 +28,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From ea08b39522c617d142c36cb37c0b2b4dbd652946 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Jun 2010 11:12:26 +0200 Subject: compat: backport small functions and defines Backport of some functions and defines needed by compat-wireless. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.29.h | 25 +++++++++++++++++++++++++ include/linux/compat-2.6.32.h | 2 ++ include/linux/compat-2.6.34.h | 16 ++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index f063e240..a1a989c4 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -249,6 +249,31 @@ extern int eth_mac_addr(struct net_device *dev, void *p); extern int eth_change_mtu(struct net_device *dev, int new_mtu); extern int eth_validate_addr(struct net_device *dev); +#ifdef CONFIG_NET_NS + +static inline void write_pnet(struct net **pnet, struct net *net) +{ + *pnet = net; +} + +static inline struct net *read_pnet(struct net * const *pnet) +{ + return *pnet; +} + +#else + +#define write_pnet(pnet, net) do { (void)(net);} while (0) +#define read_pnet(pnet) (&init_net) + +/* + * swap - swap value of @a and @b + */ +#define swap(a, b) \ + do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) + +#endif + #else static inline void netdev_attach_ops(struct net_device *dev, diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 2f5013f2..3a41bd60 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -92,6 +92,8 @@ struct dev_pm_ops name = { \ /* The export symbol in changed in compat/patches/15-symbol-export-conflicts.patch */ #define ieee80211_rx(hw, skb) mac80211_ieee80211_rx(hw, skb) +#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ #endif /* LINUX_26_32_COMPAT_H */ diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 2870a3b8..b1c15a71 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -200,6 +200,22 @@ do { \ #define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) #define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) +#ifdef CONFIG_NEED_DMA_MAP_STATE +#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME +#define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME +#define dma_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME) +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL)) +#define dma_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME) +#define dma_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL)) +#else +#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) +#define DEFINE_DMA_UNMAP_LEN(LEN_NAME) +#define dma_unmap_addr(PTR, ADDR_NAME) (0) +#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0) +#define dma_unmap_len(PTR, LEN_NAME) (0) +#define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 63b95138cb7b75c49139acc136892f18cd7ca779 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Jun 2010 11:12:27 +0200 Subject: compat: use kernel pm_qos_params.h Do not use pm_qos_params.h from compat-wireless if the kernel also ships this file. In kernel 2.6.35 pm_qos_params.h changed and the in kernel header file is needed. Signed-off-by: Hauke Mehrtens --- include/linux/pm_qos_params.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h index 091c13c7..e1f083c4 100644 --- a/include/linux/pm_qos_params.h +++ b/include/linux/pm_qos_params.h @@ -1,3 +1,8 @@ +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) +#include_next +#else /* interface for the pm_qos_power infrastructure of the linux kernel. * * Mark Gross @@ -23,4 +28,5 @@ int pm_qos_requirement(int qos); int pm_qos_add_notifier(int qos, struct notifier_block *notifier); int pm_qos_remove_notifier(int qos, struct notifier_block *notifier); +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */ -- cgit v1.2.3 From 1dbb46812477103bf30f415f0d6ff2d27da7924e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 13 Jun 2010 21:56:48 +0200 Subject: compat: backport dma_set_coherent_mask Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index b1c15a71..336c61b2 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -216,6 +216,14 @@ do { \ #define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) #endif +static inline int dma_set_coherent_mask(struct device *dev, u64 mask) +{ + if (!dma_supported(dev, mask)) + return -EIO; + dev->coherent_dma_mask = mask; + return 0; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 8eec28d8879cb15e9139e6c0cc90fc80af832db7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 13 Jun 2010 21:56:49 +0200 Subject: compat: backport sdio_writeb_readb This is needed by wl1251_sdio.c Use sdio_readb instead of sdio_writeb_readb as long as sdio_writeb_readb was not realy backported. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 886815d5..c6e7136c 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -23,6 +23,8 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) return sk->sk_sleep; } +#define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From b6af507a6e320b8aec2b8ef520bed4a455d26db4 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 15 Jun 2010 22:57:44 +0200 Subject: compat: backport lockdep_assert_held Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.32.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 3a41bd60..321a89ad 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -94,6 +94,8 @@ struct dev_pm_ops name = { \ #define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev) +#define lockdep_assert_held(l) do { } while (0) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ #endif /* LINUX_26_32_COMPAT_H */ -- cgit v1.2.3 From 126c387b239ace4ae5afa42884a91af41b491971 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 24 Jun 2010 22:59:23 +0200 Subject: compat: backport skb_queue_splice_init This is needed by iwmc3200wifi. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.28.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 2cab3201..71605488 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -146,6 +146,23 @@ static inline void skb_queue_splice(const struct sk_buff_head *list, } } +/** + * skb_queue_splice - join two skb lists and reinitialise the emptied list + * @list: the new list to add + * @head: the place to add it in the first list + * + * The list at @list is reinitialised + */ +static inline void skb_queue_splice_init(struct sk_buff_head *list, + struct sk_buff_head *head) +{ + if (!skb_queue_empty(list)) { + __skb_queue_splice(list, (struct sk_buff *) head, head->next); + head->qlen += list->qlen; + __skb_queue_head_init(list); + } +} + /** * skb_queue_splice_tail - join two skb lists and reinitialise the emptied list * @list: the new list to add -- cgit v1.2.3 From 776ba1d5eee6b217e3333740170c2339a1aea155 Mon Sep 17 00:00:00 2001 From: Rajkumar Manoharan Date: Tue, 29 Jun 2010 12:08:07 +0530 Subject: compat: Fix panic caused by NULL pointer derefence in rtnl_fill_ifinfo get stats netdev ops is blindy called for older kernels (< 2.6.29) and so assigning a NULL pointer from netdev_attach_ops causes a NULL pointer dereference. By default, netdev alloc provides an internal stats reference. So fill this only if ndo_get_stats is defined. Signed-off-by: Rajkumar Manoharan --- compat/compat-2.6.29.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index f94aed86..2e7e623b 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -35,7 +35,8 @@ void netdev_attach_ops(struct net_device *dev, dev->change_mtu = ops->ndo_change_mtu; dev->set_mac_address = ops->ndo_set_mac_address; dev->tx_timeout = ops->ndo_tx_timeout; - dev->get_stats = ops->ndo_get_stats; + if (ops->ndo_get_stats) + dev->get_stats = ops->ndo_get_stats; dev->vlan_rx_register = ops->ndo_vlan_rx_register; dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; -- cgit v1.2.3 From 7b8245ada847664fd3bda3c05949d60085ec94e0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 8 Jul 2010 23:11:58 +0200 Subject: compat: fix tracpoint building trace/define_trace.h can be included more often and it have to. This fixes some errors like this: WARNING: "__tracepoint_iwlwifi_dev_rx" [/home/hauke/compat-wireless/compat-wireless-git/drivers/net/wireless/iwlwifi/iwlcore.ko] undefined! Signed-off-by: Hauke Mehrtens --- include/trace/define_trace.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/trace/define_trace.h b/include/trace/define_trace.h index a31105a4..7d03ccf7 100644 --- a/include/trace/define_trace.h +++ b/include/trace/define_trace.h @@ -1,10 +1,5 @@ -#ifndef _COMPAT_TRACE_DEFINE_TRACE_H -#define _COMPAT_TRACE_DEFINE_TRACE_H 1 - #include #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) #include_next #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) */ - -#endif /* _COMPAT_TRACE_DEFINE_TRACE_H */ -- cgit v1.2.3 From 8444e0fd85383df3ead06cf4409413458628f45f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 18 Jul 2010 21:09:22 +0200 Subject: compat: fix build if CONFIG_PCCARD=y and CONFIG_PCMCIA=n The includes are needed for pccard_loop_tuple. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 0b434fcf..e4dff722 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -7,12 +7,10 @@ #include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) #include #include #include #endif -#endif #include #include -- cgit v1.2.3 From f1d0e0ba58c9057b4a9d8887effae2ff0f15731f Mon Sep 17 00:00:00 2001 From: Kshitij Kulshreshtha Date: Mon, 2 Aug 2010 00:02:49 +0200 Subject: compat: backport hex_to_bin first introduced in v2.6.35 Signed-off-by: Kshitij Kulshreshtha --- compat/Makefile | 1 + compat/compat-2.6.35.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.35.h | 2 ++ 3 files changed, 37 insertions(+) create mode 100644 compat/compat-2.6.35.c diff --git a/compat/Makefile b/compat/Makefile index 2005ff3a..bcd8fe76 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -26,3 +26,4 @@ compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o +compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c new file mode 100644 index 00000000..0d702ed3 --- /dev/null +++ b/compat/compat-2.6.35.c @@ -0,0 +1,34 @@ +/* + * Copyright 2010 Kshitij Kulshreshtha + * + * 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.35. + */ + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) +#include + +/** + * hex_to_bin - convert a hex digit to its real value + * @ch: ascii character represents hex digit + * + * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad + * input. + */ +int hex_to_bin(char ch) +{ + if ((ch >= '0') && (ch <= '9')) + return ch - '0'; + ch = tolower(ch); + if ((ch >= 'a') && (ch <= 'f')) + return ch - 'a' + 10; + return -1; +} +EXPORT_SYMBOL(hex_to_bin); + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) */ diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index c6e7136c..f0562cd7 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -25,6 +25,8 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) #define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret) +int hex_to_bin(char ch); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 30b46494a003a2718fd7e88dead620be16327cd2 Mon Sep 17 00:00:00 2001 From: Kshitij Kulshreshtha Date: Mon, 2 Aug 2010 00:02:50 +0200 Subject: compat: header was removed in v2.6.36 the header in versions < 2.6.36 requires types defined in so include it first. Signed-off-by: Kshitij Kulshreshtha --- include/pcmcia/cs.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 include/pcmcia/cs.h diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h new file mode 100644 index 00000000..1c5e0fa5 --- /dev/null +++ b/include/pcmcia/cs.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_PCMCIA_CS_H +#define _COMPAT_PCMCIA_CS_H +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) +#include +#endif + +#include_next +#endif -- cgit v1.2.3 From 1b21e2520d95b370078744fc26bc0aad5e895c2a Mon Sep 17 00:00:00 2001 From: Kshitij Kulshreshtha Date: Mon, 2 Aug 2010 00:02:51 +0200 Subject: compat: define struct va_format introduced in v2.6.36 Signed-off-by: Kshitij Kulshreshtha --- include/linux/compat-2.6.36.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 03071080..b14c7727 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -8,6 +8,11 @@ #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) +struct va_format { + const char *fmt; + va_list *va; +}; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 226b1c2b99ba3f6381b686ccacb2b691aa77fbe3 Mon Sep 17 00:00:00 2001 From: Kshitij Kulshreshtha Date: Wed, 4 Aug 2010 16:18:35 +0200 Subject: compat: backport pcmcia_{read,write}_config byte from v2.6.36 Signed-off-by: Kshitij Kulshreshtha --- include/pcmcia/ds.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/pcmcia/ds.h diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h new file mode 100644 index 00000000..fc437037 --- /dev/null +++ b/include/pcmcia/ds.h @@ -0,0 +1,36 @@ +#ifndef _COMPAT_PCMCIA_DS_H +#define _COMPAT_PCMCIA_DS_H +#include + +#include_next + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) +/** + * pcmcia_read_config_byte() - read a byte from a card configuration register + * + * pcmcia_read_config_byte() reads a byte from a configuration register in + * attribute memory. + */ +static inline int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val) +{ + int ret; + conf_reg_t reg = { 0, CS_READ, where, 0 }; + ret = pcmcia_access_configuration_register(p_dev, ®); + *val = reg.Value; + return ret; +} + +/** + * pcmcia_write_config_byte() - write a byte to a card configuration register + * + * pcmcia_write_config_byte() writes a byte to a configuration register in + * attribute memory. + */ +static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val) +{ + conf_reg_t reg = { 0, CS_WRITE, where, val }; + return pcmcia_access_configuration_register(p_dev, ®); +} +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) */ + +#endif -- cgit v1.2.3 From d6f0174d44360fb2777581c5124d42cc85266dab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 5 Aug 2010 12:09:22 -0700 Subject: compat: move struct va_format to 2.6.35 header This was added as of the 2.6.35-rc1 kernel. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.35.h | 5 +++++ include/linux/compat-2.6.36.h | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index f0562cd7..d2e82ccd 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -8,6 +8,11 @@ #include #include +struct va_format { + const char *fmt; + va_list *va; +}; + /* added on linux/kernel.h */ #define USHRT_MAX ((u16)(~0U)) #define SHRT_MAX ((s16)(USHRT_MAX>>1)) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index b14c7727..03071080 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -8,11 +8,6 @@ #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) -struct va_format { - const char *fmt; - va_list *va; -}; - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From a092b2412f79c61eddd9e892e7cc7cec2aa132ea Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Aug 2010 16:03:42 -0700 Subject: compat: add br_port_exists() and ask for inclusion upstream The br_port_exists() call is used internally on private bridge code on net/bridge/ to check if a netdevice is a bridge port. The way to check if a netdevice is a bridge port has changed for 2.6.36 from checking the netdev->br_port pointer to checking for a IFF_BRIDGE_PORT flag on the netdev->priv_flags. Instead of requiring backport code to ifdef the checks lets move the private br_port_exists() to a public header accessible by drivers and consistantly use it to check for the bridge port. I'll submit a patch upstream to move br_port_exists() to a public header so that we don't have to later even require a patch on backported code. We'll see if it gets accepted though. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.37.h | 27 +++++++++++++++++++++++++++ include/linux/compat-2.6.h | 1 + 2 files changed, 28 insertions(+) create mode 100644 include/linux/compat-2.6.37.h diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h new file mode 100644 index 00000000..a33c9a24 --- /dev/null +++ b/include/linux/compat-2.6.37.h @@ -0,0 +1,27 @@ +#ifndef LINUX_26_37_COMPAT_H +#define LINUX_26_37_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ + +#endif /* LINUX_26_37_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index ef51195f..25490f2e 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -29,5 +29,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From d85f0e0bc0ba2ccd3ef351c4db9ad99600211d47 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 7 Aug 2010 15:32:18 +0200 Subject: compat: backport n_tty_ioctl_helper This function is needed by some bluetooth drivers Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.28.c | 128 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.28.h | 6 ++ 2 files changed, 134 insertions(+) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 115bd23a..bfb645a8 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -13,6 +13,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) #include +#include +#include /* 2.6.28 compat code goes here */ @@ -370,4 +372,130 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, } EXPORT_SYMBOL(skb_add_rx_frag); +void tty_write_unlock(struct tty_struct *tty) +{ + mutex_unlock(&tty->atomic_write_lock); + wake_up_interruptible_poll(&tty->write_wait, POLLOUT); +} + +int tty_write_lock(struct tty_struct *tty, int ndelay) +{ + if (!mutex_trylock(&tty->atomic_write_lock)) { + if (ndelay) + return -EAGAIN; + if (mutex_lock_interruptible(&tty->atomic_write_lock)) + return -ERESTARTSYS; + } + return 0; +} + +/** + * send_prio_char - send priority character + * + * Send a high priority character to the tty even if stopped + * + * Locking: none for xchar method, write ordering for write method. + */ + +static int send_prio_char(struct tty_struct *tty, char ch) +{ + int was_stopped = tty->stopped; + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + if (tty->ops->send_xchar) { + tty->ops->send_xchar(tty, ch); +#else + if (tty->driver->send_xchar) { + tty->driver->send_xchar(tty, ch); +#endif + return 0; + } + + if (tty_write_lock(tty, 0) < 0) + return -ERESTARTSYS; + + if (was_stopped) + start_tty(tty); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + tty->ops->write(tty, &ch, 1); +#else + tty->driver->write(tty, &ch, 1); +#endif + if (was_stopped) + stop_tty(tty); + tty_write_unlock(tty); + return 0; +} + +int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + unsigned long flags; +#endif + int retval; + + switch (cmd) { + case TCXONC: + retval = tty_check_change(tty); + if (retval) + return retval; + switch (arg) { + case TCOOFF: + if (!tty->flow_stopped) { + tty->flow_stopped = 1; + stop_tty(tty); + } + break; + case TCOON: + if (tty->flow_stopped) { + tty->flow_stopped = 0; + start_tty(tty); + } + break; + case TCIOFF: + if (STOP_CHAR(tty) != __DISABLED_CHAR) + return send_prio_char(tty, STOP_CHAR(tty)); + break; + case TCION: + if (START_CHAR(tty) != __DISABLED_CHAR) + return send_prio_char(tty, START_CHAR(tty)); + break; + default: + return -EINVAL; + } + return 0; + case TCFLSH: + return tty_perform_flush(tty, arg); + case TIOCPKT: + { + int pktmode; + + if (tty->driver->type != TTY_DRIVER_TYPE_PTY || + tty->driver->subtype != PTY_TYPE_MASTER) + return -ENOTTY; + if (get_user(pktmode, (int __user *) arg)) + return -EFAULT; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + spin_lock_irqsave(&tty->ctrl_lock, flags); +#endif + if (pktmode) { + if (!tty->packet) { + tty->packet = 1; + tty->link->ctrl_status = 0; + } + } else + tty->packet = 0; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) + spin_unlock_irqrestore(&tty->ctrl_lock, flags); +#endif + return 0; + } + default: + /* Try the mode commands */ + return tty_mode_ioctl(tty, file, cmd, arg); + } +} +EXPORT_SYMBOL(n_tty_ioctl_helper); + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 71605488..649fbbc3 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -230,6 +230,12 @@ unsigned long round_jiffies_up(unsigned long j); extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, int size); +#define wake_up_interruptible_poll(x, m) \ + __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m)) + +extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, + unsigned int cmd, unsigned long arg); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ -- cgit v1.2.3 From 3494e3fc0cafbb4a340d558d38e4c0e46fdd5b55 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 7 Aug 2010 15:32:19 +0200 Subject: compat: move va_format to compat-2.6.36.h This struct was introduced in kernel 2.6.36 and not 2.6.35. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 5 ----- include/linux/compat-2.6.36.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index d2e82ccd..f0562cd7 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -8,11 +8,6 @@ #include #include -struct va_format { - const char *fmt; - va_list *va; -}; - /* added on linux/kernel.h */ #define USHRT_MAX ((u16)(~0U)) #define SHRT_MAX ((s16)(USHRT_MAX>>1)) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 03071080..b14c7727 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -8,6 +8,11 @@ #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) +struct va_format { + const char *fmt; + va_list *va; +}; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From df1d0a5557657b6e0da2a92375bb30a3d7c792f5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 7 Aug 2010 15:32:20 +0200 Subject: compat: fix compiler warning Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.27.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index d667222a..b9d70294 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -236,6 +236,8 @@ static inline void debugfs_remove_recursive(struct dentry *dentry) _dev; \ }) +#define dev_name(dev) dev_name((struct device *)dev) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 8a5dfc1b503de3f0208eecf879ff5e2465cfd29e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 7 Aug 2010 15:32:21 +0200 Subject: compat: update compat_firmware_class.c Refresh code based on recent version in linux-next. Signed-off-by: Hauke Mehrtens --- compat/compat_firmware_class.c | 290 +++++++++++++++++++++-------------------- 1 file changed, 149 insertions(+), 141 deletions(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 02f38a25..70ab25cd 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -88,27 +88,31 @@ static DEFINE_MUTEX(fw_lock); struct firmware_priv { struct completion completion; - struct bin_attribute attr_data; struct firmware *fw; unsigned long status; struct page **pages; int nr_pages; int page_array_size; struct timer_list timeout; + struct device dev; bool nowait; char fw_id[]; }; -static void -fw_load_abort(struct firmware_priv *fw_priv) +static struct firmware_priv *to_firmware_priv(struct device *dev) +{ + return container_of(dev, struct firmware_priv, dev); +} + +static void fw_load_abort(struct firmware_priv *fw_priv) { set_bit(FW_STATUS_ABORT, &fw_priv->status); wmb(); complete(&fw_priv->completion); } -static ssize_t -firmware_timeout_show(struct class *class, char *buf) +static ssize_t firmware_timeout_show(struct class *class, + char *buf) { return sprintf(buf, "%d\n", loading_timeout); } @@ -125,12 +129,13 @@ firmware_timeout_show(struct class *class, char *buf) * * Note: zero means 'wait forever'. **/ -static ssize_t -firmware_timeout_store(struct class *class, const char *buf, size_t count) +static ssize_t firmware_timeout_store(struct class *class, + const char *buf, size_t count) { loading_timeout = simple_strtol(buf, NULL, 10); if (loading_timeout < 0) loading_timeout = 0; + return count; } @@ -142,14 +147,13 @@ static struct class_attribute firmware_class_attrs[] = { static void fw_dev_release(struct device *dev) { - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); int i; for (i = 0; i < fw_priv->nr_pages; i++) __free_page(fw_priv->pages[i]); kfree(fw_priv->pages); kfree(fw_priv); - kfree(dev); module_put(THIS_MODULE); } @@ -157,7 +161,7 @@ static void fw_dev_release(struct device *dev) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) { - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id)) return -ENOMEM; @@ -172,7 +176,7 @@ static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) static int firmware_uevent(struct device *dev, char **envp, int num_envp, char *buf, int size) { - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); int error, len = 0, i = 0; error = add_uevent_var(envp, num_envp, &i, @@ -209,11 +213,27 @@ static struct class firmware_class = { static ssize_t firmware_loading_show(struct device *dev, struct device_attribute *attr, char *buf) { - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); + return sprintf(buf, "%d\n", loading); } +static void firmware_free_data(const struct firmware *fw) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) + int i; + vunmap(fw->data); + if (fw->pages) { + for (i = 0; i < PFN_UP(fw->size); i++) + __free_page(fw->pages[i]); + kfree(fw->pages); + } +#else + vunmap(fw->data); +#endif +} + /* Some architectures don't have PAGE_KERNEL_RO */ #ifndef PAGE_KERNEL_RO #define PAGE_KERNEL_RO PAGE_KERNEL @@ -221,7 +241,6 @@ static ssize_t firmware_loading_show(struct device *dev, /** * firmware_loading_store - set value in the 'loading' control file * @dev: device pointer - * @attr: device attribute pointer * @buf: buffer to scan for loading control value * @count: number of bytes in @buf * @@ -235,7 +254,7 @@ static ssize_t firmware_loading_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); int loading = simple_strtol(buf, NULL, 10); int i; @@ -246,21 +265,21 @@ static ssize_t firmware_loading_store(struct device *dev, mutex_unlock(&fw_lock); break; } - vfree(fw_priv->fw->data); - fw_priv->fw->data = NULL; + firmware_free_data(fw_priv->fw); + memset(fw_priv->fw, 0, sizeof(struct firmware)); + /* If the pages are not owned by 'struct firmware' */ for (i = 0; i < fw_priv->nr_pages; i++) __free_page(fw_priv->pages[i]); kfree(fw_priv->pages); fw_priv->pages = NULL; fw_priv->page_array_size = 0; fw_priv->nr_pages = 0; - fw_priv->fw->size = 0; set_bit(FW_STATUS_LOADING, &fw_priv->status); mutex_unlock(&fw_lock); break; case 0: if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { - vfree(fw_priv->fw->data); + vunmap(fw_priv->fw->data); fw_priv->fw->data = vmap(fw_priv->pages, fw_priv->nr_pages, 0, PAGE_KERNEL_RO); @@ -268,7 +287,12 @@ static ssize_t firmware_loading_store(struct device *dev, dev_err(dev, "%s: vmap() failed\n", __func__); goto err; } - /* Pages will be freed by vfree() */ + /* Pages are now owned by 'struct firmware' */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) + fw_priv->fw->pages = fw_priv->pages; + fw_priv->pages = NULL; +#endif + fw_priv->page_array_size = 0; fw_priv->nr_pages = 0; complete(&fw_priv->completion); @@ -290,12 +314,12 @@ static ssize_t firmware_loading_store(struct device *dev, static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); -static ssize_t -firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) +static ssize_t firmware_data_read(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) { struct device *dev = to_dev(kobj); - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t ret_count; @@ -334,8 +358,7 @@ out: return ret_count; } -static int -fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) +static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) { int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; @@ -384,12 +407,12 @@ fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) * Data written to the 'data' attribute will be later handed to * the driver as a firmware image. **/ -static ssize_t -firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) +static ssize_t firmware_data_write(struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) { struct device *dev = to_dev(kobj); - struct firmware_priv *fw_priv = dev_get_drvdata(dev); + struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t retval; @@ -430,116 +453,103 @@ out: return retval; } -static struct bin_attribute firmware_attr_data_tmpl = { - .attr = {.name = "data", .mode = 0644}, +static struct bin_attribute firmware_attr_data = { + .attr = { .name = "data", .mode = 0644 }, .size = 0, .read = firmware_data_read, .write = firmware_data_write, }; -static void -firmware_class_timeout(u_long data) +static void firmware_class_timeout(u_long data) { struct firmware_priv *fw_priv = (struct firmware_priv *) data; + fw_load_abort(fw_priv); } -static int fw_register_device(struct device **dev_p, const char *fw_name, - struct device *device) +static struct firmware_priv * +fw_create_instance(struct firmware *firmware, const char *fw_name, + struct device *device, bool uevent, bool nowait) { - int retval; - struct firmware_priv *fw_priv = - kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); - struct device *f_dev = kzalloc(sizeof(*f_dev), GFP_KERNEL); - - *dev_p = NULL; + struct firmware_priv *fw_priv; + struct device *f_dev; + int error; - if (!fw_priv || !f_dev) { + fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); + if (!fw_priv) { dev_err(device, "%s: kmalloc failed\n", __func__); - retval = -ENOMEM; - goto error_kfree; + error = -ENOMEM; + goto err_out; } + fw_priv->fw = firmware; + fw_priv->nowait = nowait; strcpy(fw_priv->fw_id, fw_name); init_completion(&fw_priv->completion); - fw_priv->attr_data = firmware_attr_data_tmpl; - fw_priv->timeout.function = firmware_class_timeout; - fw_priv->timeout.data = (u_long) fw_priv; - init_timer(&fw_priv->timeout); + setup_timer(&fw_priv->timeout, + firmware_class_timeout, (u_long) fw_priv); + f_dev = &fw_priv->dev; + + device_initialize(f_dev); dev_set_name(f_dev, "%s", dev_name(device)); f_dev->parent = device; f_dev->class = &firmware_class; - dev_set_drvdata(f_dev, fw_priv); - dev_set_uevent_suppress(f_dev, 1); - retval = device_register(f_dev); - if (retval) { - dev_err(device, "%s: device_register failed\n", __func__); - put_device(f_dev); - return retval; - } - *dev_p = f_dev; - return 0; - -error_kfree: - kfree(f_dev); - kfree(fw_priv); - return retval; -} -static int fw_setup_device(struct firmware *fw, struct device **dev_p, - const char *fw_name, struct device *device, - int uevent, bool nowait) -{ - struct device *f_dev; - struct firmware_priv *fw_priv; - int retval; - - *dev_p = NULL; - retval = fw_register_device(&f_dev, fw_name, device); - if (retval) - goto out; + dev_set_uevent_suppress(f_dev, true); /* Need to pin this module until class device is destroyed */ __module_get(THIS_MODULE); - fw_priv = dev_get_drvdata(f_dev); - - fw_priv->nowait = nowait; + error = device_add(f_dev); + if (error) { + dev_err(device, "%s: device_register failed\n", __func__); + goto err_put_dev; + } - fw_priv->fw = fw; - sysfs_bin_attr_init(&fw_priv->attr_data); - retval = sysfs_create_bin_file(&f_dev->kobj, &fw_priv->attr_data); - if (retval) { + error = device_create_bin_file(f_dev, &firmware_attr_data); + if (error) { dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); - goto error_unreg; + goto err_del_dev; } - retval = device_create_file(f_dev, &dev_attr_loading); - if (retval) { + error = device_create_file(f_dev, &dev_attr_loading); + if (error) { dev_err(device, "%s: device_create_file failed\n", __func__); - goto error_unreg; + goto err_del_bin_attr; } if (uevent) - dev_set_uevent_suppress(f_dev, 0); - *dev_p = f_dev; - goto out; + dev_set_uevent_suppress(f_dev, false); + + return fw_priv; + +err_del_bin_attr: + device_remove_bin_file(f_dev, &firmware_attr_data); +err_del_dev: + device_del(f_dev); +err_put_dev: + put_device(f_dev); +err_out: + return ERR_PTR(error); +} + +static void fw_destroy_instance(struct firmware_priv *fw_priv) +{ + struct device *f_dev = &fw_priv->dev; -error_unreg: + device_remove_file(f_dev, &dev_attr_loading); + device_remove_bin_file(f_dev, &firmware_attr_data); device_unregister(f_dev); -out: - return retval; } -static int -_request_firmware(const struct firmware **firmware_p, const char *name, - struct device *device, int uevent, bool nowait) +static int _request_firmware(const struct firmware **firmware_p, + const char *name, struct device *device, + bool uevent, bool nowait) { - struct device *f_dev; struct firmware_priv *fw_priv; struct firmware *firmware; - int retval; + int retval = 0; if (!firmware_p) return -EINVAL; @@ -560,41 +570,40 @@ _request_firmware(const struct firmware **firmware_p, const char *name, if (uevent) dev_dbg(device, "firmware: requesting %s\n", name); - retval = fw_setup_device(firmware, &f_dev, name, device, - uevent, nowait); - if (retval) - goto error_kfree_fw; - - fw_priv = dev_get_drvdata(f_dev); + fw_priv = fw_create_instance(firmware, name, device, uevent, nowait); + if (IS_ERR(fw_priv)) { + retval = PTR_ERR(fw_priv); + goto out; + } if (uevent) { - if (loading_timeout > 0) { - fw_priv->timeout.expires = jiffies + loading_timeout * HZ; - add_timer(&fw_priv->timeout); - } + if (loading_timeout > 0) + mod_timer(&fw_priv->timeout, + round_jiffies_up(jiffies + + loading_timeout * HZ)); + + kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); + } + + wait_for_completion(&fw_priv->completion); - kobject_uevent(&f_dev->kobj, KOBJ_ADD); - wait_for_completion(&fw_priv->completion); - set_bit(FW_STATUS_DONE, &fw_priv->status); - del_timer_sync(&fw_priv->timeout); - } else - wait_for_completion(&fw_priv->completion); + set_bit(FW_STATUS_DONE, &fw_priv->status); + del_timer_sync(&fw_priv->timeout); mutex_lock(&fw_lock); - if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) { + if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) retval = -ENOENT; - release_firmware(fw_priv->fw); - *firmware_p = NULL; - } fw_priv->fw = NULL; mutex_unlock(&fw_lock); - device_unregister(f_dev); - goto out; -error_kfree_fw: - kfree(firmware); - *firmware_p = NULL; + fw_destroy_instance(fw_priv); + out: + if (retval) { + release_firmware(firmware); + firmware_p = NULL; + } + return retval; } @@ -629,8 +638,7 @@ void release_firmware(const struct firmware *fw) { if (fw) { if (!fw_is_builtin_firmware(fw)) - vfree(fw->data); - + firmware_free_data(fw); kfree(fw); } } @@ -646,23 +654,24 @@ struct firmware_work { int uevent; }; -static int -request_firmware_work_func(void *arg) +static int request_firmware_work_func(void *arg) { struct firmware_work *fw_work = arg; const struct firmware *fw; int ret; + if (!arg) { WARN_ON(1); return 0; } - ret = _request_firmware(&fw, fw_work->name, fw_work->device, - fw_work->uevent, true); + ret = _request_firmware(&fw, fw_work->name, fw_work->device, + fw_work->uevent, true); fw_work->cont(fw, fw_work->context); module_put(fw_work->module); kfree(fw_work); + return ret; } @@ -690,34 +699,33 @@ request_firmware_nowait( void (*cont)(const struct firmware *fw, void *context)) { struct task_struct *task; - struct firmware_work *fw_work = kmalloc(sizeof (struct firmware_work), - gfp); + struct firmware_work *fw_work; + fw_work = kzalloc(sizeof (struct firmware_work), gfp); if (!fw_work) return -ENOMEM; + + fw_work->module = module; + fw_work->name = name; + fw_work->device = device; + fw_work->context = context; + fw_work->cont = cont; + fw_work->uevent = uevent; + if (!try_module_get(module)) { kfree(fw_work); return -EFAULT; } - *fw_work = (struct firmware_work) { - .module = module, - .name = name, - .device = device, - .context = context, - .cont = cont, - .uevent = uevent, - }; - task = kthread_run(request_firmware_work_func, fw_work, "firmware/%s", name); - if (IS_ERR(task)) { fw_work->cont(NULL, fw_work->context); module_put(fw_work->module); kfree(fw_work); return PTR_ERR(task); } + return 0; } -- cgit v1.2.3 From 82eaf999cdb8a00eebbeba3bdc41dec85f1e9ce1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 10 Aug 2010 22:21:26 +0200 Subject: compat: backport SDIO_CLASS_BT_AMP This is needed by drivers/bluetooth/btsdio.c Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index a33c9a24..cf0279e7 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -22,6 +22,8 @@ #define br_port_exists(dev) (dev->br_port) #endif +#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 042761265f52bb6647fa6cf608c90d0e4c9f45b8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 17 Aug 2010 20:32:31 +0200 Subject: compat: backport init_dummy_netdev NETREG_DUMMY is not available for older kernels, it should be set to something not normal. NETREG_DUMMY is set to 5 in new kernel versions. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.29.c | 40 ++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.29.h | 2 ++ 2 files changed, 42 insertions(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 2e7e623b..a2354f9b 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -124,6 +124,46 @@ int eth_validate_addr(struct net_device *dev) EXPORT_SYMBOL(eth_validate_addr); /* Source: net/ethernet/eth.c */ +#define NETREG_DUMMY 5 +/** + * init_dummy_netdev - init a dummy network device for NAPI + * @dev: device to init + * + * This takes a network device structure and initialize the minimum + * amount of fields so it can be used to schedule NAPI polls without + * registering a full blown interface. This is to be used by drivers + * that need to tie several hardware interfaces to a single NAPI + * poll scheduler due to HW limitations. + */ +int init_dummy_netdev(struct net_device *dev) +{ + /* Clear everything. Note we don't initialize spinlocks + * are they aren't supposed to be taken by any of the + * NAPI code and this dummy netdev is supposed to be + * only ever used for NAPI polls + */ + memset(dev, 0, sizeof(struct net_device)); + + /* make sure we BUG if trying to hit standard + * register/unregister code path + */ + dev->reg_state = NETREG_DUMMY; + + /* initialize the ref count */ + atomic_set(&dev->refcnt, 1); + + /* NAPI wants this */ + INIT_LIST_HEAD(&dev->napi_list); + + /* a dummy interface is started by default */ + set_bit(__LINK_STATE_PRESENT, &dev->state); + set_bit(__LINK_STATE_START, &dev->state); + + return 0; +} +EXPORT_SYMBOL_GPL(init_dummy_netdev); +/* Source: net/core/dev.c */ + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index a1a989c4..cce678f7 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -274,6 +274,8 @@ static inline struct net *read_pnet(struct net * const *pnet) #endif +extern int init_dummy_netdev(struct net_device *dev); + #else static inline void netdev_attach_ops(struct net_device *dev, -- cgit v1.2.3 From 4c4626e870c14cbd26024f648d87450871c64e8e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 17 Aug 2010 20:32:32 +0200 Subject: compat: backport net_ns_type_operations net_ns_type_operations needs to be exported. This only works for kernel >= 2.6.35 because struct kobj_ns_type_operations was introduced in kernel 2.6.35. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-2.6.37.c | 45 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.37.h | 2 ++ 3 files changed, 48 insertions(+) create mode 100644 compat/compat-2.6.37.c diff --git a/compat/Makefile b/compat/Makefile index bcd8fe76..b067be27 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -27,3 +27,4 @@ compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o +compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c new file mode 100644 index 00000000..655b92fc --- /dev/null +++ b/compat/compat-2.6.37.c @@ -0,0 +1,45 @@ +/* + * Copyright 2010 Hauke Mehrtens + * + * 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.37. + */ + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) + +#include +#include +#include + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) +static const void *net_current_ns(void) +{ + return current->nsproxy->net_ns; +} + +static const void *net_initial_ns(void) +{ + return &init_net; +} + +static const void *net_netlink_ns(struct sock *sk) +{ + return sock_net(sk); +} + +struct kobj_ns_type_operations net_ns_type_operations = { + .type = KOBJ_NS_TYPE_NET, + .current_ns = net_current_ns, + .netlink_ns = net_netlink_ns, + .initial_ns = net_initial_ns, +}; +EXPORT_SYMBOL_GPL(net_ns_type_operations); + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)*/ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) */ diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index cf0279e7..5bd6edb0 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -24,6 +24,8 @@ #define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ +extern struct kobj_ns_type_operations net_ns_type_operations; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 4715fbe76040b652ad32cd133fbc6f6ceb4975c1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 17 Aug 2010 20:32:33 +0200 Subject: compat: fix warning in device_rename Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.36.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index b14c7727..5b48215c 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -13,6 +13,8 @@ struct va_format { va_list *va; }; +#define device_rename(dev, new_name) device_rename(dev, (char *)new_name) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 6561208a3d30b3f76308892ccc8333eb72496a11 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 25 Aug 2010 15:27:51 -0700 Subject: compat: define PM_EVENT_SLEEP only if not defined This fixes a compilation warning on Ubuntu's 2.6.24 kernel which added the PM_EVENT_SLEEP even though upstream Linux 2.6.24.7 (the last 2.6.24) does not have it. Its a trivial change and I'm willing to support it to avoid compilation. Tested against /lib/modules/2.6.24-27-lpia/build These kernel headers can be foudn here: http://kernel.org/pub/linux/kernel/people/mcgrof/ubuntu/debs/kernel-headers/ Install with dpkg -i --force-architecture *.deb Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 8d329b33..ad3220a7 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -58,7 +58,9 @@ int compat_pm_qos_power_deinit(void); * 2.6.25 adds PM_EVENT_HIBERNATE as well here but * we don't have this on <= 2.6.23) */ +#ifndef PM_EVENT_SLEEP /* some distribution have mucked with their own headers to add this.. */ #define PM_EVENT_SLEEP (PM_EVENT_SUSPEND) +#endif /* Although we don't care about wimax this is needed for rfkill input stuff */ #define KEY_WIMAX 246 -- cgit v1.2.3 From c45d02641e880a63059b9f7417b13ca0c6412cde Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 30 Aug 2010 18:54:31 -0700 Subject: compat: add support for ndo_init backport ath6kl uses this. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.29.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index a2354f9b..bc4288f4 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -25,6 +25,7 @@ void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops) { dev->open = ops->ndo_open; + dev->init = ops->ndo_init; dev->stop = ops->ndo_stop; dev->hard_start_xmit = ops->ndo_start_xmit; dev->change_rx_flags = ops->ndo_change_rx_flags; -- cgit v1.2.3 From e13fed0e09571e9be10d70461e1a1c46831ab0f0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Sep 2010 06:19:13 -0700 Subject: compat: backport linux/pci-aspm.h pci-aspm.h was introduced in kernel 2.6.25 and is used by the ath5k and iwlwifi driver. v2: Do not place the empty functions into pci-aspm.h. Now we do not have to change pci-aspm.h when it changes in the mainline kernel only compat-2.6.26.h has to be changed. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.26.h | 9 +++++++++ include/linux/pci-aspm.h | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 include/linux/pci-aspm.h diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 82511774..30ee46c0 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -394,6 +394,15 @@ struct net *dev_net(const struct net_device *dev) #endif /* xtensa */ +#define PCIE_LINK_STATE_L0S 1 +#define PCIE_LINK_STATE_L1 2 +#define PCIE_LINK_STATE_CLKPM 4 + +static inline void pci_disable_link_state(struct pci_dev *pdev, int state) +{ +} +/* source: include/linux/pci-aspm.h */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ #endif /* LINUX_26_26_COMPAT_H */ diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h new file mode 100644 index 00000000..2bc6efb3 --- /dev/null +++ b/include/linux/pci-aspm.h @@ -0,0 +1,5 @@ +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */ -- cgit v1.2.3 From 539ed0ab0af21d61c422ba2a85d7554f74158d51 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Sep 2010 09:19:58 -0700 Subject: compat: backport skb_checksum_none_assert This is needed by atlx, b44, atl1c and atl1e. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 5bd6edb0..8ea0bab5 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -26,6 +28,21 @@ extern struct kobj_ns_type_operations net_ns_type_operations; +/** + * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE + * @skb: skb to check + * + * fresh skbs have their ip_summed set to CHECKSUM_NONE. + * Instead of forcing ip_summed to CHECKSUM_NONE, we can + * use this helper, to document places where we make this assertion. + */ +static inline void skb_checksum_none_assert(struct sk_buff *skb) +{ +#ifdef DEBUG + BUG_ON(skb->ip_summed != CHECKSUM_NONE); +#endif +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 48926c5b2fb3901d5cbc94e308153511001e0bcc Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Sep 2010 09:19:59 -0700 Subject: compat: backport printk_once This is needed by brcm80211. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.30.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h index eface8c2..28f3d54a 100644 --- a/include/linux/compat-2.6.30.h +++ b/include/linux/compat-2.6.30.h @@ -30,6 +30,18 @@ static inline void dev_set_uevent_suppress(struct device *dev, int val) dev->uevent_suppress = val; } +/* + * Print a one-time message (analogous to WARN_ONCE() et al): + */ +#define printk_once(x...) ({ \ + static bool __print_once; \ + \ + if (!__print_once) { \ + __print_once = true; \ + printk(x); \ + } \ +}) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ #endif /* LINUX_26_30_COMPAT_H */ -- cgit v1.2.3 From 764a6496348bc04e03434d5c6d8761e5f5e2b280 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 15 Sep 2010 13:42:32 -0700 Subject: compat: backport loff_t noop_llseek This is needed by some debug parts of mac80211. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.35.c | 17 +++++++++++++++++ include/linux/compat-2.6.35.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 0d702ed3..abb08c70 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -31,4 +31,21 @@ int hex_to_bin(char ch) } EXPORT_SYMBOL(hex_to_bin); +/** + * noop_llseek - No Operation Performed llseek implementation + * @file: file structure to seek on + * @offset: file offset to seek to + * @origin: type of seek + * + * This is an implementation of ->llseek useable for the rare special case when + * userspace expects the seek to succeed but the (device) file is actually not + * able to perform the seek. In this case you use noop_llseek() instead of + * falling back to the default implementation of ->llseek. + */ +loff_t noop_llseek(struct file *file, loff_t offset, int origin) +{ + return file->f_pos; +} +EXPORT_SYMBOL(noop_llseek); + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) */ diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index f0562cd7..32fd0391 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -27,6 +27,8 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) int hex_to_bin(char ch); +extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From ea840943377e5592e90f983542070d2912cc0f8f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 15 Sep 2010 13:42:33 -0700 Subject: compat: backport list_for_each_entry_continue_rcu This is needed for new driver carl9170. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.31.h | 11 +++++++++++ include/linux/compat-2.6.33.h | 14 ++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 54ddefdc..6c454cb2 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -191,6 +191,17 @@ void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) cancel_work_sync(&comp->work); } +/** + * list_entry_rcu - get the struct for this entry + * @ptr: the &struct list_head pointer. + * @type: the type of the struct this is embedded in. + * @member: the name of the list_struct within the struct. + * + * This primitive may safely run concurrently with the _rcu list-mutation + * primitives such as list_add_rcu() as long as it's guarded by rcu_read_lock(). + */ +#define list_entry_rcu(ptr, type, member) \ + container_of(rcu_dereference(ptr), type, member) #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index e4dff722..e7e20d94 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -98,6 +98,20 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, #define kfifo_out(a, b, c) __kfifo_get(*a, b, c) #define kfifo_len(a) __kfifo_len(*a) +/** + * list_for_each_entry_continue_rcu - continue iteration over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the list_struct within the struct. + * + * Continue to iterate over list of given type, continuing after + * the current position. + */ +#define list_for_each_entry_continue_rcu(pos, head, member) \ + for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \ + prefetch(pos->member.next), &pos->member != (head); \ + pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 84c7c92fb4d3b3882b2c6f46c533d5abfef7ae29 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 19 Sep 2010 10:42:08 -0700 Subject: compat: backport PCMCIA API changes. This backports the API change to pcmcia_enable_device Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 8ea0bab5..7fce42aa 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -43,6 +43,8 @@ static inline void skb_checksum_none_assert(struct sk_buff *skb) #endif } +#define pcmcia_enable_device(link) pcmcia_request_configuration(link, &link->conf) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 56e3de9c7a56c018fa440a90341163b089a7ca5d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 19 Sep 2010 10:42:09 -0700 Subject: compat: backport some usb urb functions These functions have to be backported, because they were thread-unsafe. This is commit b3e670443b7fb8a2d29831b62b44a039c283e351 in mainline kernel. CC: Christian Lamparter Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-2.6.28.c | 56 ----------------------- compat/compat-2.6.36.c | 100 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.28.h | 2 - include/linux/compat-2.6.36.h | 12 +++++ 5 files changed, 113 insertions(+), 58 deletions(-) create mode 100644 compat/compat-2.6.36.c diff --git a/compat/Makefile b/compat/Makefile index b067be27..1f053f2c 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -27,4 +27,5 @@ compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o +compat-$(CONFIG_COMPAT_KERNEL_36) += compat-2.6.36.o compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index bfb645a8..c11ba409 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -224,62 +224,6 @@ void usb_poison_anchored_urbs(struct usb_anchor *anchor) EXPORT_SYMBOL_GPL(usb_poison_anchored_urbs); #endif -/** - * usb_get_from_anchor - get an anchor's oldest urb - * @anchor: the anchor whose urb you want - * - * this will take the oldest urb from an anchor, - * unanchor and return it - */ -struct urb *usb_get_from_anchor(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - if (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.next, struct urb, - anchor_list); - usb_get_urb(victim); - spin_unlock_irqrestore(&anchor->lock, flags); - usb_unanchor_urb(victim); - } else { - spin_unlock_irqrestore(&anchor->lock, flags); - victim = NULL; - } - - return victim; -} - -EXPORT_SYMBOL_GPL(usb_get_from_anchor); - -/** - * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs - * @anchor: the anchor whose urbs you want to unanchor - * - * use this to get rid of all an anchor's urbs - */ -void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - while (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.prev, struct urb, - anchor_list); - usb_get_urb(victim); - spin_unlock_irqrestore(&anchor->lock, flags); - /* this may free the URB */ - usb_unanchor_urb(victim); - usb_put_urb(victim); - spin_lock_irqsave(&anchor->lock, flags); - } - spin_unlock_irqrestore(&anchor->lock, flags); -} - -EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); - /** * usb_anchor_empty - is an anchor empty * @anchor: the anchor you want to query diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c new file mode 100644 index 00000000..bd9335d6 --- /dev/null +++ b/compat/compat-2.6.36.c @@ -0,0 +1,100 @@ +/* + * Copyright 2010 Hauke Mehrtens + * + * 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.36. + */ + +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) + +#include + +#ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX +/* Callers must hold anchor->lock */ +static void __usb_unanchor_urb(struct urb *urb, struct usb_anchor *anchor) +{ + urb->anchor = NULL; + list_del(&urb->anchor_list); + usb_put_urb(urb); + if (list_empty(&anchor->urb_list)) + wake_up(&anchor->wait); +} + +/** + * usb_unlink_anchored_urbs - asynchronously cancel transfer requests en masse + * @anchor: anchor the requests are bound to + * + * this allows all outstanding URBs to be unlinked starting + * from the back of the queue. This function is asynchronous. + * The unlinking is just tiggered. It may happen after this + * function has returned. + * + * This routine should not be called by a driver after its disconnect + * method has returned. + */ +void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + + while ((victim = usb_get_from_anchor(anchor)) != NULL) { + usb_unlink_urb(victim); + usb_put_urb(victim); + } +} +EXPORT_SYMBOL_GPL(compat_usb_unlink_anchored_urbs); + +/** + * usb_get_from_anchor - get an anchor's oldest urb + * @anchor: the anchor whose urb you want + * + * this will take the oldest urb from an anchor, + * unanchor and return it + */ +struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + if (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.next, struct urb, + anchor_list); + usb_get_urb(victim); + __usb_unanchor_urb(victim, anchor); + } else { + victim = NULL; + } + spin_unlock_irqrestore(&anchor->lock, flags); + + return victim; +} +EXPORT_SYMBOL_GPL(compat_usb_get_from_anchor); + +/** + * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs + * @anchor: the anchor whose urbs you want to unanchor + * + * use this to get rid of all an anchor's urbs + */ +void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) +{ + struct urb *victim; + unsigned long flags; + + spin_lock_irqsave(&anchor->lock, flags); + while (!list_empty(&anchor->urb_list)) { + victim = list_entry(anchor->urb_list.prev, struct urb, + anchor_list); + __usb_unanchor_urb(victim, anchor); + } + spin_unlock_irqrestore(&anchor->lock, flags); +} +EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); +#endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) */ diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 649fbbc3..1de39ad3 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -62,8 +62,6 @@ extern void usb_unpoison_urb(struct urb *urb); extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); #endif -extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); -extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); extern int usb_anchor_empty(struct usb_anchor *anchor); #endif /* CONFIG_USB */ #endif diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 5b48215c..2df34d63 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) +#include + #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) @@ -15,6 +17,16 @@ struct va_format { #define device_rename(dev, new_name) device_rename(dev, (char *)new_name) +#ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX +#define usb_scuttle_anchored_urbs(anchor) compat_usb_scuttle_anchored_urbs(anchor) +#define usb_get_from_anchor(anchor) compat_usb_get_from_anchor(anchor) +#define usb_unlink_anchored_urbs(anchor) compat_usb_unlink_anchored_urbs(anchor) + +extern void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor); +extern struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor); +extern void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor); +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From a61410a8587b4a1458607f91ebc0b1d93a9c6447 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 19 Sep 2010 10:42:10 -0700 Subject: compat: move pmcia backport code into compat-2.6.36.h We have all out backport headers in include/linux/compat-2.6.XX.h also the pcmcia part there. CC: Kshitij Kulshreshtha Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.36.h | 29 +++++++++++++++++++++++++++++ include/pcmcia/ds.h | 36 ------------------------------------ 2 files changed, 29 insertions(+), 36 deletions(-) delete mode 100644 include/pcmcia/ds.h diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 2df34d63..1d929d79 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -6,6 +6,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) #include +#include +#include #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) @@ -27,6 +29,33 @@ extern struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor); extern void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor); #endif +/** + * pcmcia_read_config_byte() - read a byte from a card configuration register + * + * pcmcia_read_config_byte() reads a byte from a configuration register in + * attribute memory. + */ +static inline int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val) +{ + int ret; + conf_reg_t reg = { 0, CS_READ, where, 0 }; + ret = pcmcia_access_configuration_register(p_dev, ®); + *val = reg.Value; + return ret; +} + +/** + * pcmcia_write_config_byte() - write a byte to a card configuration register + * + * pcmcia_write_config_byte() writes a byte to a configuration register in + * attribute memory. + */ +static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val) +{ + conf_reg_t reg = { 0, CS_WRITE, where, val }; + return pcmcia_access_configuration_register(p_dev, ®); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h deleted file mode 100644 index fc437037..00000000 --- a/include/pcmcia/ds.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _COMPAT_PCMCIA_DS_H -#define _COMPAT_PCMCIA_DS_H -#include - -#include_next - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) -/** - * pcmcia_read_config_byte() - read a byte from a card configuration register - * - * pcmcia_read_config_byte() reads a byte from a configuration register in - * attribute memory. - */ -static inline int pcmcia_read_config_byte(struct pcmcia_device *p_dev, off_t where, u8 *val) -{ - int ret; - conf_reg_t reg = { 0, CS_READ, where, 0 }; - ret = pcmcia_access_configuration_register(p_dev, ®); - *val = reg.Value; - return ret; -} - -/** - * pcmcia_write_config_byte() - write a byte to a card configuration register - * - * pcmcia_write_config_byte() writes a byte to a configuration register in - * attribute memory. - */ -static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t where, u8 val) -{ - conf_reg_t reg = { 0, CS_WRITE, where, val }; - return pcmcia_access_configuration_register(p_dev, ®); -} -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) */ - -#endif -- cgit v1.2.3 From 1594b0d57d4fb20d8518d138f56a121cab78f1c8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 19 Sep 2010 10:42:11 -0700 Subject: compat: pcmcia/cs.h is removed form new kernels On older kernel versions we have to include pcmcia/cs_types.h and pcmcia/cs.h before pcmcia/cistpl.h. Signed-off-by: Hauke Mehrtens --- include/pcmcia/cistpl.h | 10 ++++++++++ include/pcmcia/cs.h | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 include/pcmcia/cistpl.h delete mode 100644 include/pcmcia/cs.h diff --git a/include/pcmcia/cistpl.h b/include/pcmcia/cistpl.h new file mode 100644 index 00000000..789dc59d --- /dev/null +++ b/include/pcmcia/cistpl.h @@ -0,0 +1,10 @@ +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) +#include +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) +#include +#endif + +#include_next diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h deleted file mode 100644 index 1c5e0fa5..00000000 --- a/include/pcmcia/cs.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef _COMPAT_PCMCIA_CS_H -#define _COMPAT_PCMCIA_CS_H -#include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) -#include -#endif - -#include_next -#endif -- cgit v1.2.3 From d00367190fd13353d21b820f3b49f8421161e17e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 25 Sep 2010 13:22:17 +0200 Subject: compat: fix build error in init_dummy_netdev In kernel <= 2.6.28 the member napi_list in struct net_device is only availabe if CONFIG_NETPOLL is set. We should initialize it only if it is available. This should fix the problem reported by Philip. This should also go into stable. CC: philipp_subx@redfish-solutions.com Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.29.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index bc4288f4..cded3cc0 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -153,8 +153,10 @@ int init_dummy_netdev(struct net_device *dev) /* initialize the ref count */ atomic_set(&dev->refcnt, 1); +#ifdef CONFIG_NETPOLL /* NAPI wants this */ INIT_LIST_HEAD(&dev->napi_list); +#endif /* a dummy interface is started by default */ set_bit(__LINK_STATE_PRESENT, &dev->state); -- cgit v1.2.3 From 49a1b74cb1df6682d1dff0cd0f18aad3c558ac17 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 7 Oct 2010 14:47:53 -0700 Subject: compat: backport netlink changes used in the nl80211 cleanup Signed-off-by: Felix Fietkau --- compat/Makefile | 1 - compat/compat-2.6.31.c | 64 ------------------------ compat/compat-2.6.37.c | 112 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.31.h | 4 -- include/linux/compat-2.6.37.h | 65 ++++++++++++++++++++++++ 5 files changed, 177 insertions(+), 69 deletions(-) delete mode 100644 compat/compat-2.6.31.c diff --git a/compat/Makefile b/compat/Makefile index 1f053f2c..c15a8f35 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -23,7 +23,6 @@ compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o -compat-$(CONFIG_COMPAT_KERNEL_31) += compat-2.6.31.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o diff --git a/compat/compat-2.6.31.c b/compat/compat-2.6.31.c deleted file mode 100644 index dc8588fe..00000000 --- a/compat/compat-2.6.31.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.31. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) - -#include - -/** - * genl_register_family_with_ops - register a generic netlink family - * @family: generic netlink family - * @ops: operations to be registered - * @n_ops: number of elements to register - * - * Registers the specified family and operations from the specified table. - * Only one family may be registered with the same family name or identifier. - * - * The family id may equal GENL_ID_GENERATE causing an unique id to - * be automatically generated and assigned. - * - * Either a doit or dumpit callback must be specified for every registered - * operation or the function will fail. Only one operation structure per - * command identifier may be registered. - * - * See include/net/genetlink.h for more documenation on the operations - * structure. - * - * This is equivalent to calling genl_register_family() followed by - * genl_register_ops() for every operation entry in the table taking - * care to unregister the family on error path. - * - * Return 0 on success or a negative error code. - */ -int genl_register_family_with_ops(struct genl_family *family, - struct genl_ops *ops, size_t n_ops) -{ - int err, i; - - err = genl_register_family(family); - if (err) - return err; - - for (i = 0; i < n_ops; ++i, ++ops) { - err = genl_register_ops(family, ops); - if (err) - goto err_out; - } - return 0; -err_out: - genl_unregister_family(family); - return err; -} -EXPORT_SYMBOL(genl_register_family_with_ops); - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ - diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 655b92fc..52c5a324 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -42,4 +42,116 @@ EXPORT_SYMBOL_GPL(net_ns_type_operations); #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)*/ +#undef genl_info +#undef genl_unregister_family + +static LIST_HEAD(compat_nl_fam); + +static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) +{ + struct genl_ops *ops; + + list_for_each_entry(ops, &family->family.ops_list, ops.ops_list) + if (ops->cmd == cmd) + return ops; + + return NULL; +} + + +static int nl_doit_wrapper(struct sk_buff *skb, struct genl_info *info) +{ + struct compat_genl_info compat_info; + struct genl_family *family; + struct genl_ops *ops; + int err; + + list_for_each_entry(family, &compat_nl_fam, list) { + if (family->id == info->nlhdr->nlmsg_type) + goto found; + } + return -ENOENT; + +found: + ops = genl_get_cmd(info->genlhdr->cmd, family); + if (!ops) + return -ENOENT; + + memset(&compat_info.user_ptr, 0, sizeof(compat_info.user_ptr)); + compat_info.info = info; +#define __copy(_field) compat_info._field = info->_field + __copy(snd_seq); + __copy(snd_pid); + __copy(genlhdr); + __copy(attrs); +#undef __copy + if (family->pre_doit) { + err = family->pre_doit(ops, skb, &compat_info); + if (err) + return err; + } + + err = ops->doit(skb, &compat_info); + + if (family->post_doit) + family->post_doit(ops, skb, &compat_info); + + return err; +} + +int compat_genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops) +{ + int i, ret; + +#define __copy(_field) family->family._field = family->_field + __copy(id); + __copy(hdrsize); + __copy(version); + __copy(maxattr); + strncpy(family->family.name, family->name, sizeof(family->family.name)); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) + __copy(netnsok); +#endif +#undef __copy + + ret = genl_register_family(&family->family); + if (ret < 0) + return ret; + + family->attrbuf = family->family.attrbuf; + family->id = family->family.id; + + for (i = 0; i < n_ops; i++) { +#define __copy(_field) ops[i].ops._field = ops[i]._field + __copy(cmd); + __copy(flags); + __copy(policy); + __copy(dumpit); + __copy(done); +#undef __copy + ops[i].ops.doit = nl_doit_wrapper; + ret = genl_register_ops(&family->family, &ops[i].ops); + if (ret < 0) + goto error_ops; + } + list_add(&family->list, &compat_nl_fam); + + return ret; + +error_ops: + compat_genl_unregister_family(family); + return ret; +} +EXPORT_SYMBOL(compat_genl_register_family_with_ops); + +int compat_genl_unregister_family(struct genl_family *family) +{ + int err; + err = genl_unregister_family(&family->family); + list_del(&family->list); + return err; +} +EXPORT_SYMBOL(compat_genl_unregister_family); + #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) */ diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 6c454cb2..d2e0f01b 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -114,10 +114,6 @@ static inline struct rtable *skb_rtable(const struct sk_buff *skb) return (struct rtable *)skb_dst(skb); } -extern int genl_register_family_with_ops(struct genl_family *family, - struct genl_ops *ops, size_t n_ops); - - /* Backport threaded IRQ support */ static inline diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 7fce42aa..3bb92285 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -45,6 +45,71 @@ static inline void skb_checksum_none_assert(struct sk_buff *skb) #define pcmcia_enable_device(link) pcmcia_request_configuration(link, &link->conf) +#include + +struct compat_genl_info { + struct genl_info *info; + + u32 snd_seq; + u32 snd_pid; + struct genlmsghdr *genlhdr; + struct nlattr **attrs; + void *user_ptr[2]; +}; +#define genl_info compat_genl_info + +struct compat_genl_ops { + struct genl_ops ops; + + u8 cmd; + u8 internal_flags; + unsigned int flags; + const struct nla_policy *policy; + + int (*doit)(struct sk_buff *skb, struct genl_info *info); + int (*dumpit)(struct sk_buff *skb, struct netlink_callback *cb); + int (*done)(struct netlink_callback *cb); +}; +#define genl_ops compat_genl_ops + +struct compat_genl_family { + struct genl_family family; + + struct list_head list; + + unsigned int id, hdrsize, version, maxattr; + const char *name; + bool netnsok; + + struct nlattr **attrbuf; + + int (*pre_doit)(struct genl_ops *ops, struct sk_buff *skb, + struct genl_info *info); + + void (*post_doit)(struct genl_ops *ops, struct sk_buff *skb, + struct genl_info *info); +}; + +#define genl_family compat_genl_family + +#define genl_register_family_with_ops compat_genl_register_family_with_ops + +int genl_register_family_with_ops(struct genl_family *family, + struct genl_ops *ops, size_t n_ops); + +#define genl_unregister_family compat_genl_unregister_family + +int genl_unregister_family(struct genl_family *family); + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) +#define genl_info_net(_info) genl_info_net((_info)->info) +#endif + +#define genlmsg_reply(_msg, _info) genlmsg_reply(_msg, (_info)->info) +#define genlmsg_put(_skb, _pid, _seq, _fam, _flags, _cmd) genlmsg_put(_skb, _pid, _seq, &(_fam)->family, _flags, _cmd) +#define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp) +#define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 0c1093c999d0bb07ef832ead6583674188b098a4 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Oct 2010 23:22:23 +0200 Subject: compat: backport some more kfifo stuff Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index e7e20d94..6a7cd3ed 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -94,10 +94,43 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, /* Backport for kfifo * kfifo_alloc and kfifo_free must be backported manually */ -#define kfifo_in(a, b, c) __kfifo_put(*a, b, c) -#define kfifo_out(a, b, c) __kfifo_get(*a, b, c) +#define kfifo_in(a, b, c) __kfifo_put(*a, (unsigned char *)b, c) +#define kfifo_out(a, b, c) __kfifo_get(*a, (unsigned char *)b, c) #define kfifo_len(a) __kfifo_len(*a) +/** + * kfifo_is_empty - returns true if the fifo is empty + * @fifo: the fifo to be used. + */ +static inline __must_check int kfifo_is_empty(struct kfifo **fifo) +{ + return (*fifo)->in == (*fifo)->out; +} + +/** + * kfifo_size - returns the size of the fifo in bytes + * @fifo: the fifo to be used. + */ +static inline __must_check unsigned int kfifo_size(struct kfifo *fifo) +{ + return fifo->size; +} + +/** + * kfifo_is_full - returns true if the fifo is full + * @fifo: the fifo to be used. + */ +static inline __must_check int kfifo_is_full(struct kfifo **fifo) +{ + return kfifo_len(fifo) == kfifo_size(*fifo); +} + +static inline void compat_kfifo_free(struct kfifo **fifo) { + if (*fifo) + kfifo_free(*fifo); +} +#define kfifo_free compat_kfifo_free + /** * list_for_each_entry_continue_rcu - continue iteration over list of given type * @pos: the type * to use as a loop cursor. -- cgit v1.2.3 From 10ae528628558aaac1278b88ce0732512cb0d9ec Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Oct 2010 23:22:24 +0200 Subject: compat: rename member in struct mmc_host. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 3bb92285..716f528a 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -110,6 +110,9 @@ int genl_unregister_family(struct genl_family *family); #define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp) #define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp) +/* rename member in struct mmc_host in include/linux/mmc/host.h */ +#define max_segs max_hw_segs + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 5e389ef4f4b281e73815ec7661de75c53c2f5ae9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 11 Oct 2010 10:41:45 -0700 Subject: compat: fix a crash in the netlink backport Do not set the .doit wrapper if there is no .doit function. Signed-off-by: Felix Fietkau --- compat/compat-2.6.37.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 52c5a324..d949a929 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -130,7 +130,8 @@ int compat_genl_register_family_with_ops(struct genl_family *family, __copy(dumpit); __copy(done); #undef __copy - ops[i].ops.doit = nl_doit_wrapper; + if (ops[i].doit) + ops[i].ops.doit = nl_doit_wrapper; ret = genl_register_ops(&family->family, &ops[i].ops); if (ret < 0) goto error_ops; -- cgit v1.2.3 From cd70b7a481f2befdb06401e62c3653db22099eb1 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 18 Oct 2010 22:36:35 +0200 Subject: compat: backport sock_recv_ts_and_drops This is needed for bluetooth Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 6a7cd3ed..c2dbc1ba 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -145,6 +145,8 @@ static inline void compat_kfifo_free(struct kfifo **fifo) { prefetch(pos->member.next), &pos->member != (head); \ pos = list_entry_rcu(pos->member.next, typeof(*pos), member)) +#define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 4bf6730eac2ce1fb1610c9a4be822a2c738f379a Mon Sep 17 00:00:00 2001 From: Blaise Gassend Date: Fri, 22 Oct 2010 02:32:04 -0700 Subject: compat: Fixes missing sem member in struct device for RT PREEMPT prior to 2.6.34 The RT PREEMPT patch eliminates the sem member in struct device breaking device_lock, device_unlock and device_trylock in kernels prior to 2.6.34. The attached patch replaces the use of sem by a use of mutex. Signed-off-by: Blaise Gassend Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.34.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 336c61b2..1cfd6e5c 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -142,17 +142,32 @@ do { \ static inline void device_lock(struct device *dev) { +#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ + defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) + mutex_lock(&dev->parent->mutex); +#else down(&dev->sem); +#endif } static inline int device_trylock(struct device *dev) { +#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ + defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) + return mutex_trylock(&dev->mutex); +#else return down_trylock(&dev->sem); +#endif } static inline void device_unlock(struct device *dev) { +#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ + defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) + mutex_unlock(&dev->mutex); +#else up(&dev->sem); +#endif } #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) -- cgit v1.2.3 From 76eda6f7bc726e7b7a2ffa0559bdc861b52d8e04 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 23 Oct 2010 20:13:59 +0200 Subject: compat: fix device_lock functions on non rt kernel CONFIG_NONE and CONFIG_PREEMPT_VOLUNTARY are not added by the last RT patch. I have not found any references to CONFIG_NONE, probably CONFIG_PREEMPT_NONE was meant, but that is also wrong like CONFIG_PREEMPT_VOLUNTARY. These two options are also in the normal kernel config system without the rt patch. This patch only checks for KConfig options added by the rt patch, but a rt-patch user could also select PREEMPT_NONE or PREEMPT_VOLUNTARY, and compat-wireless will not build. I do not think this will hapen often, so leave it like this. This patch fixes build with all non rt-kernels. CC: Blaise Gassend Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 1cfd6e5c..f710d08b 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -142,8 +142,7 @@ do { \ static inline void device_lock(struct device *dev) { -#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ - defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) +#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP) mutex_lock(&dev->parent->mutex); #else down(&dev->sem); @@ -152,8 +151,7 @@ static inline void device_lock(struct device *dev) static inline int device_trylock(struct device *dev) { -#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ - defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) +#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP) return mutex_trylock(&dev->mutex); #else return down_trylock(&dev->sem); @@ -162,8 +160,7 @@ static inline int device_trylock(struct device *dev) static inline void device_unlock(struct device *dev) { -#if defined(CONFIG_NONE) || defined(CONFIG_PREEMPT_RT) || \ - defined(CONFIG_PREEMPT_VOLUNTARY) || defined(CONFIG_PREEMPT_DESKTOP) +#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP) mutex_unlock(&dev->mutex); #else up(&dev->sem); -- cgit v1.2.3 From 9e6334f51655ac71c9d18207654d934af991f755 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 23 Oct 2010 20:14:00 +0200 Subject: compat: lock correct mutex in device_lock This seams to be an error as all the other functions are working on the other struct. CC: Blaise Gassend Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index f710d08b..763abcac 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -143,7 +143,7 @@ do { \ static inline void device_lock(struct device *dev) { #if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP) - mutex_lock(&dev->parent->mutex); + mutex_lock(&dev->mutex); #else down(&dev->sem); #endif -- cgit v1.2.3 From a5556e6fe2349fbf913801e4ff486d6b8edf4699 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 23 Oct 2010 20:14:01 +0200 Subject: compat: add empty implementation for usb_enable_autosuspend This is needed by drivers/bluetooth/btusb.c Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 763abcac..93fc4ef7 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) #include +#include #define netdev_mc_count(dev) ((dev)->mc_count) #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) @@ -236,6 +237,12 @@ static inline int dma_set_coherent_mask(struct device *dev, u64 mask) return 0; } +/* USB autosuspend and autoresume */ +static inline int usb_enable_autosuspend(struct usb_device *udev) +{ return 0; } +static inline int usb_disable_autosuspend(struct usb_device *udev) +{ return 0; } + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 8288d931f0f25111de0583977167da03babb23b7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 5 Nov 2010 20:27:02 +0100 Subject: compat: fix build with kernel 2.6.37rc1 Some backports are also needed when compiling against kernel 2.6.37. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 20 -------------------- include/linux/compat-2.6.38.h | 30 ++++++++++++++++++++++++++++++ include/linux/compat-2.6.h | 1 + 3 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 include/linux/compat-2.6.38.h diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 716f528a..6c026a34 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -7,23 +7,6 @@ #include -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - #define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ extern struct kobj_ns_type_operations net_ns_type_operations; @@ -110,9 +93,6 @@ int genl_unregister_family(struct genl_family *family); #define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp) #define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp) -/* rename member in struct mmc_host in include/linux/mmc/host.h */ -#define max_segs max_hw_segs - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h new file mode 100644 index 00000000..fa77a89e --- /dev/null +++ b/include/linux/compat-2.6.38.h @@ -0,0 +1,30 @@ +#ifndef LINUX_26_38_COMPAT_H +#define LINUX_26_38_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +/* rename member in struct mmc_host in include/linux/mmc/host.h */ +#define max_segs max_hw_segs + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ + +#endif /* LINUX_26_38_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 25490f2e..2706797c 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -30,5 +30,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From 4b598d6861c090bb1619cc1fc1dae56cd1541f9d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 5 Nov 2010 20:27:03 +0100 Subject: compat: remove unnecessary ifdefs and empty file The Makefile only builds the needed compat-2.6.XX.c files and not all, so the ifdefs are not needed. compat-2.6.30.c did not had any real content so remove it. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 - compat/compat-2.6.14.c | 4 ---- compat/compat-2.6.18.c | 4 ---- compat/compat-2.6.19.c | 4 ---- compat/compat-2.6.21.c | 4 ---- compat/compat-2.6.22.c | 4 ---- compat/compat-2.6.23.c | 5 ----- compat/compat-2.6.24.c | 6 ------ compat/compat-2.6.25.c | 5 ----- compat/compat-2.6.26.c | 6 ------ compat/compat-2.6.27.c | 5 ----- compat/compat-2.6.28.c | 4 ---- compat/compat-2.6.29.c | 6 ------ compat/compat-2.6.30.c | 18 ------------------ compat/compat-2.6.32.c | 5 ----- compat/compat-2.6.33.c | 5 ----- compat/compat-2.6.35.c | 3 --- compat/compat-2.6.36.c | 4 ---- compat/compat-2.6.37.c | 4 ---- 19 files changed, 97 deletions(-) delete mode 100644 compat/compat-2.6.30.c diff --git a/compat/Makefile b/compat/Makefile index c15a8f35..46049af1 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -22,7 +22,6 @@ compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o -compat-$(CONFIG_COMPAT_KERNEL_30) += compat-2.6.30.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o diff --git a/compat/compat-2.6.14.c b/compat/compat-2.6.14.c index e0af181f..3de847d9 100644 --- a/compat/compat-2.6.14.c +++ b/compat/compat-2.6.14.c @@ -10,9 +10,5 @@ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14)) - /* 2.6.14 compat code goes here */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) */ - diff --git a/compat/compat-2.6.18.c b/compat/compat-2.6.18.c index c7fb2e41..c7961eeb 100644 --- a/compat/compat-2.6.18.c +++ b/compat/compat-2.6.18.c @@ -10,9 +10,5 @@ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) - /* 2.6.18 compat code goes here */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) */ - diff --git a/compat/compat-2.6.19.c b/compat/compat-2.6.19.c index fc75b64d..60c34045 100644 --- a/compat/compat-2.6.19.c +++ b/compat/compat-2.6.19.c @@ -10,9 +10,5 @@ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)) - /* 2.6.19 compat code goes here */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19) */ - diff --git a/compat/compat-2.6.21.c b/compat/compat-2.6.21.c index e2737fb2..7cf88619 100644 --- a/compat/compat-2.6.21.c +++ b/compat/compat-2.6.21.c @@ -10,9 +10,5 @@ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21)) - /* 2.6.21 compat code goes here */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,21) */ - diff --git a/compat/compat-2.6.22.c b/compat/compat-2.6.22.c index b1ff1f3b..d4df7b7d 100644 --- a/compat/compat-2.6.22.c +++ b/compat/compat-2.6.22.c @@ -10,9 +10,5 @@ #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)) - /* 2.6.22 compat code goes here */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) */ - diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index 136d9499..87f2a8c8 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -10,9 +10,6 @@ #include -/* All things not in 2.6.22 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) - /* On net/core/dev.c as of 2.6.24 */ int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int glbl) @@ -245,5 +242,3 @@ int pci_try_set_mwi(struct pci_dev *dev) EXPORT_SYMBOL(pci_try_set_mwi); #endif -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)) */ - diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index 31a9212f..a5c9c972 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -9,10 +9,6 @@ */ #include - -/* All things not in 2.6.22 and 2.6.23 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) - #include /* @@ -181,5 +177,3 @@ int compat_is_pcie(struct pci_dev *pdev) } EXPORT_SYMBOL(compat_is_pcie); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) */ - diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 75468210..7cb996b6 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -8,9 +8,6 @@ * Compatibility file for Linux wireless for kernels 2.6.25. */ -/* All things not in 2.6.22, 2.6.23 and 2.6.24 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25)) - #include /** @@ -98,5 +95,3 @@ define_strict_strtox(l, long) EXPORT_SYMBOL(strict_strtoul); EXPORT_SYMBOL(strict_strtol); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,25) */ - diff --git a/compat/compat-2.6.26.c b/compat/compat-2.6.26.c index b9bf9e76..f4715067 100644 --- a/compat/compat-2.6.26.c +++ b/compat/compat-2.6.26.c @@ -16,10 +16,6 @@ #include -/* All things not in 2.6.25 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) - - /* 2.6.24 does not have the struct kobject with a name */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) @@ -89,5 +85,3 @@ int dev_set_name(struct device *dev, const char *fmt, ...) } EXPORT_SYMBOL_GPL(dev_set_name); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */ - diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index b78d4653..25bee281 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -9,9 +9,6 @@ */ #include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) - #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) #include @@ -240,5 +237,3 @@ void debugfs_remove_recursive(struct dentry *dentry) EXPORT_SYMBOL_GPL(debugfs_remove_recursive); #endif /* CONFIG_DEBUG_FS */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */ - diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index c11ba409..7a834d27 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -9,9 +9,6 @@ */ #include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) - #include #include #include @@ -442,4 +439,3 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, } EXPORT_SYMBOL(n_tty_ioctl_helper); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28) */ diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index cded3cc0..14f5e902 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -9,9 +9,6 @@ */ #include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) - #include #include @@ -167,6 +164,3 @@ int init_dummy_netdev(struct net_device *dev) EXPORT_SYMBOL_GPL(init_dummy_netdev); /* Source: net/core/dev.c */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */ - diff --git a/compat/compat-2.6.30.c b/compat/compat-2.6.30.c deleted file mode 100644 index f8219189..00000000 --- a/compat/compat-2.6.30.c +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2007 Luis R. Rodriguez - * - * 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.30. - */ - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - -/* 2.6.30 compat code goes here */ - -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30) */ - diff --git a/compat/compat-2.6.32.c b/compat/compat-2.6.32.c index 22c2c197..013150d0 100644 --- a/compat/compat-2.6.32.c +++ b/compat/compat-2.6.32.c @@ -9,9 +9,6 @@ */ #include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) - #include int __dev_addr_add(struct dev_addr_list **list, int *count, @@ -120,5 +117,3 @@ void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, } EXPORT_SYMBOL_GPL(__dev_addr_unsync); -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ - diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 055082e7..c8e568df 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -9,9 +9,6 @@ */ #include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) - #include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) @@ -133,5 +130,3 @@ EXPORT_SYMBOL(pcmcia_loop_tuple); #endif /* CONFIG_PCCARD */ -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ - diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index abb08c70..44a15d63 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -9,8 +9,6 @@ */ #include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) #include /** @@ -48,4 +46,3 @@ loff_t noop_llseek(struct file *file, loff_t offset, int origin) } EXPORT_SYMBOL(noop_llseek); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35) */ diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index bd9335d6..5faefb4b 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -9,9 +9,6 @@ */ #include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) - #include #ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX @@ -97,4 +94,3 @@ void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); #endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36) */ diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index d949a929..81f466f3 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -9,9 +9,6 @@ */ #include - -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) - #include #include #include @@ -155,4 +152,3 @@ int compat_genl_unregister_family(struct genl_family *family) } EXPORT_SYMBOL(compat_genl_unregister_family); -#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) */ -- cgit v1.2.3 From af9fe6fe19c34f57a1f353bd8c2e4d8447edb51e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 8 Nov 2010 16:53:11 -0800 Subject: compat: backport upstream firmware_class bug through f45f3c1f This backports this patch: commit f45f3c1f3f616ca1d1e1eb5e7a720ca63cb59550 Author: Johannes Berg Date: Wed Aug 18 17:15:18 2010 +0200 firmware_class: fix typo in error path In the error path, _request_firmware sets firmware_p to NULL rather than *firmware_p, which leads to passing a freed firmware struct to drivers when the firmware file cannot be found. Fix this. Broken by commit f8a4bd3456b988fc73b2c. Reported-by: Wey-Yi Guy Signed-off-by: Johannes Berg Acked-by: Dmitry Torokhov Signed-off-by: Pekka Enberg Signed-off-by: Greg Kroah-Hartman All kernels older than 2.6.33 would be affected by this. Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 70ab25cd..79cd543e 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -601,7 +601,7 @@ static int _request_firmware(const struct firmware **firmware_p, out: if (retval) { release_firmware(firmware); - firmware_p = NULL; + *firmware_p = NULL; } return retval; -- cgit v1.2.3 From 6392771b4700535fe7e6410db10285832fcd1e45 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 10 Nov 2010 14:50:00 -0800 Subject: compat: backport pm_qos_*_request Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.36.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 1d929d79..4f6e24c8 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -8,6 +8,7 @@ #include #include #include +#include #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) @@ -56,6 +57,39 @@ static inline int pcmcia_write_config_byte(struct pcmcia_device *p_dev, off_t wh return pcmcia_access_configuration_register(p_dev, ®); } +struct pm_qos_request_list { + u32 qos; + void *request; +}; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) + +#define pm_qos_add_request(_req, _class, _value) do { \ + (_req)->request = #_req; \ + (_req)->qos = _class; \ + pm_qos_add_requirement((_class), (_req)->request, (_value)); \ + } while(0) + +#define pm_qos_update_request(_req, _value) \ + pm_qos_update_requirement((_req)->qos, (_req)->request, (_value)) + +#define pm_qos_remove_request(_req) \ + pm_qos_remove_requirement((_req)->qos, (_req)->request) + +#else + +#define pm_qos_add_request(_req, _class, _value) do { \ + (_req)->request = pm_qos_add_request((_class), (_value)); \ + } while (0) + +#define pm_qos_update_request(_req, _value) \ + pm_qos_update_request((_req)->request, (_value) + +#define pm_qos_remove_request(_req) \ + pm_qos_remove_request((_req)->request) + +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 4972107277fd24701e641765e8a93068f3a8a42b Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 10 Nov 2010 15:02:50 -0800 Subject: compat: backport pm_qos_request Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.35.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 32fd0391..c4de1693 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -29,6 +29,8 @@ int hex_to_bin(char ch); extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); +#define pm_qos_request(_qos) pm_qos_requirement(_qos) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 9adca90d70cb202906294a9b20666b6cca82417a Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 10 Nov 2010 15:38:55 -0800 Subject: compat: add a wrapper for rfkill.h With this we can get rid of some of the rfkill related patching mess. Signed-off-by: Felix Fietkau --- include/linux/rfkill.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 include/linux/rfkill.h diff --git a/include/linux/rfkill.h b/include/linux/rfkill.h new file mode 100644 index 00000000..d615ac9f --- /dev/null +++ b/include/linux/rfkill.h @@ -0,0 +1,32 @@ +#ifndef __COMPAT_RFKILL_H +#define __COMPAT_RFKILL_H + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) + +#include_next + +#else + +#include + +#undef CONFIG_RFKILL +#undef CONFIG_RFKILL_INPUT +#undef CONFIG_RFKILL_LEDS + +#ifdef CONFIG_RFKILL_BACKPORT +#define CONFIG_RFKILL 1 +#endif + +#ifdef CONFIG_RFKILL_BACKPORT_INPUT +#define CONFIG_RFKILL_INPUT +#endif + +#ifdef CONFIG_RFKILL_BACKPORT_LEDS +#define CONFIG_RFKILL_LEDS +#endif + +#include + +#endif + +#endif -- cgit v1.2.3 From ea54195721209a5cfc6ab4806e7fa1d61dc002ef Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 10 Nov 2010 16:28:48 -0800 Subject: compat: backport sign_extend32() commit 5faec21f3a6973219481394534ce0e5f17507d84 Author: Andreas Herrmann Date: Mon Aug 30 19:04:01 2010 +0000 bitops: Provide generic sign_extend32 function This patch moves code out from wireless drivers where two different functions are defined in three code locations for the same purpose and provides a common function to sign extend a 32-bit value. Signed-off-by: Andreas Herrmann Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- include/linux/bitops.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 679369be..aa76af18 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -111,6 +111,17 @@ static inline __u8 ror8(__u8 word, unsigned int shift) return (word >> shift) | (word << (8 - shift)); } +/** + * sign_extend32 - sign extend a 32-bit value using specified bit as sign-bit + * @value: value to sign extend + * @index: 0 based bit index (0<=index<32) to sign bit + */ +static inline __s32 sign_extend32(__u32 value, int index) +{ + __u8 shift = 31 - index; + return (__s32)(value << shift) >> shift; +} + static inline unsigned fls_long(unsigned long l) { if (sizeof(l) == 4) -- cgit v1.2.3 From e8a029b5e74e4262aa498da9e7dd11b46f9a4aaf Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 12 Nov 2010 11:14:44 -0800 Subject: compat: fix pm_qos_params compile error on 2.6.35 Linux 2.6.35 pm_qos_params.h is missing a #ifndef/define/endif around its header file contents, causing a compile error when its functions are overwritten by macros in the compat header files. Fix this by adding these to the compat version of this header file. Signed-off-by: Felix Fietkau --- include/linux/pm_qos_params.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h index e1f083c4..d0e3ad86 100644 --- a/include/linux/pm_qos_params.h +++ b/include/linux/pm_qos_params.h @@ -1,5 +1,8 @@ #include +#ifndef __COMPAT_LINUX_PM_QOS_PARAMS_H +#define __COMPAT_LINUX_PM_QOS_PARAMS_H + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) #include_next #else @@ -30,3 +33,4 @@ int pm_qos_add_notifier(int qos, struct notifier_block *notifier); int pm_qos_remove_notifier(int qos, struct notifier_block *notifier); #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */ +#endif -- cgit v1.2.3 From fef7b52ed76fb739f82fdd2321086210cd7f5b68 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 12 Nov 2010 11:15:28 -0800 Subject: compat: fix a typo in pm_qos_update_request for 2.6.35 Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.36.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 4f6e24c8..83b7f062 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -83,7 +83,7 @@ struct pm_qos_request_list { } while (0) #define pm_qos_update_request(_req, _value) \ - pm_qos_update_request((_req)->request, (_value) + pm_qos_update_request((_req)->request, (_value)) #define pm_qos_remove_request(_req) \ pm_qos_remove_request((_req)->request) -- cgit v1.2.3 From 6f82007bafd6c005952a32d58a24dfdcf546a09b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 13 Nov 2010 00:23:15 +0100 Subject: compat: add missing pm_runtime.h Signed-off-by: Hauke Mehrtens --- include/linux/pm_runtime.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 include/linux/pm_runtime.h diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h new file mode 100644 index 00000000..eec965ba --- /dev/null +++ b/include/linux/pm_runtime.h @@ -0,0 +1,14 @@ +#include + +#ifndef __COMPAT_LINUX_PM_RUNTIME_H +#define __COMPAT_LINUX_PM_RUNTIME_H + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) +#include_next +#else + +static inline void pm_runtime_enable(struct device *dev) {} + +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) */ + +#endif -- cgit v1.2.3 From a24f730f0b9122b72054807c85264876af1c4a1e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 21 Nov 2010 21:48:36 +0100 Subject: compat: backport Generic exponentially weighted moving average (EWMA) Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-2.6.38.c | 50 +++++++++++++++++++++++++++++++++++++++++++ include/linux/average.h | 5 +++++ include/linux/compat-2.6.38.h | 29 +++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 compat/compat-2.6.38.c create mode 100644 include/linux/average.h diff --git a/compat/Makefile b/compat/Makefile index 46049af1..18a9afcc 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -27,3 +27,4 @@ compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o compat-$(CONFIG_COMPAT_KERNEL_36) += compat-2.6.36.o compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o +compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o diff --git a/compat/compat-2.6.38.c b/compat/compat-2.6.38.c new file mode 100644 index 00000000..172aa193 --- /dev/null +++ b/compat/compat-2.6.38.c @@ -0,0 +1,50 @@ +/* + * Copyright 2010 Hauke Mehrtens + * + * 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 +#include +#include + +/** + * 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(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(ewma_add); + diff --git a/include/linux/average.h b/include/linux/average.h new file mode 100644 index 00000000..ece86ca3 --- /dev/null +++ b/include/linux/average.h @@ -0,0 +1,5 @@ +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) */ diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index fa77a89e..85eac512 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -25,6 +27,33 @@ /* rename member in struct mmc_host in include/linux/mmc/host.h */ #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; +}; + +extern void ewma_init(struct ewma *avg, unsigned long factor, + unsigned long weight); + +extern struct ewma *ewma_add(struct ewma *avg, unsigned long val); + +/** + * 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,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 5b6e5a5ca2577a45363e0aa156277f8127559edd Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 21 Nov 2010 21:48:37 +0100 Subject: compat: update wireless.h with new version from linux-next Signed-off-by: Hauke Mehrtens --- include/linux/wireless.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/wireless.h b/include/linux/wireless.h index e6827eed..4395b28b 100644 --- a/include/linux/wireless.h +++ b/include/linux/wireless.h @@ -1157,6 +1157,6 @@ struct __compat_iw_event { #define IW_EV_PARAM_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_param)) #define IW_EV_ADDR_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct sockaddr)) #define IW_EV_QUAL_PK_LEN (IW_EV_LCP_PK_LEN + sizeof(struct iw_quality)) -#define IW_EV_POINT_PK_LEN (IW_EV_LCP_LEN + 4) +#define IW_EV_POINT_PK_LEN (IW_EV_LCP_PK_LEN + 4) #endif /* _LINUX_WIRELESS_H */ -- cgit v1.2.3 From 34dd5d583f9182f8c848d980491ba36d03a27d03 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 25 Nov 2010 15:49:04 +0100 Subject: compat: backport pr_warn Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 85eac512..dfc406e9 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -54,6 +54,8 @@ static inline unsigned long ewma_read(const struct ewma *avg) return DIV_ROUND_CLOSEST(avg->internal, avg->factor); } +#define pr_warn pr_warning + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From cb00e6d086096878dd5086fad481b63e67519f25 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 28 Nov 2010 13:05:16 +0100 Subject: compat: backport LED class software blinking Signed-off-by: Felix Fietkau --- compat/compat-2.6.37.c | 172 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.37.h | 13 ++++ 2 files changed, 185 insertions(+) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 81f466f3..669402d8 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -152,3 +152,175 @@ int compat_genl_unregister_family(struct genl_family *family) } EXPORT_SYMBOL(compat_genl_unregister_family); +#ifdef CONFIG_LEDS_CLASS + +#undef led_brightness_set +#undef led_classdev_unregister + +spinlock_t led_lock; +static LIST_HEAD(led_timers); + +struct led_timer { + struct list_head list; + struct led_classdev *cdev; + struct timer_list blink_timer; + unsigned long blink_delay_on; + unsigned long blink_delay_off; + int blink_brightness; +}; + +static void led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + led_cdev->brightness = brightness; + led_cdev->brightness_set(led_cdev, brightness); +} + +static struct led_timer *led_get_timer(struct led_classdev *led_cdev) +{ + struct led_timer *p; + unsigned long flags; + + spin_lock_irqsave(&led_lock, flags); + list_for_each_entry(p, &led_timers, list) { + if (p->cdev == led_cdev) + goto found; + } + p = NULL; +found: + spin_unlock_irqrestore(&led_lock, flags); + return p; +} + +static void led_stop_software_blink(struct led_timer *led) +{ + del_timer_sync(&led->blink_timer); + led->blink_delay_on = 0; + led->blink_delay_off = 0; +} + +static void led_timer_function(unsigned long data) +{ + struct led_timer *led = (struct led_timer *)data; + unsigned long brightness; + unsigned long delay; + + if (!led->blink_delay_on || !led->blink_delay_off) { + led->cdev->brightness_set(led->cdev, LED_OFF); + return; + } + + brightness = led->cdev->brightness; + if (!brightness) { + /* Time to switch the LED on. */ + brightness = led->blink_brightness; + delay = led->blink_delay_on; + } else { + /* Store the current brightness value to be able + * to restore it when the delay_off period is over. + */ + led->blink_brightness = brightness; + brightness = LED_OFF; + delay = led->blink_delay_off; + } + + led_brightness_set(led->cdev, brightness); + mod_timer(&led->blink_timer, jiffies + msecs_to_jiffies(delay)); +} + +static struct led_timer *led_new_timer(struct led_classdev *led_cdev) +{ + struct led_timer *led; + unsigned long flags; + + led = kzalloc(sizeof(struct led_timer), GFP_ATOMIC); + if (!led) + return NULL; + + led->cdev = led_cdev; + init_timer(&led->blink_timer); + led->blink_timer.function = led_timer_function; + led->blink_timer.data = (unsigned long) led; + + spin_lock_irqsave(&led_lock, flags); + list_add(&led->list, &led_timers); + spin_unlock_irqrestore(&led_lock, flags); + + return led; +} + +void led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off) +{ + struct led_timer *led = led_get_timer(led_cdev); + int current_brightness; + + if (!led) { + led = led_new_timer(led_cdev); + if (!led) + return; + } + + /* blink with 1 Hz as default if nothing specified */ + if (!*delay_on && !*delay_off) + *delay_on = *delay_off = 500; + + if (led->blink_delay_on == *delay_on && + led->blink_delay_off == *delay_off) + return; + + current_brightness = led_cdev->brightness; + if (current_brightness) + led->blink_brightness = current_brightness; + if (!led->blink_brightness) + led->blink_brightness = led_cdev->max_brightness; + + led_stop_software_blink(led); + led->blink_delay_on = *delay_on; + led->blink_delay_off = *delay_off; + + /* never on - don't blink */ + if (!*delay_on) + return; + + /* never off - just set to brightness */ + if (!*delay_off) { + led_brightness_set(led_cdev, led->blink_brightness); + return; + } + + mod_timer(&led->blink_timer, jiffies + 1); +} +EXPORT_SYMBOL(led_blink_set); + +void compat_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +{ + struct led_timer *led = led_get_timer(led_cdev); + + if (led) + led_stop_software_blink(led); + + return led_cdev->brightness_set(led_cdev, brightness); +} +EXPORT_SYMBOL(compat_led_brightness_set); + +void compat_led_classdev_unregister(struct led_classdev *led_cdev) +{ + struct led_timer *led = led_get_timer(led_cdev); + unsigned long flags; + + if (led) { + del_timer_sync(&led->blink_timer); + spin_lock_irqsave(&led_lock, flags); + list_del(&led->list); + spin_unlock_irqrestore(&led_lock, flags); + kfree(led); + } + + led_classdev_unregister(led_cdev); +} +EXPORT_SYMBOL(compat_led_classdev_unregister); + +#endif diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 6c026a34..502d2b19 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) #include +#include #define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ @@ -93,6 +94,18 @@ int genl_unregister_family(struct genl_family *family); #define genl_register_mc_group(_fam, _grp) genl_register_mc_group(&(_fam)->family, _grp) #define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp) + +extern void led_blink_set(struct led_classdev *led_cdev, + unsigned long *delay_on, + unsigned long *delay_off); + +#define led_classdev_unregister compat_led_classdev_unregister +extern void compat_led_classdev_unregister(struct led_classdev *led_cdev); + +#define led_brightness_set compat_led_brightness_set +extern void compat_led_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 53f02799156e702e88bbf970797792dbfde99bba Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 28 Nov 2010 13:17:00 +0100 Subject: Felix's patch backported my software blink emulation, but if the kernel is 2.6.25 or newer we can also try the HW offload first. Signed-off-by: Johannes Berg --- compat/compat-2.6.37.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 669402d8..48707ff8 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -253,9 +253,16 @@ void led_blink_set(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - struct led_timer *led = led_get_timer(led_cdev); + struct led_timer *led; int current_brightness; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) + if (led_cdev->blink_set && + !led_cdev->blink_set(led_cdev, delay_on, delay_off)) + return; +#endif + + led = led_get_timer(led_cdev); if (!led) { led = led_new_timer(led_cdev); if (!led) -- cgit v1.2.3 From d4164510dfe7c71ea6f26e433be4b29959508b30 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 1 Dec 2010 16:03:29 +0100 Subject: compat: fix build with CONFIG_LEDS_CLASS=m Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.37.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 48707ff8..a522b4e5 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -152,7 +152,7 @@ int compat_genl_unregister_family(struct genl_family *family) } EXPORT_SYMBOL(compat_genl_unregister_family); -#ifdef CONFIG_LEDS_CLASS +#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) #undef led_brightness_set #undef led_classdev_unregister -- cgit v1.2.3 From 65ac8aa63aac94af782b98c44d6f432712834199 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 1 Dec 2010 16:03:30 +0100 Subject: compat: fix build for kernel <= 2.6.29 The max_brightness member in struct led_classdev was added in kernel 2.6.30, so use LED_FULL for older kernel versions. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.37.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index a522b4e5..8636c653 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -281,7 +281,11 @@ void led_blink_set(struct led_classdev *led_cdev, if (current_brightness) led->blink_brightness = current_brightness; if (!led->blink_brightness) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) led->blink_brightness = led_cdev->max_brightness; +#else + led->blink_brightness = LED_FULL; +#endif led_stop_software_blink(led); led->blink_delay_on = *delay_on; -- cgit v1.2.3 From 3547391afd58ff016adcf8c7ea8f5949cf88be41 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 13 Dec 2010 17:19:01 -0800 Subject: compat: backport PCI_EXP_LNKCTL_ES added for on 2.6.29 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index cce678f7..78b2d58d 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -17,6 +17,8 @@ #include #include +#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */ + /* * Older kernels do not have struct net_device_ops but what we can * do is just define the data structure and use a caller to let us -- cgit v1.2.3 From dbafa57910460edc809f62c4c7331af0800197e8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 17 Dec 2010 14:41:36 -0800 Subject: compat: backport skb_checksum_start_offset This is needed by atlx, atl1c and atl1e. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index dfc406e9..05211564 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) #include +#include /* * This is not part of The 2.6.37 kernel yet but we @@ -56,6 +57,11 @@ static inline unsigned long ewma_read(const struct ewma *avg) #define pr_warn pr_warning +static inline int skb_checksum_start_offset(const struct sk_buff *skb) +{ + return skb->csum_start - skb_headroom(skb); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 218ef1807396652f1d78aa3b74ca3d3197c59258 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 17 Dec 2010 14:41:37 -0800 Subject: compat backport no_printk This is needed by brcm80211. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.36.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 83b7f062..1f2f5076 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -90,6 +90,13 @@ struct pm_qos_request_list { #endif +/* + * Dummy printk for disabled debugging statements to use whilst maintaining + * gcc's format and side-effect checking. + */ +static inline __attribute__ ((format (printf, 1, 2))) +int no_printk(const char *s, ...) { return 0; } + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 64bcd1b74a292b6baadb5a9f7c63eac8bf45ea5d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 17 Dec 2010 14:41:38 -0800 Subject: compat: backport pci_is_pcie and pci_pcie_cap compat_is_pcie already did the same thing as pci_is_pcie, but this method is now in kernel so the mainline drivers should use this function instead of accessing the member in the struct directly. We backported this function for older kernels. pci_pcie_cap is used in rtlwifi so we also need this. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.24.c | 12 ------------ include/linux/compat-2.6.24.h | 3 --- include/linux/compat-2.6.33.h | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index a5c9c972..5e2a77d2 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -165,15 +165,3 @@ int eth_rebuild_header(struct sk_buff *skb) } EXPORT_SYMBOL(eth_rebuild_header); -/* 2.6.24 will introduce struct pci_dev is_pcie bit. To help - * with the compatibility code (compat.diff) being smaller, we provide a helper - * so in cases where that will be used we can simply slap ifdefs with this - * routine. Use compat_ prefex to not pollute namespace. */ -int compat_is_pcie(struct pci_dev *pdev) -{ - int cap; - cap = pci_find_capability(pdev, PCI_CAP_ID_EXP); - return cap ? 1 : 0; -} -EXPORT_SYMBOL(compat_is_pcie); - diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index f9c777ca..6e09530d 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -249,9 +249,6 @@ static inline int usb_endpoint_num(const struct usb_endpoint_descriptor *epd) return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; } -/* Helper to make struct pci_dev is_pcie compatibility code smaller */ -int compat_is_pcie(struct pci_dev *pdev); - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) */ #endif /* LINUX_26_24_COMPAT_H */ diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index c2dbc1ba..2ccf141d 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) #include +#include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) #include #include @@ -147,6 +148,37 @@ static inline void compat_kfifo_free(struct kfifo **fifo) { #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb) +/** + * pci_pcie_cap - get the saved PCIe capability offset + * @dev: PCI device + * + * PCIe capability offset is calculated at PCI device initialization + * time and saved in the data structure. This function returns saved + * PCIe capability offset. Using this instead of pci_find_capability() + * reduces unnecessary search in the PCI configuration space. If you + * need to calculate PCIe capability offset from raw device for some + * reasons, please use pci_find_capability() instead. + */ +static inline int pci_pcie_cap(struct pci_dev *dev) +{ + return pci_find_capability(dev, PCI_CAP_ID_EXP); +} + +/** + * pci_is_pcie - check if the PCI device is PCI Express capable + * @dev: PCI device + * + * Retrun true if the PCI device is PCI Express capable, false otherwise. + */ +static inline bool pci_is_pcie(struct pci_dev *dev) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) + return dev->is_pcie; +#else + return !!pci_pcie_cap(dev); +#endif +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From a313802fd5ebf370447e36f551e9b662e3cfe333 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 22 Dec 2010 21:37:20 +0100 Subject: Signed-off-by: Johannes Berg --- compat/compat-2.6.23.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index 87f2a8c8..67d00750 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -217,14 +217,6 @@ void __dev_set_rx_mode(struct net_device *dev) dev->set_multicast_list(dev); } -#ifndef HAVE_PCI_SET_MWI -int pci_try_set_mwi(struct pci_dev *dev) -{ - return 0; -} -EXPORT_SYMBOL(pci_try_set_mwi); -#else - /** * pci_try_set_mwi - enables memory-write-invalidate PCI transaction * @dev: the PCI device for which MWI is enabled @@ -236,7 +228,10 @@ EXPORT_SYMBOL(pci_try_set_mwi); */ int pci_try_set_mwi(struct pci_dev *dev) { - int rc = pci_set_mwi(dev); + int rc = 0; +#ifdef HAVE_PCI_SET_MWI + rc = pci_set_mwi(dev); +#endif return rc; } EXPORT_SYMBOL(pci_try_set_mwi); -- cgit v1.2.3 From d70640f0d55cfd3cd15f4b2901eeaf69b51b3fdd Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 22 Dec 2010 22:11:05 +0100 Subject: This has disappeared upstream and is no longer used. Signed-off-by: Johannes Berg --- compat/compat-2.6.24.c | 9 --------- include/linux/compat-2.6.24.h | 7 ------- 2 files changed, 16 deletions(-) diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index 5e2a77d2..b9ae16b8 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -18,15 +18,6 @@ struct net init_net; EXPORT_SYMBOL(init_net); -/* Part of net/ethernet/eth.c as of 2.6.24 */ -char *print_mac(char *buf, const u8 *addr) -{ - sprintf(buf, MAC_FMT, - addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); - return buf; -} -EXPORT_SYMBOL(print_mac); - /* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 6e09530d..456dcb6c 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -162,13 +162,6 @@ struct ssb_device_id { #define dev_get_by_index(a, b) dev_get_by_index(b) #define __dev_get_by_index(a, b) __dev_get_by_index(b) -/* - * Display a 6 byte device address (MAC) in a readable format. - */ -#define MAC_FMT "%02x:%02x:%02x:%02x:%02x:%02x" -extern char *print_mac(char *buf, const u8 *addr); -#define DECLARE_MAC_BUF(var) char var[18] __maybe_unused - extern int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len); -- cgit v1.2.3 From 454fb1a4a698bd2935af76800bc17e14b086476a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 1 Jan 2011 06:23:33 -0800 Subject: compat: backport pci_wake_from_d3 This is needed by atl1c. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.28.c | 22 ++++++++++++++++++++++ include/linux/compat-2.6.28.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 7a834d27..72c9e09d 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -439,3 +439,25 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, } EXPORT_SYMBOL(n_tty_ioctl_helper); +/** + * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold + * @dev: PCI device to prepare + * @enable: True to enable wake-up event generation; false to disable + * + * Many drivers want the device to wake up the system from D3_hot or D3_cold + * and this function allows them to set that up cleanly - pci_enable_wake() + * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI + * ordering constraints. + * + * This function only returns error code if the device is not capable of + * generating PME# from both D3_hot and D3_cold, and the platform is unable to + * enable wake-up power for it. + */ +int pci_wake_from_d3(struct pci_dev *dev, bool enable) +{ + return pci_pme_capable(dev, PCI_D3cold) ? + pci_enable_wake(dev, PCI_D3cold, enable) : + pci_enable_wake(dev, PCI_D3hot, enable); +} +EXPORT_SYMBOL(pci_wake_from_d3); + diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 1de39ad3..b9024d67 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -234,6 +234,8 @@ extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +int pci_wake_from_d3(struct pci_dev *dev, bool enable); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ -- cgit v1.2.3 From 51efcd7ba3a0f8a20cbadd61006c4ec901312b5b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 1 Jan 2011 06:23:34 -0800 Subject: compat: backport alloc_workqueue This is needed by rtlwifi. The function signature of __create_workqueue changed in kernel 2.6.28, so two different defines are needed. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.28.h | 2 ++ include/linux/compat-2.6.36.h | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index b9024d67..fdb8fb2c 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -236,6 +236,8 @@ extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, int pci_wake_from_d3(struct pci_dev *dev, bool enable); +#define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 1f2f5076..74d2309d 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -97,6 +97,10 @@ struct pm_qos_request_list { static inline __attribute__ ((format (printf, 1, 2))) int no_printk(const char *s, ...) { return 0; } +#ifndef alloc_workqueue +#define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From dcd6955e683d812efef2df62deb4d19d9a15339a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 1 Jan 2011 06:23:35 -0800 Subject: compat: add generic functions for suspend/resume This define is used to generate a suspend and a resume function for pci devices using the old power management interface. The new interface was introduced in kernel 2.6.29. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.29.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 78b2d58d..b4e12369 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -278,6 +278,36 @@ static inline struct net *read_pnet(struct net * const *pnet) extern int init_dummy_netdev(struct net_device *dev); +#define compat_pci_suspend(fn) \ + int fn##_compat(struct pci_dev *pdev, pm_message_t state) \ + { \ + int r; \ + \ + r = fn(&pdev->dev); \ + if (r) \ + return r; \ + \ + pci_save_state(pdev); \ + pci_disable_device(pdev); \ + pci_set_power_state(pdev, PCI_D3hot); \ + \ + return 0; \ + } + +#define compat_pci_resume(fn) \ + int fn##_compat(struct pci_dev *pdev) \ + { \ + int r; \ + \ + pci_set_power_state(pdev, PCI_D0); \ + r = pci_enable_device(pdev); \ + if (r) \ + return r; \ + pci_restore_state(pdev); \ + \ + return fn(&pdev->dev); \ + } + #else static inline void netdev_attach_ops(struct net_device *dev, @@ -285,6 +315,10 @@ static inline void netdev_attach_ops(struct net_device *dev, { dev->netdev_ops = ops; } + +#define compat_pci_suspend(fn) +#define compat_pci_resume(fn) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ #endif /* LINUX_26_29_COMPAT_H */ -- cgit v1.2.3 From 985cff1fe4ed1bc06e0e1d23c21ed27599a818c9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 6 Jan 2011 18:16:38 +0100 Subject: compat: backport kfifo This is a copy of the hole kfifo implementation from a recent kernel version. When we ship this implementation we do not have to backport any kfifo related stuff any more. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/kfifo.c | 608 ++++++++++++++++++++++++++++++ include/linux/compat-2.6.33.h | 41 -- include/linux/kfifo.h | 857 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 1466 insertions(+), 41 deletions(-) create mode 100644 compat/kfifo.c create mode 100644 include/linux/kfifo.h diff --git a/compat/Makefile b/compat/Makefile index 18a9afcc..9c042caa 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -2,6 +2,7 @@ obj-m += compat.o #compat-objs := obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o +obj-$(CONFIG_COMPAT_KFIFO) += kfifo.o compat-y += main.o diff --git a/compat/kfifo.c b/compat/kfifo.c new file mode 100644 index 00000000..01a0700e --- /dev/null +++ b/compat/kfifo.c @@ -0,0 +1,608 @@ +/* + * A generic kernel FIFO implementation + * + * Copyright (C) 2009/2010 Stefani Seibold + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include + +/* + * internal helper to calculate the unused elements in a fifo + */ +static inline unsigned int kfifo_unused(struct __kfifo *fifo) +{ + return (fifo->mask + 1) - (fifo->in - fifo->out); +} + +int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, + size_t esize, gfp_t gfp_mask) +{ + /* + * round down to the next power of 2, since our 'let the indices + * wrap' technique works only in this case. + */ + if (!is_power_of_2(size)) + size = rounddown_pow_of_two(size); + + fifo->in = 0; + fifo->out = 0; + fifo->esize = esize; + + if (size < 2) { + fifo->data = NULL; + fifo->mask = 0; + return -EINVAL; + } + + fifo->data = kmalloc(size * esize, gfp_mask); + + if (!fifo->data) { + fifo->mask = 0; + return -ENOMEM; + } + fifo->mask = size - 1; + + return 0; +} +EXPORT_SYMBOL(__kfifo_alloc); + +void __kfifo_free(struct __kfifo *fifo) +{ + kfree(fifo->data); + fifo->in = 0; + fifo->out = 0; + fifo->esize = 0; + fifo->data = NULL; + fifo->mask = 0; +} +EXPORT_SYMBOL(__kfifo_free); + +int __kfifo_init(struct __kfifo *fifo, void *buffer, + unsigned int size, size_t esize) +{ + size /= esize; + + if (!is_power_of_2(size)) + size = rounddown_pow_of_two(size); + + fifo->in = 0; + fifo->out = 0; + fifo->esize = esize; + fifo->data = buffer; + + if (size < 2) { + fifo->mask = 0; + return -EINVAL; + } + fifo->mask = size - 1; + + return 0; +} +EXPORT_SYMBOL(__kfifo_init); + +static void kfifo_copy_in(struct __kfifo *fifo, const void *src, + unsigned int len, unsigned int off) +{ + unsigned int size = fifo->mask + 1; + unsigned int esize = fifo->esize; + unsigned int l; + + off &= fifo->mask; + if (esize != 1) { + off *= esize; + size *= esize; + len *= esize; + } + l = min(len, size - off); + + memcpy(fifo->data + off, src, l); + memcpy(fifo->data, src + l, len - l); + /* + * make sure that the data in the fifo is up to date before + * incrementing the fifo->in index counter + */ + smp_wmb(); +} + +unsigned int __kfifo_in(struct __kfifo *fifo, + const void *buf, unsigned int len) +{ + unsigned int l; + + l = kfifo_unused(fifo); + if (len > l) + len = l; + + kfifo_copy_in(fifo, buf, len, fifo->in); + fifo->in += len; + return len; +} +EXPORT_SYMBOL(__kfifo_in); + +static void kfifo_copy_out(struct __kfifo *fifo, void *dst, + unsigned int len, unsigned int off) +{ + unsigned int size = fifo->mask + 1; + unsigned int esize = fifo->esize; + unsigned int l; + + off &= fifo->mask; + if (esize != 1) { + off *= esize; + size *= esize; + len *= esize; + } + l = min(len, size - off); + + memcpy(dst, fifo->data + off, l); + memcpy(dst + l, fifo->data, len - l); + /* + * make sure that the data is copied before + * incrementing the fifo->out index counter + */ + smp_wmb(); +} + +unsigned int __kfifo_out_peek(struct __kfifo *fifo, + void *buf, unsigned int len) +{ + unsigned int l; + + l = fifo->in - fifo->out; + if (len > l) + len = l; + + kfifo_copy_out(fifo, buf, len, fifo->out); + return len; +} +EXPORT_SYMBOL(__kfifo_out_peek); + +unsigned int __kfifo_out(struct __kfifo *fifo, + void *buf, unsigned int len) +{ + len = __kfifo_out_peek(fifo, buf, len); + fifo->out += len; + return len; +} +EXPORT_SYMBOL(__kfifo_out); + +static unsigned long kfifo_copy_from_user(struct __kfifo *fifo, + const void __user *from, unsigned int len, unsigned int off, + unsigned int *copied) +{ + unsigned int size = fifo->mask + 1; + unsigned int esize = fifo->esize; + unsigned int l; + unsigned long ret; + + off &= fifo->mask; + if (esize != 1) { + off *= esize; + size *= esize; + len *= esize; + } + l = min(len, size - off); + + ret = copy_from_user(fifo->data + off, from, l); + if (unlikely(ret)) + ret = DIV_ROUND_UP(ret + len - l, esize); + else { + ret = copy_from_user(fifo->data, from + l, len - l); + if (unlikely(ret)) + ret = DIV_ROUND_UP(ret, esize); + } + /* + * make sure that the data in the fifo is up to date before + * incrementing the fifo->in index counter + */ + smp_wmb(); + *copied = len - ret; + /* return the number of elements which are not copied */ + return ret; +} + +int __kfifo_from_user(struct __kfifo *fifo, const void __user *from, + unsigned long len, unsigned int *copied) +{ + unsigned int l; + unsigned long ret; + unsigned int esize = fifo->esize; + int err; + + if (esize != 1) + len /= esize; + + l = kfifo_unused(fifo); + if (len > l) + len = l; + + ret = kfifo_copy_from_user(fifo, from, len, fifo->in, copied); + if (unlikely(ret)) { + len -= ret; + err = -EFAULT; + } else + err = 0; + fifo->in += len; + return err; +} +EXPORT_SYMBOL(__kfifo_from_user); + +static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to, + unsigned int len, unsigned int off, unsigned int *copied) +{ + unsigned int l; + unsigned long ret; + unsigned int size = fifo->mask + 1; + unsigned int esize = fifo->esize; + + off &= fifo->mask; + if (esize != 1) { + off *= esize; + size *= esize; + len *= esize; + } + l = min(len, size - off); + + ret = copy_to_user(to, fifo->data + off, l); + if (unlikely(ret)) + ret = DIV_ROUND_UP(ret + len - l, esize); + else { + ret = copy_to_user(to + l, fifo->data, len - l); + if (unlikely(ret)) + ret = DIV_ROUND_UP(ret, esize); + } + /* + * make sure that the data is copied before + * incrementing the fifo->out index counter + */ + smp_wmb(); + *copied = len - ret; + /* return the number of elements which are not copied */ + return ret; +} + +int __kfifo_to_user(struct __kfifo *fifo, void __user *to, + unsigned long len, unsigned int *copied) +{ + unsigned int l; + unsigned long ret; + unsigned int esize = fifo->esize; + int err; + + if (esize != 1) + len /= esize; + + l = fifo->in - fifo->out; + if (len > l) + len = l; + ret = kfifo_copy_to_user(fifo, to, len, fifo->out, copied); + if (unlikely(ret)) { + len -= ret; + err = -EFAULT; + } else + err = 0; + fifo->out += len; + return err; +} +EXPORT_SYMBOL(__kfifo_to_user); + +static int setup_sgl_buf(struct scatterlist *sgl, void *buf, + int nents, unsigned int len) +{ + int n; + unsigned int l; + unsigned int off; + struct page *page; + + if (!nents) + return 0; + + if (!len) + return 0; + + n = 0; + page = virt_to_page(buf); + off = offset_in_page(buf); + l = 0; + + while (len >= l + PAGE_SIZE - off) { + struct page *npage; + + l += PAGE_SIZE; + buf += PAGE_SIZE; + npage = virt_to_page(buf); + if (page_to_phys(page) != page_to_phys(npage) - l) { + sg_set_page(sgl, page, l - off, off); + sgl = sg_next(sgl); + if (++n == nents || sgl == NULL) + return n; + page = npage; + len -= l - off; + l = off = 0; + } + } + sg_set_page(sgl, page, len, off); + return n + 1; +} + +static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, + int nents, unsigned int len, unsigned int off) +{ + unsigned int size = fifo->mask + 1; + unsigned int esize = fifo->esize; + unsigned int l; + unsigned int n; + + off &= fifo->mask; + if (esize != 1) { + off *= esize; + size *= esize; + len *= esize; + } + l = min(len, size - off); + + n = setup_sgl_buf(sgl, fifo->data + off, nents, l); + n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l); + + return n; +} + +unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len) +{ + unsigned int l; + + l = kfifo_unused(fifo); + if (len > l) + len = l; + + return setup_sgl(fifo, sgl, nents, len, fifo->in); +} +EXPORT_SYMBOL(__kfifo_dma_in_prepare); + +unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len) +{ + unsigned int l; + + l = fifo->in - fifo->out; + if (len > l) + len = l; + + return setup_sgl(fifo, sgl, nents, len, fifo->out); +} +EXPORT_SYMBOL(__kfifo_dma_out_prepare); + +unsigned int __kfifo_max_r(unsigned int len, size_t recsize) +{ + unsigned int max = (1 << (recsize << 3)) - 1; + + if (len > max) + return max; + return len; +} + +#define __KFIFO_PEEK(data, out, mask) \ + ((data)[(out) & (mask)]) +/* + * __kfifo_peek_n internal helper function for determinate the length of + * the next record in the fifo + */ +static unsigned int __kfifo_peek_n(struct __kfifo *fifo, size_t recsize) +{ + unsigned int l; + unsigned int mask = fifo->mask; + unsigned char *data = fifo->data; + + l = __KFIFO_PEEK(data, fifo->out, mask); + + if (--recsize) + l |= __KFIFO_PEEK(data, fifo->out + 1, mask) << 8; + + return l; +} + +#define __KFIFO_POKE(data, in, mask, val) \ + ( \ + (data)[(in) & (mask)] = (unsigned char)(val) \ + ) + +/* + * __kfifo_poke_n internal helper function for storeing the length of + * the record into the fifo + */ +static void __kfifo_poke_n(struct __kfifo *fifo, unsigned int n, size_t recsize) +{ + unsigned int mask = fifo->mask; + unsigned char *data = fifo->data; + + __KFIFO_POKE(data, fifo->in, mask, n); + + if (recsize > 1) + __KFIFO_POKE(data, fifo->in + 1, mask, n >> 8); +} + +unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize) +{ + return __kfifo_peek_n(fifo, recsize); +} +EXPORT_SYMBOL(__kfifo_len_r); + +unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, + unsigned int len, size_t recsize) +{ + if (len + recsize > kfifo_unused(fifo)) + return 0; + + __kfifo_poke_n(fifo, len, recsize); + + kfifo_copy_in(fifo, buf, len, fifo->in + recsize); + fifo->in += len + recsize; + return len; +} +EXPORT_SYMBOL(__kfifo_in_r); + +static unsigned int kfifo_out_copy_r(struct __kfifo *fifo, + void *buf, unsigned int len, size_t recsize, unsigned int *n) +{ + *n = __kfifo_peek_n(fifo, recsize); + + if (len > *n) + len = *n; + + kfifo_copy_out(fifo, buf, len, fifo->out + recsize); + return len; +} + +unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, void *buf, + unsigned int len, size_t recsize) +{ + unsigned int n; + + if (fifo->in == fifo->out) + return 0; + + return kfifo_out_copy_r(fifo, buf, len, recsize, &n); +} +EXPORT_SYMBOL(__kfifo_out_peek_r); + +unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf, + unsigned int len, size_t recsize) +{ + unsigned int n; + + if (fifo->in == fifo->out) + return 0; + + len = kfifo_out_copy_r(fifo, buf, len, recsize, &n); + fifo->out += n + recsize; + return len; +} +EXPORT_SYMBOL(__kfifo_out_r); + +void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize) +{ + unsigned int n; + + n = __kfifo_peek_n(fifo, recsize); + fifo->out += n + recsize; +} +EXPORT_SYMBOL(__kfifo_skip_r); + +int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from, + unsigned long len, unsigned int *copied, size_t recsize) +{ + unsigned long ret; + + len = __kfifo_max_r(len, recsize); + + if (len + recsize > kfifo_unused(fifo)) { + *copied = 0; + return 0; + } + + __kfifo_poke_n(fifo, len, recsize); + + ret = kfifo_copy_from_user(fifo, from, len, fifo->in + recsize, copied); + if (unlikely(ret)) { + *copied = 0; + return -EFAULT; + } + fifo->in += len + recsize; + return 0; +} +EXPORT_SYMBOL(__kfifo_from_user_r); + +int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, + unsigned long len, unsigned int *copied, size_t recsize) +{ + unsigned long ret; + unsigned int n; + + if (fifo->in == fifo->out) { + *copied = 0; + return 0; + } + + n = __kfifo_peek_n(fifo, recsize); + if (len > n) + len = n; + + ret = kfifo_copy_to_user(fifo, to, len, fifo->out + recsize, copied); + if (unlikely(ret)) { + *copied = 0; + return -EFAULT; + } + fifo->out += n + recsize; + return 0; +} +EXPORT_SYMBOL(__kfifo_to_user_r); + +unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) +{ + if (!nents) + BUG(); + + len = __kfifo_max_r(len, recsize); + + if (len + recsize > kfifo_unused(fifo)) + return 0; + + return setup_sgl(fifo, sgl, nents, len, fifo->in + recsize); +} +EXPORT_SYMBOL(__kfifo_dma_in_prepare_r); + +void __kfifo_dma_in_finish_r(struct __kfifo *fifo, + unsigned int len, size_t recsize) +{ + len = __kfifo_max_r(len, recsize); + __kfifo_poke_n(fifo, len, recsize); + fifo->in += len + recsize; +} +EXPORT_SYMBOL(__kfifo_dma_in_finish_r); + +unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) +{ + if (!nents) + BUG(); + + len = __kfifo_max_r(len, recsize); + + if (len + recsize > fifo->in - fifo->out) + return 0; + + return setup_sgl(fifo, sgl, nents, len, fifo->out + recsize); +} +EXPORT_SYMBOL(__kfifo_dma_out_prepare_r); + +void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize) +{ + unsigned int len; + + len = __kfifo_peek_n(fifo, recsize); + fifo->out += len + recsize; +} +EXPORT_SYMBOL(__kfifo_dma_out_finish_r); diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 2ccf141d..8aabda01 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -12,7 +12,6 @@ #include #include #endif -#include #include #define release_firmware compat_release_firmware @@ -92,46 +91,6 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, #endif /* CONFIG_PCCARD */ -/* Backport for kfifo - * kfifo_alloc and kfifo_free must be backported manually - */ -#define kfifo_in(a, b, c) __kfifo_put(*a, (unsigned char *)b, c) -#define kfifo_out(a, b, c) __kfifo_get(*a, (unsigned char *)b, c) -#define kfifo_len(a) __kfifo_len(*a) - -/** - * kfifo_is_empty - returns true if the fifo is empty - * @fifo: the fifo to be used. - */ -static inline __must_check int kfifo_is_empty(struct kfifo **fifo) -{ - return (*fifo)->in == (*fifo)->out; -} - -/** - * kfifo_size - returns the size of the fifo in bytes - * @fifo: the fifo to be used. - */ -static inline __must_check unsigned int kfifo_size(struct kfifo *fifo) -{ - return fifo->size; -} - -/** - * kfifo_is_full - returns true if the fifo is full - * @fifo: the fifo to be used. - */ -static inline __must_check int kfifo_is_full(struct kfifo **fifo) -{ - return kfifo_len(fifo) == kfifo_size(*fifo); -} - -static inline void compat_kfifo_free(struct kfifo **fifo) { - if (*fifo) - kfifo_free(*fifo); -} -#define kfifo_free compat_kfifo_free - /** * list_for_each_entry_continue_rcu - continue iteration over list of given type * @pos: the type * to use as a loop cursor. diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h new file mode 100644 index 00000000..e30bb546 --- /dev/null +++ b/include/linux/kfifo.h @@ -0,0 +1,857 @@ +#include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#include_next +#else +/* + * A generic kernel FIFO implementation + * + * Copyright (C) 2009/2010 Stefani Seibold + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef _LINUX_KFIFO_H +#define _LINUX_KFIFO_H + +/* + * How to porting drivers to the new generic FIFO API: + * + * - Modify the declaration of the "struct kfifo *" object into a + * in-place "struct kfifo" object + * - Init the in-place object with kfifo_alloc() or kfifo_init() + * Note: The address of the in-place "struct kfifo" object must be + * passed as the first argument to this functions + * - Replace the use of __kfifo_put into kfifo_in and __kfifo_get + * into kfifo_out + * - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get + * into kfifo_out_spinlocked + * Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc + * must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked + * as the last parameter + * - The formerly __kfifo_* functions are renamed into kfifo_* + */ + +/* + * Note about locking : There is no locking required until only * one reader + * and one writer is using the fifo and no kfifo_reset() will be * called + * kfifo_reset_out() can be safely used, until it will be only called + * in the reader thread. + * For multiple writer and one reader there is only a need to lock the writer. + * And vice versa for only one writer and multiple reader there is only a need + * to lock the reader. + */ + +#include +#include +#include +#include + +struct __kfifo { + unsigned int in; + unsigned int out; + unsigned int mask; + unsigned int esize; + void *data; +}; + +#define __STRUCT_KFIFO_COMMON(datatype, recsize, ptrtype) \ + union { \ + struct __kfifo kfifo; \ + datatype *type; \ + char (*rectype)[recsize]; \ + ptrtype *ptr; \ + const ptrtype *ptr_const; \ + } + +#define __STRUCT_KFIFO(type, size, recsize, ptrtype) \ +{ \ + __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \ + type buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \ +} + +#define STRUCT_KFIFO(type, size) \ + struct __STRUCT_KFIFO(type, size, 0, type) + +#define __STRUCT_KFIFO_PTR(type, recsize, ptrtype) \ +{ \ + __STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \ + type buf[0]; \ +} + +#define STRUCT_KFIFO_PTR(type) \ + struct __STRUCT_KFIFO_PTR(type, 0, type) + +/* + * define compatibility "struct kfifo" for dynamic allocated fifos + */ +struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void); + +#define STRUCT_KFIFO_REC_1(size) \ + struct __STRUCT_KFIFO(unsigned char, size, 1, void) + +#define STRUCT_KFIFO_REC_2(size) \ + struct __STRUCT_KFIFO(unsigned char, size, 2, void) + +/* + * define kfifo_rec types + */ +struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void); +struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void); + +/* + * helper macro to distinguish between real in place fifo where the fifo + * array is a part of the structure and the fifo type where the array is + * outside of the fifo structure. + */ +#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo)) + +/** + * DECLARE_KFIFO_PTR - macro to declare a fifo pointer object + * @fifo: name of the declared fifo + * @type: type of the fifo elements + */ +#define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo + +/** + * DECLARE_KFIFO - macro to declare a fifo object + * @fifo: name of the declared fifo + * @type: type of the fifo elements + * @size: the number of elements in the fifo, this must be a power of 2 + */ +#define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo + +/** + * INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO + * @fifo: name of the declared fifo datatype + */ +#define INIT_KFIFO(fifo) \ +(void)({ \ + typeof(&(fifo)) __tmp = &(fifo); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + __kfifo->in = 0; \ + __kfifo->out = 0; \ + __kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\ + __kfifo->esize = sizeof(*__tmp->buf); \ + __kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \ +}) + +/** + * DEFINE_KFIFO - macro to define and initialize a fifo + * @fifo: name of the declared fifo datatype + * @type: type of the fifo elements + * @size: the number of elements in the fifo, this must be a power of 2 + * + * Note: the macro can be used for global and local fifo data type variables. + */ +#define DEFINE_KFIFO(fifo, type, size) \ + DECLARE_KFIFO(fifo, type, size) = \ + (typeof(fifo)) { \ + { \ + { \ + .in = 0, \ + .out = 0, \ + .mask = __is_kfifo_ptr(&(fifo)) ? \ + 0 : \ + ARRAY_SIZE((fifo).buf) - 1, \ + .esize = sizeof(*(fifo).buf), \ + .data = __is_kfifo_ptr(&(fifo)) ? \ + NULL : \ + (fifo).buf, \ + } \ + } \ + } + + +static inline unsigned int __must_check +__kfifo_uint_must_check_helper(unsigned int val) +{ + return val; +} + +static inline int __must_check +__kfifo_int_must_check_helper(int val) +{ + return val; +} + +/** + * kfifo_initialized - Check if the fifo is initialized + * @fifo: address of the fifo to check + * + * Return %true if fifo is initialized, otherwise %false. + * Assumes the fifo was 0 before. + */ +#define kfifo_initialized(fifo) ((fifo)->kfifo.mask) + +/** + * kfifo_esize - returns the size of the element managed by the fifo + * @fifo: address of the fifo to be used + */ +#define kfifo_esize(fifo) ((fifo)->kfifo.esize) + +/** + * kfifo_recsize - returns the size of the record length field + * @fifo: address of the fifo to be used + */ +#define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype)) + +/** + * kfifo_size - returns the size of the fifo in elements + * @fifo: address of the fifo to be used + */ +#define kfifo_size(fifo) ((fifo)->kfifo.mask + 1) + +/** + * kfifo_reset - removes the entire fifo content + * @fifo: address of the fifo to be used + * + * Note: usage of kfifo_reset() is dangerous. It should be only called when the + * fifo is exclusived locked or when it is secured that no other thread is + * accessing the fifo. + */ +#define kfifo_reset(fifo) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + __tmp->kfifo.in = __tmp->kfifo.out = 0; \ +}) + +/** + * kfifo_reset_out - skip fifo content + * @fifo: address of the fifo to be used + * + * Note: The usage of kfifo_reset_out() is safe until it will be only called + * from the reader thread and there is only one concurrent reader. Otherwise + * it is dangerous and must be handled in the same way as kfifo_reset(). + */ +#define kfifo_reset_out(fifo) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + __tmp->kfifo.out = __tmp->kfifo.in; \ +}) + +/** + * kfifo_len - returns the number of used elements in the fifo + * @fifo: address of the fifo to be used + */ +#define kfifo_len(fifo) \ +({ \ + typeof((fifo) + 1) __tmpl = (fifo); \ + __tmpl->kfifo.in - __tmpl->kfifo.out; \ +}) + +/** + * kfifo_is_empty - returns true if the fifo is empty + * @fifo: address of the fifo to be used + */ +#define kfifo_is_empty(fifo) \ +({ \ + typeof((fifo) + 1) __tmpq = (fifo); \ + __tmpq->kfifo.in == __tmpq->kfifo.out; \ +}) + +/** + * kfifo_is_full - returns true if the fifo is full + * @fifo: address of the fifo to be used + */ +#define kfifo_is_full(fifo) \ +({ \ + typeof((fifo) + 1) __tmpq = (fifo); \ + kfifo_len(__tmpq) > __tmpq->kfifo.mask; \ +}) + +/** + * kfifo_avail - returns the number of unused elements in the fifo + * @fifo: address of the fifo to be used + */ +#define kfifo_avail(fifo) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmpq = (fifo); \ + const size_t __recsize = sizeof(*__tmpq->rectype); \ + unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \ + (__recsize) ? ((__avail <= __recsize) ? 0 : \ + __kfifo_max_r(__avail - __recsize, __recsize)) : \ + __avail; \ +}) \ +) + +/** + * kfifo_skip - skip output data + * @fifo: address of the fifo to be used + */ +#define kfifo_skip(fifo) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_skip_r(__kfifo, __recsize); \ + else \ + __kfifo->out++; \ +}) + +/** + * kfifo_peek_len - gets the size of the next fifo record + * @fifo: address of the fifo to be used + * + * This function returns the size of the next fifo record in number of bytes. + */ +#define kfifo_peek_len(fifo) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \ + __kfifo_len_r(__kfifo, __recsize); \ +}) \ +) + +/** + * kfifo_alloc - dynamically allocates a new fifo buffer + * @fifo: pointer to the fifo + * @size: the number of elements in the fifo, this must be a power of 2 + * @gfp_mask: get_free_pages mask, passed to kmalloc() + * + * This macro dynamically allocates a new fifo buffer. + * + * The numer of elements will be rounded-up to a power of 2. + * The fifo will be release with kfifo_free(). + * Return 0 if no error, otherwise an error code. + */ +#define kfifo_alloc(fifo, size, gfp_mask) \ +__kfifo_int_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + __is_kfifo_ptr(__tmp) ? \ + __kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \ + -EINVAL; \ +}) \ +) + +/** + * kfifo_free - frees the fifo + * @fifo: the fifo to be freed + */ +#define kfifo_free(fifo) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__is_kfifo_ptr(__tmp)) \ + __kfifo_free(__kfifo); \ +}) + +/** + * kfifo_init - initialize a fifo using a preallocated buffer + * @fifo: the fifo to assign the buffer + * @buffer: the preallocated buffer to be used + * @size: the size of the internal buffer, this have to be a power of 2 + * + * This macro initialize a fifo using a preallocated buffer. + * + * The numer of elements will be rounded-up to a power of 2. + * Return 0 if no error, otherwise an error code. + */ +#define kfifo_init(fifo, buffer, size) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + __is_kfifo_ptr(__tmp) ? \ + __kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \ + -EINVAL; \ +}) + +/** + * kfifo_put - put data into the fifo + * @fifo: address of the fifo to be used + * @val: the data to be added + * + * This macro copies the given value into the fifo. + * It returns 0 if the fifo was full. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_put(fifo, val) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((val) + 1) __val = (val); \ + unsigned int __ret; \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) { \ + typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \ + __dummy = (typeof(__val))NULL; \ + } \ + if (__recsize) \ + __ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \ + __recsize); \ + else { \ + __ret = !kfifo_is_full(__tmp); \ + if (__ret) { \ + (__is_kfifo_ptr(__tmp) ? \ + ((typeof(__tmp->type))__kfifo->data) : \ + (__tmp->buf) \ + )[__kfifo->in & __tmp->kfifo.mask] = \ + *(typeof(__tmp->type))__val; \ + smp_wmb(); \ + __kfifo->in++; \ + } \ + } \ + __ret; \ +}) + +/** + * kfifo_get - get data from the fifo + * @fifo: address of the fifo to be used + * @val: the var where to store the data to be added + * + * This macro reads the data from the fifo. + * It returns 0 if the fifo was empty. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_get(fifo, val) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((val) + 1) __val = (val); \ + unsigned int __ret; \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) \ + __val = (typeof(__tmp->ptr))0; \ + if (__recsize) \ + __ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \ + __recsize); \ + else { \ + __ret = !kfifo_is_empty(__tmp); \ + if (__ret) { \ + *(typeof(__tmp->type))__val = \ + (__is_kfifo_ptr(__tmp) ? \ + ((typeof(__tmp->type))__kfifo->data) : \ + (__tmp->buf) \ + )[__kfifo->out & __tmp->kfifo.mask]; \ + smp_wmb(); \ + __kfifo->out++; \ + } \ + } \ + __ret; \ +}) \ +) + +/** + * kfifo_peek - get data from the fifo without removing + * @fifo: address of the fifo to be used + * @val: the var where to store the data to be added + * + * This reads the data from the fifo without removing it from the fifo. + * It returns 0 if the fifo was empty. Otherwise it returns the number + * processed elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_peek(fifo, val) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((val) + 1) __val = (val); \ + unsigned int __ret; \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) \ + __val = (typeof(__tmp->ptr))NULL; \ + if (__recsize) \ + __ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \ + __recsize); \ + else { \ + __ret = !kfifo_is_empty(__tmp); \ + if (__ret) { \ + *(typeof(__tmp->type))__val = \ + (__is_kfifo_ptr(__tmp) ? \ + ((typeof(__tmp->type))__kfifo->data) : \ + (__tmp->buf) \ + )[__kfifo->out & __tmp->kfifo.mask]; \ + smp_wmb(); \ + } \ + } \ + __ret; \ +}) \ +) + +/** + * kfifo_in - put data into the fifo + * @fifo: address of the fifo to be used + * @buf: the data to be added + * @n: number of elements to be added + * + * This macro copies the given buffer into the fifo and returns the + * number of copied elements. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_in(fifo, buf, n) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((buf) + 1) __buf = (buf); \ + unsigned long __n = (n); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) { \ + typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \ + __dummy = (typeof(__buf))NULL; \ + } \ + (__recsize) ?\ + __kfifo_in_r(__kfifo, __buf, __n, __recsize) : \ + __kfifo_in(__kfifo, __buf, __n); \ +}) + +/** + * kfifo_in_spinlocked - put data into the fifo using a spinlock for locking + * @fifo: address of the fifo to be used + * @buf: the data to be added + * @n: number of elements to be added + * @lock: pointer to the spinlock to use for locking + * + * This macro copies the given values buffer into the fifo and returns the + * number of copied elements. + */ +#define kfifo_in_spinlocked(fifo, buf, n, lock) \ +({ \ + unsigned long __flags; \ + unsigned int __ret; \ + spin_lock_irqsave(lock, __flags); \ + __ret = kfifo_in(fifo, buf, n); \ + spin_unlock_irqrestore(lock, __flags); \ + __ret; \ +}) + +/* alias for kfifo_in_spinlocked, will be removed in a future release */ +#define kfifo_in_locked(fifo, buf, n, lock) \ + kfifo_in_spinlocked(fifo, buf, n, lock) + +/** + * kfifo_out - get data from the fifo + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * + * This macro get some data from the fifo and return the numbers of elements + * copied. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_out(fifo, buf, n) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((buf) + 1) __buf = (buf); \ + unsigned long __n = (n); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) { \ + typeof(__tmp->ptr) __dummy = NULL; \ + __buf = __dummy; \ + } \ + (__recsize) ?\ + __kfifo_out_r(__kfifo, __buf, __n, __recsize) : \ + __kfifo_out(__kfifo, __buf, __n); \ +}) \ +) + +/** + * kfifo_out_spinlocked - get data from the fifo using a spinlock for locking + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * @lock: pointer to the spinlock to use for locking + * + * This macro get the data from the fifo and return the numbers of elements + * copied. + */ +#define kfifo_out_spinlocked(fifo, buf, n, lock) \ +__kfifo_uint_must_check_helper( \ +({ \ + unsigned long __flags; \ + unsigned int __ret; \ + spin_lock_irqsave(lock, __flags); \ + __ret = kfifo_out(fifo, buf, n); \ + spin_unlock_irqrestore(lock, __flags); \ + __ret; \ +}) \ +) + +/* alias for kfifo_out_spinlocked, will be removed in a future release */ +#define kfifo_out_locked(fifo, buf, n, lock) \ + kfifo_out_spinlocked(fifo, buf, n, lock) + +/** + * kfifo_from_user - puts some data from user space into the fifo + * @fifo: address of the fifo to be used + * @from: pointer to the data to be added + * @len: the length of the data to be added + * @copied: pointer to output variable to store the number of copied bytes + * + * This macro copies at most @len bytes from the @from into the + * fifo, depending of the available space and returns -EFAULT/0. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_from_user(fifo, from, len, copied) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + const void __user *__from = (from); \ + unsigned int __len = (len); \ + unsigned int *__copied = (copied); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_from_user_r(__kfifo, __from, __len, __copied, __recsize) : \ + __kfifo_from_user(__kfifo, __from, __len, __copied); \ +}) \ +) + +/** + * kfifo_to_user - copies data from the fifo into user space + * @fifo: address of the fifo to be used + * @to: where the data must be copied + * @len: the size of the destination buffer + * @copied: pointer to output variable to store the number of copied bytes + * + * This macro copies at most @len bytes from the fifo into the + * @to buffer and returns -EFAULT/0. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_to_user(fifo, to, len, copied) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + void __user *__to = (to); \ + unsigned int __len = (len); \ + unsigned int *__copied = (copied); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \ + __kfifo_to_user(__kfifo, __to, __len, __copied); \ +}) \ +) + +/** + * kfifo_dma_in_prepare - setup a scatterlist for DMA input + * @fifo: address of the fifo to be used + * @sgl: pointer to the scatterlist array + * @nents: number of entries in the scatterlist array + * @len: number of elements to transfer + * + * This macro fills a scatterlist for DMA input. + * It returns the number entries in the scatterlist array. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct scatterlist *__sgl = (sgl); \ + int __nents = (nents); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ + __kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len); \ +}) + +/** + * kfifo_dma_in_finish - finish a DMA IN operation + * @fifo: address of the fifo to be used + * @len: number of bytes to received + * + * This macro finish a DMA IN operation. The in counter will be updated by + * the len parameter. No error checking will be done. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_in_finish(fifo, len) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \ + else \ + __kfifo->in += __len / sizeof(*__tmp->type); \ +}) + +/** + * kfifo_dma_out_prepare - setup a scatterlist for DMA output + * @fifo: address of the fifo to be used + * @sgl: pointer to the scatterlist array + * @nents: number of entries in the scatterlist array + * @len: number of elements to transfer + * + * This macro fills a scatterlist for DMA output which at most @len bytes + * to transfer. + * It returns the number entries in the scatterlist array. + * A zero means there is no space available and the scatterlist is not filled. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + struct scatterlist *__sgl = (sgl); \ + int __nents = (nents); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + (__recsize) ? \ + __kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \ + __kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len); \ +}) + +/** + * kfifo_dma_out_finish - finish a DMA OUT operation + * @fifo: address of the fifo to be used + * @len: number of bytes transferd + * + * This macro finish a DMA OUT operation. The out counter will be updated by + * the len parameter. No error checking will be done. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macros. + */ +#define kfifo_dma_out_finish(fifo, len) \ +(void)({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + unsigned int __len = (len); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (__recsize) \ + __kfifo_dma_out_finish_r(__kfifo, __recsize); \ + else \ + __kfifo->out += __len / sizeof(*__tmp->type); \ +}) + +/** + * kfifo_out_peek - gets some data from the fifo + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * + * This macro get the data from the fifo and return the numbers of elements + * copied. The data is not removed from the fifo. + * + * Note that with only one concurrent reader and one concurrent + * writer, you don't need extra locking to use these macro. + */ +#define kfifo_out_peek(fifo, buf, n) \ +__kfifo_uint_must_check_helper( \ +({ \ + typeof((fifo) + 1) __tmp = (fifo); \ + typeof((buf) + 1) __buf = (buf); \ + unsigned long __n = (n); \ + const size_t __recsize = sizeof(*__tmp->rectype); \ + struct __kfifo *__kfifo = &__tmp->kfifo; \ + if (0) { \ + typeof(__tmp->ptr) __dummy __attribute__ ((unused)) = NULL; \ + __buf = __dummy; \ + } \ + (__recsize) ? \ + __kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \ + __kfifo_out_peek(__kfifo, __buf, __n); \ +}) \ +) + +extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, + size_t esize, gfp_t gfp_mask); + +extern void __kfifo_free(struct __kfifo *fifo); + +extern int __kfifo_init(struct __kfifo *fifo, void *buffer, + unsigned int size, size_t esize); + +extern unsigned int __kfifo_in(struct __kfifo *fifo, + const void *buf, unsigned int len); + +extern unsigned int __kfifo_out(struct __kfifo *fifo, + void *buf, unsigned int len); + +extern int __kfifo_from_user(struct __kfifo *fifo, + const void __user *from, unsigned long len, unsigned int *copied); + +extern int __kfifo_to_user(struct __kfifo *fifo, + void __user *to, unsigned long len, unsigned int *copied); + +extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len); + +extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len); + +extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, + void *buf, unsigned int len); + +extern unsigned int __kfifo_in_r(struct __kfifo *fifo, + const void *buf, unsigned int len, size_t recsize); + +extern unsigned int __kfifo_out_r(struct __kfifo *fifo, + void *buf, unsigned int len, size_t recsize); + +extern int __kfifo_from_user_r(struct __kfifo *fifo, + const void __user *from, unsigned long len, unsigned int *copied, + size_t recsize); + +extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, + unsigned long len, unsigned int *copied, size_t recsize); + +extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); + +extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo, + unsigned int len, size_t recsize); + +extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); + +extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize); + +extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize); + +extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize); + +extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, + void *buf, unsigned int len, size_t recsize); + +extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize); + +#endif +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) */ -- cgit v1.2.3 From 4bf0115eb5f8b869231213604db8cabeaa9ee902 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 6 Jan 2011 12:46:26 -0800 Subject: compat: add check for CONFIG_COMPAT_KFIFO=m Signed-off-by: Luis R. Rodriguez --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 04877c54..9ff4611c 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,10 @@ ifneq ($(CONFIG_FW_LOADER),) endif endif +ifeq ($(CONFIG_COMPAT_KERNEL_36),y) + export CONFIG_COMPAT_KFIFO=m +endif #CONFIG_COMPAT_KERNEL_36 + obj-y += compat/ # This hack lets us put our include path first than the kernel's -- cgit v1.2.3 From 476130cf845cd49a19c9bbd1972154636858ab96 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Feb 2011 22:04:12 +0100 Subject: compat: backport alloc_ordered_workqueue This was moved from a patch in compat-wireless to this place. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 502d2b19..e993f753 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -106,6 +106,8 @@ extern void compat_led_classdev_unregister(struct led_classdev *led_cdev); extern void compat_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness); +#define alloc_ordered_workqueue(name, flags) create_singlethread_workqueue(name) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 236993030f0b793f398941a2e3365cf66589b76c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 1 Feb 2011 22:04:13 +0100 Subject: compat: add support for kernel 2.6.38 Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 17 ----------------- include/linux/compat-2.6.39.h | 27 +++++++++++++++++++++++++++ include/linux/compat-2.6.h | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 include/linux/compat-2.6.39.h diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 05211564..004fe274 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -8,23 +8,6 @@ #include #include -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - /* rename member in struct mmc_host in include/linux/mmc/host.h */ #define max_segs max_hw_segs diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h new file mode 100644 index 00000000..c0c98fdb --- /dev/null +++ b/include/linux/compat-2.6.39.h @@ -0,0 +1,27 @@ +#ifndef LINUX_26_39_COMPAT_H +#define LINUX_26_39_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ + +#endif /* LINUX_26_39_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 2706797c..478f833c 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -31,5 +31,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From d8e8bfe0a796ba032c9b2e817caed1137f2c01c9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 21 Feb 2011 14:32:22 -0800 Subject: compat: backport usb_pipe_endpoint() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.35.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index c4de1693..857a5217 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -7,6 +7,7 @@ #include #include #include +#include /* added on linux/kernel.h */ #define USHRT_MAX ((u16)(~0U)) @@ -31,6 +32,14 @@ extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); #define pm_qos_request(_qos) pm_qos_requirement(_qos) +static inline struct usb_host_endpoint * +usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) +{ + struct usb_host_endpoint **eps; + eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out; + return eps[usb_pipeendpoint(pipe)]; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 7c31a0c3a60724ba4415f5559c6424faf2e035c7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 21 Feb 2011 14:32:23 -0800 Subject: compat: backport tty_{lock,unlock,locked} Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.36.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 74d2309d..0e3b7747 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -9,6 +9,7 @@ #include #include #include +#include #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) @@ -101,6 +102,23 @@ int no_printk(const char *s, ...) { return 0; } #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0) #endif +#define EXTPROC 0200000 +#define TIOCPKT_IOCTL 64 + +static inline void tty_lock(void) __acquires(kernel_lock) +{ +#ifdef CONFIG_LOCK_KERNEL + /* kernel_locked is 1 for !CONFIG_LOCK_KERNEL */ + WARN_ON(kernel_locked()); +#endif + lock_kernel(); +} +static inline void tty_unlock(void) __releases(kernel_lock) +{ + unlock_kernel(); +} +#define tty_locked() (kernel_locked()) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From ec19f7ffdc262007a4b438c1bc105128039b2bd9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 21 Feb 2011 14:32:24 -0800 Subject: compat: backport tty_set_termios This code is copied from the kernel sources. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-2.6.39.c | 111 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.39.h | 7 +++ 3 files changed, 119 insertions(+) create mode 100644 compat/compat-2.6.39.c diff --git a/compat/Makefile b/compat/Makefile index 9c042caa..f87b024a 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -29,3 +29,4 @@ compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o compat-$(CONFIG_COMPAT_KERNEL_36) += compat-2.6.36.o compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o +compat-$(CONFIG_COMPAT_KERNEL_39) += compat-2.6.39.o diff --git a/compat/compat-2.6.39.c b/compat/compat-2.6.39.c new file mode 100644 index 00000000..c2966f71 --- /dev/null +++ b/compat/compat-2.6.39.c @@ -0,0 +1,111 @@ +/* + * Copyright 2011 Hauke Mehrtens + * + * 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.39. + */ + +#include +#include + +/* + * Termios Helper Methods + */ +static void unset_locked_termios(struct ktermios *termios, + struct ktermios *old, + struct ktermios *locked) +{ + int i; + +#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z))) + + if (!locked) { + printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n"); + return; + } + + NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag); + NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag); + NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag); + NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag); + termios->c_line = locked->c_line ? old->c_line : termios->c_line; + for (i = 0; i < NCCS; i++) + termios->c_cc[i] = locked->c_cc[i] ? + old->c_cc[i] : termios->c_cc[i]; + /* FIXME: What should we do for i/ospeed */ +} + +/** + * tty_set_termios - update termios values + * @tty: tty to update + * @new_termios: desired new value + * + * Perform updates to the termios values set on this terminal. There + * is a bit of layering violation here with n_tty in terms of the + * internal knowledge of this function. + * + * Locking: termios_mutex + */ +int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) +{ + struct ktermios old_termios; + struct tty_ldisc *ld; + unsigned long flags; + + /* + * Perform the actual termios internal changes under lock. + */ + + + /* FIXME: we need to decide on some locking/ordering semantics + for the set_termios notification eventually */ + mutex_lock(&tty->termios_mutex); + old_termios = *tty->termios; + *tty->termios = *new_termios; + unset_locked_termios(tty->termios, &old_termios, tty->termios_locked); + + /* See if packet mode change of state. */ + if (tty->link && tty->link->packet) { + int extproc = (old_termios.c_lflag & EXTPROC) | + (tty->termios->c_lflag & EXTPROC); + int old_flow = ((old_termios.c_iflag & IXON) && + (old_termios.c_cc[VSTOP] == '\023') && + (old_termios.c_cc[VSTART] == '\021')); + int new_flow = (I_IXON(tty) && + STOP_CHAR(tty) == '\023' && + START_CHAR(tty) == '\021'); + if ((old_flow != new_flow) || extproc) { + spin_lock_irqsave(&tty->ctrl_lock, flags); + if (old_flow != new_flow) { + tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); + if (new_flow) + tty->ctrl_status |= TIOCPKT_DOSTOP; + else + tty->ctrl_status |= TIOCPKT_NOSTOP; + } + if (extproc) + tty->ctrl_status |= TIOCPKT_IOCTL; + spin_unlock_irqrestore(&tty->ctrl_lock, flags); + wake_up_interruptible(&tty->link->read_wait); + } + } + + if (tty->ops->set_termios) + (*tty->ops->set_termios)(tty, &old_termios); + else + tty_termios_copy_hw(tty->termios, &old_termios); + + ld = tty_ldisc_ref(tty); + if (ld != NULL) { + if (ld->ops->set_termios) + (ld->ops->set_termios)(tty, &old_termios); + tty_ldisc_deref(ld); + } + mutex_unlock(&tty->termios_mutex); + return 0; +} +EXPORT_SYMBOL_GPL(tty_set_termios); + diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index c0c98fdb..1c7b322c 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -22,6 +24,11 @@ #define br_port_exists(dev) (dev->br_port) #endif +#define tiocmget(tty) tiocmget(tty, NULL) +#define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) + +extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ #endif /* LINUX_26_39_COMPAT_H */ -- cgit v1.2.3 From 6dae50166e03b355746a6d34d7c255c4abe9b97a Mon Sep 17 00:00:00 2001 From: Vasanthakumar Thiagarajan Date: Thu, 24 Feb 2011 15:39:31 -0800 Subject: compat: Define usleep_range(min, max) as msleep(max/1000) for <2.6.36 ops_flush() of ath9k uses usleep_range(). Signed-off-by: Vasanthakumar Thiagarajan --- include/linux/compat-2.6.36.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 0e3b7747..806993b2 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -119,6 +119,7 @@ static inline void tty_unlock(void) __releases(kernel_lock) } #define tty_locked() (kernel_locked()) +#define usleep_range(_min, _max) msleep((_max) / 1000) #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 6e14c4a4fb52ed3d359224ccb34c04484640920d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 27 Feb 2011 14:49:44 +0100 Subject: compat: add tty_set_termios only for kernel >= 2.6.27 tty_set_termios does not build with older kernel versions and is only needed by bluetooth which works only for kernel >= 2.6.27. Reported-by: Juan Carlos Garza Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.39.c | 2 ++ include/linux/compat-2.6.39.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compat/compat-2.6.39.c b/compat/compat-2.6.39.c index c2966f71..8d858776 100644 --- a/compat/compat-2.6.39.c +++ b/compat/compat-2.6.39.c @@ -11,6 +11,7 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) /* * Termios Helper Methods */ @@ -108,4 +109,5 @@ int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) return 0; } EXPORT_SYMBOL_GPL(tty_set_termios); +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 1c7b322c..0c4f0305 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -27,7 +27,9 @@ #define tiocmget(tty) tiocmget(tty, NULL) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ -- cgit v1.2.3 From 89e9cfba02399c3a639848973ca4d3f25bd2b680 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 30 Mar 2011 12:55:40 -0700 Subject: compat: backport IRQ namespace cleanup This backports this upstream patch: commit a0cd9ca2b907d7ee26575e7b63ac92dad768a75e Author: Thomas Gleixner Date: Thu Feb 10 11:36:33 2011 +0100 genirq: Namespace cleanup The irq namespace has become quite convoluted. My bad. Clean it up and deprecate the old functions. All new functions follow the scheme: irq number based: irq_set/get/xxx/_xxx(unsigned int irq, ...) irq_data based: irq_data_set/get/xxx/_xxx(struct irq_data *d, ....) irq_desc based: irq_desc_get_xxx(struct irq_desc *desc) Signed-off-by: Thomas Gleixner Cc: Thomas Gleixner Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.39.h | 76 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 0c4f0305..bf4442bf 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) #include +#include /* * This is not part of The 2.6.37 kernel yet but we @@ -31,6 +32,81 @@ extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ +static inline int irq_set_irq_wake(unsigned int irq, unsigned int on) +{ + return set_irq_wake(irq, on); +} +static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip) +{ + return set_irq_chip(irq, chip); +} +static inline int irq_set_handler_data(unsigned int irq, void *data) +{ + return set_irq_data(irq, data); +} +static inline int irq_set_chip_data(unsigned int irq, void *data) +{ + return set_irq_chip_data(irq, data); +} +static inline int irq_set_irq_type(unsigned int irq, unsigned int type) +{ + return set_irq_type(irq, type); +} +static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry) +{ + return set_irq_msi(irq, entry); +} +static inline struct irq_chip *irq_get_chip(unsigned int irq) +{ + return get_irq_chip(irq); +} +static inline void *irq_get_chip_data(unsigned int irq) +{ + return get_irq_chip_data(irq); +} +static inline void *irq_get_handler_data(unsigned int irq) +{ + return get_irq_data(irq); +} + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) +static inline void *irq_data_get_irq_handler_data(struct irq_data *d) +{ + return irq_data_get_irq_data(d); +} +#endif + +static inline struct msi_desc *irq_get_msi_desc(unsigned int irq) +{ + return get_irq_msi(irq); +} +static inline void irq_set_noprobe(unsigned int irq) +{ + set_irq_noprobe(irq); +} +static inline void irq_set_probe(unsigned int irq) +{ + set_irq_probe(irq); +} +static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc) +{ + return get_irq_desc_chip(desc); +} +static inline void *irq_desc_get_handler_data(struct irq_desc *desc) +{ + return get_irq_desc_data(desc); +} + +static inline void *irq_desc_get_chip_data(struct irq_desc *desc) +{ + return get_irq_desc_chip_data(desc); +} + +static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) +{ + return get_irq_desc_msi(desc); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ #endif /* LINUX_26_39_COMPAT_H */ -- cgit v1.2.3 From 844bd647e14ab1c39f8095f9ac7a5b3348a369fe Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 31 Mar 2011 09:21:32 -0700 Subject: compat: backport netdev_refcnt_read. Backport of upstream commit: 29b4433d991c88d86ca48a4c1cc33c671475be4b net: percpu net_device refcount Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index e993f753..cee23a89 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -108,6 +108,8 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev, #define alloc_ordered_workqueue(name, flags) create_singlethread_workqueue(name) +#define netdev_refcnt_read(a) atomic_read(&a->refcnt) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 2936c7cf5a570ad83e690bb0742972817d5da833 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 31 Mar 2011 09:21:33 -0700 Subject: compat: add support for kernel 2.6.39 Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.39.h | 17 ----------------- include/linux/compat-2.6.40.h | 27 +++++++++++++++++++++++++++ include/linux/compat-2.6.h | 1 + 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 include/linux/compat-2.6.40.h diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index bf4442bf..2c62d90e 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -8,23 +8,6 @@ #include #include -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - #define tiocmget(tty) tiocmget(tty, NULL) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) diff --git a/include/linux/compat-2.6.40.h b/include/linux/compat-2.6.40.h new file mode 100644 index 00000000..42f9feeb --- /dev/null +++ b/include/linux/compat-2.6.40.h @@ -0,0 +1,27 @@ +#ifndef LINUX_26_40_COMPAT_H +#define LINUX_26_40_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */ + +#endif /* LINUX_26_40_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 478f833c..8e45fc06 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -32,5 +32,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From dbadbde6593e36f16bdd0788e5c68f91b7989259 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 31 Mar 2011 09:21:34 -0700 Subject: compat: fix build for kernel < 2.6.29 get_irq_desc_chip(), get_irq_desc_data(), get_irq_desc_chip_data() and get_irq_desc_msi() are not available in kernel < 2.6.29. Luis please add this into the linux-2.6.39.y branch. Cc: Thomas Gleixner Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.39.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 2c62d90e..104fce09 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -71,6 +71,8 @@ static inline void irq_set_probe(unsigned int irq) { set_irq_probe(irq); } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc) { return get_irq_desc_chip(desc); @@ -89,6 +91,7 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) { return get_irq_desc_msi(desc); } +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ -- cgit v1.2.3 From c932d9783a3b6a21e7b6199cb037caaca9b6b1e8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 31 Mar 2011 09:21:35 -0700 Subject: compat: semaphore.h mpoved from asm/ to linux/ In kernel <= 2.6.25 linux/semaphore.h does not exist. Signed-off-by: Hauke Mehrtens --- include/linux/semaphore.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/linux/semaphore.h diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h new file mode 100644 index 00000000..78af4db3 --- /dev/null +++ b/include/linux/semaphore.h @@ -0,0 +1,12 @@ +#ifndef _COMPAT_LINUX_SEMAPHORE_H +#define _COMPAT_LINUX_SEMAPHORE_H 1 + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) +#include_next +#else +#include +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */ + +#endif /* _COMPAT_LINUX_SEMAPHORE_H */ -- cgit v1.2.3 From 65ccfe67dececa0ab142da06e2b2df69c1536664 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Apr 2011 16:39:16 +0200 Subject: compat: integrate kfifo into compat.ko Signed-off-by: Hauke Mehrtens --- compat/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index f87b024a..f92ac349 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -2,7 +2,6 @@ obj-m += compat.o #compat-objs := obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o -obj-$(CONFIG_COMPAT_KFIFO) += kfifo.o compat-y += main.o @@ -14,7 +13,6 @@ compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o - compat-$(CONFIG_COMPAT_KERNEL_25) += \ compat-2.6.25.o \ pm_qos_params.o @@ -26,7 +24,10 @@ compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o -compat-$(CONFIG_COMPAT_KERNEL_36) += compat-2.6.36.o +compat-$(CONFIG_COMPAT_KERNEL_36) += \ + compat-2.6.36.o \ + kfifo.o + compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o compat-$(CONFIG_COMPAT_KERNEL_39) += compat-2.6.39.o -- cgit v1.2.3 From 60d4de5fbfc60c3f192abf249f51ec9ad3d62e42 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Apr 2011 16:39:17 +0200 Subject: compat: add kstrtox compat/kstrtox.c is copied from lib/kstrtox.c in the Linux kernel. This is needed by some drivers now. For kernel < 2.6.26 div_u64 needs to be backported. We should not copy the files like kstrtox.c, kfifo.c and so on to compat/ by hand, but copy them when creating compat-wireless along with the wireless drivers. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 5 +- compat/kstrtox.c | 227 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.26.h | 44 ++++++++ include/linux/compat-2.6.39.h | 61 ++++++++++++ include/linux/math64.h | 10 ++ 5 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 compat/kstrtox.c create mode 100644 include/linux/math64.h diff --git a/compat/Makefile b/compat/Makefile index f92ac349..ddfd88de 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -30,4 +30,7 @@ compat-$(CONFIG_COMPAT_KERNEL_36) += \ compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o -compat-$(CONFIG_COMPAT_KERNEL_39) += compat-2.6.39.o +compat-$(CONFIG_COMPAT_KERNEL_39) += \ + compat-2.6.39.o \ + kstrtox.o + diff --git a/compat/kstrtox.c b/compat/kstrtox.c new file mode 100644 index 00000000..05672e81 --- /dev/null +++ b/compat/kstrtox.c @@ -0,0 +1,227 @@ +/* + * Convert integer string representation to an integer. + * If an integer doesn't fit into specified type, -E is returned. + * + * Integer starts with optional sign. + * kstrtou*() functions do not accept sign "-". + * + * Radix 0 means autodetection: leading "0x" implies radix 16, + * leading "0" implies radix 8, otherwise radix is 10. + * Autodetection hints work after optional sign, but not before. + * + * If -E is returned, result is not touched. + */ +#include +#include +#include +#include +#include +#include + +static inline char _tolower(const char c) +{ + return c | 0x20; +} + +static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) +{ + unsigned long long acc; + int ok; + + if (base == 0) { + if (s[0] == '0') { + if (_tolower(s[1]) == 'x' && isxdigit(s[2])) + base = 16; + else + base = 8; + } else + base = 10; + } + if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') + s += 2; + + acc = 0; + ok = 0; + while (*s) { + unsigned int val; + + if ('0' <= *s && *s <= '9') + val = *s - '0'; + else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') + val = _tolower(*s) - 'a' + 10; + else if (*s == '\n') { + if (*(s + 1) == '\0') + break; + else + return -EINVAL; + } else + return -EINVAL; + + if (val >= base) + return -EINVAL; + if (acc > div_u64(ULLONG_MAX - val, base)) + return -ERANGE; + acc = acc * base + val; + ok = 1; + + s++; + } + if (!ok) + return -EINVAL; + *res = acc; + return 0; +} + +int kstrtoull(const char *s, unsigned int base, unsigned long long *res) +{ + if (s[0] == '+') + s++; + return _kstrtoull(s, base, res); +} +EXPORT_SYMBOL(kstrtoull); + +int kstrtoll(const char *s, unsigned int base, long long *res) +{ + unsigned long long tmp; + int rv; + + if (s[0] == '-') { + rv = _kstrtoull(s + 1, base, &tmp); + if (rv < 0) + return rv; + if ((long long)(-tmp) >= 0) + return -ERANGE; + *res = -tmp; + } else { + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if ((long long)tmp < 0) + return -ERANGE; + *res = tmp; + } + return 0; +} +EXPORT_SYMBOL(kstrtoll); + +/* Internal, do not use. */ +int _kstrtoul(const char *s, unsigned int base, unsigned long *res) +{ + unsigned long long tmp; + int rv; + + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (unsigned long long)(unsigned long)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(_kstrtoul); + +/* Internal, do not use. */ +int _kstrtol(const char *s, unsigned int base, long *res) +{ + long long tmp; + int rv; + + rv = kstrtoll(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (long long)(long)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(_kstrtol); + +int kstrtouint(const char *s, unsigned int base, unsigned int *res) +{ + unsigned long long tmp; + int rv; + + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (unsigned long long)(unsigned int)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtouint); + +int kstrtoint(const char *s, unsigned int base, int *res) +{ + long long tmp; + int rv; + + rv = kstrtoll(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (long long)(int)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtoint); + +int kstrtou16(const char *s, unsigned int base, u16 *res) +{ + unsigned long long tmp; + int rv; + + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (unsigned long long)(u16)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtou16); + +int kstrtos16(const char *s, unsigned int base, s16 *res) +{ + long long tmp; + int rv; + + rv = kstrtoll(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (long long)(s16)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtos16); + +int kstrtou8(const char *s, unsigned int base, u8 *res) +{ + unsigned long long tmp; + int rv; + + rv = kstrtoull(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (unsigned long long)(u8)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtou8); + +int kstrtos8(const char *s, unsigned int base, s8 *res) +{ + long long tmp; + int rv; + + rv = kstrtoll(s, base, &tmp); + if (rv < 0) + return rv; + if (tmp != (long long)(s8)tmp) + return -ERANGE; + *res = tmp; + return 0; +} +EXPORT_SYMBOL(kstrtos8); diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 30ee46c0..9a67e9d6 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -16,6 +16,7 @@ #endif #include #include +#include /* These jiffie helpers added as of 2.6.26 */ @@ -403,6 +404,49 @@ static inline void pci_disable_link_state(struct pci_dev *pdev, int state) } /* source: include/linux/pci-aspm.h */ + +#if BITS_PER_LONG == 64 + +/** + * div_u64_rem - unsigned 64bit divide with 32bit divisor with remainder + * + * This is commonly provided by 32bit archs to provide an optimized 64bit + * divide. + */ +static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) +{ + *remainder = dividend % divisor; + return dividend / divisor; +} + +#elif BITS_PER_LONG == 32 + +#ifndef div_u64_rem +static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder) +{ + *remainder = do_div(dividend, divisor); + return dividend; +} +#endif + +#endif /* BITS_PER_LONG */ + +/** + * div_u64 - unsigned 64bit divide with 32bit divisor + * + * This is the most common 64bit divide and should be used if possible, + * as many 32bit archs can optimize this variant better than a full 64bit + * divide. + */ +#ifndef div_u64 +static inline u64 div_u64(u64 dividend, u32 divisor) +{ + u32 remainder; + return div_u64_rem(dividend, divisor, &remainder); +} +#endif +/* source: include/math64.h */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ #endif /* LINUX_26_26_COMPAT_H */ diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 104fce09..3a366e29 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -7,6 +7,7 @@ #include #include +#include #define tiocmget(tty) tiocmget(tty, NULL) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) @@ -93,6 +94,66 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) } #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */ +/* Internal, do not use. */ +int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); +int __must_check _kstrtol(const char *s, unsigned int base, long *res); + +int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res); +int __must_check kstrtoll(const char *s, unsigned int base, long long *res); +static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res) +{ + /* + * We want to shortcut function call, but + * __builtin_types_compatible_p(unsigned long, unsigned long long) = 0. + */ + if (sizeof(unsigned long) == sizeof(unsigned long long) && + __alignof__(unsigned long) == __alignof__(unsigned long long)) + return kstrtoull(s, base, (unsigned long long *)res); + else + return _kstrtoul(s, base, res); +} + +static inline int __must_check kstrtol(const char *s, unsigned int base, long *res) +{ + /* + * We want to shortcut function call, but + * __builtin_types_compatible_p(long, long long) = 0. + */ + if (sizeof(long) == sizeof(long long) && + __alignof__(long) == __alignof__(long long)) + return kstrtoll(s, base, (long long *)res); + else + return _kstrtol(s, base, res); +} + +int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res); +int __must_check kstrtoint(const char *s, unsigned int base, int *res); + +static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res) +{ + return kstrtoull(s, base, res); +} + +static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res) +{ + return kstrtoll(s, base, res); +} + +static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res) +{ + return kstrtouint(s, base, res); +} + +static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res) +{ + return kstrtoint(s, base, res); +} + +int __must_check kstrtou16(const char *s, unsigned int base, u16 *res); +int __must_check kstrtos16(const char *s, unsigned int base, s16 *res); +int __must_check kstrtou8(const char *s, unsigned int base, u8 *res); +int __must_check kstrtos8(const char *s, unsigned int base, s8 *res); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ #endif /* LINUX_26_39_COMPAT_H */ diff --git a/include/linux/math64.h b/include/linux/math64.h new file mode 100644 index 00000000..eb9e8e15 --- /dev/null +++ b/include/linux/math64.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_LINUX_MATH64_H +#define _COMPAT_LINUX_MATH64_H 1 + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */ + +#endif /* _COMPAT_LINUX_MATH64_H */ -- cgit v1.2.3 From be5674a947b35ae18938d63402fce4aefcca4800 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 7 Apr 2011 16:39:18 +0200 Subject: compat: remove sdio_set_host_pm_flags Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 93fc4ef7..f6ffde06 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -243,6 +243,9 @@ static inline int usb_enable_autosuspend(struct usb_device *udev) static inline int usb_disable_autosuspend(struct usb_device *udev) { return 0; } +#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ +#define sdio_set_host_pm_flags(a, b) 0 + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 98d6ba708cc6f295b126dee35a2c96ed23f24148 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 20 Apr 2011 23:31:50 +0200 Subject: compat: add time_to_tm time_to_tm is needed in net/mac80211/debugfs_sta.c now. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.32.c | 97 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.32.h | 28 +++++++++++++ 2 files changed, 125 insertions(+) diff --git a/compat/compat-2.6.32.c b/compat/compat-2.6.32.c index 013150d0..0b3af074 100644 --- a/compat/compat-2.6.32.c +++ b/compat/compat-2.6.32.c @@ -117,3 +117,100 @@ void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, } EXPORT_SYMBOL_GPL(__dev_addr_unsync); +/* + * Nonzero if YEAR is a leap year (every 4 years, + * except every 100th isn't, and every 400th is). + */ +static int __isleap(long year) +{ + return (year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0); +} + +/* do a mathdiv for long type */ +static long math_div(long a, long b) +{ + return a / b - (a % b < 0); +} + +/* How many leap years between y1 and y2, y1 must less or equal to y2 */ +static long leaps_between(long y1, long y2) +{ + long leaps1 = math_div(y1 - 1, 4) - math_div(y1 - 1, 100) + + math_div(y1 - 1, 400); + long leaps2 = math_div(y2 - 1, 4) - math_div(y2 - 1, 100) + + math_div(y2 - 1, 400); + return leaps2 - leaps1; +} + +/* How many days come before each month (0-12). */ +static const unsigned short __mon_yday[2][13] = { + /* Normal years. */ + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + /* Leap years. */ + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} +}; + +#define SECS_PER_HOUR (60 * 60) +#define SECS_PER_DAY (SECS_PER_HOUR * 24) + +/** + * time_to_tm - converts the calendar time to local broken-down time + * + * @totalsecs the number of seconds elapsed since 00:00:00 on January 1, 1970, + * Coordinated Universal Time (UTC). + * @offset offset seconds adding to totalsecs. + * @result pointer to struct tm variable to receive broken-down time + */ +void time_to_tm(time_t totalsecs, int offset, struct tm *result) +{ + long days, rem, y; + const unsigned short *ip; + + days = totalsecs / SECS_PER_DAY; + rem = totalsecs % SECS_PER_DAY; + rem += offset; + while (rem < 0) { + rem += SECS_PER_DAY; + --days; + } + while (rem >= SECS_PER_DAY) { + rem -= SECS_PER_DAY; + ++days; + } + + result->tm_hour = rem / SECS_PER_HOUR; + rem %= SECS_PER_HOUR; + result->tm_min = rem / 60; + result->tm_sec = rem % 60; + + /* January 1, 1970 was a Thursday. */ + result->tm_wday = (4 + days) % 7; + if (result->tm_wday < 0) + result->tm_wday += 7; + + y = 1970; + + while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { + /* Guess a corrected year, assuming 365 days per year. */ + long yg = y + math_div(days, 365); + + /* Adjust DAYS and Y to match the guessed year. */ + days -= (yg - y) * 365 + leaps_between(y, yg); + y = yg; + } + + result->tm_year = y - 1900; + + result->tm_yday = days; + + ip = __mon_yday[__isleap(y)]; + for (y = 11; days < ip[y]; y--) + continue; + days -= ip[y]; + + result->tm_mon = y; + result->tm_mday = days + 1; +} +EXPORT_SYMBOL(time_to_tm); +/* source: kernel/time/timeconv.c*/ + diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 321a89ad..3506291d 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -96,6 +96,34 @@ struct dev_pm_ops name = { \ #define lockdep_assert_held(l) do { } while (0) +/* + * Similar to the struct tm in userspace , but it needs to be here so + * that the kernel source is self contained. + */ +struct tm { + /* + * the number of seconds after the minute, normally in the range + * 0 to 59, but can be up to 60 to allow for leap seconds + */ + int tm_sec; + /* the number of minutes after the hour, in the range 0 to 59*/ + int tm_min; + /* the number of hours past midnight, in the range 0 to 23 */ + int tm_hour; + /* the day of the month, in the range 1 to 31 */ + int tm_mday; + /* the number of months since January, in the range 0 to 11 */ + int tm_mon; + /* the number of years since 1900 */ + long tm_year; + /* the number of days since Sunday, in the range 0 to 6 */ + int tm_wday; + /* the number of days since January 1, in the range 0 to 365 */ + int tm_yday; +}; + +void time_to_tm(time_t totalsecs, int offset, struct tm *result); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ #endif /* LINUX_26_32_COMPAT_H */ -- cgit v1.2.3 From c9a8b44cf462694c22f1754400733fa0469701b3 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 24 Apr 2011 18:11:14 +0200 Subject: compat: do not include kstrto* for kernel >= 2.6.38.4 kstrto* went into kernel 2.6.38.4 and causes conflicts with the version included in compat-wireless. We use strict_strtol to check if kstrto* is already available. kstrto* was not moved to compat-2.6.38.h because kernel version <= 2.6.38.3 needs this backport and some distributions like Ubuntu still ship an older version of this kernel. Reported-by: Andreas Hartmann Signed-off-by: Hauke Mehrtens --- compat/kstrtox.c | 9 +++++++++ include/linux/compat-2.6.39.h | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/compat/kstrtox.c b/compat/kstrtox.c index 05672e81..10aa91b4 100644 --- a/compat/kstrtox.c +++ b/compat/kstrtox.c @@ -11,6 +11,14 @@ * * If -E is returned, result is not touched. */ +#include +/* + * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the + * version included in compat-wireless. We use strict_strtol to check if + * kstrto* is already available. + */ +#ifndef strict_strtol + #include #include #include @@ -225,3 +233,4 @@ int kstrtos8(const char *s, unsigned int base, s8 *res) return 0; } EXPORT_SYMBOL(kstrtos8); +#endif /* #ifndef strict_strtol */ diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 3a366e29..b4d85fdb 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -94,6 +94,12 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) } #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */ +/* + * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the + * version included in compat-wireless. We use strict_strtol to check if + * kstrto* is already available. + */ +#ifndef strict_strtol /* Internal, do not use. */ int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); int __must_check _kstrtol(const char *s, unsigned int base, long *res); @@ -153,6 +159,7 @@ int __must_check kstrtou16(const char *s, unsigned int base, u16 *res); int __must_check kstrtos16(const char *s, unsigned int base, s16 *res); int __must_check kstrtou8(const char *s, unsigned int base, u8 *res); int __must_check kstrtos8(const char *s, unsigned int base, s8 *res); +#endif /* ifndef strict_strtol */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */ -- cgit v1.2.3 From d771b0f4787f3358afdfbd53fea26baf265fd67c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 24 Apr 2011 18:11:15 +0200 Subject: compat: fix TASK_INTERRUPTIBLE missing When compiling against the Ubuntu Natty kernel (2.6.38-8-generic) TASK_INTERRUPTIBLE is not defined here. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.39.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-2.6.39.c b/compat/compat-2.6.39.c index 8d858776..5bb93221 100644 --- a/compat/compat-2.6.39.c +++ b/compat/compat-2.6.39.c @@ -10,6 +10,7 @@ #include #include +#include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) /* -- cgit v1.2.3 From 37ffaa79245035655920cdfc5747011285e7c58b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 27 Apr 2011 20:04:16 +0200 Subject: compat: backport vzalloc() vzalloc() is used in rtl8192ce now. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.37.c | 19 +++++++++++++++++++ include/linux/compat-2.6.37.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 8636c653..c49efeaf 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -334,4 +334,23 @@ void compat_led_classdev_unregister(struct led_classdev *led_cdev) } EXPORT_SYMBOL(compat_led_classdev_unregister); +/** + * vzalloc - allocate virtually contiguous memory with zero fill + * @size: allocation size + * Allocate enough pages to cover @size from the page level + * allocator and map them into contiguous kernel virtual space. + * The memory allocated is set to zero. + * + * For tight control over page level allocator and protection flags + * use __vmalloc() instead. + */ +void *vzalloc(unsigned long size) +{ + void *buf; + buf = vmalloc(size); + memset(buf, 0, size); + return buf; +} +EXPORT_SYMBOL(vzalloc); + #endif diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index cee23a89..57868f52 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -110,6 +110,8 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev, #define netdev_refcnt_read(a) atomic_read(&a->refcnt) +extern void *vzalloc(unsigned long size); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From b2299b6c5978a12ea06df1c6a66d64179ca68f5e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 27 Apr 2011 21:01:22 +0200 Subject: compat: handle fail of vmalloc() Only memset the memory if we get a valid pointer. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.37.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index c49efeaf..8698e1dc 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -348,7 +348,8 @@ void *vzalloc(unsigned long size) { void *buf; buf = vmalloc(size); - memset(buf, 0, size); + if (buf) + memset(buf, 0, size); return buf; } EXPORT_SYMBOL(vzalloc); -- cgit v1.2.3 From fabcc6f5a62fbceed6c8e8315eaaf94b0ca576cf Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 10 May 2011 13:10:14 +0200 Subject: compat: add missing include Reported-By: George Nychis Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.37.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 8698e1dc..a62b13fc 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -12,6 +12,7 @@ #include #include #include +#include #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) static const void *net_current_ns(void) -- cgit v1.2.3 From d58ef50c2b6f349d6acaaed75dde51b5cd4d69cb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 10 May 2011 13:10:15 +0200 Subject: compat: backport kfree_rcu Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.40.h | 60 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/include/linux/compat-2.6.40.h b/include/linux/compat-2.6.40.h index 42f9feeb..9ec8c1b1 100644 --- a/include/linux/compat-2.6.40.h +++ b/include/linux/compat-2.6.40.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -22,6 +24,64 @@ #define br_port_exists(dev) (dev->br_port) #endif +static __always_inline bool __is_kfree_rcu_offset(unsigned long offset) +{ + return offset < 4096; +} + +static __always_inline +void __kfree_rcu(struct rcu_head *head, unsigned long offset) +{ + typedef void (*rcu_callback)(struct rcu_head *); + + /* This causes build failures with some kernel versions at positions + * where this methods is not used at all. + */ + /* BUILD_BUG_ON(!__builtin_constant_p(offset)); */ + + /* See the kfree_rcu() header comment. */ + /* BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); */ + + call_rcu(head, (rcu_callback)offset); +} + +static inline void __rcu_reclaim(struct rcu_head *head) +{ + unsigned long offset = (unsigned long)head->func; + + if (__is_kfree_rcu_offset(offset)) + kfree((void *)head - offset); + else + head->func(head); +} + +/** + * kfree_rcu() - kfree an object after a grace period. + * @ptr: pointer to kfree + * @rcu_head: the name of the struct rcu_head within the type of @ptr. + * + * Many rcu callbacks functions just call kfree() on the base structure. + * These functions are trivial, but their size adds up, and furthermore + * when they are used in a kernel module, that module must invoke the + * high-latency rcu_barrier() function at module-unload time. + * + * The kfree_rcu() function handles this issue. Rather than encoding a + * function address in the embedded rcu_head structure, kfree_rcu() instead + * encodes the offset of the rcu_head structure within the base structure. + * Because the functions are not allowed in the low-order 4096 bytes of + * kernel virtual memory, offsets up to 4095 bytes can be accommodated. + * If the offset is larger than 4095 bytes, a compile-time error will + * be generated in __kfree_rcu(). If this error is triggered, you can + * either fall back to use of call_rcu() or rearrange the structure to + * position the rcu_head structure into the first 4096 bytes. + * + * Note that the allowable offset might decrease in the future, for example, + * to allow something like kmem_cache_free_rcu(). + */ +#define kfree_rcu(ptr, rcu_head) \ + __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) + + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */ #endif /* LINUX_26_40_COMPAT_H */ -- cgit v1.2.3 From 3e6f9970d444e1256f94033f75fe257e3e47168e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 10 May 2011 13:10:16 +0200 Subject: compat: backport ethtool_cmd_speed Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.27.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index b9d70294..ed2035cc 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -20,6 +20,7 @@ #include #include #include +#include #define PCI_PM_CAP_PME_SHIFT 11 @@ -238,6 +239,17 @@ static inline void debugfs_remove_recursive(struct dentry *dentry) #define dev_name(dev) dev_name((struct device *)dev) +static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, + __u32 speed) +{ + ep->speed = (__u16)speed; +} + +static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) +{ + return ep->speed; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 95e33817c189bf6289dac6d851268cac8748bd6f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 14 May 2011 19:47:32 +0200 Subject: compat: add header linux/printk.h Some drivers are including linux/printk.h and this is not available for kernel < 2.6.37, but the needed declared methods are all in linux/kernel.h. Signed-off-by: Hauke Mehrtens --- include/linux/printk.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/linux/printk.h diff --git a/include/linux/printk.h b/include/linux/printk.h new file mode 100644 index 00000000..c0822ac4 --- /dev/null +++ b/include/linux/printk.h @@ -0,0 +1,12 @@ +#ifndef _COMPAT_LINUX_PRINTK_H +#define _COMPAT_LINUX_PRINTK_H 1 + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) +#include_next +#else +#include +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)) */ + +#endif /* _COMPAT_LINUX_PRINTK_H */ -- cgit v1.2.3 From ee46d3bbc5b208f0314f6d6525d4bebadc449900 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 16 May 2011 19:43:33 +0200 Subject: compat: add an empty definition for __rcu Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.36.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 806993b2..7a825228 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -120,6 +120,9 @@ static inline void tty_unlock(void) __releases(kernel_lock) #define tty_locked() (kernel_locked()) #define usleep_range(_min, _max) msleep((_max) / 1000) + +#define __rcu + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 224fabcef85c2577626acf3469fb94eaba00e9d5 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 16 May 2011 19:43:35 +0200 Subject: compat: backport rcu_dereference_protected Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.34.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index f6ffde06..d1f9d804 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -246,6 +246,8 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ #define sdio_set_host_pm_flags(a, b) 0 +#define rcu_dereference_protected(p, c) (p) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 4a647c60ea4b983b3d0eafcfb66eae2ad6447bca Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 16 May 2011 20:10:18 +0200 Subject: compat: backport rcu_access_pointer Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.34.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index d1f9d804..ad06a073 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -247,6 +247,7 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define sdio_set_host_pm_flags(a, b) 0 #define rcu_dereference_protected(p, c) (p) +#define rcu_access_pointer(p) ACCESS_ONCE(p) #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ -- cgit v1.2.3 From 23f6b43c2a450243de61334e482d20c833b4affb Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 16 May 2011 20:10:19 +0200 Subject: compat: backport rtnl_dereference Signed-off-by: Felix Fietkau --- include/linux/compat-2.6.37.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 57868f52..a83c9c72 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -112,6 +112,9 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev, extern void *vzalloc(unsigned long size); +#define rtnl_dereference(p) \ + rcu_dereference_protected(p, lockdep_rtnl_is_held()) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 52ca55640277af096e5cbceb87a6cc3bd724fc6b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 May 2011 12:47:32 +0200 Subject: compat: backport rcu_dereference_raw Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index ad06a073..663a67e8 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -249,6 +249,8 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define rcu_dereference_protected(p, c) (p) #define rcu_access_pointer(p) ACCESS_ONCE(p) +#define rcu_dereference_raw(p) rcu_dereference(p) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 092edf5ac80e46c0ea76f3945fbd71aded7acb2d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 May 2011 12:47:33 +0200 Subject: compat: backport RCU_INIT_POINTER Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index a83c9c72..e0dd6b43 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -115,6 +115,15 @@ extern void *vzalloc(unsigned long size); #define rtnl_dereference(p) \ rcu_dereference_protected(p, lockdep_rtnl_is_held()) +/** + * RCU_INIT_POINTER() - initialize an RCU protected pointer + * + * Initialize an RCU-protected pointer in such a way to avoid RCU-lockdep + * splats. + */ +#define RCU_INIT_POINTER(p, v) \ + p = (typeof(*v) __force __rcu *)(v) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 45e6f3eb4ab9b137e617cddacdc40b6725ea1099 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 May 2011 12:47:34 +0200 Subject: compat: remove wrong backport of kfree_rcu Backporting kfree_rcu() in compat does not work as struct rcu_head->func is always interpreted as a pointer in older kernel versions, but when using kfree_rcu() it is set to an offset. rcu_head->func is used in some functions in the kernel not backported by compat-wireless. In older kernel versions in __rcu_reclaim just the else path is available. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.40.h | 58 ------------------------------------------- 1 file changed, 58 deletions(-) diff --git a/include/linux/compat-2.6.40.h b/include/linux/compat-2.6.40.h index 9ec8c1b1..b3fc8f73 100644 --- a/include/linux/compat-2.6.40.h +++ b/include/linux/compat-2.6.40.h @@ -24,64 +24,6 @@ #define br_port_exists(dev) (dev->br_port) #endif -static __always_inline bool __is_kfree_rcu_offset(unsigned long offset) -{ - return offset < 4096; -} - -static __always_inline -void __kfree_rcu(struct rcu_head *head, unsigned long offset) -{ - typedef void (*rcu_callback)(struct rcu_head *); - - /* This causes build failures with some kernel versions at positions - * where this methods is not used at all. - */ - /* BUILD_BUG_ON(!__builtin_constant_p(offset)); */ - - /* See the kfree_rcu() header comment. */ - /* BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); */ - - call_rcu(head, (rcu_callback)offset); -} - -static inline void __rcu_reclaim(struct rcu_head *head) -{ - unsigned long offset = (unsigned long)head->func; - - if (__is_kfree_rcu_offset(offset)) - kfree((void *)head - offset); - else - head->func(head); -} - -/** - * kfree_rcu() - kfree an object after a grace period. - * @ptr: pointer to kfree - * @rcu_head: the name of the struct rcu_head within the type of @ptr. - * - * Many rcu callbacks functions just call kfree() on the base structure. - * These functions are trivial, but their size adds up, and furthermore - * when they are used in a kernel module, that module must invoke the - * high-latency rcu_barrier() function at module-unload time. - * - * The kfree_rcu() function handles this issue. Rather than encoding a - * function address in the embedded rcu_head structure, kfree_rcu() instead - * encodes the offset of the rcu_head structure within the base structure. - * Because the functions are not allowed in the low-order 4096 bytes of - * kernel virtual memory, offsets up to 4095 bytes can be accommodated. - * If the offset is larger than 4095 bytes, a compile-time error will - * be generated in __kfree_rcu(). If this error is triggered, you can - * either fall back to use of call_rcu() or rearrange the structure to - * position the rcu_head structure into the first 4096 bytes. - * - * Note that the allowable offset might decrease in the future, for example, - * to allow something like kmem_cache_free_rcu(). - */ -#define kfree_rcu(ptr, rcu_head) \ - __kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head)) - - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */ #endif /* LINUX_26_40_COMPAT_H */ -- cgit v1.2.3 From d08656f975103c1bfbbf314abd175acf33a8b8f8 Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Mon, 23 May 2011 17:17:05 +0300 Subject: compat: add an empty implementation for pm_wakeup_event() Needed for wl12xx compilation Signed-off-by: Eliad Peller --- include/linux/compat-2.6.36.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 7a825228..7bb2bb82 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -123,6 +123,8 @@ static inline void tty_unlock(void) __releases(kernel_lock) #define __rcu +static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From c03570efe213adbab12e869a2426cf95b6d2b45b Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Thu, 9 Jun 2011 18:35:03 +0300 Subject: compat: define create_freezable_workqueue create_freezeable_workqueue() was renamed to create_freezable_workqueue(). Signed-off-by: Eliad Peller --- include/linux/compat-2.6.38.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 004fe274..2dd19109 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -39,6 +39,7 @@ static inline unsigned long ewma_read(const struct ewma *avg) } #define pr_warn pr_warning +#define create_freezable_workqueue create_freezeable_workqueue static inline int skb_checksum_start_offset(const struct sk_buff *skb) { -- cgit v1.2.3 From 1cd0ced7c679ad23232eb14756a3cabb6fd28777 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 10 Jun 2011 00:04:43 +0200 Subject: compat: add support for kernel 3.0 Kernel 2.6.40 is now 3.0. The br_port_exists() is function is not in 3.0 yet, so it should go to compat-3.1.h Add to compat-3.0-stable --- include/linux/compat-2.6.40.h | 29 ----------------------------- include/linux/compat-2.6.h | 2 +- include/linux/compat-3.1.h | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 30 deletions(-) delete mode 100644 include/linux/compat-2.6.40.h create mode 100644 include/linux/compat-3.1.h diff --git a/include/linux/compat-2.6.40.h b/include/linux/compat-2.6.40.h deleted file mode 100644 index b3fc8f73..00000000 --- a/include/linux/compat-2.6.40.h +++ /dev/null @@ -1,29 +0,0 @@ -#ifndef LINUX_26_40_COMPAT_H -#define LINUX_26_40_COMPAT_H - -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) - -#include - -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,40)) */ - -#endif /* LINUX_26_40_COMPAT_H */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 8e45fc06..893a1590 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -32,6 +32,6 @@ #include #include #include -#include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h new file mode 100644 index 00000000..855490ec --- /dev/null +++ b/include/linux/compat-3.1.h @@ -0,0 +1,27 @@ +#ifndef LINUX_3_1_COMPAT_H +#define LINUX_3_1_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ + +#endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From dff5517444fe01f5c8313bdf374be7df76f65aeb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 10 Jun 2011 00:04:44 +0200 Subject: compat: add device name in register_netdevice(dev) dev_alloc_name() is not called explicitly in the driver code any more, but it is done in register_netdevice(). This causes devices getting wrong names like "wlan%d". With this patch they get names like wlan0 again. Add to compat-3.0-stable CC: Ignacy Gawedzki --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.0.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 include/linux/compat-3.0.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 893a1590..e4ca6aa6 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -32,6 +32,7 @@ #include #include #include +#include #include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h new file mode 100644 index 00000000..5d050930 --- /dev/null +++ b/include/linux/compat-3.0.h @@ -0,0 +1,31 @@ +#ifndef LINUX_3_0_COMPAT_H +#define LINUX_3_0_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) + +/* + * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171 + * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is + * called automatically. This is not implemented in older kernel + * versions so it will result in device wrong names. + */ +static inline int register_netdevice_name(struct net_device *dev) +{ + int err; + + if (strchr(dev->name, '%')) { + err = dev_alloc_name(dev, dev->name); + if (err < 0) + return err; + } + + return register_netdevice(dev); +} + +#define register_netdevice(dev) register_netdevice_name(dev) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */ + +#endif /* LINUX_3_0_COMPAT_H */ -- cgit v1.2.3 From 3fb0e48bdb4606656422b85d5f01b1eeef92fe67 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 10 Jun 2011 00:04:45 +0200 Subject: compat: rename CONFIG_COMPAT_KERNEL_ CONFIG_COMPAT_KERNEL_XX was renamed to CONFIG_COMPAT_KERNEL_2_6_XX in compat-wireless to support kernel 3.XX, do the same in compat. Add to compat-3.0-stable --- compat/Makefile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index ddfd88de..e2a6add6 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -6,31 +6,31 @@ obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o compat-y += main.o # Compat kernel compatibility code -compat-$(CONFIG_COMPAT_KERNEL_14) += compat-2.6.14.o -compat-$(CONFIG_COMPAT_KERNEL_18) += compat-2.6.18.o -compat-$(CONFIG_COMPAT_KERNEL_19) += compat-2.6.19.o -compat-$(CONFIG_COMPAT_KERNEL_21) += compat-2.6.21.o -compat-$(CONFIG_COMPAT_KERNEL_22) += compat-2.6.22.o -compat-$(CONFIG_COMPAT_KERNEL_23) += compat-2.6.23.o -compat-$(CONFIG_COMPAT_KERNEL_24) += compat-2.6.24.o -compat-$(CONFIG_COMPAT_KERNEL_25) += \ +compat-$(CONFIG_COMPAT_KERNEL_2_6_14) += compat-2.6.14.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_18) += compat-2.6.18.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_19) += compat-2.6.19.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_21) += compat-2.6.21.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_22) += compat-2.6.22.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_23) += compat-2.6.23.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_24) += compat-2.6.24.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_25) += \ compat-2.6.25.o \ pm_qos_params.o -compat-$(CONFIG_COMPAT_KERNEL_26) += compat-2.6.26.o -compat-$(CONFIG_COMPAT_KERNEL_27) += compat-2.6.27.o -compat-$(CONFIG_COMPAT_KERNEL_28) += compat-2.6.28.o -compat-$(CONFIG_COMPAT_KERNEL_29) += compat-2.6.29.o -compat-$(CONFIG_COMPAT_KERNEL_32) += compat-2.6.32.o -compat-$(CONFIG_COMPAT_KERNEL_33) += compat-2.6.33.o -compat-$(CONFIG_COMPAT_KERNEL_35) += compat-2.6.35.o -compat-$(CONFIG_COMPAT_KERNEL_36) += \ +compat-$(CONFIG_COMPAT_KERNEL_2_6_26) += compat-2.6.26.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_27) += compat-2.6.27.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_28) += compat-2.6.28.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_29) += compat-2.6.29.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_32) += compat-2.6.32.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_33) += compat-2.6.33.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += compat-2.6.35.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += \ compat-2.6.36.o \ kfifo.o -compat-$(CONFIG_COMPAT_KERNEL_37) += compat-2.6.37.o -compat-$(CONFIG_COMPAT_KERNEL_38) += compat-2.6.38.o -compat-$(CONFIG_COMPAT_KERNEL_39) += \ +compat-$(CONFIG_COMPAT_KERNEL_2_6_37) += compat-2.6.37.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_38) += compat-2.6.38.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o -- cgit v1.2.3 From 81a9bbc3a9c2bbfbef3ab0423bc65c2ac71f844c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 10 Jun 2011 00:04:46 +0200 Subject: compat: add KEY_WPS_BUTTON This is needed for carl9170. Add to compat-3.0-stable --- include/linux/compat-2.6.34.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 663a67e8..9743d6c1 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -251,6 +251,8 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define rcu_dereference_raw(p) rcu_dereference(p) +#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 1099a7e30b01c9055a970cfa8c289458f1eada0a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 10 Jun 2011 00:04:47 +0200 Subject: compat: add bcma --- include/linux/compat-3.0.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index 5d050930..667ea387 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -26,6 +26,26 @@ static inline int register_netdevice_name(struct net_device *dev) #define register_netdevice(dev) register_netdevice_name(dev) +/* BCMA core, see drivers/bcma/ */ +#ifndef BCMA_CORE +/* Broadcom's specific AMBA core, see drivers/bcma/ */ +struct bcma_device_id { + __u16 manuf; + __u16 id; + __u8 rev; + __u8 class; +}; +#define BCMA_CORE(_manuf, _id, _rev, _class) \ + { .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, } +#define BCMA_CORETABLE_END \ + { 0, }, + +#define BCMA_ANY_MANUF 0xFFFF +#define BCMA_ANY_ID 0xFFFF +#define BCMA_ANY_REV 0xFF +#define BCMA_ANY_CLASS 0xFF +#endif /* BCMA_CORE */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */ #endif /* LINUX_3_0_COMPAT_H */ -- cgit v1.2.3 From 50d796c448e6b1d95aa1a6e14b332890ad224305 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 28 Jun 2011 20:39:57 +0200 Subject: compat: replace genl_dump_check_consistent remove the usage of genl_dump_check_consistent from the code. This was introduced in: commit 9720bb3ab0b80659c63ed337eab66104a4156db0 Author: Johannes Berg Date: Tue Jun 21 09:45:33 2011 +0200 nl80211: use netlink consistent dump feature for BSS dumps Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.1.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 855490ec..be68c817 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -22,6 +22,8 @@ #define br_port_exists(dev) (dev->br_port) #endif +#define genl_dump_check_consistent(cb, user_hdr, family) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From 2204419d9ce529b16f22207810065e78b53b029e Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 29 Jun 2011 16:47:15 -0400 Subject: Signed-off-by: Pavel Roskin Debian backports netdev_name as a function. As we cannot test if a function is present, use an equivalent macro. Reported by Sivaraman V and Alex --- include/linux/compat-2.6.34.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 9743d6c1..bada7005 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -20,12 +20,11 @@ /* netdev_printk helpers, similar to dev_printk */ -static inline const char *netdev_name(const struct net_device *dev) -{ - if (dev->reg_state != NETREG_REGISTERED) - return "(unregistered net_device)"; - return dev->name; -} +#ifndef netdev_name +#define netdev_name(__dev) \ + ((__dev->reg_state != NETREG_REGISTERED) ? \ + "(unregistered net_device)" : __dev->name) +#endif #define netdev_printk(level, netdev, format, args...) \ dev_printk(level, (netdev)->dev.parent, \ -- cgit v1.2.3 From 7d35284cf37755408256ba0e0ede8cb961527d73 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Wed, 29 Jun 2011 18:01:10 -0400 Subject: Signed-off-by: Pavel Roskin set_irq_probe() and set_irq_probe() are missing on Linux 2.6.24, so the code won't compile. compat-wireless doesn't need those functions. Keep the functions for Linux 2.6.25 and newer for other compat packages. --- include/linux/compat-2.6.39.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index b4d85fdb..406f8ebf 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -64,6 +64,8 @@ static inline struct msi_desc *irq_get_msi_desc(unsigned int irq) { return get_irq_msi(irq); } + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) static inline void irq_set_noprobe(unsigned int irq) { set_irq_noprobe(irq); @@ -72,6 +74,7 @@ static inline void irq_set_probe(unsigned int irq) { set_irq_probe(irq); } +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc) -- cgit v1.2.3 From 807b8b85d0d51abbb6cafd1bc964c29e2f8240f2 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 15 Jul 2011 17:50:25 +0200 Subject: compat: add pr__once macros Add functions from 2.6.38 kernel commit: commit 16cb839f13324978bd58082e69de81a711802b11 Author: Joe Perches Date: Wed Jan 12 16:59:46 2011 -0800 include/linux/printk.h: add pr__once macros Signed-off-by: Stanislaw Gruszka --- include/linux/compat-2.6.38.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 2dd19109..dfe12507 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -46,6 +46,31 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb) return skb->csum_start - skb_headroom(skb); } +/* from include/linux/printk.h */ +#define pr_emerg_once(fmt, ...) \ + printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_alert_once(fmt, ...) \ + printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_crit_once(fmt, ...) \ + printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err_once(fmt, ...) \ + printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn_once(fmt, ...) \ + printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_notice_once(fmt, ...) \ + printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info_once(fmt, ...) \ + printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) +#define pr_cont_once(fmt, ...) \ + printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__) +#if defined(DEBUG) +#define pr_debug_once(fmt, ...) \ + printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#else +#define pr_debug_once(fmt, ...) \ + no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 802463abbe2fca7e412c8373394d919d5f7bebb0 Mon Sep 17 00:00:00 2001 From: Stanislaw Gruszka Date: Fri, 15 Jul 2011 17:50:26 +0200 Subject: compat: add alloc_netdev_mqs Function was added in 2.6.38 kernel commit: commit 36909ea43814cba34f7c921e99cba33d770a54e1 Author: Tom Herbert Date: Sun Jan 9 19:36:31 2011 +0000 net: Add alloc_netdev_mqs function Emulate it using alloc_netdev_mq(), newer kernels use opposite emulation method :-) Signed-off-by: Stanislaw Gruszka --- include/linux/compat-2.6.38.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index dfe12507..937976b3 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -71,6 +71,10 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb) no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #endif +/* include/linux/netdevice.h */ +#define alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) \ + alloc_netdev_mq(sizeof_priv, name, setup, max(txqs, rxqs)) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 88ffc8d7db0ae68387083079c7ddda00191daa35 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 19 Jul 2011 18:07:53 -0700 Subject: compat: backport ETH_P_LINK_CTL Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 937976b3..1f9ab523 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -75,6 +75,8 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb) #define alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) \ alloc_netdev_mq(sizeof_priv, name, setup, max(txqs, rxqs)) +#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 65655292c6ed9c17e302650fb98ad0e44dc62826 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 22 Jul 2011 18:51:09 +0200 Subject: compat: backport generic pr_fmt Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.28.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index fdb8fb2c..c92c8b48 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -238,6 +238,10 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable); #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active) +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ -- cgit v1.2.3 From 468b47d64ce2d71e30f2029d54336a87d25c9ee6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 22 Jul 2011 18:51:10 +0200 Subject: compat: add include/crypto/aes.h Signed-off-by: Hauke Mehrtens --- include/crypto/aes.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 include/crypto/aes.h diff --git a/include/crypto/aes.h b/include/crypto/aes.h new file mode 100644 index 00000000..8031a54d --- /dev/null +++ b/include/crypto/aes.h @@ -0,0 +1,21 @@ +#ifndef _COMPAT_CRYPTO_AES_H +#define _COMPAT_CRYPTO_AES_H + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)) +#include_next +#else + +#define AES_MIN_KEY_SIZE 16 +#define AES_MAX_KEY_SIZE 32 +#define AES_KEYSIZE_128 16 +#define AES_KEYSIZE_192 24 +#define AES_KEYSIZE_256 32 +#define AES_BLOCK_SIZE 16 +#define AES_MAX_KEYLENGTH (15 * 16) +#define AES_MAX_KEYLENGTH_U32 (AES_MAX_KEYLENGTH / sizeof(u32)) + +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)) */ + +#endif -- cgit v1.2.3 From bc0a7c4993401d38905130c11017669c71a9ec82 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 2 Aug 2011 23:14:19 +0200 Subject: compat: add skb_walk_frags() and skb_has_frag_list() These functions are needed for ./net/bluetooth/l2cap_core.c and ./net/bluetooth/af_bluetooth.c. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.31.h | 3 +++ include/linux/compat-2.6.37.h | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index d2e0f01b..ce944bb8 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -199,6 +199,9 @@ void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) #define list_entry_rcu(ptr, type, member) \ container_of(rcu_dereference(ptr), type, member) +#define skb_walk_frags(skb, iter) \ + for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ #endif /* LINUX_26_31_COMPAT_H */ diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index e0dd6b43..d375746f 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -124,6 +124,11 @@ extern void *vzalloc(unsigned long size); #define RCU_INIT_POINTER(p, v) \ p = (typeof(*v) __force __rcu *)(v) +static inline bool skb_has_frag_list(const struct sk_buff *skb) +{ + return skb_shinfo(skb)->frag_list != NULL; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ -- cgit v1.2.3 From 4b24bdcc9764c7c186e5d351a6076ad0d3cbb213 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 2 Aug 2011 23:14:20 +0200 Subject: compat: add IFF_TX_SKB_SHARING This flag should be ignored by older kernel versions. Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.1.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index be68c817..f9b7e889 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -24,6 +24,9 @@ #define genl_dump_check_consistent(cb, user_hdr, family) +#define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing + * skbs on transmit */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From a673c5fb8bf3197ffc971de4f5f264ae5378ce6f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 2 Aug 2011 23:14:21 +0200 Subject: compat: add PCMCIA_DEVICE_MANF_CARD_PROD_ID3 Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.1.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index f9b7e889..cff65213 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -27,6 +27,15 @@ #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing * skbs on transmit */ +#define PCMCIA_DEVICE_MANF_CARD_PROD_ID3(manf, card, v3, vh3) { \ + .match_flags = PCMCIA_DEV_ID_MATCH_MANF_ID| \ + PCMCIA_DEV_ID_MATCH_CARD_ID| \ + PCMCIA_DEV_ID_MATCH_PROD_ID3, \ + .manf_id = (manf), \ + .card_id = (card), \ + .prod_id = { NULL, NULL, (v3), NULL }, \ + .prod_id_hash = { 0, 0, (vh3), 0 }, } + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From bd69b9e6866c081d5bc968037681871fb7c905ea Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 2 Aug 2011 23:14:22 +0200 Subject: compat: add linux/export.h Export will be added in linux-3.2, for older kernel versions the stuff is in linux/module.h. Signed-off-by: Hauke Mehrtens --- include/linux/export.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/linux/export.h diff --git a/include/linux/export.h b/include/linux/export.h new file mode 100644 index 00000000..f7842b7a --- /dev/null +++ b/include/linux/export.h @@ -0,0 +1,12 @@ +#ifndef _COMPAT_LINUX_EXPORT_H +#define _COMPAT_LINUX_EXPORT_H 1 + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) +#include_next +#else +#include +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ + +#endif /* _COMPAT_LINUX_EXPORT_H */ -- cgit v1.2.3 From 29f7643a8934e811423b00e53cda4ef66c3c527e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 2 Aug 2011 23:14:23 +0200 Subject: compat: add linux/atmoic.h This include is needed by some drivers. Signed-off-by: Hauke Mehrtens --- include/linux/atomic.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/linux/atomic.h diff --git a/include/linux/atomic.h b/include/linux/atomic.h new file mode 100644 index 00000000..378b748f --- /dev/null +++ b/include/linux/atomic.h @@ -0,0 +1,46 @@ +#ifndef _COMPAT_LINUX_ATOMIC_H +#define _COMPAT_LINUX_ATOMIC_H 1 + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) +#include_next +#else + +#include + +/** + * atomic_inc_not_zero_hint - increment if not null + * @v: pointer of type atomic_t + * @hint: probable value of the atomic before the increment + * + * This version of atomic_inc_not_zero() gives a hint of probable + * value of the atomic. This helps processor to not read the memory + * before doing the atomic read/modify/write cycle, lowering + * number of bus transactions on some arches. + * + * Returns: 0 if increment was not done, 1 otherwise. + */ +#ifndef atomic_inc_not_zero_hint +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint) +{ + int val, c = hint; + + /* sanity test, should be removed by compiler if hint is a constant */ + if (!hint) + return atomic_inc_not_zero(v); + + do { + val = atomic_cmpxchg(v, c, c + 1); + if (val == c) + return 1; + c = val; + } while (c); + + return 0; +} +#endif + +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) */ + +#endif /* _COMPAT_LINUX_ATOMIC_H */ -- cgit v1.2.3 From c2544bbb8399893f2a96800f132ab9b5ed76a39c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 11 Aug 2011 13:02:37 +0200 Subject: compat: add round_down Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index bada7005..7bda52b7 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -252,6 +252,16 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */ +/* + * This looks more complex than it should be. But we need to + * get the type for the ~ right in round_down (it needs to be + * as wide as the result!), and we want to evaluate the macro + * arguments just once each. + */ +#define __round_mask(x, y) ((__typeof__(x))((y)-1)) +#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) +#define round_down(x, y) ((x) & ~__round_mask(x, y)) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 22b6f16ce0247be6be50d36a9f75658f4f5886ba Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 15 Aug 2011 20:32:50 +0200 Subject: compat: add support for linux 3.1 br_port_exists is not in mainline, will it ever? Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.1.h | 17 ----------------- include/linux/compat-3.2.h | 27 +++++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 17 deletions(-) create mode 100644 include/linux/compat-3.2.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index e4ca6aa6..d933602d 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -34,5 +34,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index cff65213..93bb1f6e 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -5,23 +5,6 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - #define genl_dump_check_consistent(cb, user_hdr, family) #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h new file mode 100644 index 00000000..9cba4614 --- /dev/null +++ b/include/linux/compat-3.2.h @@ -0,0 +1,27 @@ +#ifndef LINUX_3_2_COMPAT_H +#define LINUX_3_2_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) + +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ + +#endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From 55a12f9e3f95e8555e84d413b18c16ab54a257e6 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 12 Aug 2011 20:23:08 +0200 Subject: The led_lock is never initialised, so there are warnings/errors. It can also be made static. Signed-off-by: Johannes Berg --- compat/compat-2.6.37.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index a62b13fc..257880ea 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -158,7 +158,7 @@ EXPORT_SYMBOL(compat_genl_unregister_family); #undef led_brightness_set #undef led_classdev_unregister -spinlock_t led_lock; +static DEFINE_SPINLOCK(led_lock); static LIST_HEAD(led_timers); struct led_timer { -- cgit v1.2.3 From 9f860356c6e0f74d84213a9b7cd45a5889f1147f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 23 Aug 2011 13:38:28 +0200 Subject: compat: pm_qos_params.h was renamed to pm_qos.h pm_qos.h was renamed to pm_qos_params.h in: commit 1eee4691c3f058d1cf9757947ad9d9e03145a12c Author: Jean Pihet Date: Thu Aug 18 10:31:55 2011 +0200 PM QoS: Move and rename the implementation files For older kernel versions the old header file should be used instead of the new one. Signed-off-by: Hauke Mehrtens --- include/linux/pm_qos.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/linux/pm_qos.h diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h new file mode 100644 index 00000000..c58c1c1f --- /dev/null +++ b/include/linux/pm_qos.h @@ -0,0 +1,12 @@ +#ifndef _COMPAT_LINUX_PM_QOS_H +#define _COMPAT_LINUX_PM_QOS_H 1 + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) +#include_next +#else +#include +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */ + +#endif /* _COMPAT_LINUX_PM_QOS_H */ -- cgit v1.2.3 From 9e41b36082792b25577e27f0217884684e17e196 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 23 Aug 2011 13:38:29 +0200 Subject: compat: add PMSG_IS_AUTO Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.2.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index 9cba4614..d10495cc 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -22,6 +22,8 @@ #define br_port_exists(dev) (dev->br_port) #endif +#define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From fbf40660143b4612aa16623793fc3520dd0a5d7c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 24 Aug 2011 13:20:37 +0200 Subject: compat: add mac_pton() Signed-off-by: Hauke Mehrtens --- compat/Makefile | 1 + compat/compat-3.0.c | 37 +++++++++++++++++++++++++++++++++++++ include/linux/compat-3.0.h | 2 ++ 3 files changed, 40 insertions(+) create mode 100644 compat/compat-3.0.c diff --git a/compat/Makefile b/compat/Makefile index e2a6add6..8e3739c4 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -33,4 +33,5 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_38) += compat-2.6.38.o compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o +compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c new file mode 100644 index 00000000..312eea00 --- /dev/null +++ b/compat/compat-3.0.c @@ -0,0 +1,37 @@ +/* + * Copyright 2011 Hauke Mehrtens + * Copyright 2011 Alexey Dobriyan + * + * 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 3.0. + */ + +#include +#include + +int mac_pton(const char *s, u8 *mac) +{ + int i; + + /* XX:XX:XX:XX:XX:XX */ + if (strlen(s) < 3 * ETH_ALEN - 1) + return 0; + + /* Don't dirty result unless string is valid MAC. */ + for (i = 0; i < ETH_ALEN; i++) { + if (!strchr("0123456789abcdefABCDEF", s[i * 3])) + return 0; + if (!strchr("0123456789abcdefABCDEF", s[i * 3 + 1])) + return 0; + if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':') + return 0; + } + for (i = 0; i < ETH_ALEN; i++) { + mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]); + } + return 1; +} +EXPORT_SYMBOL(mac_pton); diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index 667ea387..7954ddb1 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -46,6 +46,8 @@ struct bcma_device_id { #define BCMA_ANY_CLASS 0xFF #endif /* BCMA_CORE */ +int mac_pton(const char *s, u8 *mac); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */ #endif /* LINUX_3_0_COMPAT_H */ -- cgit v1.2.3 From c904948e1e5928c10d4c3025d13ab0e9d0ef4ba6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 24 Aug 2011 13:20:38 +0200 Subject: compat: add cordic lib compat/cordic.c was copied from lib/cordic.c and include/linux/cordic.h was copied from include/linux/cordic.h Signed-off-by: Hauke Mehrtens --- compat/Makefile | 2 + compat/cordic.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/cordic.h | 48 +++++++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 compat/cordic.c create mode 100644 include/linux/cordic.h diff --git a/compat/Makefile b/compat/Makefile index 8e3739c4..31e44595 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,4 +34,6 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o +compat-$(CONFIG_COMPAT_KERNEL_3_1) += \ + cordic.o diff --git a/compat/cordic.c b/compat/cordic.c new file mode 100644 index 00000000..aa27a88d --- /dev/null +++ b/compat/cordic.c @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include +#include + +#define CORDIC_ANGLE_GEN 39797 +#define CORDIC_PRECISION_SHIFT 16 +#define CORDIC_NUM_ITER (CORDIC_PRECISION_SHIFT + 2) + +#define FIXED(X) ((s32)((X) << CORDIC_PRECISION_SHIFT)) +#define FLOAT(X) (((X) >= 0) \ + ? ((((X) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1) \ + : -((((-(X)) >> (CORDIC_PRECISION_SHIFT - 1)) + 1) >> 1)) + +static const s32 arctan_table[] = { + 2949120, + 1740967, + 919879, + 466945, + 234379, + 117304, + 58666, + 29335, + 14668, + 7334, + 3667, + 1833, + 917, + 458, + 229, + 115, + 57, + 29 +}; + +/* + * cordic_calc_iq() - calculates the i/q coordinate for given angle + * + * theta: angle in degrees for which i/q coordinate is to be calculated + * coord: function output parameter holding the i/q coordinate + */ +struct cordic_iq cordic_calc_iq(s32 theta) +{ + struct cordic_iq coord; + s32 angle, valtmp; + unsigned iter; + int signx = 1; + int signtheta; + + coord.i = CORDIC_ANGLE_GEN; + coord.q = 0; + angle = 0; + + theta = FIXED(theta); + signtheta = (theta < 0) ? -1 : 1; + theta = ((theta + FIXED(180) * signtheta) % FIXED(360)) - + FIXED(180) * signtheta; + + if (FLOAT(theta) > 90) { + theta -= FIXED(180); + signx = -1; + } else if (FLOAT(theta) < -90) { + theta += FIXED(180); + signx = -1; + } + + for (iter = 0; iter < CORDIC_NUM_ITER; iter++) { + if (theta > angle) { + valtmp = coord.i - (coord.q >> iter); + coord.q += (coord.i >> iter); + angle += arctan_table[iter]; + } else { + valtmp = coord.i + (coord.q >> iter); + coord.q -= (coord.i >> iter); + angle -= arctan_table[iter]; + } + coord.i = valtmp; + } + + coord.i *= signx; + coord.q *= signx; + return coord; +} +EXPORT_SYMBOL(cordic_calc_iq); + +MODULE_DESCRIPTION("Cordic functions"); +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/linux/cordic.h b/include/linux/cordic.h new file mode 100644 index 00000000..f932093e --- /dev/null +++ b/include/linux/cordic.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef __CORDIC_H_ +#define __CORDIC_H_ + +#include + +/** + * struct cordic_iq - i/q coordinate. + * + * @i: real part of coordinate (in phase). + * @q: imaginary part of coordinate (quadrature). + */ +struct cordic_iq { + s32 i; + s32 q; +}; + +/** + * cordic_calc_iq() - calculates the i/q coordinate for given angle. + * + * @theta: angle in degrees for which i/q coordinate is to be calculated. + * @coord: function output parameter holding the i/q coordinate. + * + * The function calculates the i/q coordinate for a given angle using + * cordic algorithm. The coordinate consists of a real (i) and an + * imaginary (q) part. The real part is essentially the cosine of the + * angle and the imaginary part is the sine of the angle. The returned + * values are scaled by 2^16 for precision. The range for theta is + * for -180 degrees to +180 degrees. Passed values outside this range are + * converted before doing the actual calculation. + */ +struct cordic_iq cordic_calc_iq(s32 theta); + +#endif /* __CORDIC_H_ */ -- cgit v1.2.3 From 40f7615a33d1dc82efb5eb5d97cf404237fd8254 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 24 Aug 2011 13:20:39 +0200 Subject: compat: add crc8 lib compat/crc8.c was copied from lib/crc8.c and include/linux/crc8.h was copied from include/linux/crc8.h Signed-off-by: Hauke Mehrtens --- compat/Makefile | 3 +- compat/crc8.c | 86 +++++++++++++++++++++++++++++++++++++++++++ include/linux/crc8.h | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 compat/crc8.c create mode 100644 include/linux/crc8.h diff --git a/compat/Makefile b/compat/Makefile index 31e44595..2fb18934 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -35,5 +35,6 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_1) += \ - cordic.o + cordic.o \ + crc8.o diff --git a/compat/crc8.c b/compat/crc8.c new file mode 100644 index 00000000..87b59caf --- /dev/null +++ b/compat/crc8.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include +#include +#include + +/* + * crc8_populate_msb - fill crc table for given polynomial in reverse bit order. + * + * table: table to be filled. + * polynomial: polynomial for which table is to be filled. + */ +void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial) +{ + int i, j; + const u8 msbit = 0x80; + u8 t = msbit; + + table[0] = 0; + + for (i = 1; i < CRC8_TABLE_SIZE; i *= 2) { + t = (t << 1) ^ (t & msbit ? polynomial : 0); + for (j = 0; j < i; j++) + table[i+j] = table[j] ^ t; + } +} +EXPORT_SYMBOL(crc8_populate_msb); + +/* + * crc8_populate_lsb - fill crc table for given polynomial in regular bit order. + * + * table: table to be filled. + * polynomial: polynomial for which table is to be filled. + */ +void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial) +{ + int i, j; + u8 t = 1; + + table[0] = 0; + + for (i = (CRC8_TABLE_SIZE >> 1); i; i >>= 1) { + t = (t >> 1) ^ (t & 1 ? polynomial : 0); + for (j = 0; j < CRC8_TABLE_SIZE; j += 2*i) + table[i+j] = table[j] ^ t; + } +} +EXPORT_SYMBOL(crc8_populate_lsb); + +/* + * crc8 - calculate a crc8 over the given input data. + * + * table: crc table used for calculation. + * pdata: pointer to data buffer. + * nbytes: number of bytes in data buffer. + * crc: previous returned crc8 value. + */ +u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc) +{ + /* loop over the buffer data */ + while (nbytes-- > 0) + crc = table[(crc ^ *pdata++) & 0xff]; + + return crc; +} +EXPORT_SYMBOL(crc8); + +MODULE_DESCRIPTION("CRC8 (by Williams, Ross N.) function"); +MODULE_AUTHOR("Broadcom Corporation"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/linux/crc8.h b/include/linux/crc8.h new file mode 100644 index 00000000..13c8dabb --- /dev/null +++ b/include/linux/crc8.h @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2011 Broadcom Corporation + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION + * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#ifndef __CRC8_H_ +#define __CRC8_H_ + +#include + +/* see usage of this value in crc8() description */ +#define CRC8_INIT_VALUE 0xFF + +/* + * Return value of crc8() indicating valid message+crc. This is true + * if a CRC is inverted before transmission. The CRC computed over the + * whole received bitstream is _table[x], where x is the bit pattern + * of the modification (almost always 0xff). + */ +#define CRC8_GOOD_VALUE(_table) (_table[0xFF]) + +/* required table size for crc8 algorithm */ +#define CRC8_TABLE_SIZE 256 + +/* helper macro assuring right table size is used */ +#define DECLARE_CRC8_TABLE(_table) \ + static u8 _table[CRC8_TABLE_SIZE] + +/** + * crc8_populate_lsb - fill crc table for given polynomial in regular bit order. + * + * @table: table to be filled. + * @polynomial: polynomial for which table is to be filled. + * + * This function fills the provided table according the polynomial provided for + * regular bit order (lsb first). Polynomials in CRC algorithms are typically + * represented as shown below. + * + * poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1 + * + * For lsb first direction x^7 maps to the lsb. So the polynomial is as below. + * + * - lsb first: poly = 10101011(1) = 0xAB + */ +void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); + +/** + * crc8_populate_msb - fill crc table for given polynomial in reverse bit order. + * + * @table: table to be filled. + * @polynomial: polynomial for which table is to be filled. + * + * This function fills the provided table according the polynomial provided for + * reverse bit order (msb first). Polynomials in CRC algorithms are typically + * represented as shown below. + * + * poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1 + * + * For msb first direction x^7 maps to the msb. So the polynomial is as below. + * + * - msb first: poly = (1)11010101 = 0xD5 + */ +void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); + +/** + * crc8() - calculate a crc8 over the given input data. + * + * @table: crc table used for calculation. + * @pdata: pointer to data buffer. + * @nbytes: number of bytes in data buffer. + * @crc: previous returned crc8 value. + * + * The CRC8 is calculated using the polynomial given in crc8_populate_msb() + * or crc8_populate_lsb(). + * + * The caller provides the initial value (either %CRC8_INIT_VALUE + * or the previous returned value) to allow for processing of + * discontiguous blocks of data. When generating the CRC the + * caller is responsible for complementing the final return value + * and inserting it into the byte stream. When validating a byte + * stream (including CRC8), a final return value of %CRC8_GOOD_VALUE + * indicates the byte stream data can be considered valid. + * + * Reference: + * "A Painless Guide to CRC Error Detection Algorithms", ver 3, Aug 1993 + * Williams, Ross N., rossross.net + * (see URL http://www.ross.net/crc/download/crc_v3.txt). + */ +u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc); + +#endif /* __CRC8_H_ */ -- cgit v1.2.3 From 2e1ae46654ef7cb93406fc5b327e026b7bbf84bd Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 1 Sep 2011 00:20:10 +0200 Subject: compat: add __always_unused Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 8aabda01..43f19893 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -138,6 +138,12 @@ static inline bool pci_is_pcie(struct pci_dev *dev) #endif } +#ifdef __GNUC__ +#define __always_unused __attribute__((unused)) +#else +#define __always_unused /* unimplemented */ +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From b22456c9fc7f11567f1feb7192a107dc67a674cd Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 1 Sep 2011 00:20:11 +0200 Subject: compat: add skb_frag_dma_map Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.2.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index d10495cc..009e3410 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -5,6 +5,9 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) +#include +#include + /* * This is not part of The 2.6.37 kernel yet but we * we use it to optimize the backport code we @@ -24,6 +27,37 @@ #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) +/** + * skb_frag_page - retrieve the page refered to by a paged fragment + * @frag: the paged fragment + * + * Returns the &struct page associated with @frag. + */ +static inline struct page *skb_frag_page(const skb_frag_t *frag) +{ + return frag->page; +} + +/** + * skb_frag_dma_map - maps a paged fragment via the DMA API + * @device: the device to map the fragment to + * @frag: the paged fragment to map + * @offset: the offset within the fragment (starting at the + * fragment's own offset) + * @size: the number of bytes to map + * @direction: the direction of the mapping (%PCI_DMA_*) + * + * Maps the page associated with @frag to @device. + */ +static inline dma_addr_t skb_frag_dma_map(struct device *dev, + const skb_frag_t *frag, + size_t offset, size_t size, + enum dma_data_direction dir) +{ + return dma_map_page(dev, skb_frag_page(frag), + frag->page_offset + offset, size, dir); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From 0808fead43321864838f6dc822b21cbf83725dab Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 1 Sep 2011 00:20:12 +0200 Subject: compat: add kstrtou8_from_user Signed-off-by: Hauke Mehrtens --- compat/compat-3.0.c | 25 +++++++++++++++++++++++++ include/linux/compat-3.0.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c index 312eea00..f517e9fb 100644 --- a/compat/compat-3.0.c +++ b/compat/compat-3.0.c @@ -35,3 +35,28 @@ int mac_pton(const char *s, u8 *mac) return 1; } EXPORT_SYMBOL(mac_pton); + +#define kstrto_from_user(f, g, type) \ +int f(const char __user *s, size_t count, unsigned int base, type *res) \ +{ \ + /* sign, base 2 representation, newline, terminator */ \ + char buf[1 + sizeof(type) * 8 + 1 + 1]; \ + \ + count = min(count, sizeof(buf) - 1); \ + if (copy_from_user(buf, s, count)) \ + return -EFAULT; \ + buf[count] = '\0'; \ + return g(buf, base, res); \ +} \ +EXPORT_SYMBOL(f) + +kstrto_from_user(kstrtoull_from_user, kstrtoull, unsigned long long); +kstrto_from_user(kstrtoll_from_user, kstrtoll, long long); +kstrto_from_user(kstrtoul_from_user, kstrtoul, unsigned long); +kstrto_from_user(kstrtol_from_user, kstrtol, long); +kstrto_from_user(kstrtouint_from_user, kstrtouint, unsigned int); +kstrto_from_user(kstrtoint_from_user, kstrtoint, int); +kstrto_from_user(kstrtou16_from_user, kstrtou16, u16); +kstrto_from_user(kstrtos16_from_user, kstrtos16, s16); +kstrto_from_user(kstrtou8_from_user, kstrtou8, u8); +kstrto_from_user(kstrtos8_from_user, kstrtos8, s8); diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index 7954ddb1..8c8720e0 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -48,6 +48,37 @@ struct bcma_device_id { int mac_pton(const char *s, u8 *mac); +int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res); +int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res); +int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res); +int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res); +int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res); +int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res); +int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res); +int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res); +int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res); +int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res); + +static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res) +{ + return kstrtoull_from_user(s, count, base, res); +} + +static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res) +{ + return kstrtoll_from_user(s, count, base, res); +} + +static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res) +{ + return kstrtouint_from_user(s, count, base, res); +} + +static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res) +{ + return kstrtoint_from_user(s, count, base, res); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */ #endif /* LINUX_3_0_COMPAT_H */ -- cgit v1.2.3 From 45d4203f1e61ee2204a10fae8100bd16d0ecb8ef Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 21 Sep 2011 19:04:23 +0200 Subject: compat: add rcu_read_lock_held() just the version without lock debug support is implemented, if you want to debug the logs use a more recent kernel version. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.34.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 7bda52b7..0ab344ce 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -262,6 +262,11 @@ static inline int usb_disable_autosuspend(struct usb_device *udev) #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) #define round_down(x, y) ((x) & ~__round_mask(x, y)) +static inline int rcu_read_lock_held(void) +{ + return 1; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 8331446ead4dd43ffffbe0c8db16c5103d8a8c28 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 21 Sep 2011 19:04:24 +0200 Subject: compat: add lower_32_bits Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.27.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index ed2035cc..22fadcd2 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -250,6 +250,12 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) return ep->speed; } +/** + * lower_32_bits - return bits 0-31 of a number + * @n: the number we're accessing + */ +#define lower_32_bits(n) ((u32)(n)) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From ebcc0426c50fe5f2ec28b64edca677a3c7d8b377 Mon Sep 17 00:00:00 2001 From: Pavel Roskin Date: Fri, 23 Sep 2011 17:48:05 -0400 Subject: compat: provide INIT_WORK with 2 arguments for kernels before 2.6.20 Also provide work_func_t. Originally implemented and tested in ndiswrapper. Signed-off-by: Pavel Roskin --- include/linux/compat-2.6.20.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 include/linux/compat-2.6.20.h diff --git a/include/linux/compat-2.6.20.h b/include/linux/compat-2.6.20.h new file mode 100644 index 00000000..14579e29 --- /dev/null +++ b/include/linux/compat-2.6.20.h @@ -0,0 +1,21 @@ +#ifndef LINUX_26_20_COMPAT_H +#define LINUX_26_20_COMPAT_H + +#include + +/* Compat work for 2.6.20 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + +#include + +typedef void (*work_func_t)(struct work_struct *work); +typedef void (*compat_work_func_t)(void *work); +static inline void (INIT_WORK)(struct work_struct *work, work_func_t func) +{ + INIT_WORK(work, (compat_work_func_t)func, work); +} +#undef INIT_WORK + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) */ + +#endif /* LINUX_26_20_COMPAT_H */ -- cgit v1.2.3 From f7d5a0caee9dc9d510278cedae4cf171835e9656 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Sep 2011 20:43:44 +0200 Subject: compat: add IS_ERR_OR_NULL() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 43f19893..386ee4c9 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -144,6 +144,11 @@ static inline bool pci_is_pcie(struct pci_dev *dev) #define __always_unused /* unimplemented */ #endif +static inline long __must_check IS_ERR_OR_NULL(const void *ptr) +{ + return !ptr || IS_ERR_VALUE((unsigned long)ptr); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From 2239769c556d3f4444a47889be0d60435a91c3b5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 1 Oct 2011 12:32:54 +0200 Subject: compat: add skb_tx_timestamp() and skb_defer_rx_timestamp() Just add an empty implementation of these functions to do the same as when timestamping is deactivated. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.36.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 7bb2bb82..f4d6f800 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -125,6 +125,15 @@ static inline void tty_unlock(void) __releases(kernel_lock) static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {} +static inline bool skb_defer_rx_timestamp(struct sk_buff *skb) +{ + return false; +} + +static inline void skb_tx_timestamp(struct sk_buff *skb) +{ +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 124b5f1f2af9221acef2df1a89099f356146da47 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 4 Oct 2011 13:11:45 +0200 Subject: compat: add ETH_P_TDLS Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.2.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index 009e3410..859a2e33 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -58,6 +58,8 @@ static inline dma_addr_t skb_frag_dma_map(struct device *dev, frag->page_offset + offset, size, dir); } +#define ETH_P_TDLS 0x890D /* TDLS */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From a839eee468e9d9b9df92251374acc10c42020faf Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 4 Oct 2011 13:11:46 +0200 Subject: compat: add is_unicast_ether_addr Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 1f9ab523..ad04ebcc 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -7,6 +7,7 @@ #include #include +#include /* rename member in struct mmc_host in include/linux/mmc/host.h */ #define max_segs max_hw_segs @@ -77,6 +78,17 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb) #define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ +/** + * is_unicast_ether_addr - Determine if the Ethernet address is unicast + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Return true if the address is a unicast address. + */ +static inline int is_unicast_ether_addr(const u8 *addr) +{ + return !is_multicast_ether_addr(addr); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 966e8478176097f929df89406291aa75bb574984 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 4 Oct 2011 13:11:47 +0200 Subject: compat: add linux/of.h just when CONFIG_OF is set. In kernel < 2.6.34 linux/of.h unconditionally includes asm/prom.h which is not available on all architectures. In newer kernel versions this is just included if CONFIG_OF is set. For these old kernel just include linux/of.h when CONFIG_OF is set. This fixes a compile problem with ath6kl as it uses linux/of.h only when CONFIG_OF is set. Signed-off-by: Hauke Mehrtens --- include/linux/of.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 include/linux/of.h diff --git a/include/linux/of.h b/include/linux/of.h new file mode 100644 index 00000000..c5dc87c2 --- /dev/null +++ b/include/linux/of.h @@ -0,0 +1,16 @@ +#ifndef _COMPAT_LINUX_OF_H +#define _COMPAT_LINUX_OF_H 1 + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +#include_next +#else + +#ifdef CONFIG_OF +#include_next +#endif /* CONFIG_OF */ + +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */ + +#endif /* _COMPAT_LINUX_OF_H */ -- cgit v1.2.3 From b5edac3c763cc8562b77c1599153ab778cac4649 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 6 Oct 2011 10:45:26 +0200 Subject: Depending on the arguments to alloc_netdev_mqs(), it may give a warning due to the use of max(). Fix the warning with max_t(). Signed-off-by: Johannes Berg --- include/linux/compat-2.6.38.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index ad04ebcc..63f9dd6a 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -74,7 +74,8 @@ static inline int skb_checksum_start_offset(const struct sk_buff *skb) /* include/linux/netdevice.h */ #define alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) \ - alloc_netdev_mq(sizeof_priv, name, setup, max(txqs, rxqs)) + alloc_netdev_mq(sizeof_priv, name, setup, \ + max_t(unsigned int, txqs, rxqs)) #define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ -- cgit v1.2.3 From de70e06e7c84debcfde536601004bfb1032b432a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Nov 2011 22:25:03 +0100 Subject: compat: backport system_nrt_wq The workqueue system_nrt_wq is not available in kernel version < 2.6.36. This backport code creates such a queue but this old kernel does not have WQ_NON_REENTRANT, so we use a single threaded queue instead as it should meat the same restrictions. Signed-off-by: Hauke Mehrtens --- compat/compat-2.6.36.c | 15 +++++++++++++++ compat/main.c | 2 ++ include/linux/compat-2.6.36.h | 15 +++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 5faefb4b..aab25df7 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -92,5 +92,20 @@ void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) spin_unlock_irqrestore(&anchor->lock, flags); } EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); + +struct workqueue_struct *system_nrt_wq __read_mostly; +EXPORT_SYMBOL_GPL(system_nrt_wq); + +void compat_system_workqueue_create() +{ + system_nrt_wq = create_singlethread_workqueue("events_nrt"); + WARN_ON(system_nrt_wq); +} + +void compat_system_workqueue_destroy() +{ + destroy_workqueue(system_nrt_wq); +} + #endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ diff --git a/compat/main.c b/compat/main.c index a1a48d01..f830488f 100644 --- a/compat/main.c +++ b/compat/main.c @@ -36,6 +36,7 @@ static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); + compat_system_workqueue_create(); printk(KERN_INFO COMPAT_PROJECT " backport release: " @@ -52,6 +53,7 @@ module_init(compat_init); static void __exit compat_exit(void) { compat_pm_qos_power_deinit(); + compat_system_workqueue_destroy(); return; } diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index f4d6f800..29ade270 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -134,6 +134,21 @@ static inline void skb_tx_timestamp(struct sk_buff *skb) { } +extern struct workqueue_struct *system_nrt_wq; + +void compat_system_workqueue_create(void); +void compat_system_workqueue_destroy(void); + +#else + +static inline void compat_system_workqueue_create(void) +{ +} + +static inline void compat_system_workqueue_destroy(void) +{ +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ -- cgit v1.2.3 From 6aa696275db413e824d7efd4c5846d8028d808fd Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 6 Nov 2011 22:25:04 +0100 Subject: comapt: add skb_frag_size() and hex_byte_pack() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.26.h | 3 +++ include/linux/compat-3.2.h | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 9a67e9d6..177792a3 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -447,6 +447,9 @@ static inline u64 div_u64(u64 dividend, u32 divisor) #endif /* source: include/math64.h */ +#define hex_asc_lo(x) hex_asc((x) & 0x0f) +#define hex_asc_hi(x) hex_asc(((x) & 0xf0) >> 4) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)) */ #endif /* LINUX_26_26_COMPAT_H */ diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index 859a2e33..ceaaecc4 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -60,6 +60,18 @@ static inline dma_addr_t skb_frag_dma_map(struct device *dev, #define ETH_P_TDLS 0x890D /* TDLS */ +static inline unsigned int skb_frag_size(const skb_frag_t *frag) +{ + return frag->size; +} + +static inline char *hex_byte_pack(char *buf, u8 byte) +{ + *buf++ = hex_asc_hi(byte); + *buf++ = hex_asc_lo(byte); + return buf; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From fd3c35562f613a8b1599facf110120db2bd2d10b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 8 Nov 2011 21:46:31 +0100 Subject: compat: add some workarounds for Debian squeeze Debian squeeze also backports some stuff and this conflicts with compat wireless stuff. This is a nice way of making compat work with debian squeeze without breaking normal kernels. Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.33.h | 9 +++++++++ include/linux/compat-2.6.34.h | 6 ++++++ 2 files changed, 15 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 386ee4c9..539b4692 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -55,6 +55,9 @@ static inline void compat_release_firmware(const struct firmware *fw) /* this will never happen on older kernels */ #define NETDEV_POST_INIT 0xffff +/* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */ +#define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b) + static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length) { @@ -107,6 +110,9 @@ int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, #define sock_recv_ts_and_drops(msg, sk, skb) sock_recv_timestamp(msg, sk, skb) +/* mask pci_pcie_cap as debian squeeze also backports this */ +#define pci_pcie_cap(a) compat_pci_pcie_cap(a) + /** * pci_pcie_cap - get the saved PCIe capability offset * @dev: PCI device @@ -144,6 +150,9 @@ static inline bool pci_is_pcie(struct pci_dev *dev) #define __always_unused /* unimplemented */ #endif +/* mask IS_ERR_OR_NULL as debian squeeze also backports this */ +#define IS_ERR_OR_NULL(a) compat_IS_ERR_OR_NULL(a) + static inline long __must_check IS_ERR_OR_NULL(const void *ptr) { return !ptr || IS_ERR_VALUE((unsigned long)ptr); diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 0ab344ce..562ccf79 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -212,6 +212,8 @@ do { \ #define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) #define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) +/* only include this if DEFINE_DMA_UNMAP_ADDR is not set as debian squeeze also backports this */ +#ifndef DEFINE_DMA_UNMAP_ADDR #ifdef CONFIG_NEED_DMA_MAP_STATE #define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME #define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME @@ -227,6 +229,10 @@ do { \ #define dma_unmap_len(PTR, LEN_NAME) (0) #define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0) #endif +#endif + +/* mask dma_set_coherent_mask as debian squeeze also backports this */ +#define dma_set_coherent_mask(a, b) compat_dma_set_coherent_mask(a, b) static inline int dma_set_coherent_mask(struct device *dev, u64 mask) { -- cgit v1.2.3 From 1beb89be71396017e1858161472f09a4694a0864 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Mon, 14 Nov 2011 17:58:07 +0100 Subject: compat: add skb_complete_wifi_ack & feature flag This just needs to be empty -- older kernels don't have the necessary infrastructure for this. Signed-off-by: Johannes Berg --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.3.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 include/linux/compat-3.3.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index d933602d..c23e94a4 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -35,5 +35,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h new file mode 100644 index 00000000..2e1e6d3e --- /dev/null +++ b/include/linux/compat-3.3.h @@ -0,0 +1,20 @@ +#ifndef LINUX_3_3_COMPAT_H +#define LINUX_3_3_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) + +/* include to override NL80211_FEATURE_SK_TX_STATUS */ +#include + + +static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) +{ + WARN_ON(1); +} +#define NL80211_FEATURE_SK_TX_STATUS 0 + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */ + +#endif /* LINUX_3_3_COMPAT_H */ -- cgit v1.2.3 From 365a14b5d4f1a5119ba5e5aaef280eeebee4b9e4 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 17 Nov 2011 17:20:39 -0500 Subject: compat: use separate CONFIG_COMPAT_KFIFO option for building kfifo.o Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index 2fb18934..fc43ba18 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -24,9 +24,9 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_29) += compat-2.6.29.o compat-$(CONFIG_COMPAT_KERNEL_2_6_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_2_6_33) += compat-2.6.33.o compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += compat-2.6.35.o -compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += \ - compat-2.6.36.o \ - kfifo.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += compat-2.6.36.o + +compat-$(CONFIG_COMPAT_KFIFO) += kfifo.o compat-$(CONFIG_COMPAT_KERNEL_2_6_37) += compat-2.6.37.o compat-$(CONFIG_COMPAT_KERNEL_2_6_38) += compat-2.6.38.o -- cgit v1.2.3 From 76aa861bac39a0aa2ae7e53743d3ba78ba7e7049 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 17 Nov 2011 17:20:40 -0500 Subject: compat: add CONFIG_COMPAT_FIRMWARE_DATA_RW_NEEDS_FILP Some kernels have versions of (struct bin_attribute)->{read,write} that require a struct file * as their first argument. This change accommodates them in the firmware loader class. Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 79cd543e..4eb5ba7e 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -314,9 +314,15 @@ static ssize_t firmware_loading_store(struct device *dev, static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); +#if defined(CONFIG_COMPAT_FIRMWARE_DATA_RW_NEEDS_FILP) +static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) +#else static ssize_t firmware_data_read(struct kobject *kobj, struct bin_attribute *bin_attr, char *buffer, loff_t offset, size_t count) +#endif { struct device *dev = to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); @@ -407,9 +413,15 @@ static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) * Data written to the 'data' attribute will be later handed to * the driver as a firmware image. **/ +#if defined(CONFIG_COMPAT_FIRMWARE_DATA_RW_NEEDS_FILP) +static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj, + struct bin_attribute *bin_attr, + char *buffer, loff_t offset, size_t count) +#else static ssize_t firmware_data_write(struct kobject *kobj, struct bin_attribute *bin_attr, char *buffer, loff_t offset, size_t count) +#endif { struct device *dev = to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); -- cgit v1.2.3 From b88dc2f2c3ee68ef04f5ace2d2425573f17e5adf Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 17 Nov 2011 17:20:41 -0500 Subject: compat: check CONFIG_COMPAT_FIRMWARE_CLASS in compat-2.6.33.h If a pre-2.6.33 kernel has backported suitable firmware loader functionality, then it doesn't need the compat_firmware_class. In that case, compat-2.6.33 should not redefine the *_firmware function names. Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 539b4692..e9e888a3 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -14,9 +14,11 @@ #endif #include +#if defined(CONFIG_COMPAT_FIRMWARE_CLASS) #define release_firmware compat_release_firmware #define request_firmware compat_request_firmware #define request_firmware_nowait compat_request_firmware_nowait +#endif #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) int compat_request_firmware(const struct firmware **fw, const char *name, -- cgit v1.2.3 From 1d86517258376a4b71c3a99a663aa88dcb975928 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 17 Nov 2011 17:20:42 -0500 Subject: compat: support RHEL6 as a build target This patch enables compatibility with RHEL6 as a build target, mostly with simple tricks similar to what was added for compatibility with Debian Squeeze. Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 4 ++-- compat/compat-2.6.37.c | 4 ++-- include/linux/compat-2.6.33.h | 7 +++++++ include/linux/compat-2.6.34.h | 19 +++++++++++++++++++ include/linux/compat-2.6.35.h | 3 +++ include/linux/compat-2.6.36.h | 3 +++ include/linux/compat-2.6.37.h | 6 ++++++ 7 files changed, 42 insertions(+), 4 deletions(-) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 44a15d63..7a31a540 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -18,7 +18,7 @@ * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad * input. */ -int hex_to_bin(char ch) +int compat_hex_to_bin(char ch) { if ((ch >= '0') && (ch <= '9')) return ch - '0'; @@ -27,7 +27,7 @@ int hex_to_bin(char ch) return ch - 'a' + 10; return -1; } -EXPORT_SYMBOL(hex_to_bin); +EXPORT_SYMBOL(compat_hex_to_bin); /** * noop_llseek - No Operation Performed llseek implementation diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 257880ea..d7259bb6 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -345,7 +345,7 @@ EXPORT_SYMBOL(compat_led_classdev_unregister); * For tight control over page level allocator and protection flags * use __vmalloc() instead. */ -void *vzalloc(unsigned long size) +void *compat_vzalloc(unsigned long size) { void *buf; buf = vmalloc(size); @@ -353,6 +353,6 @@ void *vzalloc(unsigned long size) memset(buf, 0, size); return buf; } -EXPORT_SYMBOL(vzalloc); +EXPORT_SYMBOL(compat_vzalloc); #endif diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index e9e888a3..c900a6fc 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -13,6 +13,7 @@ #include #endif #include +#include #if defined(CONFIG_COMPAT_FIRMWARE_CLASS) #define release_firmware compat_release_firmware @@ -49,7 +50,10 @@ static inline void compat_release_firmware(const struct firmware *fw) } #endif +/* mask KEY_RFKILL as RHEL6 backports this */ +#if !defined(KEY_RFKILL) #define KEY_RFKILL 247 /* Key that controls all radios */ +#endif #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ @@ -131,6 +135,9 @@ static inline int pci_pcie_cap(struct pci_dev *dev) return pci_find_capability(dev, PCI_CAP_ID_EXP); } +/* mask pci_is_pcie as RHEL6 backports this */ +#define pci_is_pcie(a) compat_pci_is_pcie(a) + /** * pci_is_pcie - check if the PCI device is PCI Express capable * @dev: PCI device diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 562ccf79..a9c9dd11 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -46,6 +46,9 @@ #define netdev_info(dev, format, args...) \ netdev_printk(KERN_INFO, dev, format, ##args) +/* mask netdev_dbg as RHEL6 backports this */ +#if !defined(netdev_dbg) + #if defined(DEBUG) #define netdev_dbg(__dev, format, args...) \ netdev_printk(KERN_DEBUG, __dev, format, ##args) @@ -64,6 +67,11 @@ do { \ }) #endif +#endif + +/* mask netdev_vdbg as RHEL6 backports this */ +#if !defined(netdev_dbg) + #if defined(VERBOSE_DEBUG) #define netdev_vdbg netdev_dbg #else @@ -76,6 +84,8 @@ do { \ }) #endif +#endif + /* * netdev_WARN() acts like dev_printk(), but with the key difference * of using a WARN/WARN_ON to get the message out, including the @@ -107,6 +117,9 @@ do { \ #define netif_info(priv, type, dev, fmt, args...) \ netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args) +/* mask netif_dbg as RHEL6 backports this */ +#if !defined(netif_dbg) + #if defined(DEBUG) #define netif_dbg(priv, type, dev, format, args...) \ netif_printk(priv, type, KERN_DEBUG, dev, format, ##args) @@ -127,6 +140,11 @@ do { \ }) #endif +#endif + +/* mask netif_vdbg as RHEL6 backports this */ +#if !defined(netif_vdbg) + #if defined(VERBOSE_DEBUG) #define netif_vdbg netdev_dbg #else @@ -137,6 +155,7 @@ do { \ 0; \ }) #endif +#endif /* source: include/linux/netdevice.h */ diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 857a5217..5e43002f 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -26,6 +26,9 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) #define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret) +/* mask hex_to_bin as RHEL6 backports this */ +#define hex_to_bin(a) compat_hex_to_bin(a) + int hex_to_bin(char ch); extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 29ade270..b5d9975f 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -14,6 +14,9 @@ #define kparam_block_sysfs_write(a) #define kparam_unblock_sysfs_write(a) +/* mask va_format as RHEL6 backports this */ +#define va_format compat_va_format + struct va_format { const char *fmt; va_list *va; diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index d375746f..c19e7818 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -12,6 +12,9 @@ extern struct kobj_ns_type_operations net_ns_type_operations; +/* mask skb_checksum_none_assert as RHEL6 backports this */ +#define skb_checksum_none_assert(a) compat_skb_checksum_none_assert(a) + /** * skb_checksum_none_assert - make sure skb ip_summed is CHECKSUM_NONE * @skb: skb to check @@ -110,6 +113,9 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev, #define netdev_refcnt_read(a) atomic_read(&a->refcnt) +/* mask vzalloc as RHEL6 backports this */ +#define vzalloc(a) compat_vzalloc(a) + extern void *vzalloc(unsigned long size); #define rtnl_dereference(p) \ -- cgit v1.2.3 From 63ea3fade83abd8b66f27c00aea9965883b6797a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 17 Nov 2011 22:23:09 +0100 Subject: compat: add support for kernel 3.2 This adds suport for kernel 3.2. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 17 ----------------- include/linux/compat-3.3.h | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index ceaaecc4..db0f648a 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -8,23 +8,6 @@ #include #include -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) /** diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 2e1e6d3e..4e96ddcf 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -8,6 +8,22 @@ /* include to override NL80211_FEATURE_SK_TX_STATUS */ #include +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) +#else +#define br_port_exists(dev) (dev->br_port) +#endif static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) { -- cgit v1.2.3 From 46c619e9b5196622cb9ff07998aaaab492f29965 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 18 Nov 2011 00:05:45 +0100 Subject: compat: backport kfree_rcu() This adds a nested function everywhere kfree_rcu() was called. This function frees the memory and is given as a function to call_rcu(). The kfree_rcu define was made by Johannes Berg. The rcu callback could happen every time also after the module was unloaded and this will cause problems. A rcu_barrier() was added into every module_exit so that this will not be called after the module was unloaded. The define overwriting module_exit is based on the original module_exit which looks like this: /* This is only required if you want to be unloadable. */ /#define module_exit(exitfn) \ static inline exitcall_t __exittest(void) \ { return exitfn; } \ void cleanup_module(void) __attribute__((alias(#exitfn))); We replaced the call to the actual function exitfn() with a call to our function which calls the original exitfn() and then rcu_barrier() As a module will not be unloaded that ofter it should not have a big performance impact when rcu_barrier() is called on every module exit, also when no kfree_rcu() backport is used in that module. Signed-off-by: Hauke Mehrtens CC: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.0.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index 8c8720e0..22ab5399 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) +#include + /* * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171 * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is @@ -79,6 +81,50 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t return kstrtoint_from_user(s, count, base, res); } +/* + * This adds a nested function everywhere kfree_rcu() was called. This + * function frees the memory and is given as a function to call_rcu(). + * The rcu callback could happen every time also after the module was + * unloaded and this will cause problems. + */ +#define kfree_rcu(data, rcuhead) do { \ + void __kfree_rcu_fn(struct rcu_head *rcu_head) \ + { \ + void *___ptr; \ + ___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\ + kfree(___ptr); \ + } \ + call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \ + } while (0) + +#ifdef MODULE + +/* + * The define overwriting module_exit is based on the original module_exit + * which looks like this: + * #define module_exit(exitfn) \ + * static inline exitcall_t __exittest(void) \ + * { return exitfn; } \ + * void cleanup_module(void) __attribute__((alias(#exitfn))); + * + * We replaced the call to the actual function exitfn() with a call to our + * function which calls the original exitfn() and then rcu_barrier() + * + * As a module will not be unloaded that ofter it should not have a big + * performance impact when rcu_barrier() is called on every module exit, + * also when no kfree_rcu() backport is used in that module. + */ +#undef module_exit +#define module_exit(exitfn) \ + static void __exit __exit_compat(void) \ + { \ + exitfn(); \ + rcu_barrier(); \ + } \ + void cleanup_module(void) __attribute__((alias("__exit_compat"))); + +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */ #endif /* LINUX_3_0_COMPAT_H */ -- cgit v1.2.3 From 2ffd0a5e8b5f0442f97823b9d1f6d6d2e40ae255 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 17 Nov 2011 22:23:11 +0100 Subject: compat: backport netdev_features_t Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 4e96ddcf..9383a6ea 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -31,6 +31,8 @@ static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) } #define NL80211_FEATURE_SK_TX_STATUS 0 +typedef u32 netdev_features_t; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */ #endif /* LINUX_3_3_COMPAT_H */ -- cgit v1.2.3 From 47605dffae9c3d049b2667933c5b68630682d842 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 16 Nov 2011 19:39:33 -0500 Subject: compat: avoid warning in compat_system_workqueue_create The check in the WARN_ON is inverted. Signed-off-by: John W. Linville --- compat/compat-2.6.36.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index aab25df7..fe24da83 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -99,7 +99,7 @@ EXPORT_SYMBOL_GPL(system_nrt_wq); void compat_system_workqueue_create() { system_nrt_wq = create_singlethread_workqueue("events_nrt"); - WARN_ON(system_nrt_wq); + WARN_ON(!system_nrt_wq); } void compat_system_workqueue_destroy() -- cgit v1.2.3 From a63f3966024f9e6fccde1186c8ae53de26e1d73e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Sun, 20 Nov 2011 10:39:22 +0100 Subject: compat: fix misplaced #ifdef for the workqueue backport Signed-off-by: Felix Fietkau --- compat/compat-2.6.36.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index fe24da83..dfab2ea9 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -93,6 +93,8 @@ void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) } EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); +#endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ + struct workqueue_struct *system_nrt_wq __read_mostly; EXPORT_SYMBOL_GPL(system_nrt_wq); @@ -106,6 +108,3 @@ void compat_system_workqueue_destroy() { destroy_workqueue(system_nrt_wq); } - -#endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ - -- cgit v1.2.3 From 545ece91974440f6447bbd27a44775bdaeee8212 Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Fri, 18 Nov 2011 15:52:44 -0500 Subject: compat: implement dummy security_sk_clone This has been defined in include/linux/security.h for some time, but was only given an EXPORT_SYMBOL for 3.1. Add a compat_* definition to avoid breaking the module load with an undefined symbol. Signed-off-by: John W. Linville --- include/linux/compat-3.1.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 93bb1f6e..e247791a 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -19,6 +19,17 @@ .prod_id = { NULL, NULL, (v3), NULL }, \ .prod_id_hash = { 0, 0, (vh3), 0 }, } +/* + * This has been defined in include/linux/security.h for some time, but was + * only given an EXPORT_SYMBOL for 3.1. Add a compat_* definition to avoid + * breaking the compile. + */ +#define security_sk_clone(a, b) compat_security_sk_clone(a, b) + +static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) +{ +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From e77058754c01b758ae1607eb8b7ffbddd13160c9 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 2 Dec 2011 11:28:26 +0100 Subject: compat: backport atomic64 support Signed-off-by: Felix Fietkau --- compat/Makefile | 5 +++++ compat/compat_atomic.c | 33 +++++++++++++++++++++++++++++++++ include/linux/compat-2.6.31.h | 14 ++++++++++++++ include/linux/compat-3.1.h | 12 ++++++++++++ 4 files changed, 64 insertions(+) create mode 100644 compat/compat_atomic.c diff --git a/compat/Makefile b/compat/Makefile index fc43ba18..9e4db448 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -38,3 +38,8 @@ compat-$(CONFIG_COMPAT_KERNEL_3_1) += \ cordic.o \ crc8.o +ifndef CONFIG_64BIT +ifndef CONFIG_GENERIC_ATOMIC64 + compat-y += compat_atomic.o +endif +endif diff --git a/compat/compat_atomic.c b/compat/compat_atomic.c new file mode 100644 index 00000000..747e275b --- /dev/null +++ b/compat/compat_atomic.c @@ -0,0 +1,33 @@ +#include +#include + +#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && (defined(CONFIG_UML) || defined(CONFIG_X86))) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64)) + +static DEFINE_SPINLOCK(lock); + +long long atomic64_read(const atomic64_t *v) +{ + unsigned long flags; + long long val; + + spin_lock_irqsave(&lock, flags); + val = v->counter; + spin_unlock_irqrestore(&lock, flags); + return val; +} +EXPORT_SYMBOL(atomic64_read); + +long long atomic64_add_return(long long a, atomic64_t *v) +{ + unsigned long flags; + long long val; + + spin_lock_irqsave(&lock, flags); + val = v->counter += a; + spin_unlock_irqrestore(&lock, flags); + return val; +} +EXPORT_SYMBOL(atomic64_add_return); + +#endif + diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index ce944bb8..25db973d 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -202,6 +202,20 @@ void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp) #define skb_walk_frags(skb, iter) \ for (iter = skb_shinfo(skb)->frag_list; iter; iter = iter->next) +#ifndef CONFIG_64BIT + +typedef struct { + long long counter; +} atomic64_t; + +extern long long atomic64_read(const atomic64_t *v); +extern long long atomic64_add_return(long long a, atomic64_t *v); + +#define atomic64_inc_return(v) atomic64_add_return(1LL, (v)) + +#endif + + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ #endif /* LINUX_26_31_COMPAT_H */ diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index e247791a..0832183c 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -30,6 +30,18 @@ static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) { } +/* + * In many versions, several architectures do not seem to include an + * atomic64_t implementation, and do not include the software emulation from + * asm-generic/atomic64_t. + * Detect and handle this here. + */ +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && !defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64)) +#include +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From 0c51ea9ee6ad49b34dadf92798f7109f12cd0490 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 2 Dec 2011 12:12:46 +0100 Subject: compat: fix security_sk_clone dummy backport compile linux/security.h needs to be included before the dummy function overrides it, otherwise the macro that redirects it to the compat version will apply to the kernel function as well, causing multiple conflicting definitions Signed-off-by: Felix Fietkau --- include/linux/compat-3.1.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 0832183c..5b00ac96 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) +#include + #define genl_dump_check_consistent(cb, user_hdr, family) #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing -- cgit v1.2.3 From cf471d233ec6b80d5c29a12a344a3eef03ff20e6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 3 Dec 2011 15:49:25 +0100 Subject: compat: add config var for CORDIC and CRC8 Sometimes the kernel version compat-wireless is build against has support for cordic and crc8 in its source, but these modules were not build when the kernel was build, because no one selected them. The modules are needed for the bcmsmac driver and they should be build every time when they were not already build while the kernel was build. Signed-off-by: Hauke Mehrtens --- compat/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index 9e4db448..fa9c6cb9 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,9 +34,9 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o -compat-$(CONFIG_COMPAT_KERNEL_3_1) += \ - cordic.o \ - crc8.o + +compat-$(CONFIG_COMPAT_CORDIC) += cordic.o +compat-$(CONFIG_COMPAT_CRC8) += crc8.o ifndef CONFIG_64BIT ifndef CONFIG_GENERIC_ATOMIC64 -- cgit v1.2.3 From 984ab77279488f3fea4436da76c0f81a618cef1b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 3 Dec 2011 15:49:26 +0100 Subject: compat: add module_usb_driver and module_platform_driver Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.2.h | 9 +++++++++ include/linux/compat-3.3.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index db0f648a..fb9ef68b 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -55,6 +55,15 @@ static inline char *hex_byte_pack(char *buf, u8 byte) return buf; } +/* module_platform_driver() - Helper macro for drivers that don't do + * anything special in module init/exit. This eliminates a lot of + * boilerplate. Each module may only use this macro once, and + * calling it replaces module_init() and module_exit() + */ +#define module_platform_driver(__platform_driver) \ + module_driver(__platform_driver, platform_driver_register, \ + platform_driver_unregister) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 9383a6ea..821333c4 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -33,6 +33,41 @@ static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) typedef u32 netdev_features_t; +/* source include/linux/device.h */ +/** + * module_driver() - Helper macro for drivers that don't do anything + * special in module init/exit. This eliminates a lot of boilerplate. + * Each module may only use this macro once, and calling it replaces + * module_init() and module_exit(). + * + * Use this macro to construct bus specific macros for registering + * drivers, and do not use it on its own. + */ +#define module_driver(__driver, __register, __unregister) \ +static int __init __driver##_init(void) \ +{ \ + return __register(&(__driver)); \ +} \ +module_init(__driver##_init); \ +static void __exit __driver##_exit(void) \ +{ \ + __unregister(&(__driver)); \ +} \ +module_exit(__driver##_exit); + +/* source include/linux/usb.h */ +/** + * module_usb_driver() - Helper macro for registering a USB driver + * @__usb_driver: usb_driver struct + * + * Helper macro for USB drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_usb_driver(__usb_driver) \ + module_driver(__usb_driver, usb_register, \ + usb_deregister) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */ #endif /* LINUX_3_3_COMPAT_H */ -- cgit v1.2.3 From 0334240f5e499c615bee55aa6224f3e640ad8079 Mon Sep 17 00:00:00 2001 From: Nikolay Martynov Date: Mon, 16 Jan 2012 00:07:55 -0500 Subject: Add dma_zalloc_coherent to fix build with kernels older than 3.2 Signed-off-by: Nikolay Martynov Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index fb9ef68b..a17c4adf 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -64,6 +64,15 @@ static inline char *hex_byte_pack(char *buf, u8 byte) module_driver(__platform_driver, platform_driver_register, \ platform_driver_unregister) +static inline void *dma_zalloc_coherent(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t flag) +{ + void *ret = dma_alloc_coherent(dev, size, dma_handle, flag); + if (ret) + memset(ret, 0, size); + return ret; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From fd3a74e12f687509da0a996b4e01c4fa6ca32ff8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 31 Jan 2012 14:44:41 -0800 Subject: compat: backport __netdev_printk() This was added in v3.2, and will be used by the new shiny alx Ethernet driver which is not yet upstream. Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.2.c | 26 ++++++++++++++++++++++++++ include/linux/compat-3.2.h | 3 +++ 3 files changed, 30 insertions(+) create mode 100644 compat/compat-3.2.c diff --git a/compat/Makefile b/compat/Makefile index fa9c6cb9..3c72ef9b 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,6 +34,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o +compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c new file mode 100644 index 00000000..2e4902fe --- /dev/null +++ b/compat/compat-3.2.c @@ -0,0 +1,26 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.2. + */ + +int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf) +{ + int r; + + if (dev && dev->dev.parent) + r = dev_printk(level, dev->dev.parent, "%s: %pV", + netdev_name(dev), vaf); + else if (dev) + r = printk("%s%s: %pV", level, netdev_name(dev), vaf); + else + r = printk("%s(NULL net_device): %pV", level, vaf); + + return r; +} +EXPORT_SYMBOL(__netdev_printk); diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index a17c4adf..cb14f0b1 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -73,6 +73,9 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size, return ret; } +extern int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From d2b5324b2d3532f150cb82dc2cd1d53d40ceceab Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 26 Jan 2012 23:51:45 +0100 Subject: compat: move br_port_exists() to compat-2.6.36.h br_port_exists() was moved to a new compat-*.h file for every new kernel release, as it is not in mainline. This patch moves it to compat- 2.6.36.h so it has not to be moved any more for a new kernel version. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.36.h | 15 +++++++++++++++ include/linux/compat-3.3.h | 17 ----------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index b5d9975f..314fb353 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -142,6 +142,8 @@ extern struct workqueue_struct *system_nrt_wq; void compat_system_workqueue_create(void); void compat_system_workqueue_destroy(void); +#define br_port_exists(dev) (dev->br_port) + #else static inline void compat_system_workqueue_create(void) @@ -152,6 +154,19 @@ static inline void compat_system_workqueue_destroy(void) { } +/* + * This is not part of The 2.6.37 kernel yet but we + * we use it to optimize the backport code we + * need to implement. Instead of using ifdefs + * to check what version of the check we use + * we just replace all checks on current code + * with this. I'll submit this upstream too, that + * way all we'd have to do is to implement this + * for older kernels, then we would not have to + * edit the upstrema code for backport efforts. + */ +#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ #endif /* LINUX_26_36_COMPAT_H */ diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 821333c4..4965f234 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -8,23 +8,6 @@ /* include to override NL80211_FEATURE_SK_TX_STATUS */ #include -/* - * This is not part of The 2.6.37 kernel yet but we - * we use it to optimize the backport code we - * need to implement. Instead of using ifdefs - * to check what version of the check we use - * we just replace all checks on current code - * with this. I'll submit this upstream too, that - * way all we'd have to do is to implement this - * for older kernels, then we would not have to - * edit the upstrema code for backport efforts. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) -#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT) -#else -#define br_port_exists(dev) (dev->br_port) -#endif - static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) { WARN_ON(1); -- cgit v1.2.3 From 76d24cc3d9c3a56ed90752c233200e372d55744f Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Thu, 26 Jan 2012 13:00:56 -0500 Subject: compat: use kconfig.h in compat-2.6.h for 3.1 and later kernels This file was introduced in commit 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99 and included in 3.1 and later kernels. It includes itself, as well as some other definitions that are used elsewhere. Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index c23e94a4..3ccd0516 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -2,7 +2,9 @@ #define LINUX_26_COMPAT_H #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) +#include +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) #include #else #include -- cgit v1.2.3 From 61edfc0cb7f9bd5624d77d6755ec5ad8724a2da4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 3 Feb 2012 10:25:35 -0800 Subject: Revert "compat: backport __netdev_printk()" Reverting for now until this is fixed for all kernels that we support. This reverts commit fd3a74e12f687509da0a996b4e01c4fa6ca32ff8. --- compat/Makefile | 1 - compat/compat-3.2.c | 26 -------------------------- include/linux/compat-3.2.h | 3 --- 3 files changed, 30 deletions(-) delete mode 100644 compat/compat-3.2.c diff --git a/compat/Makefile b/compat/Makefile index 3c72ef9b..fa9c6cb9 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,7 +34,6 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o -compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c deleted file mode 100644 index 2e4902fe..00000000 --- a/compat/compat-3.2.c +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 2012 Luis R. Rodriguez - * - * 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 3.2. - */ - -int __netdev_printk(const char *level, const struct net_device *dev, - struct va_format *vaf) -{ - int r; - - if (dev && dev->dev.parent) - r = dev_printk(level, dev->dev.parent, "%s: %pV", - netdev_name(dev), vaf); - else if (dev) - r = printk("%s%s: %pV", level, netdev_name(dev), vaf); - else - r = printk("%s(NULL net_device): %pV", level, vaf); - - return r; -} -EXPORT_SYMBOL(__netdev_printk); diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index cb14f0b1..a17c4adf 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -73,9 +73,6 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size, return ret; } -extern int __netdev_printk(const char *level, const struct net_device *dev, - struct va_format *vaf); - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From 7850d43b207e3d227264de98c3efeab5c477cfe8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 3 Feb 2012 13:51:42 -0800 Subject: compat: fix building for 3.0 kernels Changes integrated from compat-wireless Signed-off-by: Luis R. Rodriguez --- Makefile | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 9ff4611c..8b6484ae 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,23 @@ endif # This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for # each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) -COMPAT_LATEST_VERSION = 33 -KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') + +COMPAT_LATEST_VERSION = 3 +KERNEL_VERSION := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') + +ifneq ($(KERNEL_VERSION),2) +KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p') +else +COMPAT_26LATEST_VERSION = 39 +KERNEL_26SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') +COMPAT_26VERSIONS := $(shell I=$(COMPAT_26LATEST_VERSION); while [ "$$I" -gt $(KERNEL_26SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) +$(foreach ver,$(COMPAT_26VERSIONS),$(eval CONFIG_COMPAT_KERNEL_2_6_$(ver)=y)) +KERNEL_SUBLEVEL := -1 +endif + COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_$(ver)=y)) +$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_3_$(ver)=y)) + endif ifeq ($(CONFIG_COMPAT_KERNEL_33),y) -- cgit v1.2.3 From 0a1a1f9d4e1f6482d345ac440bfe3dc67fc4e356 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 3 Feb 2012 15:10:46 -0800 Subject: compat: add .gitignore Signed-off-by: Luis R. Rodriguez --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..0f4ebc6d --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*~ +Module.symvers +module.order +.pc -- cgit v1.2.3 From bf6052e711bd263425bcdebc7b8fa7115db5c9bc Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 3 Feb 2012 15:11:07 -0800 Subject: compat: add compat kernel checker and downloader This adds get-compat-kernels, a utility that is intended to be Linux distribution agnostic that downloads and installs all kernel headers for all supported kernel releases of compat. You also have the option of specifying you want to also install the actual kernel image (get-compat-kernels -i). We start off by adding support for Ubuntu on x86_64 as that is what a few of us maintaining compat and compat-wireless run. Just for kernel headers (default run of get-compat-kernels), you'll need currently 205 M of hard drive space. Once done with running get-compat-kernels, you can then start running ckmake to verify your compat kernel changes won't bust compilation against any known supported kernel. I'd like to start requiring runs against this script for patch submissions. Eventually we can try to add the same runs against compat-wireless so we can verify integrity against compilation for different kernel versions. Support for different Linux distributios is welcomed. Debug log goes out to ckmake.log Example output: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-8-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-12-generic [OK] Trying kernel 2.6.38-11-generic [OK] Trying kernel 2.6.38-10-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Cc: kernel-team@lists.ubuntu.com Signed-off-by: Luis R. Rodriguez --- .gitignore | 1 + bin/ckmake | 65 +++++++++++++++++++++ bin/get-compat-kernels | 154 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 220 insertions(+) create mode 100755 bin/ckmake create mode 100755 bin/get-compat-kernels diff --git a/.gitignore b/.gitignore index 0f4ebc6d..e27f6c2f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ Module.symvers module.order .pc +ckmake.log diff --git a/bin/ckmake b/bin/ckmake new file mode 100755 index 00000000..4d45fb99 --- /dev/null +++ b/bin/ckmake @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Copyright (C) 2012, Luis R. Rodriguez +# Copyright (C) 2012, Hauke Mehrtens +# +# 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. +# +# You can use this to compile a module accross all installed kernels +# found. This relies on distribution specific kernels, but can handle +# your own custom list of target kernels. Log is setnt to LOG variable. + +# Pretty colors +GREEN="\033[01;32m" +YELLOW="\033[01;33m" +NORMAL="\033[00m" +BLUE="\033[34m" +RED="\033[31m" +PURPLE="\033[35m" +CYAN="\033[36m" +UNDERLINE="\033[02m" + +#export KCFLAGS="-Wno-unused-but-set-variable" +KERNEL_DIR="/lib/modules" +KLIBS="" +LOG="ckmake.log" + +LSB_RED_ID=$(/usr/bin/lsb_release -i -s) +case $LSB_RED_ID in +"Ubuntu") + for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r); do + KLIBS="$KLIBS $i" + done + ;; +*) + echo -e "Unsupported distribution" + exit + ;; +esac + +nice make clean 2>&1 > $LOG + +for i in $KLIBS; do + KERNEL=$(basename $i) + DIR=${i}/build/ + echo -e "--------------------------------------------" >> $LOG + + if [[ ! -d $DIR ]]; then + continue + fi + + echo -en "Trying kernel ${BLUE}" | tee -a $LOG + printf "%40s\t" "${KERNEL}" | tee -a $LOG + echo -en "${NORMAL}" | tee -a $LOG + + ionice -c 3 nice -n 20 make KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG + if [[ $? -eq 0 ]]; then + echo -e "${GREEN}[OK]${NORMAL}" | tee -a $LOG + else + echo -e "${RED}[FAILED]${NORMAL}" | tee -a $LOG + fi + + nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG +done diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels new file mode 100755 index 00000000..07ac17bd --- /dev/null +++ b/bin/get-compat-kernels @@ -0,0 +1,154 @@ +#!/bin/bash +# +# Copyright (C) 2012, Luis R. Rodriguez +# +# 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. +# +# You can use this script to install all mainline kernels used +# to test compile the Linux kernel compatibility module. You can +# then use ckmake to cross compile against all supported kernels. + +function get_ubuntu_kernels() { + KERNELS="" + + KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" + + KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_amd64.deb" + + KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2_3.3.0-030300rc2.201201311735_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-image-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_amd64.deb" + + for i in $KERNELS; do + FILE=$(basename $i) + PKG=$(echo $FILE | awk -F"_" '{print $1}') + + echo "$i" | grep image 2>&1 > /dev/null + if [[ $? = 0 && $INSTALL_IMAGES != "y" ]]; then + continue + fi + + if [[ ! -f $FILE ]]; then + wget -c $i + fi + done + + # Let dpkg figure out dependency magic. + # + # XXX: I tried adding some magic to not install a package if + # if its already presently installed but then had to deal + # with the dependency mess. I welcome someone else to + # figure this out. Running this can come in handy once + # a new public kernel gets released. + sudo dpkg -i *.deb +} + +function usage() { + echo -e "Usage: $0 [ -i ]" + echo -e "" + echo -e "If you specify [ -i ] you will also download all kernel images and install them" +} + +INSTALL_IMAGES="n" + +if [[ $# -gt 1 ]]; then + usage + exit +fi + +if [[ $# -eq 1 && $1 != "-i" ]]; then + usage + exit +fi + +if [[ $# -eq 1 && $1 = "-i" ]]; then + INSTALL_IMAGES="y" +fi + + +LSB_RED_ID=$(/usr/bin/lsb_release -i -s) +case $LSB_RED_ID in +"Ubuntu") + get_ubuntu_kernels + ;; +*) + echo -e "Unsupported distribution" + exit + ;; +esac -- cgit v1.2.3 From 943182c56b345d23cc3401dbe7a153838e2dc21c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 3 Feb 2012 16:56:18 -0800 Subject: compat: export compat kernel versions info The reason this worked on compat-wireless was that config.mk exported every variable. We need to do the same. Signed-off-by: Luis R. Rodriguez --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8b6484ae..3a6b2df8 100644 --- a/Makefile +++ b/Makefile @@ -33,12 +33,12 @@ else COMPAT_26LATEST_VERSION = 39 KERNEL_26SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') COMPAT_26VERSIONS := $(shell I=$(COMPAT_26LATEST_VERSION); while [ "$$I" -gt $(KERNEL_26SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_26VERSIONS),$(eval CONFIG_COMPAT_KERNEL_2_6_$(ver)=y)) +$(foreach ver,$(COMPAT_26VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_2_6_$(ver)=y)) KERNEL_SUBLEVEL := -1 endif COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_VERSIONS),$(eval CONFIG_COMPAT_KERNEL_3_$(ver)=y)) +$(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_3_$(ver)=y)) endif -- cgit v1.2.3 From 95a119f3f13c3513baac430ff40175ad8faeea2c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 31 Jan 2012 14:44:41 -0800 Subject: compat: backport __netdev_printk() This was added in v3.2, and will be used by the new shiny alx Ethernet driver which is not yet upstream. This now has some fixes for 2.6.35. Tested with ckmake. Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.2.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/compat-3.2.h | 3 +++ 3 files changed, 38 insertions(+) create mode 100644 compat/compat-3.2.c diff --git a/compat/Makefile b/compat/Makefile index fa9c6cb9..3c72ef9b 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -34,6 +34,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o +compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c new file mode 100644 index 00000000..80f5597b --- /dev/null +++ b/compat/compat-3.2.c @@ -0,0 +1,34 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.2. + */ + +#include +#include + +int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf) +{ + int r; + + if (dev && dev->dev.parent) +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)) + r = dev_printk(level, dev->dev.parent, "%s: %pV", + netdev_name(dev), vaf); +#else + /* XXX: this could likely be done better but I'm lazy */ + r = printk("%s%s: %pV", level, netdev_name(dev), vaf); +#endif + else if (dev) + r = printk("%s%s: %pV", level, netdev_name(dev), vaf); + else + r = printk("%s(NULL net_device): %pV", level, vaf); + + return r; +} +EXPORT_SYMBOL(__netdev_printk); diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index a17c4adf..cb14f0b1 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -73,6 +73,9 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size, return ret; } +extern int __netdev_printk(const char *level, const struct net_device *dev, + struct va_format *vaf); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)) */ #endif /* LINUX_3_2_COMPAT_H */ -- cgit v1.2.3 From fd3788cef4493c287524e66221727a13b0d8cf2d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 00:36:04 -0800 Subject: compat: add x86 support to get-compat-kernels for Ubuntu Now both x86_64 and x86 are supported. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 97 +++++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 40 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 07ac17bd..7a253c2c 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -11,89 +11,106 @@ # then use ckmake to cross compile against all supported kernels. function get_ubuntu_kernels() { + + ARCH=$(uname -m) + TARGET="" + + case $ARCH in + "x86_64") + TARGET="amd64" + ;; + "i686") + TARGET="i386" + ;; + *) + echo -e "Unsupported architecture" + exit + ;; + esac + KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2_3.3.0-030300rc2.201201311735_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_amd64.deb" - KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-image-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_amd64.deb" + KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-image-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb" for i in $KERNELS; do FILE=$(basename $i) -- cgit v1.2.3 From a256f5102ea7b23a27015128481775202fb43e7b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 16:44:01 -0800 Subject: compat: fix for new CONFIG_COMPAT_KERNEL_2_6_* name changes On the CONFIG_COMPAT_KERNEL_2_6* name change earlier we forgot to update a few checks. Signed-off-by: Luis R. Rodriguez --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3a6b2df8..9215e6e8 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) endif -# This generates a bunch of CONFIG_COMPAT_KERNEL_22 CONFIG_COMPAT_KERNEL_23 .. etc for +# This generates a bunch of CONFIG_COMPAT_KERNEL_2_6_22 CONFIG_COMPAT_KERNEL_3_0 .. etc for # each kernel release you need an object for. ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) @@ -42,15 +42,15 @@ $(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_3_$(ver)=y)) endif -ifeq ($(CONFIG_COMPAT_KERNEL_33),y) +ifeq ($(CONFIG_COMPAT_KERNEL_2_6_33),y) ifneq ($(CONFIG_FW_LOADER),) export CONFIG_COMPAT_FIRMWARE_CLASS=m endif endif -ifeq ($(CONFIG_COMPAT_KERNEL_36),y) +ifeq ($(CONFIG_COMPAT_KERNEL_2_6_36),y) export CONFIG_COMPAT_KFIFO=m -endif #CONFIG_COMPAT_KERNEL_36 +endif #CONFIG_COMPAT_KERNEL_2_6_36 obj-y += compat/ -- cgit v1.2.3 From 4ec0edbd1cc2e6165e29f8ba466324e975e1cd73 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 17:21:43 -0800 Subject: compat: backport phys_addr_t (CONFIG_PHYS_ADDR_T_64BIT) mcgrof@tux ~/linux-stable (git::linux-3.2.y)$ \ git describe --contains 600715dcdf567c86f8b2c6173fcfb4b873e25a19 v2.6.28-rc1~271^2^4~6 The CONFIG_PHYS_ADDR_T_64BIT was added as of v2.6.28-rc1~271^2^4~6, this is either u32 or u64 dependent on 64BIT || ARCH_PHYS_ADDR_T_64BIT. The ARCH_PHYS_ADDR_T_64BIT allows architectures to override the value even if the platform does not have CONFIG_64BIT. We simplify this check by just checking for all known architecture variables and also the CONFIG_64BIT -- but we skip adding this if the arch is x86 or PPC which already had phys_addr_t. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.28.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index c92c8b48..c4865f09 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -8,6 +8,7 @@ #include #include #include +#include #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ @@ -15,6 +16,21 @@ #include +#if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC) +/* + * CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures + * as of 2.6.28 but x86 and ppc had it already. + */ +#else +#if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defned(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT) +#define CONFIG_PHYS_ADDR_T_64BIT 1 +typedef u64 phys_addr_t; +#else +typedef u32 phys_addr_t; +#endif + +#endif /* non x86 and ppc */ + #ifndef WARN_ONCE #define WARN_ONCE(condition, format...) ({ \ static int __warned; \ -- cgit v1.2.3 From e079e9b66ea06373a3be82f9bed1702082a69310 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 19:22:02 -0800 Subject: compat: backport making atomic_t and atomic64_t universal mcgrof@tux ~/linux-next (git::master)$ \ git describe --contains ea435467500612636f8f4fb639ff6e76b2496e4b v2.6.29-rc1~390 This commit moved atomic_t and atomic64_t to a generic place, but some archs already had it defined. Just include that header for the archs that had it. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index b4e12369..1e538bbd 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -16,6 +16,32 @@ #include #include +#include + +#if \ + defined(CONFIG_ALPHA) || defined(CONFIG_AVR32) || \ + defined(CONFIG_BLACKFIN) || defined(CONFIG_CRIS) || \ + defined(CONFIG_H8300) || defined(CONFIG_IA64) || \ + defined(CONFIG_M68K) || defined(CONFIG_MIPS) || \ + defined(CONFIG_PARISC) || defined(CONFIG_S390) || \ + defined(CONFIG_PPC64) || defined(CONFIG_PPC32) || \ + defined(CONFIG_SUPERH) || defined(CONFIG_SPARC) || \ + defined(CONFIG_FRV) || defined(CONFIG_X86) || \ + defined(CONFIG_M32R) || defined(CONFIG_M68K) || \ + defined(CONFIG_MN10300) || defined(CONFIG_XTENSA) +#include +#else +typedef struct { + volatile int counter; +} atomic_t; + +#ifdef CONFIG_64BIT +typedef struct { + volatile long counter; +} atomic64_t; +#endif /* CONFIG_64BIT */ + +#endif #define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */ -- cgit v1.2.3 From b861c7e684d90598f8662f7cbb9ca7f7df0d5efc Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 7 Feb 2012 20:01:55 -0800 Subject: compat: extend phys_addr_t backport to 2.6.24 x86 only got phys_addr_t as of 2.6.25. This patch addresses that. The only arch that had phys_addr_t prior to that is PPC. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 14 ++++++++++++++ include/linux/compat-2.6.28.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index ad3220a7..c389ab2c 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -17,6 +17,20 @@ #include #include +/* + * phys_addr_t was added as a generic arch typedef on 2.6.28, + * that backport is dealt with in compat-2.6.28.h + */ +#if defined(CONFIG_X86) || defined(CONFIG_X86_64) + +#if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defined(CONFIG_PHYS_64BIT) +typedef u64 phys_addr_t; +#else +typedef u32 phys_addr_t; +#endif + +#endif /* x86 */ + /* The macro below uses a const upstream, this differs */ /** diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index c4865f09..c0ca70b1 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -19,7 +19,8 @@ #if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC) /* * CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures - * as of 2.6.28 but x86 and ppc had it already. + * as of 2.6.28 but x86 and ppc had it already. x86 only got phys_addr_t + * as of 2.6.25 but then is backported in compat-2.6.25.h */ #else #if defined(CONFIG_64BIT) || defined(CONFIG_X86_PAE) || defned(CONFIG_PPC64) || defined(CONFIG_PHYS_64BIT) -- cgit v1.2.3 From 04f2c8aee54e3d1c0db2427458c5cf865d5b2baf Mon Sep 17 00:00:00 2001 From: "John W. Linville" Date: Wed, 15 Feb 2012 16:36:25 -0500 Subject: compat: add dummy lockdep_rtnl_is_held implementation Obviously, this is wrong. But the base kernel will have rtnl_mutex declared static, with no way to access it. I think this is the best we can do... Signed-off-by: John W. Linville Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.34.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index a9c9dd11..da242ce0 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -292,6 +292,18 @@ static inline int rcu_read_lock_held(void) return 1; } +#ifdef CONFIG_PROVE_LOCKING +/* + * Obviously, this is wrong. But the base kernel will have rtnl_mutex + * declared static, with no way to access it. I think this is the best + * we can do... + */ +static inline int lockdep_rtnl_is_held(void) +{ + return 1; +} +#endif /* #ifdef CONFIG_PROVE_LOCKING */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From a30bd3ceb80183417d53eeecb297f18a23ab660d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 16 Feb 2012 20:18:47 -0800 Subject: compat: README pointing to new shiny site Signed-off-by: Luis R. Rodriguez --- README | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 README diff --git a/README b/README new file mode 100644 index 00000000..c9ff2c83 --- /dev/null +++ b/README @@ -0,0 +1,8 @@ +compat +======= + +This is the Linux kernel backport compatibility module. + +For more details please visit: + +http://mcgrof.github.com/compat/ -- cgit v1.2.3 From 7bf2796dc1899d68c721a1b74777df4879c89a2e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 14:20:31 -0800 Subject: compat: fix few compilations by adding compat_autoconf.h support The Makefile was generating the appropriate CONFIG_COMPAT_KERNEL_* variables for our Makefiles but this was being ignored by C files as compat had no compat_autoconf.h being generated. This patch addresses this but also puhes out the CONFIG_COMPAT_KERNEL_* variable generation to scripts. We have now two scripts: scripts/gen-compat-config.sh - generates .config for Makefile propagation scripts/gen-compat-autoconf.sh - generates compat_autoconf.h for code propagation This fixes running ckmake on older kernels. This issue was present only on compat and not compat_wireless as compat_wireless was generating its own compat_autoconf.h. This fixes compilation against some older kernels of just the compat module alone. Some work is still required for some newer and really ancient kernels: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [FAILED] Trying kernel 3.2.2-030202-generic [FAILED] Trying kernel 3.1.10-030110-generic [FAILED] Trying kernel 3.0.18-030018-generic [FAILED] Trying kernel 2.6.39-02063904-generic [FAILED] Trying kernel 2.6.38-8-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-12-generic [OK] Trying kernel 2.6.38-11-generic [OK] Trying kernel 2.6.38-10-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [FAILED] Trying kernel 2.6.24-020624-generic [FAILED] Signed-off-by: Luis R. Rodriguez --- .gitignore | 10 ++++ Makefile | 59 ++++++++++------------ include/linux/compat_autoconf.h | 37 -------------- scripts/gen-compat-autoconf.sh | 105 ++++++++++++++++++++++++++++++++++++++++ scripts/gen-compat-config.sh | 50 +++++++++++++++++++ 5 files changed, 191 insertions(+), 70 deletions(-) delete mode 100644 include/linux/compat_autoconf.h create mode 100755 scripts/gen-compat-autoconf.sh create mode 100755 scripts/gen-compat-config.sh diff --git a/.gitignore b/.gitignore index e27f6c2f..498cb5ad 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,13 @@ Module.symvers module.order .pc ckmake.log +.config +include/linux/compat_autoconf.h +.tmp_versions/ +compat/*.cmd +compat/*.o +compat/*.mod.c +compat/*.ko +modules.order +modules +*.patch diff --git a/Makefile b/Makefile index 9215e6e8..fdcff5c7 100644 --- a/Makefile +++ b/Makefile @@ -20,37 +20,14 @@ export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) endif -# This generates a bunch of CONFIG_COMPAT_KERNEL_2_6_22 CONFIG_COMPAT_KERNEL_3_0 .. etc for -# each kernel release you need an object for. -ifneq ($(wildcard $(KLIB_BUILD)/Makefile),) +# to check config and compat autoconf +export COMPAT_CONFIG=.config +export COMPAT_AUTOCONF=include/linux/compat_autoconf.h +export MAKE -COMPAT_LATEST_VERSION = 3 -KERNEL_VERSION := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') - -ifneq ($(KERNEL_VERSION),2) -KERNEL_SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p') -else -COMPAT_26LATEST_VERSION = 39 -KERNEL_26SUBLEVEL := $(shell $(MAKE) -C $(KLIB_BUILD) kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') -COMPAT_26VERSIONS := $(shell I=$(COMPAT_26LATEST_VERSION); while [ "$$I" -gt $(KERNEL_26SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_26VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_2_6_$(ver)=y)) -KERNEL_SUBLEVEL := -1 -endif - -COMPAT_VERSIONS := $(shell I=$(COMPAT_LATEST_VERSION); while [ "$$I" -gt $(KERNEL_SUBLEVEL) ]; do echo $$I; I=$$(($$I - 1)); done) -$(foreach ver,$(COMPAT_VERSIONS),$(eval export CONFIG_COMPAT_KERNEL_3_$(ver)=y)) - -endif - -ifeq ($(CONFIG_COMPAT_KERNEL_2_6_33),y) -ifneq ($(CONFIG_FW_LOADER),) - export CONFIG_COMPAT_FIRMWARE_CLASS=m -endif -endif - -ifeq ($(CONFIG_COMPAT_KERNEL_2_6_36),y) - export CONFIG_COMPAT_KFIFO=m -endif #CONFIG_COMPAT_KERNEL_2_6_36 +# Recursion lets us ensure we get this file included. +# Trick is to run make -C $(PWD) modules later. +-include $(PWD)/$(COMPAT_CONFIG) obj-y += compat/ @@ -65,15 +42,31 @@ NOSTDINC_FLAGS := -I$(M)/include/ \ -DCOMPAT_PROJECT="\"Generic kernel\"" \ -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" -modules: +all: $(COMPAT_CONFIG) + +modules: $(COMPAT_CONFIG) $(COMPAT_AUTOCONF) $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules + @touch modules + install: modules $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \ modules_install depmod -a - @./scripts/compat_firmware_install + $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean + +$(COMPAT_AUTOCONF): ; + +$(COMPAT_CONFIG): + @$(PWD)/scripts/gen-compat-config.sh > $(PWD)/$(COMPAT_CONFIG) + @$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(PWD)/$(COMPAT_AUTOCONF) + @$(MAKE) -C $(PWD) modules + +install: modules + clean: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean -all: modules clean-files := Module.symvers modules.order Module.markers compat/modules.order +clean-files += modules $(COMPAT_CONFIG) $(COMPAT_AUTOCONF) + +.PHONY: all install clean diff --git a/include/linux/compat_autoconf.h b/include/linux/compat_autoconf.h deleted file mode 100644 index 813755c6..00000000 --- a/include/linux/compat_autoconf.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef COMPAT_AUTOCONF_INCLUDED -#define COMPAT_AUTOCONF_INCLUDED - -/* - * This is an example of a compat autconf header file that gets - * automatically generated by your projet. You will only need this - * if you are working with a lot of config options. - * - * Your project will likely just override this, or leave this as-is. - */ - -/* - * Example automatically generated C config: don't edit - * Thu Dec 10 10:34:11 PST 2009 - * compat-wireless-2.6: master-2009-11-19-5-gb4fd4dd - * linux-2.6: next-20091208 - */ -//#define COMPAT_PROJECT_FOO_RELEASE "master-2009-11-19-5-gb4fd4dd" -//#define COMPAT_UPSTREAM_FOO_KERNEL_RELEASE "next-20091208" - -/* Example kernel version minimum requirement */ -//#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10)) -//#error Compat-wireless requirement: Linux >= 2,6,10 -//#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) */ - -/* Example hard requirement */ -//#error Compat-wireless requirement: CONFIG_WIRELESS_EXT must be enabled in your kernel -//#endif /* CONFIG_WIRELESS_EXT */ - -/* - * Example of how to match your external modules kconfig options into this. - * You'll need something to generate this for you. - */ -//#ifndef CONFIG_FOO_BAR -//#define CONFIG_FOO_BAR 1 - -#endif /* COMPAT_AUTOCONF_INCLUDED */ diff --git a/scripts/gen-compat-autoconf.sh b/scripts/gen-compat-autoconf.sh new file mode 100755 index 00000000..e52cc5aa --- /dev/null +++ b/scripts/gen-compat-autoconf.sh @@ -0,0 +1,105 @@ +#!/bin/bash +# +# Copyright 2012 Luis R. Rodriguez +# Copyright 2011 Hauke Mehrtens +# Copyright 2011 John W. Linville +# +# Use this to parse a small .config equivalent looking file to generate +# our own autoconf.h. This file has defines for each config option +# just like the kernels include/linux/autoconf.h +# +# XXX: consider using scripts/kconfig/confdata.c instead. +# On the downside this would require the user to have libc though. + +# This indicates which is the oldest kernel we support +# Update this if you are adding support for older kernels. +OLDEST_KERNEL_SUPPORTED="2.6.24" + +if [ $# -ne 1 ]; then + echo "Usage $0 config-file" + exit +fi + +COMPAT_CONFIG="$1" + +if [ ! -f $COMPAT_CONFIG ]; then + echo "File $1 is not a file" + exit +fi + +# Defines a CONFIG_ option if not defined yet, this helps respect +# linux/autoconf.h +function define_config { + VAR=$1 + VALUE=$2 + case $VALUE in + n) # Try to undefine it + echo "#undef $VAR" + ;; + y) + echo "#ifndef $VAR" + echo "#define $VAR 1" + echo "#endif /* $VAR */" + ;; + m) + echo "#ifndef $VAR" + echo "#define $VAR 1" + echo "#endif /* $VAR */" + ;; + *) # Assume string + # XXX: add better checks to make sure what was on + # the right was indeed a string + echo "#ifndef $VAR" + echo "#define $VAR \"$VALUE\"" + echo "#endif /* $VAR */" + ;; + esac +} + +function kernel_version_req { + VERSION=$(echo $1 | sed -e 's/\./,/g') + echo "#if (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION))" + echo "#error compat requirement: Linux >= $VERSION" + echo "#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION($VERSION) */" +} + +cat <= \3)/' -e 's/\(#ifdef \)\(CONFIG_[^:space:]*\)/#if defined(\2) || defined(\2_MODULE)/' + continue + ;; + 'ifndef+CONFIG_'* ) + echo "#$i" | sed -e 's/+/ /' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,\2,0))/' -e 's/\(ifndef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,\2))/' -e 's/\(ifndef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (!defined(RHEL_MAJOR) || RHEL_MAJOR != \2 || RHEL_MINOR < \3)/' -e 's/\(#ifndef \)\(CONFIG_[^:space:]*\)/#if !defined(\2) \&\& !defined(\2_MODULE)/' + continue + ;; + 'else+#CONFIG_'* | 'endif+#CONFIG_'* ) + echo "#$i */" |sed -e 's/+#/ \/* /g' + continue + ;; + CONFIG_* ) + # Get the element on the left of the "=" + VAR=$(echo $i | cut -d"=" -f 1) + # Get the element on the right of the "=" + VALUE=$(echo $i | cut -d"=" -f 2) + + # Any other module which can *definitely* be built as a module goes here + define_config $VAR $VALUE + continue + ;; + esac +done + +echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh new file mode 100755 index 00000000..82b439ce --- /dev/null +++ b/scripts/gen-compat-config.sh @@ -0,0 +1,50 @@ +#!/bin/bash +# Copyright 2012 Luis R. Rodriguez +# Copyright 2012 Hauke Mehrtens +# +# This generates a bunch of CONFIG_COMPAT_KERNEL_2_6_22 +# CONFIG_COMPAT_KERNEL_3_0 .. etc for each kernel release you need an object +# for. +# +# Note: this is part of the compat.git project, not compat-wireless.git, +# send patches against compat.git. + +if [[ ! -f ${KLIB_BUILD}/Makefile ]]; then + exit +fi + +# Actual kernel version +KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') + +# 3.0 kernel stuff +COMPAT_LATEST_VERSION="3" +KERNEL_SUBLEVEL="-1" + +# This allows all these variables to be propagated through +# all of our Makefiles +echo export + +if [[ ${KERNEL_VERSION} -eq "3" ]]; then + KERNEL_SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p') +else + COMPAT_26LATEST_VERSION="39" + KERNEL_26SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^2\.6\.\([0-9]\+\).*/\1/p') + let KERNEL_26SUBLEVEL=${KERNEL_26SUBLEVEL}+1 + + for i in $(seq ${KERNEL_26SUBLEVEL} ${COMPAT_26LATEST_VERSION}); do + echo "CONFIG_COMPAT_KERNEL_2_6_${i}=y" + done +fi + +let KERNEL_SUBLEVEL=${KERNEL_SUBLEVEL}+1 +for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do + echo "CONFIG_COMPAT_KERNEL_3_${i}=y" +done + +if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} -eq "y" ]]; then + echo "CONFIG_COMPAT_FIRMWARE_CLASS=m" +fi + +if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} -eq "y" ]]; then + echo "CONFIG_COMPAT_KFIFO=m" +fi -- cgit v1.2.3 From cb9c914c4b64d6537fee1b19c6c7174372e16b16 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 17:38:10 -0800 Subject: compat: add some initial RHEL support This adds a series of CONFIG_COMPAT_${RHEL_MAJOR}_${i} tags for each known RHEL version that we supercede. I cannot verify if this is correct but this is my translation of this to script: RHEL_MAJOR := $(shell grep ^RHEL_MAJOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') ifneq ($(RHEL_MAJOR),) RHEL_MINOR := $(shell grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') COMPAT_RHEL_VERSIONS := $(shell I=$(RHEL_MINOR); while [ "$$I" -ge 0 ]; do echo $$I; I=$$(($$I - 1)); done) $(foreach ver,$(COMPAT_RHEL_VERSIONS),$(eval CONFIG_COMPAT_RHEL_$(RHEL_MAJOR)_$(ver)=y)) Cc: John W. Linville Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 82b439ce..656e8d39 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -41,6 +41,16 @@ for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do echo "CONFIG_COMPAT_KERNEL_3_${i}=y" done +# The purpose of these seem to be the inverse of the above other varibales. +# The RHEL checks seem to annotate the existance of RHEL minor versions. +RHEL_MAJOR=$(grep ^RHEL_MAJOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/p') +if [[ ! -z ${RHEL_MAJOR} ]]; then + RHEL_MINOR=$(grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') + for i in $(seq 0 ${RHEL_MINOR}); do + echo "CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" + done +fi + if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} -eq "y" ]]; then echo "CONFIG_COMPAT_FIRMWARE_CLASS=m" fi -- cgit v1.2.3 From 9053c61cf0c33154c0b4ab8511889f624e4ec97b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 18:38:14 -0800 Subject: compat: fix compilation on latest kernels The variables wasn't being set in shell. By defining the variables in shell and outputing them once onto a .config we avoid having to do release kernel checks every single time. We're back in business with the latest kernels. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-8-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-12-generic [OK] Trying kernel 2.6.38-11-generic [OK] Trying kernel 2.6.38-10-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [FAILED] Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 656e8d39..423d5952 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -32,12 +32,14 @@ else let KERNEL_26SUBLEVEL=${KERNEL_26SUBLEVEL}+1 for i in $(seq ${KERNEL_26SUBLEVEL} ${COMPAT_26LATEST_VERSION}); do + eval CONFIG_COMPAT_KERNEL_2_6_${i}=y echo "CONFIG_COMPAT_KERNEL_2_6_${i}=y" done fi let KERNEL_SUBLEVEL=${KERNEL_SUBLEVEL}+1 for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do + eval CONFIG_COMPAT_KERNEL_3_${i}=y echo "CONFIG_COMPAT_KERNEL_3_${i}=y" done @@ -47,14 +49,15 @@ RHEL_MAJOR=$(grep ^RHEL_MAJOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/ if [[ ! -z ${RHEL_MAJOR} ]]; then RHEL_MINOR=$(grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') for i in $(seq 0 ${RHEL_MINOR}); do + eval CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y echo "CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" done fi -if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} -eq "y" ]]; then +if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then echo "CONFIG_COMPAT_FIRMWARE_CLASS=m" fi -if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} -eq "y" ]]; then +if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then echo "CONFIG_COMPAT_KFIFO=m" fi -- cgit v1.2.3 From 796f3eb54986853a9f67f3a7d2702a024f3f35e4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 18:48:49 -0800 Subject: compat: fix compilation warning for compat_firmware_class on 2.6.26 This fixes this compilation issue: CC [M] /home/mcgrof/compat/compat/compat_firmware_class.o /home/mcgrof/compat/compat/compat_firmware_class.c:24:0: warning: "to_dev" redefined include/linux/input.h:1218:0: note: this is the location of the previous definition /home/mcgrof/compat/compat/compat_firmware_class.c:24:0: warning: "to_dev" redefined include/linux/input.h:1218:0: note: this is the location of the previous definition Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 4eb5ba7e..b0856778 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -21,7 +21,10 @@ #include #include +#ifdef to_dev +#undef to_dev #define to_dev(obj) container_of(obj, struct device, kobj) +#endif MODULE_AUTHOR("Manuel Estrada Sainz"); MODULE_DESCRIPTION("Multi purpose firmware loading support"); -- cgit v1.2.3 From 6c98c5c56a5663b6063fee7aabbdab0298779c5b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 18:55:11 -0800 Subject: compat: clean ckmake log of color output Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 3 +++ scripts/skip-colors | 2 ++ 2 files changed, 5 insertions(+) create mode 100755 scripts/skip-colors diff --git a/bin/ckmake b/bin/ckmake index 4d45fb99..ccb291b1 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -63,3 +63,6 @@ for i in $KLIBS; do nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG done + +cat $LOG | ./scripts/skip-colors > $LOG.tmp +mv $LOG.tmp $LOG diff --git a/scripts/skip-colors b/scripts/skip-colors new file mode 100755 index 00000000..121626fb --- /dev/null +++ b/scripts/skip-colors @@ -0,0 +1,2 @@ +#!/bin/bash +perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' -- cgit v1.2.3 From fa4bdef61b2bb3071b8dc1b63164e6e986fa5604 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 19:40:22 -0800 Subject: compat: avoid NOSTDINC_FLAGS during modpost modpost, the second part of module building, does not use NOSTDINC_FLAGS and friends so all the hackery we did to use it to prefer our header files and include compat-2.6.h will not work during modpost for older kernels. We don't really need all that stuff during modpost even for newer kernels so just avoid it all together. Signed-off-by: Luis R. Rodriguez --- Makefile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fdcff5c7..d96d0980 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,22 @@ export COMPAT_BASE_TREE := "linux-next.git" # working with. export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) + +else +# By stuffing this hear we avoid using +# this hackery on modpost, the 2nd section of module building. +# +# This hack lets us put our include path first than the kernel's +# when building our compat modules. Your own makefile would look +# the same. +NOSTDINC_FLAGS := -I$(M)/include/ \ + -include $(M)/include/linux/compat-2.6.h \ + $(CFLAGS) \ + -DCOMPAT_BASE_TREE="\"$(COMPAT_BASE_TREE)\"" \ + -DCOMPAT_BASE_TREE_VERSION="\"$(COMPAT_BASE_TREE_VERSION)\"" \ + -DCOMPAT_PROJECT="\"Generic kernel\"" \ + -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" + endif # to check config and compat autoconf @@ -31,17 +47,6 @@ export MAKE obj-y += compat/ -# This hack lets us put our include path first than the kernel's -# when building our compat modules. Your own makefile would look -# the same. -NOSTDINC_FLAGS := -I$(M)/include/ \ - -include $(M)/include/linux/compat-2.6.h \ - $(CFLAGS) \ - -DCOMPAT_BASE_TREE="\"$(COMPAT_BASE_TREE)\"" \ - -DCOMPAT_BASE_TREE_VERSION="\"$(COMPAT_BASE_TREE_VERSION)\"" \ - -DCOMPAT_PROJECT="\"Generic kernel\"" \ - -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" - all: $(COMPAT_CONFIG) modules: $(COMPAT_CONFIG) $(COMPAT_AUTOCONF) -- cgit v1.2.3 From d1a926c3a27dac90f0c3f960f5ea67de346f90ed Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 20:15:18 -0800 Subject: compat: fix compat_firmware class for all kernels Instead of ifdef checks on the to_dev() just simply rename it to avoid clashes. This fixes compiling against all supported kernels on compat. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-8-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-12-generic [OK] Trying kernel 2.6.38-11-generic [OK] Trying kernel 2.6.38-10-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index b0856778..eb97dfc0 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -21,10 +21,7 @@ #include #include -#ifdef to_dev -#undef to_dev -#define to_dev(obj) container_of(obj, struct device, kobj) -#endif +#define compat_firmware_to_dev(obj) container_of(obj, struct device, kobj) MODULE_AUTHOR("Manuel Estrada Sainz"); MODULE_DESCRIPTION("Multi purpose firmware loading support"); @@ -327,7 +324,7 @@ static ssize_t firmware_data_read(struct kobject *kobj, char *buffer, loff_t offset, size_t count) #endif { - struct device *dev = to_dev(kobj); + struct device *dev = compat_firmware_to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t ret_count; @@ -426,7 +423,7 @@ static ssize_t firmware_data_write(struct kobject *kobj, char *buffer, loff_t offset, size_t count) #endif { - struct device *dev = to_dev(kobj); + struct device *dev = compat_firmware_to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t retval; -- cgit v1.2.3 From 77141618df2ca43ecbb7da8d2f40fd94d14033ff Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 24 Feb 2012 21:25:28 -0800 Subject: compat: backport HCI monitor channel support Just throw in the header file, compat-wireless takes care of the rest. Signed-off-by: Luis R. Rodriguez --- include/net/bluetooth/hci_mon.h | 51 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 include/net/bluetooth/hci_mon.h diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h new file mode 100644 index 00000000..07a25c92 --- /dev/null +++ b/include/net/bluetooth/hci_mon.h @@ -0,0 +1,51 @@ +/* + BlueZ - Bluetooth protocol stack for Linux + + Copyright (C) 2011-2012 Intel Corporation + + 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; + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. + IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY + CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, + COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS + SOFTWARE IS DISCLAIMED. +*/ + +#ifndef __HCI_MON_H +#define __HCI_MON_H + +struct hci_mon_hdr { + __le16 opcode; + __le16 index; + __le16 len; +} __packed; +#define HCI_MON_HDR_SIZE 6 + +#define HCI_MON_NEW_INDEX 0 +#define HCI_MON_DEL_INDEX 1 +#define HCI_MON_COMMAND_PKT 2 +#define HCI_MON_EVENT_PKT 3 +#define HCI_MON_ACL_TX_PKT 4 +#define HCI_MON_ACL_RX_PKT 5 +#define HCI_MON_SCO_TX_PKT 6 +#define HCI_MON_SCO_RX_PKT 7 + +struct hci_mon_new_index { + __u8 type; + __u8 bus; + bdaddr_t bdaddr; + char name[8]; +} __packed; +#define HCI_MON_NEW_INDEX_SIZE 16 + +#endif /* __HCI_MON_H */ -- cgit v1.2.3 From 9858c345cc154043cf81f551b70d15a3b80cc437 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 12:13:14 -0800 Subject: compat: fix parallel builds We broke parallel builds by breaking GNU Make's heuristics. GNU Make does not whether or not target commands are sub-make commands or not, these must be explicitly annotated. To tell GNU Make that target command is going to be a sub-process we can use the $(MAKE) variable for a command. Another option is to tell GNU Make that a target command is *not* a sub-make command instead explicitly by prepending a command with a plus, "+" prior to the command. This will force GNU Make to avoid supporting certain flags for those targets but more importantly, it will also ensure that during execution of commands that are *not* sub-make commands it will yield the jobserver to ensure file descriptor / job sanity. Annotate to GNU Make two commands that we issue are *not* sub-make commands. This avoids stop the job server for these commands but also allows GNU Make to figure out the heuristics to run the job server for further sub-make commands -- in this case the recursive call to make. Reported-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d96d0980..d11da17d 100644 --- a/Makefile +++ b/Makefile @@ -62,8 +62,8 @@ install: modules $(COMPAT_AUTOCONF): ; $(COMPAT_CONFIG): - @$(PWD)/scripts/gen-compat-config.sh > $(PWD)/$(COMPAT_CONFIG) - @$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(PWD)/$(COMPAT_AUTOCONF) + +@$(PWD)/scripts/gen-compat-config.sh > $(PWD)/$(COMPAT_CONFIG) + +@$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(PWD)/$(COMPAT_AUTOCONF) @$(MAKE) -C $(PWD) modules install: modules -- cgit v1.2.3 From 407a6a023f7cb135f491ece44a63496029b8301a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 13:34:57 -0800 Subject: compat: move definition of COMPAT_CONFIG and COMPAT_AUTOCONF The Makefile for external modules are read twice, once during the initial make command, and then later to build the modules target *by the kernel*. This ensures that we define the variables COMPAT_CONFIG and COMPAT_AUTOCONF are only defined once. Signed-off-by: Luis R. Rodriguez --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index d11da17d..287f35f6 100644 --- a/Makefile +++ b/Makefile @@ -19,6 +19,11 @@ export COMPAT_BASE_TREE := "linux-next.git" export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) +# to check config and compat autoconf +export COMPAT_CONFIG=.config +export COMPAT_AUTOCONF=include/linux/compat_autoconf.h +export MAKE + else # By stuffing this hear we avoid using # this hackery on modpost, the 2nd section of module building. @@ -36,11 +41,6 @@ NOSTDINC_FLAGS := -I$(M)/include/ \ endif -# to check config and compat autoconf -export COMPAT_CONFIG=.config -export COMPAT_AUTOCONF=include/linux/compat_autoconf.h -export MAKE - # Recursion lets us ensure we get this file included. # Trick is to run make -C $(PWD) modules later. -include $(PWD)/$(COMPAT_CONFIG) -- cgit v1.2.3 From 1c2ed6f7d157f0cc2f9ca1dcf07723ee06f726fb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 13:41:57 -0800 Subject: compat: explicitly define paths for local configs As noted in the previous commit a Linux kernel module's Makefile will be read twice, during initial GNU make run, and later for when the kernel will build the external module. Variables that require path consideration must address in which context it needs to be defined and do so by detecting at which run time case it wants to instantiate variables. In our case we want to ensure that both COMPAT_CONFIG and COMPAT_AUTOCONF are defined within the context of the directory of the external module we are building as otherwise GNU Make will try to treat it as part of the kernel's build directory's files. We already have COMPAT_CONFIG and COMPAT_AUTOCONF defined under a ifeq ($(KERNELRELEASE),) check, we now just need to add the directory context and then remove the other now superfluous uses of the $(PWD). Signed-off-by: Luis R. Rodriguez --- Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 287f35f6..423d1ed3 100644 --- a/Makefile +++ b/Makefile @@ -20,8 +20,8 @@ export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) # to check config and compat autoconf -export COMPAT_CONFIG=.config -export COMPAT_AUTOCONF=include/linux/compat_autoconf.h +export COMPAT_CONFIG=$(PWD)/.config +export COMPAT_AUTOCONF=$(PWD)/include/linux/compat_autoconf.h export MAKE else @@ -43,7 +43,7 @@ endif # Recursion lets us ensure we get this file included. # Trick is to run make -C $(PWD) modules later. --include $(PWD)/$(COMPAT_CONFIG) +-include $(COMPAT_CONFIG) obj-y += compat/ @@ -62,8 +62,8 @@ install: modules $(COMPAT_AUTOCONF): ; $(COMPAT_CONFIG): - +@$(PWD)/scripts/gen-compat-config.sh > $(PWD)/$(COMPAT_CONFIG) - +@$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(PWD)/$(COMPAT_AUTOCONF) + +@$(PWD)/scripts/gen-compat-config.sh > $(COMPAT_CONFIG) + +@$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(COMPAT_AUTOCONF) @$(MAKE) -C $(PWD) modules install: modules -- cgit v1.2.3 From 4bd4cbf8822f28cee6b843bc23cdfd2b2cc2672f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 14:09:29 -0800 Subject: compat: remove dubious clean at install target Not sure why this was added, this is a big typo. Signed-off-by: Luis R. Rodriguez --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 423d1ed3..2f47e3f9 100644 --- a/Makefile +++ b/Makefile @@ -57,7 +57,6 @@ install: modules $(MAKE) -C $(KLIB_BUILD) M=$(PWD) $(KMODDIR_ARG) $(KMODPATH_ARG) \ modules_install depmod -a - $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean $(COMPAT_AUTOCONF): ; -- cgit v1.2.3 From e2a22de7e6e9c314afb25da49a5fb956120f1f0c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 14:16:32 -0800 Subject: compat: split COMPAT_CONFIG and COMPAT_AUTOCONF targets Let GNU Make take care of the dependency map. Signed-off-by: Luis R. Rodriguez --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2f47e3f9..537d759a 100644 --- a/Makefile +++ b/Makefile @@ -58,11 +58,11 @@ install: modules modules_install depmod -a -$(COMPAT_AUTOCONF): ; +$(COMPAT_AUTOCONF): $(COMPAT_CONFIG) + +@$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(COMPAT_AUTOCONF) $(COMPAT_CONFIG): +@$(PWD)/scripts/gen-compat-config.sh > $(COMPAT_CONFIG) - +@$(PWD)/scripts/gen-compat-autoconf.sh $(COMPAT_CONFIG) > $(COMPAT_AUTOCONF) @$(MAKE) -C $(PWD) modules install: modules -- cgit v1.2.3 From 9e138a0f7e3361fa462aaac4def5c0872496a690 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 14:27:42 -0800 Subject: compat: avoid unnecessary recursion to include a file I added recursion call to the same Makefile after noticing that GNU Make *will* fail if a file that is being included does not exist. I also added the option that the file *may* not exist by prepending the inclusion of the file with "-". It turns out that GNU Make is smart enough to look for targets for header files that are included and *will not fail* if it can successfully build that file and include it. I will note that this target file *does not need* to be a dependency to any of the final targets, GNU Make will just assume and add it. It is important to highlight that GNU Make *will* run make against itself again after it builds the file it needs to include. If GNU Make runs into this situation, where it can build the target file it needs to include, it will not fail but you will see something like this pesky warning: Makefile:16: /home/mcgrof/compat/.config: No such file or directory Under new found knowledge of how GNU Make works we simplify the reading and running of the compat Makefile by ensuring that the file we need to include is defined as a target but for sanity and reader's sake (although technically not necessary) we also add the file as a dependency to the modules target building. Furthermore the pesky warning can confuse developers / users and as it turns out we only really need it at build time. We take advantage of the fact that the kernel will use the same Makefile later upon building the external module and that we can identify when this happens in the Makefile [0] and only *require* including the header file upon module building time. [0] the part where ifeq ($(KERNELRELEASE),) is false Signed-off-by: Luis R. Rodriguez --- Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 537d759a..9e676ede 100644 --- a/Makefile +++ b/Makefile @@ -39,15 +39,12 @@ NOSTDINC_FLAGS := -I$(M)/include/ \ -DCOMPAT_PROJECT="\"Generic kernel\"" \ -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" +include $(COMPAT_CONFIG) endif -# Recursion lets us ensure we get this file included. -# Trick is to run make -C $(PWD) modules later. --include $(COMPAT_CONFIG) - obj-y += compat/ -all: $(COMPAT_CONFIG) +all: modules modules: $(COMPAT_CONFIG) $(COMPAT_AUTOCONF) $(MAKE) -C $(KLIB_BUILD) M=$(PWD) modules @@ -63,7 +60,6 @@ $(COMPAT_AUTOCONF): $(COMPAT_CONFIG) $(COMPAT_CONFIG): +@$(PWD)/scripts/gen-compat-config.sh > $(COMPAT_CONFIG) - @$(MAKE) -C $(PWD) modules install: modules -- cgit v1.2.3 From 82dd030116437f4d88f6fe8d98827d360a67ff5b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 27 Feb 2012 15:10:30 -0800 Subject: compat: optimize building by extending .PHONY I've started reading make -d output to realize that GNU Make is pretty simple but darn stupid and needs a little help in direction. Traditionally GNU Make will try to see if it needs Makefile* generation. I can count 18 variations of Makefile it looks for: Makefile Makefile.c Makefile.C Makefile.cc Makefile.cpp Makefile.f Makefile.F Makefile.l Makefile.mod Makefile.o Makefile.p Makefile.r Makefile.s Makefile.S Makefile.sh Makefile.w Makefile.web Makefile.y GNU Make will look for targets in the Makefile for each of these... GNU Make will also look for these 18 variations of files for each target that it does not a target rule for. There are two ways to help GNU Make do the right thing, write a simple empty target rule [0] or just extend the target into the .PHONY target. Lets just extend the .PHONY target with the items we see in make -d are not needed. This simple change forces GNU Make to skip 36 lookups of false targets. [0] Makefile : ; Signed-off-by: Luis R. Rodriguez --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9e676ede..82d4cbbc 100644 --- a/Makefile +++ b/Makefile @@ -69,4 +69,4 @@ clean: clean-files := Module.symvers modules.order Module.markers compat/modules.order clean-files += modules $(COMPAT_CONFIG) $(COMPAT_AUTOCONF) -.PHONY: all install clean +.PHONY: all install clean modules Makefile -- cgit v1.2.3 From dcbc5d7cca1c1fb43d6753a691c304e25c983e3c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 28 Feb 2012 14:49:12 -0800 Subject: compat: backport eth_hw_addr_random() This backports eth_hw_addr_random(). Tested with ckmake on v2.6.24..v3.3 : Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.4.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 include/linux/compat-3.4.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 3ccd0516..c14aeb86 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -38,5 +38,6 @@ #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h new file mode 100644 index 00000000..378371f4 --- /dev/null +++ b/include/linux/compat-3.4.h @@ -0,0 +1,51 @@ +#ifndef LINUX_3_4_COMPAT_H +#define LINUX_3_4_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) +static inline void eth_hw_addr_random(struct net_device *dev) +{ +#error eth_hw_addr_random() needs to be implemented for < 2.6.12 +} +#else /* kernels >= 2.6.12 */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) +static inline void eth_hw_addr_random(struct net_device *dev) +{ + get_random_bytes(dev->dev_addr, ETH_ALEN); + dev->dev_addr[0] &= 0xfe; /* clear multicast bit */ + dev->dev_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ +} +#else /* kernels >= 2.6.31 */ + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) +/* So this is 2.6.31..2.6.35 */ + +/* Just have the flags present, they won't really mean anything though */ +#define NET_ADDR_PERM 0 /* address is permanent (default) */ +#define NET_ADDR_RANDOM 1 /* address is generated randomly */ +#define NET_ADDR_STOLEN 2 /* address is stolen from other device */ + +static inline void eth_hw_addr_random(struct net_device *dev) +{ + random_ether_addr(dev->dev_addr); +} + +#else /* 2.6.36 and on */ +static inline void eth_hw_addr_random(struct net_device *dev) +{ + dev_hw_addr_random(dev, dev->dev_addr); +} +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) */ + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ + +#endif /* LINUX_5_4_COMPAT_H */ -- cgit v1.2.3 From dc2b12593817601cf58dc5022c5b592e28890305 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 28 Feb 2012 15:32:34 -0800 Subject: compat: avoid color crap on log for good This skips color output on the log file for all output as we go. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index ccb291b1..2d9a5ebe 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -41,6 +41,21 @@ esac nice make clean 2>&1 > $LOG +function tee_color_split() +{ + while read; do + echo -e $REPLY | ./scripts/skip-colors >> $LOG + echo -e $REPLY + done +} + +function log_try_kernel() +{ + echo -en "Trying kernel ${BLUE}" + printf "%40s\t" "${1}" + echo -en "${NORMAL}" +} + for i in $KLIBS; do KERNEL=$(basename $i) DIR=${i}/build/ @@ -50,19 +65,18 @@ for i in $KLIBS; do continue fi - echo -en "Trying kernel ${BLUE}" | tee -a $LOG - printf "%40s\t" "${KERNEL}" | tee -a $LOG - echo -en "${NORMAL}" | tee -a $LOG + # We cannot use tee_color_split() as bash read only spits + # out output when a newline comes in. We can modif IFS but + # I am still not sure how to do this properly. + log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG + log_try_kernel $KERNEL ionice -c 3 nice -n 20 make KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG if [[ $? -eq 0 ]]; then - echo -e "${GREEN}[OK]${NORMAL}" | tee -a $LOG + echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split else - echo -e "${RED}[FAILED]${NORMAL}" | tee -a $LOG + echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split fi nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG done - -cat $LOG | ./scripts/skip-colors > $LOG.tmp -mv $LOG.tmp $LOG -- cgit v1.2.3 From 1d5f1472645246b9cff6c5674ed5440fce9e84ba Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 2 Mar 2012 15:01:37 -0800 Subject: compat: makes all compat symbols EXPORT_SYMBOL_GPL() The Linux kernel is being backported here and a lot of code is completely derivative works of the the Linux kernel, as such only GPL-Compatible modules are intended to be used with this framework, given that users of this framework are considered completely derivative works of the Linux kernel. Only upstream Linux kernel modules or kernel modules on their way upstream are intended to be used by this. Tested with ckmake: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.23.c | 10 +++++----- compat/compat-2.6.24.c | 10 +++++----- compat/compat-2.6.25.c | 4 ++-- compat/compat-2.6.27.c | 4 ++-- compat/compat-2.6.28.c | 8 ++++---- compat/compat-2.6.29.c | 8 ++++---- compat/compat-2.6.32.c | 2 +- compat/compat-2.6.33.c | 4 ++-- compat/compat-2.6.35.c | 4 ++-- compat/compat-2.6.37.c | 12 ++++++------ compat/compat-2.6.38.c | 4 ++-- compat/compat-3.0.c | 4 ++-- compat/compat-3.2.c | 2 +- compat/compat_atomic.c | 4 ++-- compat/compat_firmware_class.c | 6 +++--- compat/cordic.c | 2 +- compat/crc8.c | 6 +++--- compat/kfifo.c | 42 +++++++++++++++++++++--------------------- compat/kstrtox.c | 20 ++++++++++---------- 19 files changed, 78 insertions(+), 78 deletions(-) diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index 67d00750..bc49e982 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -36,7 +36,7 @@ int __dev_addr_delete(struct dev_addr_list **list, int *count, } return -ENOENT; } -EXPORT_SYMBOL(__dev_addr_delete); +EXPORT_SYMBOL_GPL(__dev_addr_delete); /* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but * might as well add it */ @@ -71,7 +71,7 @@ int __dev_addr_add(struct dev_addr_list **list, int *count, (*count)++; return 0; } -EXPORT_SYMBOL(__dev_addr_add); +EXPORT_SYMBOL_GPL(__dev_addr_add); /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version. @@ -128,7 +128,7 @@ int dev_mc_sync(struct net_device *to, struct net_device *from) return err; } -EXPORT_SYMBOL(dev_mc_sync); +EXPORT_SYMBOL_GPL(dev_mc_sync); /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version. @@ -179,7 +179,7 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from) netif_tx_unlock_bh(to); netif_tx_unlock_bh(from); } -EXPORT_SYMBOL(dev_mc_unsync); +EXPORT_SYMBOL_GPL(dev_mc_unsync); /* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on * 2.6.22 so ignore that. */ @@ -234,6 +234,6 @@ int pci_try_set_mwi(struct pci_dev *dev) #endif return rc; } -EXPORT_SYMBOL(pci_try_set_mwi); +EXPORT_SYMBOL_GPL(pci_try_set_mwi); #endif diff --git a/compat/compat-2.6.24.c b/compat/compat-2.6.24.c index b9ae16b8..977db0ca 100644 --- a/compat/compat-2.6.24.c +++ b/compat/compat-2.6.24.c @@ -16,7 +16,7 @@ * for usage with tons of code that makes mention to it. */ struct net init_net; -EXPORT_SYMBOL(init_net); +EXPORT_SYMBOL_GPL(init_net); /* 2.6.22 and 2.6.23 have eth_header_cache_update defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ @@ -36,7 +36,7 @@ void eth_header_cache_update(struct hh_cache *hh, memcpy(((u8 *) hh->hh_data) + HH_DATA_OFF(sizeof(struct ethhdr)), haddr, ETH_ALEN); } -EXPORT_SYMBOL(eth_header_cache_update); +EXPORT_SYMBOL_GPL(eth_header_cache_update); /* 2.6.22 and 2.6.23 have eth_header_cache defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ @@ -65,7 +65,7 @@ int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh) hh->hh_len = ETH_HLEN; return 0; } -EXPORT_SYMBOL(eth_header_cache); +EXPORT_SYMBOL_GPL(eth_header_cache); /* 2.6.22 and 2.6.23 have eth_header() defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ @@ -118,7 +118,7 @@ int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, return -ETH_HLEN; } -EXPORT_SYMBOL(eth_header); +EXPORT_SYMBOL_GPL(eth_header); /* 2.6.22 and 2.6.23 have eth_rebuild_header defined as extern in include/linux/etherdevice.h * and actually defined in net/ethernet/eth.c but 2.6.24 exports it. Lets export it here */ @@ -154,5 +154,5 @@ int eth_rebuild_header(struct sk_buff *skb) return 0; } -EXPORT_SYMBOL(eth_rebuild_header); +EXPORT_SYMBOL_GPL(eth_rebuild_header); diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 7cb996b6..2e9c3a88 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -92,6 +92,6 @@ int strict_strto##type(const char *cp, unsigned int base, valtype *res) \ define_strict_strtoux(l, unsigned long) define_strict_strtox(l, long) -EXPORT_SYMBOL(strict_strtoul); -EXPORT_SYMBOL(strict_strtol); +EXPORT_SYMBOL_GPL(strict_strtoul); +EXPORT_SYMBOL_GPL(strict_strtol); diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index 25bee281..762f0ca1 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -64,7 +64,7 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) return !!(pme_support & (1 << state)); } -EXPORT_SYMBOL(pci_pme_capable); +EXPORT_SYMBOL_GPL(pci_pme_capable); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) /** @@ -92,7 +92,7 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) return sz; } -EXPORT_SYMBOL(mmc_align_data_size); +EXPORT_SYMBOL_GPL(mmc_align_data_size); /* * Calculate the maximum byte mode transfer size diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 72c9e09d..235dbfa7 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -161,7 +161,7 @@ next_entry: return ret; } -EXPORT_SYMBOL(pcmcia_loop_config); +EXPORT_SYMBOL_GPL(pcmcia_loop_config); #endif /* CONFIG_PCMCIA */ @@ -311,7 +311,7 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, skb->data_len += size; skb->truesize += size; } -EXPORT_SYMBOL(skb_add_rx_frag); +EXPORT_SYMBOL_GPL(skb_add_rx_frag); void tty_write_unlock(struct tty_struct *tty) { @@ -437,7 +437,7 @@ int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, return tty_mode_ioctl(tty, file, cmd, arg); } } -EXPORT_SYMBOL(n_tty_ioctl_helper); +EXPORT_SYMBOL_GPL(n_tty_ioctl_helper); /** * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold @@ -459,5 +459,5 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable) pci_enable_wake(dev, PCI_D3cold, enable) : pci_enable_wake(dev, PCI_D3hot, enable); } -EXPORT_SYMBOL(pci_wake_from_d3); +EXPORT_SYMBOL_GPL(pci_wake_from_d3); diff --git a/compat/compat-2.6.29.c b/compat/compat-2.6.29.c index 14f5e902..1beb718d 100644 --- a/compat/compat-2.6.29.c +++ b/compat/compat-2.6.29.c @@ -46,7 +46,7 @@ void netdev_attach_ops(struct net_device *dev, dev->select_queue = ops->ndo_select_queue; #endif } -EXPORT_SYMBOL(netdev_attach_ops); +EXPORT_SYMBOL_GPL(netdev_attach_ops); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) @@ -93,7 +93,7 @@ int eth_mac_addr(struct net_device *dev, void *p) memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); return 0; } -EXPORT_SYMBOL(eth_mac_addr); +EXPORT_SYMBOL_GPL(eth_mac_addr); /** * eth_change_mtu - set new MTU size @@ -110,7 +110,7 @@ int eth_change_mtu(struct net_device *dev, int new_mtu) dev->mtu = new_mtu; return 0; } -EXPORT_SYMBOL(eth_change_mtu); +EXPORT_SYMBOL_GPL(eth_change_mtu); int eth_validate_addr(struct net_device *dev) { @@ -119,7 +119,7 @@ int eth_validate_addr(struct net_device *dev) return 0; } -EXPORT_SYMBOL(eth_validate_addr); +EXPORT_SYMBOL_GPL(eth_validate_addr); /* Source: net/ethernet/eth.c */ #define NETREG_DUMMY 5 diff --git a/compat/compat-2.6.32.c b/compat/compat-2.6.32.c index 0b3af074..b5a66a86 100644 --- a/compat/compat-2.6.32.c +++ b/compat/compat-2.6.32.c @@ -211,6 +211,6 @@ void time_to_tm(time_t totalsecs, int offset, struct tm *result) result->tm_mon = y; result->tm_mday = days + 1; } -EXPORT_SYMBOL(time_to_tm); +EXPORT_SYMBOL_GPL(time_to_tm); /* source: kernel/time/timeconv.c*/ diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index c8e568df..04e2fd09 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -70,7 +70,7 @@ next_entry: kfree(buf); return ret; } -EXPORT_SYMBOL(pccard_loop_tuple); +EXPORT_SYMBOL_GPL(pccard_loop_tuple); /* Source: drivers/pcmcia/cistpl.c */ #if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) @@ -123,7 +123,7 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, &loop, pcmcia_do_loop_tuple); } -EXPORT_SYMBOL(pcmcia_loop_tuple); +EXPORT_SYMBOL_GPL(pcmcia_loop_tuple); /* Source: drivers/pcmcia/pcmcia_resource.c */ #endif /* CONFIG_PCMCIA */ diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 7a31a540..24551722 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -27,7 +27,7 @@ int compat_hex_to_bin(char ch) return ch - 'a' + 10; return -1; } -EXPORT_SYMBOL(compat_hex_to_bin); +EXPORT_SYMBOL_GPL(compat_hex_to_bin); /** * noop_llseek - No Operation Performed llseek implementation @@ -44,5 +44,5 @@ loff_t noop_llseek(struct file *file, loff_t offset, int origin) { return file->f_pos; } -EXPORT_SYMBOL(noop_llseek); +EXPORT_SYMBOL_GPL(noop_llseek); diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index d7259bb6..24b267a5 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -142,7 +142,7 @@ error_ops: compat_genl_unregister_family(family); return ret; } -EXPORT_SYMBOL(compat_genl_register_family_with_ops); +EXPORT_SYMBOL_GPL(compat_genl_register_family_with_ops); int compat_genl_unregister_family(struct genl_family *family) { @@ -151,7 +151,7 @@ int compat_genl_unregister_family(struct genl_family *family) list_del(&family->list); return err; } -EXPORT_SYMBOL(compat_genl_unregister_family); +EXPORT_SYMBOL_GPL(compat_genl_unregister_family); #if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) @@ -304,7 +304,7 @@ void led_blink_set(struct led_classdev *led_cdev, mod_timer(&led->blink_timer, jiffies + 1); } -EXPORT_SYMBOL(led_blink_set); +EXPORT_SYMBOL_GPL(led_blink_set); void compat_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness brightness) @@ -316,7 +316,7 @@ void compat_led_brightness_set(struct led_classdev *led_cdev, return led_cdev->brightness_set(led_cdev, brightness); } -EXPORT_SYMBOL(compat_led_brightness_set); +EXPORT_SYMBOL_GPL(compat_led_brightness_set); void compat_led_classdev_unregister(struct led_classdev *led_cdev) { @@ -333,7 +333,7 @@ void compat_led_classdev_unregister(struct led_classdev *led_cdev) led_classdev_unregister(led_cdev); } -EXPORT_SYMBOL(compat_led_classdev_unregister); +EXPORT_SYMBOL_GPL(compat_led_classdev_unregister); /** * vzalloc - allocate virtually contiguous memory with zero fill @@ -353,6 +353,6 @@ void *compat_vzalloc(unsigned long size) memset(buf, 0, size); return buf; } -EXPORT_SYMBOL(compat_vzalloc); +EXPORT_SYMBOL_GPL(compat_vzalloc); #endif diff --git a/compat/compat-2.6.38.c b/compat/compat-2.6.38.c index 172aa193..0074ac62 100644 --- a/compat/compat-2.6.38.c +++ b/compat/compat-2.6.38.c @@ -29,7 +29,7 @@ void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight) avg->weight = weight; avg->factor = factor; } -EXPORT_SYMBOL(ewma_init); +EXPORT_SYMBOL_GPL(ewma_init); /** * ewma_add() - Exponentially weighted moving average (EWMA) @@ -46,5 +46,5 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val) (val * avg->factor); return avg; } -EXPORT_SYMBOL(ewma_add); +EXPORT_SYMBOL_GPL(ewma_add); diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c index f517e9fb..1da45ac1 100644 --- a/compat/compat-3.0.c +++ b/compat/compat-3.0.c @@ -34,7 +34,7 @@ int mac_pton(const char *s, u8 *mac) } return 1; } -EXPORT_SYMBOL(mac_pton); +EXPORT_SYMBOL_GPL(mac_pton); #define kstrto_from_user(f, g, type) \ int f(const char __user *s, size_t count, unsigned int base, type *res) \ @@ -48,7 +48,7 @@ int f(const char __user *s, size_t count, unsigned int base, type *res) \ buf[count] = '\0'; \ return g(buf, base, res); \ } \ -EXPORT_SYMBOL(f) +EXPORT_SYMBOL_GPL(f) kstrto_from_user(kstrtoull_from_user, kstrtoull, unsigned long long); kstrto_from_user(kstrtoll_from_user, kstrtoll, long long); diff --git a/compat/compat-3.2.c b/compat/compat-3.2.c index 80f5597b..55ae6af0 100644 --- a/compat/compat-3.2.c +++ b/compat/compat-3.2.c @@ -31,4 +31,4 @@ int __netdev_printk(const char *level, const struct net_device *dev, return r; } -EXPORT_SYMBOL(__netdev_printk); +EXPORT_SYMBOL_GPL(__netdev_printk); diff --git a/compat/compat_atomic.c b/compat/compat_atomic.c index 747e275b..b8565aa5 100644 --- a/compat/compat_atomic.c +++ b/compat/compat_atomic.c @@ -15,7 +15,7 @@ long long atomic64_read(const atomic64_t *v) spin_unlock_irqrestore(&lock, flags); return val; } -EXPORT_SYMBOL(atomic64_read); +EXPORT_SYMBOL_GPL(atomic64_read); long long atomic64_add_return(long long a, atomic64_t *v) { @@ -27,7 +27,7 @@ long long atomic64_add_return(long long a, atomic64_t *v) spin_unlock_irqrestore(&lock, flags); return val; } -EXPORT_SYMBOL(atomic64_add_return); +EXPORT_SYMBOL_GPL(atomic64_add_return); #endif diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index eb97dfc0..01eda401 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -754,6 +754,6 @@ static void __exit firmware_class_exit(void) fs_initcall(firmware_class_init); module_exit(firmware_class_exit); -EXPORT_SYMBOL(release_firmware); -EXPORT_SYMBOL(request_firmware); -EXPORT_SYMBOL(request_firmware_nowait); +EXPORT_SYMBOL_GPL(release_firmware); +EXPORT_SYMBOL_GPL(request_firmware); +EXPORT_SYMBOL_GPL(request_firmware_nowait); diff --git a/compat/cordic.c b/compat/cordic.c index aa27a88d..a6340b6a 100644 --- a/compat/cordic.c +++ b/compat/cordic.c @@ -94,7 +94,7 @@ struct cordic_iq cordic_calc_iq(s32 theta) coord.q *= signx; return coord; } -EXPORT_SYMBOL(cordic_calc_iq); +EXPORT_SYMBOL_GPL(cordic_calc_iq); MODULE_DESCRIPTION("Cordic functions"); MODULE_AUTHOR("Broadcom Corporation"); diff --git a/compat/crc8.c b/compat/crc8.c index 87b59caf..fa8382d2 100644 --- a/compat/crc8.c +++ b/compat/crc8.c @@ -40,7 +40,7 @@ void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial) table[i+j] = table[j] ^ t; } } -EXPORT_SYMBOL(crc8_populate_msb); +EXPORT_SYMBOL_GPL(crc8_populate_msb); /* * crc8_populate_lsb - fill crc table for given polynomial in regular bit order. @@ -61,7 +61,7 @@ void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial) table[i+j] = table[j] ^ t; } } -EXPORT_SYMBOL(crc8_populate_lsb); +EXPORT_SYMBOL_GPL(crc8_populate_lsb); /* * crc8 - calculate a crc8 over the given input data. @@ -79,7 +79,7 @@ u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc) return crc; } -EXPORT_SYMBOL(crc8); +EXPORT_SYMBOL_GPL(crc8); MODULE_DESCRIPTION("CRC8 (by Williams, Ross N.) function"); MODULE_AUTHOR("Broadcom Corporation"); diff --git a/compat/kfifo.c b/compat/kfifo.c index 01a0700e..96e1bdfd 100644 --- a/compat/kfifo.c +++ b/compat/kfifo.c @@ -65,7 +65,7 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, return 0; } -EXPORT_SYMBOL(__kfifo_alloc); +EXPORT_SYMBOL_GPL(__kfifo_alloc); void __kfifo_free(struct __kfifo *fifo) { @@ -76,7 +76,7 @@ void __kfifo_free(struct __kfifo *fifo) fifo->data = NULL; fifo->mask = 0; } -EXPORT_SYMBOL(__kfifo_free); +EXPORT_SYMBOL_GPL(__kfifo_free); int __kfifo_init(struct __kfifo *fifo, void *buffer, unsigned int size, size_t esize) @@ -99,7 +99,7 @@ int __kfifo_init(struct __kfifo *fifo, void *buffer, return 0; } -EXPORT_SYMBOL(__kfifo_init); +EXPORT_SYMBOL_GPL(__kfifo_init); static void kfifo_copy_in(struct __kfifo *fifo, const void *src, unsigned int len, unsigned int off) @@ -138,7 +138,7 @@ unsigned int __kfifo_in(struct __kfifo *fifo, fifo->in += len; return len; } -EXPORT_SYMBOL(__kfifo_in); +EXPORT_SYMBOL_GPL(__kfifo_in); static void kfifo_copy_out(struct __kfifo *fifo, void *dst, unsigned int len, unsigned int off) @@ -176,7 +176,7 @@ unsigned int __kfifo_out_peek(struct __kfifo *fifo, kfifo_copy_out(fifo, buf, len, fifo->out); return len; } -EXPORT_SYMBOL(__kfifo_out_peek); +EXPORT_SYMBOL_GPL(__kfifo_out_peek); unsigned int __kfifo_out(struct __kfifo *fifo, void *buf, unsigned int len) @@ -185,7 +185,7 @@ unsigned int __kfifo_out(struct __kfifo *fifo, fifo->out += len; return len; } -EXPORT_SYMBOL(__kfifo_out); +EXPORT_SYMBOL_GPL(__kfifo_out); static unsigned long kfifo_copy_from_user(struct __kfifo *fifo, const void __user *from, unsigned int len, unsigned int off, @@ -246,7 +246,7 @@ int __kfifo_from_user(struct __kfifo *fifo, const void __user *from, fifo->in += len; return err; } -EXPORT_SYMBOL(__kfifo_from_user); +EXPORT_SYMBOL_GPL(__kfifo_from_user); static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to, unsigned int len, unsigned int off, unsigned int *copied) @@ -305,7 +305,7 @@ int __kfifo_to_user(struct __kfifo *fifo, void __user *to, fifo->out += len; return err; } -EXPORT_SYMBOL(__kfifo_to_user); +EXPORT_SYMBOL_GPL(__kfifo_to_user); static int setup_sgl_buf(struct scatterlist *sgl, void *buf, int nents, unsigned int len) @@ -379,7 +379,7 @@ unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, return setup_sgl(fifo, sgl, nents, len, fifo->in); } -EXPORT_SYMBOL(__kfifo_dma_in_prepare); +EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare); unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, struct scatterlist *sgl, int nents, unsigned int len) @@ -392,7 +392,7 @@ unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, return setup_sgl(fifo, sgl, nents, len, fifo->out); } -EXPORT_SYMBOL(__kfifo_dma_out_prepare); +EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare); unsigned int __kfifo_max_r(unsigned int len, size_t recsize) { @@ -447,7 +447,7 @@ unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize) { return __kfifo_peek_n(fifo, recsize); } -EXPORT_SYMBOL(__kfifo_len_r); +EXPORT_SYMBOL_GPL(__kfifo_len_r); unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, unsigned int len, size_t recsize) @@ -461,7 +461,7 @@ unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, fifo->in += len + recsize; return len; } -EXPORT_SYMBOL(__kfifo_in_r); +EXPORT_SYMBOL_GPL(__kfifo_in_r); static unsigned int kfifo_out_copy_r(struct __kfifo *fifo, void *buf, unsigned int len, size_t recsize, unsigned int *n) @@ -485,7 +485,7 @@ unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, void *buf, return kfifo_out_copy_r(fifo, buf, len, recsize, &n); } -EXPORT_SYMBOL(__kfifo_out_peek_r); +EXPORT_SYMBOL_GPL(__kfifo_out_peek_r); unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf, unsigned int len, size_t recsize) @@ -499,7 +499,7 @@ unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf, fifo->out += n + recsize; return len; } -EXPORT_SYMBOL(__kfifo_out_r); +EXPORT_SYMBOL_GPL(__kfifo_out_r); void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize) { @@ -508,7 +508,7 @@ void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize) n = __kfifo_peek_n(fifo, recsize); fifo->out += n + recsize; } -EXPORT_SYMBOL(__kfifo_skip_r); +EXPORT_SYMBOL_GPL(__kfifo_skip_r); int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from, unsigned long len, unsigned int *copied, size_t recsize) @@ -532,7 +532,7 @@ int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from, fifo->in += len + recsize; return 0; } -EXPORT_SYMBOL(__kfifo_from_user_r); +EXPORT_SYMBOL_GPL(__kfifo_from_user_r); int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, unsigned long len, unsigned int *copied, size_t recsize) @@ -557,7 +557,7 @@ int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, fifo->out += n + recsize; return 0; } -EXPORT_SYMBOL(__kfifo_to_user_r); +EXPORT_SYMBOL_GPL(__kfifo_to_user_r); unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) @@ -572,7 +572,7 @@ unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, return setup_sgl(fifo, sgl, nents, len, fifo->in + recsize); } -EXPORT_SYMBOL(__kfifo_dma_in_prepare_r); +EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare_r); void __kfifo_dma_in_finish_r(struct __kfifo *fifo, unsigned int len, size_t recsize) @@ -581,7 +581,7 @@ void __kfifo_dma_in_finish_r(struct __kfifo *fifo, __kfifo_poke_n(fifo, len, recsize); fifo->in += len + recsize; } -EXPORT_SYMBOL(__kfifo_dma_in_finish_r); +EXPORT_SYMBOL_GPL(__kfifo_dma_in_finish_r); unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) @@ -596,7 +596,7 @@ unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, return setup_sgl(fifo, sgl, nents, len, fifo->out + recsize); } -EXPORT_SYMBOL(__kfifo_dma_out_prepare_r); +EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare_r); void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize) { @@ -605,4 +605,4 @@ void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize) len = __kfifo_peek_n(fifo, recsize); fifo->out += len + recsize; } -EXPORT_SYMBOL(__kfifo_dma_out_finish_r); +EXPORT_SYMBOL_GPL(__kfifo_dma_out_finish_r); diff --git a/compat/kstrtox.c b/compat/kstrtox.c index 10aa91b4..44859d19 100644 --- a/compat/kstrtox.c +++ b/compat/kstrtox.c @@ -86,7 +86,7 @@ int kstrtoull(const char *s, unsigned int base, unsigned long long *res) s++; return _kstrtoull(s, base, res); } -EXPORT_SYMBOL(kstrtoull); +EXPORT_SYMBOL_GPL(kstrtoull); int kstrtoll(const char *s, unsigned int base, long long *res) { @@ -110,7 +110,7 @@ int kstrtoll(const char *s, unsigned int base, long long *res) } return 0; } -EXPORT_SYMBOL(kstrtoll); +EXPORT_SYMBOL_GPL(kstrtoll); /* Internal, do not use. */ int _kstrtoul(const char *s, unsigned int base, unsigned long *res) @@ -126,7 +126,7 @@ int _kstrtoul(const char *s, unsigned int base, unsigned long *res) *res = tmp; return 0; } -EXPORT_SYMBOL(_kstrtoul); +EXPORT_SYMBOL_GPL(_kstrtoul); /* Internal, do not use. */ int _kstrtol(const char *s, unsigned int base, long *res) @@ -142,7 +142,7 @@ int _kstrtol(const char *s, unsigned int base, long *res) *res = tmp; return 0; } -EXPORT_SYMBOL(_kstrtol); +EXPORT_SYMBOL_GPL(_kstrtol); int kstrtouint(const char *s, unsigned int base, unsigned int *res) { @@ -157,7 +157,7 @@ int kstrtouint(const char *s, unsigned int base, unsigned int *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtouint); +EXPORT_SYMBOL_GPL(kstrtouint); int kstrtoint(const char *s, unsigned int base, int *res) { @@ -172,7 +172,7 @@ int kstrtoint(const char *s, unsigned int base, int *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtoint); +EXPORT_SYMBOL_GPL(kstrtoint); int kstrtou16(const char *s, unsigned int base, u16 *res) { @@ -187,7 +187,7 @@ int kstrtou16(const char *s, unsigned int base, u16 *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtou16); +EXPORT_SYMBOL_GPL(kstrtou16); int kstrtos16(const char *s, unsigned int base, s16 *res) { @@ -202,7 +202,7 @@ int kstrtos16(const char *s, unsigned int base, s16 *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtos16); +EXPORT_SYMBOL_GPL(kstrtos16); int kstrtou8(const char *s, unsigned int base, u8 *res) { @@ -217,7 +217,7 @@ int kstrtou8(const char *s, unsigned int base, u8 *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtou8); +EXPORT_SYMBOL_GPL(kstrtou8); int kstrtos8(const char *s, unsigned int base, s8 *res) { @@ -232,5 +232,5 @@ int kstrtos8(const char *s, unsigned int base, s8 *res) *res = tmp; return 0; } -EXPORT_SYMBOL(kstrtos8); +EXPORT_SYMBOL_GPL(kstrtos8); #endif /* #ifndef strict_strtol */ -- cgit v1.2.3 From 086f3a1b5962866a12d8964d0baf5d7a5a3826f5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sat, 3 Mar 2012 21:03:22 -0800 Subject: compat: make all modules depend on compat Sometimes, compat based drivers do not depend on compat.ko because the base kernel is new enough. This causes compat to not be loaded and makes it harder to identify that the modules were based on compat. Re-define module_init() to make all modules that were compiled against compat also require to be linked against compat.ko. Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- compat/main.c | 5 +++++ include/linux/compat-2.6.h | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/compat/main.c b/compat/main.c index f830488f..30a4a1ee 100644 --- a/compat/main.c +++ b/compat/main.c @@ -32,6 +32,11 @@ module_param(compat_version, charp, 0400); MODULE_PARM_DESC(compat_version, "Version of the kernel compat backport work"); +void compat_dependency_symbol(void) +{ +} +EXPORT_SYMBOL_GPL(compat_dependency_symbol); + static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index c14aeb86..bb00cd45 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -10,6 +10,29 @@ #include #endif #include +#include + +/* + * The define overwriting module_init is based on the original module_init + * which looks like this: + * #define module_init(initfn) \ + * static inline initcall_t __inittest(void) \ + * { return initfn; } \ + * int init_module(void) __attribute__((alias(#initfn))); + * + * To the call to the initfn we added the symbol dependency on compat + * to make sure that compat.ko gets loaded for any compat modules. + */ +void compat_dependency_symbol(void); + +#undef module_init +#define module_init(initfn) \ + static void __init __init_compat(void) \ + { \ + compat_dependency_symbol(); \ + initfn(); \ + } \ + int init_module(void) __attribute__((alias("__init_compat"))); /* * Each compat file represents compatibility code for new kernel -- cgit v1.2.3 From fcee879e3f23863b3ab7cb4901a5e2a355e3d74a Mon Sep 17 00:00:00 2001 From: Nicolas Cavallari Date: Tue, 6 Mar 2012 10:55:28 +0100 Subject: compat: Fix module_init return type from void to int. 086f3a1 overrode module_init to make it depend on compat, but the overriding module_init has return type 'void', so strange things would happen when the module loading code see that init_module() returns positive values. This patch makes it return the value returned by the overriden module_init. Signed-off-by: Nicolas Cavallari Acked-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index bb00cd45..5715ce56 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -27,10 +27,10 @@ void compat_dependency_symbol(void); #undef module_init #define module_init(initfn) \ - static void __init __init_compat(void) \ + static int __init __init_compat(void) \ { \ compat_dependency_symbol(); \ - initfn(); \ + return initfn(); \ } \ int init_module(void) __attribute__((alias("__init_compat"))); -- cgit v1.2.3 From 17e8ea6f78b9d84f866c27e15ac726e60c44215d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 9 Mar 2012 12:21:36 -0800 Subject: compat: backport __pskb_copy() This was _not_ easy. The ckmake log: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.3.c | 172 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.1.h | 2 + include/linux/compat-3.3.h | 4 ++ 4 files changed, 179 insertions(+) create mode 100644 compat/compat-3.3.c diff --git a/compat/Makefile b/compat/Makefile index 3c72ef9b..b49e8c0a 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -35,6 +35,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o +compat-$(CONFIG_COMPAT_KERNEL_3_3) += compat-3.3.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.3.c b/compat/compat-3.3.c new file mode 100644 index 00000000..27c09e03 --- /dev/null +++ b/compat/compat-3.3.c @@ -0,0 +1,172 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.3. + */ + +#include +#include +#include +#include +#include + +static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old) +{ + new->tstamp = old->tstamp; + new->dev = old->dev; + new->transport_header = old->transport_header; + new->network_header = old->network_header; + new->mac_header = old->mac_header; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) + skb_dst_copy(new, old); + new->rxhash = old->rxhash; +#else + skb_dst_set(new, dst_clone(skb_dst(old))); +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) + new->ooo_okay = old->ooo_okay; +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) + new->l4_rxhash = old->l4_rxhash; +#endif +#ifdef CONFIG_XFRM + new->sp = secpath_get(old->sp); +#endif + memcpy(new->cb, old->cb, sizeof(old->cb)); + new->csum = old->csum; + new->local_df = old->local_df; + new->pkt_type = old->pkt_type; + new->ip_summed = old->ip_summed; + skb_copy_queue_mapping(new, old); + new->priority = old->priority; +#if IS_ENABLED(CONFIG_IP_VS) + new->ipvs_property = old->ipvs_property; +#endif + new->protocol = old->protocol; + new->mark = old->mark; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) + new->skb_iif = old->skb_iif; +#endif + __nf_copy(new, old); +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE) + new->nf_trace = old->nf_trace; +#endif +#ifdef CONFIG_NET_SCHED + new->tc_index = old->tc_index; +#ifdef CONFIG_NET_CLS_ACT + new->tc_verd = old->tc_verd; +#endif +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) + new->vlan_tci = old->vlan_tci; +#endif + + skb_copy_secmark(new, old); +} + +static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old) +{ +#ifndef NET_SKBUFF_DATA_USES_OFFSET + /* + * Shift between the two data areas in bytes + */ + unsigned long offset = new->data - old->data; +#endif + + __copy_skb_header(new, old); + +#ifndef NET_SKBUFF_DATA_USES_OFFSET + /* {transport,network,mac}_header are relative to skb->head */ + new->transport_header += offset; + new->network_header += offset; + if (skb_mac_header_was_set(new)) + new->mac_header += offset; +#endif + skb_shinfo(new)->gso_size = skb_shinfo(old)->gso_size; + skb_shinfo(new)->gso_segs = skb_shinfo(old)->gso_segs; + skb_shinfo(new)->gso_type = skb_shinfo(old)->gso_type; +} + +static void skb_clone_fraglist(struct sk_buff *skb) +{ + struct sk_buff *list; + + skb_walk_frags(skb, list) + skb_get(list); +} + + +/** + * __pskb_copy - create copy of an sk_buff with private head. + * @skb: buffer to copy + * @headroom: headroom of new skb + * @gfp_mask: allocation priority + * + * Make a copy of both an &sk_buff and part of its data, located + * in header. Fragmented data remain shared. This is used when + * the caller wishes to modify only header of &sk_buff and needs + * private copy of the header to alter. Returns %NULL on failure + * or the pointer to the buffer on success. + * The returned buffer has a reference count of 1. + */ + +struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask) +{ + unsigned int size = skb_headlen(skb) + headroom; + struct sk_buff *n = alloc_skb(size, gfp_mask); + + if (!n) + goto out; + + /* Set the data pointer */ + skb_reserve(n, headroom); + /* Set the tail pointer and length */ + skb_put(n, skb_headlen(skb)); + /* Copy the bytes */ + skb_copy_from_linear_data(skb, n->data, n->len); + + n->truesize += skb->data_len; + n->data_len = skb->data_len; + n->len = skb->len; + + if (skb_shinfo(skb)->nr_frags) { + int i; + +/* + * SKBTX_DEV_ZEROCOPY was added on 3.1 as well but requires ubuf + * stuff added to the skb which we do not have + */ +#if 0 + if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) { + if (skb_copy_ubufs(skb, gfp_mask)) { + kfree_skb(n); + n = NULL; + goto out; + } + } +#endif + for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + skb_shinfo(n)->frags[i] = skb_shinfo(skb)->frags[i]; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) + skb_frag_ref(skb, i); +#else + get_page(skb_shinfo(skb)->frags[i].page); +#endif + } + skb_shinfo(n)->nr_frags = i; + } + + if (skb_has_frag_list(skb)) { + skb_shinfo(n)->frag_list = skb_shinfo(skb)->frag_list; + skb_clone_fraglist(n); + } + + copy_skb_header(n, skb); +out: + return n; +} +EXPORT_SYMBOL_GPL(__pskb_copy); diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 5b00ac96..845499b6 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -7,6 +7,8 @@ #include +#define IS_ENABLED(option) defined(option) + #define genl_dump_check_consistent(cb, user_hdr, family) #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 4965f234..69bdcd0b 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -7,6 +7,10 @@ /* include to override NL80211_FEATURE_SK_TX_STATUS */ #include +#include + +extern struct sk_buff *__pskb_copy(struct sk_buff *skb, + int headroom, gfp_t gfp_mask); static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked) { -- cgit v1.2.3 From 7e2c38e8e574ff829e741bda0bfccd7cd2e90ac6 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 9 Mar 2012 12:53:29 -0800 Subject: compat: backport defining COMPAT_USE_64BIT_TIME Only x86 seems to use this so far. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 378371f4..0a6a8ead 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -7,6 +7,13 @@ #include +#ifdef CONFIG_X86_X32_ABI +#define COMPAT_USE_64BIT_TIME \ + (!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT)) +#else +#define COMPAT_USE_64BIT_TIME 0 +#endif + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) static inline void eth_hw_addr_random(struct net_device *dev) { -- cgit v1.2.3 From 444d2fa62f8ae729bb0569a3653bf8f643bef3a5 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 12 Mar 2012 17:13:37 -0700 Subject: compat: backport CPU mask affinity hint We cannot backport this given that the IRQ data structure was changed so simply treat this hint as if the system was uniprocessor. This backports this commit: commit e7a297b0d7d6049bd4e423ac1e17da31e4c401b8 Author: Peter P Waskiewicz Jr Date: Fri Apr 30 14:44:50 2010 -0700 genirq: Add CPU mask affinity hint This patch adds a cpumask affinity hint to the irq_desc structure, along with a registration function and a read-only proc entry for each interrupt. This affinity_hint handle for each interrupt can be used by underlying drivers that need a better mechanism to control interrupt affinity. The underlying driver can register a cpumask for the interrupt, which will allow the driver to provide the CPU mask for the interrupt to anything that requests it. The intent is to extend the userspace daemon, irqbalance, to help hint to it a preferred CPU mask to balance the interrupt into. [ tglx: Fixed compile warnings, added WARN_ON, made SMP only ] Signed-off-by: Peter P Waskiewicz Jr Cc: davem@davemloft.net Cc: arjan@linux.jf.intel.com Cc: bhutchings@solarflare.com LKML-Reference: <20100430214445.3992.41647.stgit@ppwaskie-hc2.jf.intel.com> Signed-off-by: Thomas Gleixner ckmake log: Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.35.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 5e43002f..58141239 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -19,6 +19,17 @@ #define netdev_hw_addr dev_mc_list +/* + * We cannot backport this guy as the IRQ data structure + * was modified in the kernel itself to support this. We + * treat the system as uni-processor in this case. + */ +static inline int irq_set_affinity_hint(unsigned int irq, + const struct cpumask *m) +{ + return -EINVAL; +} + static inline wait_queue_head_t *sk_sleep(struct sock *sk) { return sk->sk_sleep; -- cgit v1.2.3 From 80bf8a835893ae35db13e3ea6f5b984352019fbe Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 19 Mar 2012 16:14:47 -0700 Subject: compat: backport system work queues system_wq and system_long_wq mcgrof@tux ~/linux-stable (git::master)$ git describe --contains d320c038 v2.6.36-rc1~506^2~26 The commit d320c038 added some new system workqueues to allow us to categorize order of priority on workqueue items. We had already backported usage of system_nrt_wq but hadn't backported usage of system_wq or system_long_wq. We address this now in this patch by also ensuring that flush_workqueue() will flush these as designed, that is only prioritizing system_wq. Given that older kernels would be using the older keventd_wq for now we flush that and then system_wq, allowing users of the system_long_wq to be delayed as intended for backported kernel code using this framework. For newer kernels this is a no-op. commit d320c03830b17af64e4547075003b1eeb274bc6c Author: Tejun Heo Date: Tue Jun 29 10:07:14 2010 +0200 workqueue: s/__create_workqueue()/alloc_workqueue()/, and add system workqueues This patch makes changes to make new workqueue features available to its users. * Now that workqueue is more featureful, there should be a public workqueue creation function which takes paramters to control them. Rename __create_workqueue() to alloc_workqueue() and make 0 max_active mean WQ_DFL_ACTIVE. In the long run, all create_workqueue_*() will be converted over to alloc_workqueue(). * To further unify access interface, rename keventd_wq to system_wq and export it. * Add system_long_wq and system_nrt_wq. The former is to host long running works separately (so that flush_scheduled_work() dosen't take so long) and the latter guarantees any queued work item is never executed in parallel by multiple CPUs. These will be used by future patches to update workqueue users. Signed-off-by: Tejun Heo The ckmake [documented on 0] log: Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] [0] https://github.com/mcgrof/compat/wiki Cc: Tejun Heo Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 53 ++++++++++++++++++++++++++++++++++++++++++- include/linux/compat-2.6.36.h | 32 ++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index dfab2ea9..b79609c7 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -95,16 +95,67 @@ EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); #endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ +struct workqueue_struct *system_wq __read_mostly; +struct workqueue_struct *system_long_wq __read_mostly; struct workqueue_struct *system_nrt_wq __read_mostly; +EXPORT_SYMBOL_GPL(system_wq); +EXPORT_SYMBOL_GPL(system_long_wq); EXPORT_SYMBOL_GPL(system_nrt_wq); +int compat_schedule_work(struct work_struct *work) +{ + return queue_work(system_wq, work); +} +EXPORT_SYMBOL_GPL(compat_schedule_work); + +int compat_schedule_work_on(int cpu, struct work_struct *work) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) + return queue_work_on(cpu, system_wq, work); +#else + return queue_work(system_wq, work); +#endif +} +EXPORT_SYMBOL_GPL(compat_schedule_work_on); + +int compat_schedule_delayed_work(struct delayed_work *dwork, + unsigned long delay) +{ + return queue_delayed_work(system_wq, dwork, delay); +} +EXPORT_SYMBOL_GPL(compat_schedule_delayed_work); + +int compat_schedule_delayed_work_on(int cpu, + struct delayed_work *dwork, + unsigned long delay) +{ + return queue_delayed_work_on(cpu, system_wq, dwork, delay); +} +EXPORT_SYMBOL_GPL(compat_schedule_delayed_work_on); + +void compat_flush_scheduled_work(void) +{ + /* + * It is debatable which one we should prioritize first, lets + * go with the old kernel's one first for now (keventd_wq) and + * if think its reasonable later we can flip this around. + */ + flush_workqueue(system_wq); + flush_scheduled_work(); +} +EXPORT_SYMBOL_GPL(compat_flush_scheduled_work); + void compat_system_workqueue_create() { + system_wq = alloc_workqueue("events", 0, 0); + system_long_wq = alloc_workqueue("events_long", 0, 0); system_nrt_wq = create_singlethread_workqueue("events_nrt"); - WARN_ON(!system_nrt_wq); + BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq); } void compat_system_workqueue_destroy() { + destroy_workqueue(system_wq); + destroy_workqueue(system_long_wq); destroy_workqueue(system_nrt_wq); } diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 314fb353..4768e63e 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -137,11 +137,43 @@ static inline void skb_tx_timestamp(struct sk_buff *skb) { } +/* + * System-wide workqueues which are always present. + * + * system_wq is the one used by schedule[_delayed]_work[_on](). + * Multi-CPU multi-threaded. There are users which expect relatively + * short queue flush time. Don't queue works which can run for too + * long. + * + * system_long_wq is similar to system_wq but may host long running + * works. Queue flushing might take relatively long. + * + * system_nrt_wq is non-reentrant and guarantees that any given work + * item is never executed in parallel by multiple CPUs. Queue + * flushing might take relatively long. + */ +extern struct workqueue_struct *system_wq; +extern struct workqueue_struct *system_long_wq; extern struct workqueue_struct *system_nrt_wq; void compat_system_workqueue_create(void); void compat_system_workqueue_destroy(void); +int compat_schedule_work(struct work_struct *work); +int compat_schedule_work_on(int cpu, struct work_struct *work); +int compat_schedule_delayed_work(struct delayed_work *dwork, + unsigned long delay); +int compat_schedule_delayed_work_on(int cpu, + struct delayed_work *dwork, + unsigned long delay); +void compat_flush_scheduled_work(void); + +#define schedule_work(work) compat_schedule_work(work) +#define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work) +#define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay) +#define schedule_delayed_work_on(cpu, dwork, delay) compat_schedule_delayed_work_on(cpu, dwork, delay) +#define flush_scheduled_work(a) compat_flush_scheduled_work(a) + #define br_port_exists(dev) (dev->br_port) #else -- cgit v1.2.3 From e4e6f33801d78ad3b71836ce8a3058235fdaa6ef Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 19 Mar 2012 17:44:01 -0700 Subject: compat: backport work_busy() Best we can do is just tell the users of we are WORK_BUSY_PENDING for older kernels. The ckmake log: Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 24 ++++++++++++++++++++++++ include/linux/compat-2.6.28.h | 4 ++++ include/linux/compat-2.6.36.h | 8 ++++++++ 3 files changed, 36 insertions(+) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index b79609c7..9190ecd8 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -145,6 +145,30 @@ void compat_flush_scheduled_work(void) } EXPORT_SYMBOL_GPL(compat_flush_scheduled_work); +/** + * work_busy - test whether a work is currently pending or running + * @work: the work to be tested + * + * Test whether @work is currently pending or running. There is no + * synchronization around this function and the test result is + * unreliable and only useful as advisory hints or for debugging. + * Especially for reentrant wqs, the pending state might hide the + * running state. + * + * RETURNS: + * OR'd bitmask of WORK_BUSY_* bits. + */ +unsigned int work_busy(struct work_struct *work) +{ + unsigned int ret = 0; + + if (work_pending(work)) + ret |= WORK_BUSY_PENDING; + + return ret; +} +EXPORT_SYMBOL_GPL(work_busy); + void compat_system_workqueue_create() { system_wq = alloc_workqueue("events", 0, 0); diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index c0ca70b1..e336f39e 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -9,6 +9,8 @@ #include #include #include +#include +#include #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ @@ -16,6 +18,8 @@ #include +typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t; + #if defined(CONFIG_X86) || defined(CONFIG_X86_64) || defined(CONFIG_PPC) /* * CONFIG_PHYS_ADDR_T_64BIT was added as new to all architectures diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 4768e63e..56d59619 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -168,6 +168,14 @@ int compat_schedule_delayed_work_on(int cpu, unsigned long delay); void compat_flush_scheduled_work(void); +enum { + /* bit mask for work_busy() return values */ + WORK_BUSY_PENDING = 1 << 0, + WORK_BUSY_RUNNING = 1 << 1, +}; + +extern unsigned int work_busy(struct work_struct *work); + #define schedule_work(work) compat_schedule_work(work) #define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work) #define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay) -- cgit v1.2.3 From 22f03e353206c8f848de9d47cb1f6079fdfe9ed3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 19 Mar 2012 18:25:34 -0700 Subject: compat: fix load time issue with kfifo backport The CONFIG_COMPAT_KFIFO config option must be defined to CONFIG_COMPAT_KFIFO=y instead of CONFIG_COMPAT_KFIFO=m as the kfifo object is not a module, its simply part of the compat module. This should fix users of the kfifo backport on kernels older than 2.6.36. Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 423d5952..5d6e34cc 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -59,5 +59,5 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then - echo "CONFIG_COMPAT_KFIFO=m" + echo "CONFIG_COMPAT_KFIFO=y" fi -- cgit v1.2.3 From e0728a43ab8ea0b2076cf1b276e8cbaa31aecb4c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 19 Mar 2012 20:20:50 -0700 Subject: compat: add some tracing backport work Its not really easy to backport the tracing stuff, but lets give it a shot. We should simply review how many subsystems we want tracing for and for what target kernels we want that enabled for. It doesn't make sense to backport tracing if we won't have much users. For now add some code that at least does not break building. Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/tracepoint.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 9f5add1c..a5bd743f 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -4,7 +4,47 @@ #include #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) + #include_next + +/* Backports f42c85e7 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) +#undef TP_STRUCT__entry +#define TP_STRUCT__entry(args...) args +#endif + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) +/* Backports 091ad365, a rename */ +#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) +#define TP_PROTO TPPROTO +#define TP_ARGS TPARGS +#define TP_FMT TPFMT +#define TP_RAW_FMT TPRAWFMT +#endif + +#endif + +#else /* just disable tracing */ + +/* Disable all tracing */ +#undef TRACE_EVENT +#define TRACE_EVENT(name, proto, ...) \ +static inline void trace_ ## name(proto) {} +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(...) +#undef DEFINE_EVENT +#define DEFINE_EVENT(evt_class, name, proto, ...) \ +static inline void trace_ ## name(proto) {} + +#define TP_PROTO(args...) args +#define TP_ARGS(args...) args +#define TP_CONDITION(args...) args + +struct tracepoint_iter { +}; + #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */ #endif /* _COMPAT_LINUX_TRACEPOINT_H */ -- cgit v1.2.3 From 7d549b33d180b96a6b34e1c9d1298a1c1ec557d4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 28 Mar 2012 02:45:07 -0700 Subject: compat: complete tracepoint backport Tested also against compat-wireless against: * 2.6.33 * 2.6.32 I'm happy with this. compat ckmake: Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/tracepoint.h | 145 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 5 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index a5bd743f..44c9a5d5 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -13,10 +13,12 @@ #define TP_STRUCT__entry(args...) args #endif -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) /* Backports 091ad365, a rename */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) #define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE +#endif +/* Backpports 2939b0469 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) #define TP_PROTO TPPROTO #define TP_ARGS TPARGS @@ -24,7 +26,143 @@ #define TP_RAW_FMT TPRAWFMT #endif -#endif +/* Force disabling tracing */ + +#undef TRACE_EVENT +#define TRACE_EVENT(name, proto, ...) \ +DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) + +#undef DECLARE_EVENT_CLASS +#define DECLARE_EVENT_CLASS(...) +#undef DEFINE_EVENT + +#define DEFINE_EVENT(template, name, proto, args) \ + DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) + +#undef DECLARE_TRACE_NOARGS +#define DECLARE_TRACE_NOARGS(name) \ + __DECLARE_TRACE(name, void, , 1, void *__data, __data) + + +/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) + +#undef DECLARE_TRACE +#define DECLARE_TRACE(name, proto, args) \ + __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \ + PARAMS(void *__data, proto), \ + PARAMS(__data, args)) + +#undef DECLARE_TRACE_CONDITION +#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \ + __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \ + PARAMS(void *__data, proto), \ + PARAMS(__data, args)) + +#else + +#undef DECLARE_TRACE +#define DECLARE_TRACE(name, proto, args) \ + __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \ + PARAMS(void *__data, proto), \ + PARAMS(__data, args)) + +#undef DECLARE_TRACE_CONDITION +#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \ + __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \ + PARAMS(void *__data, proto), \ + PARAMS(__data, args)) +#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ + +/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) + +/* Backports c420970ef476d7d68df119711700666224001f43 */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) + +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline void \ + unregister_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } +#else + +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(proto)) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } +#endif /* backport c420970ef476d7d68df119711700666224001f43 */ + +#else + +#undef __DECLARE_TRACE +#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ + static inline void trace_##name(proto) \ + { } \ + static inline void trace_##name##_rcuidle(proto) \ + { } \ + static inline int \ + register_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline int \ + unregister_trace_##name(void (*probe)(data_proto), \ + void *data) \ + { \ + return -ENOSYS; \ + } \ + static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ + { \ + } + +#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ + +#undef DEFINE_TRACE_FN +#define DEFINE_TRACE_FN(name, reg, unreg) + +#undef DEFINE_TRACE +#define DEFINE_TRACE(name) + +#undef EXPORT_TRACEPOINT_SYMBOL_GPL +#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) + +#undef EXPORT_TRACEPOINT_SYMBOL +#define EXPORT_TRACEPOINT_SYMBOL(name) + +#ifdef CONFIG_TRACEPOINTS +#else /* CONFIG_TRACEPOINTS */ +#endif /* CONFIG_TRACEPOINTS */ #else /* just disable tracing */ @@ -42,9 +180,6 @@ static inline void trace_ ## name(proto) {} #define TP_ARGS(args...) args #define TP_CONDITION(args...) args -struct tracepoint_iter { -}; - #endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */ #endif /* _COMPAT_LINUX_TRACEPOINT_H */ -- cgit v1.2.3 From c5befb06c18d80fb94aafd33092237871244c94b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 30 Mar 2012 13:13:00 +0200 Subject: compat: crc8: undef pr_fmt mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Tested-by: Arend Van Spriel Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- compat/crc8.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/crc8.c b/compat/crc8.c index fa8382d2..5878171c 100644 --- a/compat/crc8.c +++ b/compat/crc8.c @@ -14,6 +14,7 @@ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#undef pr_fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -- cgit v1.2.3 From 5a14da892e41bb955b22c1f119c52d1b0cda1155 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 30 Mar 2012 11:52:59 +0200 Subject: compat-3.3: include module.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compat/compat-3.3.c:172:1: warning: data definition has no type or storage class [enabled by default] compat/compat-3.3.c:172:1: warning: type defaults to ā€˜intā€™ in declaration of ā€˜EXPORT_SYMBOL_GPLā€™ [-Wimplicit-int] compat/compat-3.3.c:172:1: warning: parameter names (without types) in function declaration [enabled by default] In newer kernels we should include export.h, but not all kernels have that so use module.h which always works. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- compat/compat-3.3.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-3.3.c b/compat/compat-3.3.c index 27c09e03..84893446 100644 --- a/compat/compat-3.3.c +++ b/compat/compat-3.3.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include -- cgit v1.2.3 From 561fe75aefcca0629df78752c7d991b97f6be870 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 14:03:18 -0700 Subject: compat: avoid inclusin of COMPAT_CONFIG at clean target Technically we can include COMPAT_CONFIG for all targets but at make clean we won't have it. Avoid that warning. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Cc: stable@orbit-lab.org Signed-off-by: Luis R. Rodriguez --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 82d4cbbc..570dd8bf 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,9 @@ NOSTDINC_FLAGS := -I$(M)/include/ \ -DCOMPAT_PROJECT="\"Generic kernel\"" \ -DCOMPAT_VERSION="\"$(COMPAT_VERSION)\"" -include $(COMPAT_CONFIG) +# Technicallay we can require the inclusion of COMPAT_CONFIG for +# all targets except clean, so avoid the warnings at clean time. +-include $(COMPAT_CONFIG) endif obj-y += compat/ -- cgit v1.2.3 From 5c363f4b3997278dff44c3e444240fcda19e901a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 14:42:17 -0700 Subject: compat: move PWD definition early This prevents bogus calls of our scripts. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Cc: stable@orbit-lab.org Signed-off-by: Luis R. Rodriguez --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 570dd8bf..8775294c 100644 --- a/Makefile +++ b/Makefile @@ -7,9 +7,8 @@ export KLIB:= /lib/modules/$(shell uname -r) endif export KLIB_BUILD ?= $(KLIB)/build -export PWD := $(shell pwd) - ifeq ($(KERNELRELEASE),) +export PWD := $(shell pwd) export COMPAT_BASE_TREE := "linux-next.git" # For this specific tree this is only relevant in # terms of the last time we synched code up with upstream -- cgit v1.2.3 From 182630e0f686a569aaf9b34781b08f27dc0ab1bb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 14:25:19 -0700 Subject: compat: fix compat_firmware_class.c compilation on older kernels CONFIG_COMPAT_FIRMWARE_CLASS is defined explicitly for any kernel >= 2.6.33 but CONFIG_FW_LOADER) || CONFIG_FW_LOADER_MODULE may still be disabled, and in those cases we should still compile. Lets clean this up by being explicit about the exported symbols within compat_firmware_class.c instead of relying on the header file to rename them for us at compile time. At the same time be consistent and use the CONFIG_FW_LOADER) || CONFIG_FW_LOADER_MODULE checks on the header to see which declarations to use. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Cc: stable@orbit-lab.org Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 6 +++--- include/linux/compat-2.6.33.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 01eda401..69b442b7 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -635,7 +635,7 @@ out: * firmware image for this or any other device. **/ int -request_firmware(const struct firmware **firmware_p, const char *name, +compat_request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) { int uevent = 1; @@ -646,7 +646,7 @@ request_firmware(const struct firmware **firmware_p, const char *name, * release_firmware: - release the resource associated with a firmware image * @fw: firmware resource to release **/ -void release_firmware(const struct firmware *fw) +void compat_release_firmware(const struct firmware *fw) { if (fw) { if (!fw_is_builtin_firmware(fw)) @@ -705,7 +705,7 @@ static int request_firmware_work_func(void *arg) * in atomic contexts. **/ int -request_firmware_nowait( +compat_request_firmware_nowait( struct module *module, int uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index c900a6fc..0c71af99 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -15,7 +15,7 @@ #include #include -#if defined(CONFIG_COMPAT_FIRMWARE_CLASS) +#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) #define release_firmware compat_release_firmware #define request_firmware compat_request_firmware #define request_firmware_nowait compat_request_firmware_nowait @@ -37,7 +37,7 @@ static inline int compat_request_firmware(const struct firmware **fw, { return -EINVAL; } -static inline int request_firmware_nowait( +static inline int compat_request_firmware_nowait( struct module *module, int uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)) -- cgit v1.2.3 From 84d907e9d2f26babcb8267bbf5c9ecb559a454d4 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 30 Mar 2012 13:11:44 +0200 Subject: compat: explicitly export generated variables Doing the blanket "export" statement at the beginning of the generated file confuses the kernel's Makefiles and causes extreme build slowdowns. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Cc: stable@orbit-lab.org Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 5d6e34cc..6cdac120 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -20,9 +20,10 @@ KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\. COMPAT_LATEST_VERSION="3" KERNEL_SUBLEVEL="-1" -# This allows all these variables to be propagated through -# all of our Makefiles -echo export +# Note that this script will export all variables explicitly, +# trying to export all with a blanket "export" statement at +# the top of the generated file causes the build to slow down +# by an order of magnitude. if [[ ${KERNEL_VERSION} -eq "3" ]]; then KERNEL_SUBLEVEL=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^3\.\([0-9]\+\).*/\1/p') @@ -33,14 +34,14 @@ else for i in $(seq ${KERNEL_26SUBLEVEL} ${COMPAT_26LATEST_VERSION}); do eval CONFIG_COMPAT_KERNEL_2_6_${i}=y - echo "CONFIG_COMPAT_KERNEL_2_6_${i}=y" + echo "export CONFIG_COMPAT_KERNEL_2_6_${i}=y" done fi let KERNEL_SUBLEVEL=${KERNEL_SUBLEVEL}+1 for i in $(seq ${KERNEL_SUBLEVEL} ${COMPAT_LATEST_VERSION}); do eval CONFIG_COMPAT_KERNEL_3_${i}=y - echo "CONFIG_COMPAT_KERNEL_3_${i}=y" + echo "export CONFIG_COMPAT_KERNEL_3_${i}=y" done # The purpose of these seem to be the inverse of the above other varibales. @@ -50,14 +51,14 @@ if [[ ! -z ${RHEL_MAJOR} ]]; then RHEL_MINOR=$(grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') for i in $(seq 0 ${RHEL_MINOR}); do eval CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y - echo "CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" + echo "export CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" done fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then - echo "CONFIG_COMPAT_FIRMWARE_CLASS=m" + echo "export CONFIG_COMPAT_FIRMWARE_CLASS=m" fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then - echo "CONFIG_COMPAT_KFIFO=y" + echo "export CONFIG_COMPAT_KFIFO=y" fi -- cgit v1.2.3 From 6331fc7aa8b1811c49172d2dc96c7adf3587950b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 14:59:56 -0700 Subject: compat: backport run-time power management (5e928f77) This backports 5e928f77a09a07f9dd595bb8a489965d69a83458 Run-time power management cannot really be backported given that the implementation added bus specific callbacks that we won't have on older kernels. If you really want run-time power management or good power management upgrade your kernel. We'll just compile this out as if run-time power management was disabled just as the kernel disables run-time power management when CONFIG_PM_RUNTIME is disabled. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 3506291d..bfa37f82 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -18,6 +18,20 @@ #define SDIO_DEVICE_ID_INTEL_IWMC3200GPS 0x1405 #define SDIO_DEVICE_ID_INTEL_IWMC3200BT 0x1406 +/* + * Backports 5e928f77a09a07f9dd595bb8a489965d69a83458 + * run-time power management cannot really be backported + * given that the implementation added bus specific + * callbacks that we won't have on older kernels. If + * you really want run-time power management or good + * power management upgrade your kernel. We'll just + * compile this out as if run-time power management was + * disabled just as the kernel disables run-time power management + * when CONFIG_PM_RUNTIME is disabled. + */ +static inline void pm_runtime_init(struct device *dev) {} +static inline void pm_runtime_remove(struct device *dev) {} + static inline void flush_delayed_work(struct delayed_work *dwork) { if (del_timer_sync(&dwork->timer)) { -- cgit v1.2.3 From b148641e4709fc0473845160cdb226e0661cffa9 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 16:42:37 -0700 Subject: compat: define PARAMS for tracepoint Not all kernels have this defined, so define it when we force disabling tracepoint. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/tracepoint.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 44c9a5d5..d469235b 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -28,6 +28,9 @@ /* Force disabling tracing */ +#undef PARAMS +#define PARAMS(args...) args + #undef TRACE_EVENT #define TRACE_EVENT(name, proto, ...) \ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) -- cgit v1.2.3 From b15d934ec065f45f9ffd58184b6aee310ea4082c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 16:44:31 -0700 Subject: compat: fix warning on trace backport for 2.6.29 and older The unregister callback returns void but we are returning something, fix that. Signed-off-by: Luis R. Rodriguez --- include/linux/tracepoint.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index d469235b..23eb7605 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -97,7 +97,6 @@ DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) static inline void \ unregister_trace_##name(void (*probe)(proto)) \ { \ - return -ENOSYS; \ } \ static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ { \ -- cgit v1.2.3 From b5c14a3a729e601a70395f583a4b1f198cc2af1f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 18:32:32 -0700 Subject: compat: complete pm runtime backport A few calls were missing. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index bfa37f82..d93269a1 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -31,6 +31,39 @@ */ static inline void pm_runtime_init(struct device *dev) {} static inline void pm_runtime_remove(struct device *dev) {} +static inline int pm_runtime_get(struct device *dev) +{ + return 0; +} + +static inline int pm_runtime_get_sync(struct device *dev) +{ + return 0; +} + +static inline int pm_runtime_put(struct device *dev) +{ + return 0; +} + +static inline int pm_runtime_put_sync(struct device *dev) +{ + return 0; +} + +static inline int pm_runtime_set_active(struct device *dev) +{ + return 0; +} + +static inline void pm_runtime_set_suspended(struct device *dev) +{ +} + +static inline void pm_runtime_disable(struct device *dev) +{ +} + static inline void flush_delayed_work(struct delayed_work *dwork) { -- cgit v1.2.3 From b057e25f4a2a28675ad6ada5c47338a4dfa366d7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 18:51:03 -0700 Subject: compat: last pm-runtime callbacks Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index d93269a1..b0c699a6 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -64,6 +64,8 @@ static inline void pm_runtime_disable(struct device *dev) { } +static inline void pm_runtime_put_noidle(struct device *dev) {} +static inline void pm_runtime_get_noresume(struct device *dev) {} static inline void flush_delayed_work(struct delayed_work *dwork) { -- cgit v1.2.3 From 22fdc7c29c8eb4e288ccc49cf7a5b0a982425987 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Mar 2012 20:05:47 -0700 Subject: compat: backport USB asynchronous autosuspend/autoresume support (9ac39f28b) Just disable it. commit 9ac39f28b5237a629e41ccfc1f73d3a55723045c Author: Alan Stern Date: Wed Nov 12 16:19:49 2008 -0500 USB: add asynchronous autosuspend/autoresume support This patch (as1160b) adds support routines for asynchronous autosuspend and autoresume, with accompanying documentation updates. There already are several potential users of this interface, and others are likely to arise as autosuspend support becomes more widespread. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman mcgrof@tux ~/linux-stable (git::master)$ git describe \ --contains 9ac39f28b5237a629e41ccfc1f73d3a55723045c v2.6.29-rc1~182^2~99 mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 1e538bbd..0892e7de 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -18,6 +18,12 @@ #include #include +/* backports */ +static inline void usb_autopm_put_interface_async(struct usb_interface *intf) +{ } +static inline int usb_autopm_get_interface_async(struct usb_interface *intf) +{ return 0; } + #if \ defined(CONFIG_ALPHA) || defined(CONFIG_AVR32) || \ defined(CONFIG_BLACKFIN) || defined(CONFIG_CRIS) || \ -- cgit v1.2.3 From 067f4e12299e1e00f95ed95b1ce9180f2e4cb58c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 31 Mar 2012 21:46:02 -0700 Subject: compat: backport in.h shortcuts added by Joe (2658) This should help compilation on 2.6.24. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 70 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index c389ab2c..184501cc 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -16,6 +16,76 @@ #include #include #include +#include +#include + +/* + * backports 2658fa803111dae1353602e7f586de8e537803e2 + * We skip proto_ports_offset() as I'm lazy. + */ + +static inline bool ipv4_is_loopback(__be32 addr) +{ + return (addr & htonl(0xff000000)) == htonl(0x7f000000); +} + +static inline bool ipv4_is_multicast(__be32 addr) +{ + return (addr & htonl(0xf0000000)) == htonl(0xe0000000); +} + +static inline bool ipv4_is_local_multicast(__be32 addr) +{ + return (addr & htonl(0xffffff00)) == htonl(0xe0000000); +} + +static inline bool ipv4_is_lbcast(__be32 addr) +{ + /* limited broadcast */ + return addr == htonl(INADDR_BROADCAST); +} + +static inline bool ipv4_is_zeronet(__be32 addr) +{ + return (addr & htonl(0xff000000)) == htonl(0x00000000); +} + +/* Special-Use IPv4 Addresses (RFC3330) */ + +static inline bool ipv4_is_private_10(__be32 addr) +{ + return (addr & htonl(0xff000000)) == htonl(0x0a000000); +} + +static inline bool ipv4_is_private_172(__be32 addr) +{ + return (addr & htonl(0xfff00000)) == htonl(0xac100000); +} + +static inline bool ipv4_is_private_192(__be32 addr) +{ + return (addr & htonl(0xffff0000)) == htonl(0xc0a80000); +} + +static inline bool ipv4_is_linklocal_169(__be32 addr) +{ + return (addr & htonl(0xffff0000)) == htonl(0xa9fe0000); +} + +static inline bool ipv4_is_anycast_6to4(__be32 addr) +{ + return (addr & htonl(0xffffff00)) == htonl(0xc0586300); +} + +static inline bool ipv4_is_test_192(__be32 addr) +{ + return (addr & htonl(0xffffff00)) == htonl(0xc0000200); +} + +static inline bool ipv4_is_test_198(__be32 addr) +{ + return (addr & htonl(0xfffe0000)) == htonl(0xc6120000); +} /* * phys_addr_t was added as a generic arch typedef on 2.6.28, -- cgit v1.2.3 From 9031a1533a584d87114d111da10e0c02f65ee9ac Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 11:02:56 -0700 Subject: compat: backport adding of __ref, __refdata, __refconst This backports: commit 312b1485fb509c9bc32eda28ad29537896658cb8 Author: Sam Ravnborg Date: Mon Jan 28 20:21:15 2008 +0100 Introduce new section reference annotations tags: __ref, __refdata, __refconst Fixes compilation on 2.6.24 of drivers who use these. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-13-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-22-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 184501cc..d4fb4a06 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -18,6 +18,18 @@ #include #include #include +#include + +/* + * Backports 312b1485fb509c9bc32eda28ad29537896658cb8 + * Author: Sam Ravnborg + * Date: Mon Jan 28 20:21:15 2008 +0100 + * + * Introduce new section reference annotations tags: __ref, __refdata, __refconst + */ +#define __ref __init_refok +#define __refdata __initdata_refok +#define __ref __exit_refok /* * backports 2658fa803111dae1353602e7f586de8e537803e2 -- cgit v1.2.3 From eafff4b3d2ce5cb9d25f8d1029f1cf9df44f5715 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 15:04:04 -0700 Subject: compat: only use PPA kernels This skips non-PPA kernels for Ubuntu with ckmake. This lets a machine host as many kernelas it wants but we stick to only using the PPA mainline vanilla kernels. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index 2d9a5ebe..8238436f 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -29,7 +29,7 @@ LOG="ckmake.log" LSB_RED_ID=$(/usr/bin/lsb_release -i -s) case $LSB_RED_ID in "Ubuntu") - for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r); do + for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do KLIBS="$KLIBS $i" done ;; -- cgit v1.2.3 From 2e4f8f257df262d51a0932dadc416875b03c2c86 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 15:40:27 -0700 Subject: compat: backport simple_open() This is not yet upstream on Linus' tree so my best guess is it will make it on the 3.5 release. commit 90c936d19fb5cb3fb6b74dc18bf4bb3314a6a599 Author: Stephen Boyd Date: Wed Mar 21 10:48:20 2012 +1100 libfs: add simple_open() debugfs and a few other drivers use an open-coded version of simple_open() to pass a pointer from the file to the read/write file ops. Add support for this simple case to libfs so that we can remove the many duplicate copies of this simple function. Signed-off-by: Stephen Boyd Cc: Al Viro Cc: Julia Lawall Signed-off-by: Andrew Morton mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.5.c | 19 +++++++++++++++++++ include/linux/compat-3.5.h | 13 +++++++++++++ scripts/gen-compat-config.sh | 2 +- 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 compat/compat-3.5.c create mode 100644 include/linux/compat-3.5.h diff --git a/compat/Makefile b/compat/Makefile index b49e8c0a..f2beca89 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -36,6 +36,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += compat-3.3.o +compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c new file mode 100644 index 00000000..d29c5f99 --- /dev/null +++ b/compat/compat-3.5.c @@ -0,0 +1,19 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.5. + */ + +#include + +int simple_open(struct inode *inode, struct file *file) +{ + if (inode->i_private) + file->private_data = inode->i_private; + return 0; +} +EXPORT_SYMBOL_GPL(simple_open); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h new file mode 100644 index 00000000..9c10a428 --- /dev/null +++ b/include/linux/compat-3.5.h @@ -0,0 +1,13 @@ +#ifndef LINUX_3_5_COMPAT_H +#define LINUX_3_5_COMPAT_H + +#include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) + +extern int simple_open(struct inode *inode, struct file *file); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ + +#endif /* LINUX_3_5_COMPAT_H */ diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 6cdac120..f56cbfc8 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -17,7 +17,7 @@ fi KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') # 3.0 kernel stuff -COMPAT_LATEST_VERSION="3" +COMPAT_LATEST_VERSION="5" KERNEL_SUBLEVEL="-1" # Note that this script will export all variables explicitly, -- cgit v1.2.3 From 3c8d9d948438b72f779cc58f48bef907ac2c36fd Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 15:44:13 -0700 Subject: compat: include compat-3.5 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 5715ce56..17905598 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -62,5 +62,6 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From a3e5dc84419f03b0dd8bcd461426badc86498d3f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 15:55:19 -0700 Subject: compat: backport truesize arg increase on skb_add_rx_frag() This backports 50269e19 by just calling the older kernel routine, and discarding the new argument. We treat kernels older than 2.6.28 a bit differently, given that those kernels lacked this routine completely. commit 50269e19ad990e79eeda101fc6df80cffd5d4831 Author: Eric Dumazet Date: Fri Mar 23 23:59:33 2012 +0000 net: add a truesize parameter to skb_add_rx_frag() skb_add_rx_frag() API is misleading. Network skbs built with this helper can use uncharged kernel memory and eventually stress/crash machine in OOM. Add a 'truesize' parameter and then fix drivers in followup patches. Signed-off-by: Eric Dumazet Cc: Wey-Yi Guy Signed-off-by: David S. Miller mcgrof@tux ~/linux-stable (git::master)$ git describe --contains 50269e19 v3.4-rc1~84^2~1 mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.28.c | 4 ++-- include/linux/compat-2.6.28.h | 2 +- include/linux/compat-3.4.h | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 235dbfa7..0ae8f465 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -303,7 +303,7 @@ unsigned long round_jiffies_up(unsigned long j) } EXPORT_SYMBOL_GPL(round_jiffies_up); -void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, +void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, int size) { skb_fill_page_desc(skb, i, page, off, size); @@ -311,7 +311,7 @@ void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, skb->data_len += size; skb->truesize += size; } -EXPORT_SYMBOL_GPL(skb_add_rx_frag); +EXPORT_SYMBOL_GPL(v2_6_28_skb_add_rx_frag); void tty_write_unlock(struct tty_struct *tty) { diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index e336f39e..3980989e 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -246,7 +246,7 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list, unsigned long round_jiffies_up(unsigned long j); -extern void skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, +extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, int size); #define wake_up_interruptible_poll(x, m) \ diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 0a6a8ead..e82e52fa 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -6,6 +6,15 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) #include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) +#define skb_add_rx_frag(skb, i, page, off, size, truesize) \ + v2_6_28_skb_add_rx_frag(skb, i, page, off, size) +#else +#define skb_add_rx_frag(skb, i, page, off, size, truesize) \ + skb_add_rx_frag(skb, i, page, off, size) +#endif #ifdef CONFIG_X86_X32_ABI #define COMPAT_USE_64BIT_TIME \ -- cgit v1.2.3 From c7b16bc37c61d55f4ae9a70a1520af5095c37461 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 17:05:38 -0700 Subject: compat: backport __netdev_alloc_skb_ip_align() mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.1.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 845499b6..1e8e05ed 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -6,6 +6,17 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) #include +#include + +static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, + unsigned int length, gfp_t gfp) +{ + struct sk_buff *skb = __netdev_alloc_skb(dev, length + NET_IP_ALIGN, gfp); + + if (NET_IP_ALIGN && skb) + skb_reserve(skb, NET_IP_ALIGN); + return skb; +} #define IS_ENABLED(option) defined(option) -- cgit v1.2.3 From c80c4efeded204ea3b5573b934bde68f617f00ab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 2 Apr 2012 20:15:36 -0700 Subject: compat: fix compilation warning on compat-3.5.c Needs to include module.h Signed-off-by: Luis R. Rodriguez --- compat/compat-3.5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c index d29c5f99..5d516f0e 100644 --- a/compat/compat-3.5.c +++ b/compat/compat-3.5.c @@ -9,6 +9,7 @@ */ #include +#include int simple_open(struct inode *inode, struct file *file) { -- cgit v1.2.3 From 89a4e35682bedcdad9582688cc78c7cd2716d7c4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 3 Apr 2012 01:16:02 -0700 Subject: compat: use make -s Avoid printing anything other than errors. This *should* speed up compiling a bit more although current tests show no improvements yet. The real benefit is a smaller and cleaner ckmake.log which will only have warnings and errors. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index 8238436f..56e1ec1a 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -71,7 +71,7 @@ for i in $KLIBS; do log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG log_try_kernel $KERNEL - ionice -c 3 nice -n 20 make KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG + ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG if [[ $? -eq 0 ]]; then echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split else -- cgit v1.2.3 From 8e67755a68394f4171e0d4fd0f6cc21fd743771a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 6 Apr 2012 12:41:07 +0200 Subject: compat: properly handle tracing We have to disable tracing on old kernels, but should disable it only on old kernels. Since 2.6.33 it pretty much hasn't changed at all, so we can keep it. Prior to 2.6.33, there are various different reasons for not supporting tracing, as noted in the tracepoint.h file. This fixes tracing as the previous attempts here at backporting it completely disabled it for all kernels, not just for those where it's not possible. Tested compilation of compat-wireless with tracing in mac80211 against 2.6.24 through 3.3, but some versions didn't compile due to unrelated issues. Cc: stable@orbit-lab.org Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/tracepoint.h | 188 +++++---------------------------------------- 1 file changed, 21 insertions(+), 167 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index 23eb7605..fc44692a 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -3,172 +3,22 @@ #include -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) - +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)) +/* + * Disable all tracing for older kernels + * < 2.6.27 had no tracing + * 2.6.27 had broken tracing + * 2.6.28-2.6.32 didn't have anything like DECLARE_EVENT_CLASS + * and faking it would be extremely difficult + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) +/* + * For 2.6.28+ include the original tracepoint.h but override + * the defines new code uses to disable tracing completely. + */ #include_next - -/* Backports f42c85e7 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) -#undef TP_STRUCT__entry -#define TP_STRUCT__entry(args...) args -#endif - -/* Backports 091ad365, a rename */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) -#define DECLARE_EVENT_CLASS TRACE_EVENT_TEMPLATE -#endif - -/* Backpports 2939b0469 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) -#define TP_PROTO TPPROTO -#define TP_ARGS TPARGS -#define TP_FMT TPFMT -#define TP_RAW_FMT TPRAWFMT #endif -/* Force disabling tracing */ - -#undef PARAMS -#define PARAMS(args...) args - -#undef TRACE_EVENT -#define TRACE_EVENT(name, proto, ...) \ -DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) - -#undef DECLARE_EVENT_CLASS -#define DECLARE_EVENT_CLASS(...) -#undef DEFINE_EVENT - -#define DEFINE_EVENT(template, name, proto, args) \ - DECLARE_TRACE(name, PARAMS(proto), PARAMS(args)) - -#undef DECLARE_TRACE_NOARGS -#define DECLARE_TRACE_NOARGS(name) \ - __DECLARE_TRACE(name, void, , 1, void *__data, __data) - - -/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) - -#undef DECLARE_TRACE -#define DECLARE_TRACE(name, proto, args) \ - __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) - -#undef DECLARE_TRACE_CONDITION -#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \ - __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) - -#else - -#undef DECLARE_TRACE -#define DECLARE_TRACE(name, proto, args) \ - __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), 1, \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) - -#undef DECLARE_TRACE_CONDITION -#define DECLARE_TRACE_CONDITION(name, proto, args, cond) \ - __DECLARE_TRACE(name, PARAMS(proto), PARAMS(args), PARAMS(cond), \ - PARAMS(void *__data, proto), \ - PARAMS(__data, args)) -#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ - -/* Backports 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) - -/* Backports c420970ef476d7d68df119711700666224001f43 */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) - -#undef __DECLARE_TRACE -#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ - static inline void trace_##name(proto) \ - { } \ - static inline void trace_##name##_rcuidle(proto) \ - { } \ - static inline int \ - register_trace_##name(void (*probe)(proto)) \ - { \ - return -ENOSYS; \ - } \ - static inline void \ - unregister_trace_##name(void (*probe)(proto)) \ - { \ - } \ - static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ - { \ - } -#else - -#undef __DECLARE_TRACE -#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ - static inline void trace_##name(proto) \ - { } \ - static inline void trace_##name##_rcuidle(proto) \ - { } \ - static inline int \ - register_trace_##name(void (*probe)(proto)) \ - { \ - return -ENOSYS; \ - } \ - static inline int \ - unregister_trace_##name(void (*probe)(proto)) \ - { \ - return -ENOSYS; \ - } \ - static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ - { \ - } -#endif /* backport c420970ef476d7d68df119711700666224001f43 */ - -#else - -#undef __DECLARE_TRACE -#define __DECLARE_TRACE(name, proto, args, cond, data_proto, data_args) \ - static inline void trace_##name(proto) \ - { } \ - static inline void trace_##name##_rcuidle(proto) \ - { } \ - static inline int \ - register_trace_##name(void (*probe)(data_proto), \ - void *data) \ - { \ - return -ENOSYS; \ - } \ - static inline int \ - unregister_trace_##name(void (*probe)(data_proto), \ - void *data) \ - { \ - return -ENOSYS; \ - } \ - static inline void check_trace_callback_type_##name(void (*cb)(data_proto)) \ - { \ - } - -#endif /* backport 38516ab59fbc5b3bb278cf5e1fe2867c70cff32e */ - -#undef DEFINE_TRACE_FN -#define DEFINE_TRACE_FN(name, reg, unreg) - -#undef DEFINE_TRACE -#define DEFINE_TRACE(name) - -#undef EXPORT_TRACEPOINT_SYMBOL_GPL -#define EXPORT_TRACEPOINT_SYMBOL_GPL(name) - -#undef EXPORT_TRACEPOINT_SYMBOL -#define EXPORT_TRACEPOINT_SYMBOL(name) - -#ifdef CONFIG_TRACEPOINTS -#else /* CONFIG_TRACEPOINTS */ -#endif /* CONFIG_TRACEPOINTS */ - -#else /* just disable tracing */ - -/* Disable all tracing */ #undef TRACE_EVENT #define TRACE_EVENT(name, proto, ...) \ static inline void trace_ ## name(proto) {} @@ -178,10 +28,14 @@ static inline void trace_ ## name(proto) {} #define DEFINE_EVENT(evt_class, name, proto, ...) \ static inline void trace_ ## name(proto) {} -#define TP_PROTO(args...) args -#define TP_ARGS(args...) args -#define TP_CONDITION(args...) args +#define TP_PROTO(args...) args +#define TP_ARGS(args...) args +#define TP_CONDITION(args...) args + +#else +/* since 2.6.33, tracing hasn't changed, so just include the kernel's file */ +#include_next -#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27)) */ +#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,32)) */ #endif /* _COMPAT_LINUX_TRACEPOINT_H */ -- cgit v1.2.3 From e343c87c59eff390abeec1048110dbd8029576da Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Apr 2012 12:00:14 -0700 Subject: compat: avoid duplicate __ref definition Cc: stable@orbit-lab.org Reported-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index d4fb4a06..d0cd50b5 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -29,7 +29,6 @@ */ #define __ref __init_refok #define __refdata __initdata_refok -#define __ref __exit_refok /* * backports 2658fa803111dae1353602e7f586de8e537803e2 -- cgit v1.2.3 From ebab6cd63a4026fdd83e47cce7c6b34e97ec1b2a Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Fri, 6 Apr 2012 23:00:34 +0200 Subject: compat: backport netif_wake_subqueue Kernels 2.6.23 - 2.6.27 had some multiqueue support, but called netif_wake_subqueue netif_start_subqueue. So to backport, just add a define. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.27.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 22fadcd2..1e2af806 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -256,6 +256,8 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) */ #define lower_32_bits(n) ((u32)(n)) +#define netif_wake_subqueue netif_start_subqueue + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 78b895ca501b9a70bccccc505b9b39e080de1503 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 10 Apr 2012 18:45:25 -0700 Subject: compat: add ndo_do_ioctl() This helps reduce the delta on backporting calls of the netdev's ioctl callback. Instead of ifdef'ing on where the ioctl callback lies in different kernels we take care of that for all kernels. This lets us for example change this backport: @@ -925,8 +954,13 @@ static int wireless_process_ioctl(struct return private(dev, iwr, cmd, info, handler); } /* Old driver API : call driver ioctl handler */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) if (dev->netdev_ops->ndo_do_ioctl) return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); +#else + if (dev->do_ioctl) + return dev->do_ioctl(dev, ifr, cmd); +#endif return -EOPNOTSUPP; } To this: --- a/net/wireless/wext-core.c +++ b/net/wireless/wext-core.c @@ -925,9 +925,7 @@ static int wireless_process_ioctl(struct return private(dev, iwr, cmd, info, handler); } /* Old driver API : call driver ioctl handler */ - if (dev->netdev_ops->ndo_do_ioctl) - return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); - return -EOPNOTSUPP; + return ndo_do_ioctl(dev, ifr, cmd); } /* If command is `set a parameter', or `get the encoding parameters', This shows more deletions than additions. This is what we want. If we add ndo_do_ioctl() upstream then this would require 0 delta! Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 0892e7de..48b62e8a 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -226,6 +226,16 @@ struct net_device_ops { #endif }; +static inline int ndo_do_ioctl(struct net_device *dev, + struct ifreq *ifr, + int cmd) +{ + if (dev->do_ioctl) + return dev->do_ioctl(dev, ifr, cmd); + return -EOPNOTSUPP; +} + + void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops); @@ -340,14 +350,27 @@ extern int init_dummy_netdev(struct net_device *dev); return fn(&pdev->dev); \ } -#else +#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ +/* Kernels >= 2.6.29 follows */ + +/* XXX: this can probably just go upstream ! */ static inline void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops) { dev->netdev_ops = ops; } +/* XXX: this can probably just go upstream! */ +static inline int ndo_do_ioctl(struct net_device *dev, + struct ifreq *ifr, + int cmd) +{ + if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl) + return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); + return -EOPNOTSUPP; +} + #define compat_pci_suspend(fn) #define compat_pci_resume(fn) -- cgit v1.2.3 From 51b3bbc1b2faec8e4192ad3d6ecfa98bdeaee7b9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 Apr 2012 23:59:24 +0200 Subject: compat: add module_pci_driver module_pci_driver is needed to register the pci driver to the pci sub system. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index e82e52fa..1b723742 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -62,6 +62,19 @@ static inline void eth_hw_addr_random(struct net_device *dev) #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) */ +/* source include/linux/pci.h */ +/** + * module_pci_driver() - Helper macro for registering a PCI driver + * @__pci_driver: pci_driver struct + * + * Helper macro for PCI drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_pci_driver(__pci_driver) \ + module_driver(__pci_driver, pci_register_driver, \ + pci_unregister_driver) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ #endif /* LINUX_5_4_COMPAT_H */ -- cgit v1.2.3 From a4ec7bfb3b390ec3ee45cc6bad75d831a31c1ba9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 Apr 2012 23:59:25 +0200 Subject: compat: add dummy file kmemleak.h Some drivers are including kmemleak.h directly and this causes a build problem on old kernel versions as it is not available on all. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/kmemleak.h | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 include/linux/kmemleak.h diff --git a/include/linux/kmemleak.h b/include/linux/kmemleak.h new file mode 100644 index 00000000..83bd199c --- /dev/null +++ b/include/linux/kmemleak.h @@ -0,0 +1,5 @@ +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */ -- cgit v1.2.3 From c1e6e1be68c1be333a98f15b632918e42057b86c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 23 Apr 2012 21:33:30 -0700 Subject: compat: backport pci_enable_device_mem() To backport b718989d correctly which added pci_enable_device_mem() the routine pcibios_enable_device() is required but we don't have access to it on modules as its an architecture specific routine that is not exported and as such only core kernel code has access to it. We implement a sloppy work around for backporting this. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 19 ++++++++++++++++++- include/linux/compat-2.6.25.h | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 2e9c3a88..15500249 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -1,5 +1,5 @@ /* - * Copyright 2007-2010 Luis R. Rodriguez + * Copyright 2007-2012 Luis R. Rodriguez * * 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 @@ -9,6 +9,23 @@ */ #include +#include + +/* + * To backport b718989d correctly pcibios_enable_device() + * is required but we don't have access to it on modules + * as its an architecture specific routine that is not + * exported and as such only core kernel code has access + * to it. We implement a sloppy work around for backporting + * this. + */ +int pci_enable_device_mem(struct pci_dev *dev) +{ + int bars = pci_select_bars(dev, IORESOURCE_MEM); + + return pci_enable_device_bars(dev, bars); +} +EXPORT_SYMBOL_GPL(pci_enable_device_mem); /** * The following things are out of ./lib/vsprintf.c diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index d0cd50b5..356186d1 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -19,6 +19,10 @@ #include #include #include +#include + +/* Backports b718989da7 */ +int __must_check pci_enable_device_mem(struct pci_dev *dev); /* * Backports 312b1485fb509c9bc32eda28ad29537896658cb8 -- cgit v1.2.3 From 10440bf0b5247e17cfcf862a9b2d8bc5dd1dd46e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 30 Apr 2012 13:38:34 -0700 Subject: compat-wireless: add -t argument for time statistics Using -t is the equilavent of doing: time ckmake; time ckmake | egrep "real|user|sys" This is useful to test compiling accross kernel twice, once under the assumption that ccache may likely be cleared, the other with ccache fresh. This will yield this output: mcgrof@tux ~/compat (git::master)$ ckmake -t Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m19.326s user 1m18.740s sys 0m22.360s real 1m18.411s user 1m15.330s sys 0m21.960s Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 77 ++++++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 22 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 56e1ec1a..d89d0677 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -25,6 +25,7 @@ UNDERLINE="\033[02m" KERNEL_DIR="/lib/modules" KLIBS="" LOG="ckmake.log" +TIME="0" LSB_RED_ID=$(/usr/bin/lsb_release -i -s) case $LSB_RED_ID in @@ -39,8 +40,6 @@ case $LSB_RED_ID in ;; esac -nice make clean 2>&1 > $LOG - function tee_color_split() { while read; do @@ -56,27 +55,61 @@ function log_try_kernel() echo -en "${NORMAL}" } -for i in $KLIBS; do - KERNEL=$(basename $i) - DIR=${i}/build/ - echo -e "--------------------------------------------" >> $LOG +function usage() +{ + echo -e "Usage: $0 [-t]" + echo -e "-t will run: 'time ckmake; time ckmake' account for" + echo -e " benchmark how long it takes to compile without ccache" + echo -e " and a run after cache kicks in" +} + +if [[ $# -gt 1 ]]; then + usage + exit 1 +fi - if [[ ! -d $DIR ]]; then - continue +if [[ $# -eq 1 ]]; then + if [[ $1 != "-t" ]]; then + usage + exit 1 fi + TIME="1" +fi - # We cannot use tee_color_split() as bash read only spits - # out output when a newline comes in. We can modif IFS but - # I am still not sure how to do this properly. - log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG - log_try_kernel $KERNEL - - ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG - if [[ $? -eq 0 ]]; then - echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split - else - echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split - fi +function run_ckmake() +{ + for i in $KLIBS; do + KERNEL=$(basename $i) + DIR=${i}/build/ + echo -e "--------------------------------------------" >> $LOG + + if [[ ! -d $DIR ]]; then + continue + fi + + # We cannot use tee_color_split() as bash read only spits + # out output when a newline comes in. We can modif IFS but + # I am still not sure how to do this properly. + log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG + log_try_kernel $KERNEL + + ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG + if [[ $? -eq 0 ]]; then + echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split + else + echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split + fi + + nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG + done +} + +nice make clean 2>&1 > $LOG + +if [[ $TIME != "1" ]]; then + run_ckmake + exit 0 +fi - nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG -done +time $0 +time $0 | egrep "real|user|sys" -- cgit v1.2.3 From bfddeba400a92c7e7b9918a41333f299b3068aed Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 30 Apr 2012 13:45:27 -0700 Subject: compat-wireless: propagate errors with ckmake If compilation failed with any kernel then propagate that error. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index d89d0677..71142c93 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -26,6 +26,7 @@ KERNEL_DIR="/lib/modules" KLIBS="" LOG="ckmake.log" TIME="0" +RET="" LSB_RED_ID=$(/usr/bin/lsb_release -i -s) case $LSB_RED_ID in @@ -94,10 +95,17 @@ function run_ckmake() log_try_kernel $KERNEL ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG - if [[ $? -eq 0 ]]; then + CUR_RET=$? + + if [[ $RET = "" ]]; then + RET=$CUR_RET + fi + + if [[ $CUR_RET -eq 0 ]]; then echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split else echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split + RET=$CUR_RET fi nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG @@ -108,8 +116,10 @@ nice make clean 2>&1 > $LOG if [[ $TIME != "1" ]]; then run_ckmake - exit 0 + exit $RET fi time $0 time $0 | egrep "real|user|sys" + +exit $RET -- cgit v1.2.3 From 68c694025c24de105abf7f30dea6207e0769cddb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 4 May 2012 17:42:57 -0700 Subject: compat: add optional target options for ckmake This also adds -q option to suppress build messages that succeed, this helps reduce the size of ckmake.log if you care only about errors or warnings. In theory this should help build time but I haven't seen this help yet Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 71142c93..1e980974 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -58,24 +58,43 @@ function log_try_kernel() function usage() { - echo -e "Usage: $0 [-t]" + echo -e "Usage: $0 [-t] " echo -e "-t will run: 'time ckmake; time ckmake' account for" echo -e " benchmark how long it takes to compile without ccache" echo -e " and a run after cache kicks in" + echo -e "-q will ask ckmake to run make with -s to only output errors" + echo + echo -e " is the arguments you want to pass to the" + echo -e "child make call that ckmake will use. For example if you have" + echo -e "a target 'linux' on your Makefile you can run 'cmake linux'" } -if [[ $# -gt 1 ]]; then - usage - exit 1 -fi - -if [[ $# -eq 1 ]]; then - if [[ $1 != "-t" ]]; then - usage - exit 1 - fi - TIME="1" -fi +ARGS="" +QUIET="" + +for i in $@ ; do + case $1 in + "-h") + usage + exit 1 + ;; + "--help") + usage + exit 1 + ;; + "-t") + TIME="1" + shift + ;; + "-q") + QUIET="-s" + shift + ;; + *) + ARGS="${ARGS} $1" + shift + esac +done function run_ckmake() { @@ -94,7 +113,7 @@ function run_ckmake() log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG log_try_kernel $KERNEL - ionice -c 3 nice -n 20 make -s KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable &>> $LOG + ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG CUR_RET=$? if [[ $RET = "" ]]; then -- cgit v1.2.3 From 0ab94cd7b71098c5280de878753f26aaffa01f68 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 4 May 2012 18:00:33 -0700 Subject: compat: use -s instead of -q And also fix variable propagation when ckmake -t is used. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 1e980974..2d422af9 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -26,6 +26,9 @@ KERNEL_DIR="/lib/modules" KLIBS="" LOG="ckmake.log" TIME="0" +QUIET="" +ARGS="" + RET="" LSB_RED_ID=$(/usr/bin/lsb_release -i -s) @@ -69,9 +72,6 @@ function usage() echo -e "a target 'linux' on your Makefile you can run 'cmake linux'" } -ARGS="" -QUIET="" - for i in $@ ; do case $1 in "-h") @@ -86,7 +86,7 @@ for i in $@ ; do TIME="1" shift ;; - "-q") + "-s") QUIET="-s" shift ;; @@ -138,7 +138,7 @@ if [[ $TIME != "1" ]]; then exit $RET fi -time $0 -time $0 | egrep "real|user|sys" +time $0 $QUIET $ARGS +time $0 $QUIET $ARGS | egrep "real|user|sys" exit $RET -- cgit v1.2.3 From 0c87b947d0a5cf64c026ce035b49c46ac11f4607 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 7 May 2012 12:54:04 -0700 Subject: compat: backport sdio power management API This backports the patch below by simply ignoring support for it for older kernels. commit da68c4eb258cd9f3f0b8aeb7e46b8118bb6358b6 Author: Nicolas Pitre Date: Fri Mar 5 13:43:31 2010 -0800 sdio: introduce API for special power management features This patch series provides the core changes needed to allow SDIO cards to remain powered and active while the host system is suspended, and let them wake up the host system when needed. This is used to implement wake-on-lan with SDIO wireless cards at the moment. Patches to add that support to the libertas driver will be posted separately. This patch: Some SDIO cards have the ability to keep on running autonomously when the host system is suspended, and wake it up when needed. This however requires that the host controller preserve power to the card, and configure itself appropriately for wake-up. There is however 4 layers of abstractions involved: the host controller driver, the MMC core code, the SDIO card management code, and the actual SDIO function driver. To make things simple and manageable, host drivers must advertise their PM capabilities with a feature bitmask, then function drivers can query and set those features from their suspend method. Then each layer in the suspend call chain is expected to act upon those bits accordingly. [akpm@linux-foundation.org: fix typo in comment] Signed-off-by: Nicolas Pitre Cc: Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-2.6.34.h | 20 ++++++++++++++++++++ compat/main.c | 2 ++ include/linux/compat-2.6.34.h | 28 +++++++++++++++++++++++++--- 4 files changed, 48 insertions(+), 3 deletions(-) create mode 100644 compat/compat-2.6.34.h diff --git a/compat/Makefile b/compat/Makefile index f2beca89..bda677b6 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -23,6 +23,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_28) += compat-2.6.28.o compat-$(CONFIG_COMPAT_KERNEL_2_6_29) += compat-2.6.29.o compat-$(CONFIG_COMPAT_KERNEL_2_6_32) += compat-2.6.32.o compat-$(CONFIG_COMPAT_KERNEL_2_6_33) += compat-2.6.33.o +compat-$(CONFIG_COMPAT_KERNEL_2_6_34) += compat-2.6.34.o compat-$(CONFIG_COMPAT_KERNEL_2_6_35) += compat-2.6.35.o compat-$(CONFIG_COMPAT_KERNEL_2_6_36) += compat-2.6.36.o diff --git a/compat/compat-2.6.34.h b/compat/compat-2.6.34.h new file mode 100644 index 00000000..173fe522 --- /dev/null +++ b/compat/compat-2.6.34.h @@ -0,0 +1,20 @@ +#ifndef LINUX_26_34_COMPAT_PRIVATE_H +#define LINUX_26_34_COMPAT_PRIVATE_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) + +#include + +void init_compat_mmc_pm_flags(void); + +#else /* Kernels >= 2.6.34 */ + +static inline void init_compat_mmc_pm_flags(void) +{ +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ + +#endif /* LINUX_26_34_COMPAT_PRIVATE_H */ diff --git a/compat/main.c b/compat/main.c index 30a4a1ee..e04cc88a 100644 --- a/compat/main.c +++ b/compat/main.c @@ -37,11 +37,13 @@ void compat_dependency_symbol(void) } EXPORT_SYMBOL_GPL(compat_dependency_symbol); + static int __init compat_init(void) { /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); compat_system_workqueue_create(); + init_compat_mmc_pm_flags(); printk(KERN_INFO COMPAT_PROJECT " backport release: " diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index da242ce0..b5a40e2a 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -7,6 +7,24 @@ #include #include +#include + +/* + * Backports da68c4eb25 + * sdio: introduce API for special power management features + * + * We wimply carry around the data structures and flags, and + * make the host return no flags set by the driver. + */ +typedef unsigned int mmc_pm_flag_t; + +#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ +#define MMC_PM_WAKE_SDIO_IRQ (1 << 1) /* wake up host system on SDIO IRQ assertion */ + +extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func); +extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); + +void init_compat_mmc_pm_flags(void); #define netdev_mc_count(dev) ((dev)->mc_count) #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) @@ -267,9 +285,6 @@ static inline int usb_enable_autosuspend(struct usb_device *udev) static inline int usb_disable_autosuspend(struct usb_device *udev) { return 0; } -#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */ -#define sdio_set_host_pm_flags(a, b) 0 - #define rcu_dereference_protected(p, c) (p) #define rcu_access_pointer(p) ACCESS_ONCE(p) @@ -304,6 +319,13 @@ static inline int lockdep_rtnl_is_held(void) } #endif /* #ifdef CONFIG_PROVE_LOCKING */ +#else /* Kernels >= 2.6.34 */ + +static inline void init_compat_mmc_pm_flags(void) +{ +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ + #endif /* LINUX_26_34_COMPAT_H */ -- cgit v1.2.3 From 769a891787949f4113a489521dfb393bbc1d0207 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 7 May 2012 18:47:37 -0700 Subject: compat: add compat/compat-2.6.34.c Forgot to add this file from my previous commit. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.34.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 compat/compat-2.6.34.c diff --git a/compat/compat-2.6.34.c b/compat/compat-2.6.34.c new file mode 100644 index 00000000..b905a26c --- /dev/null +++ b/compat/compat-2.6.34.c @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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.34. + */ + +#include + +#include "compat-2.6.34.h" + +static mmc_pm_flag_t compat_mmc_pm_flags; + +void init_compat_mmc_pm_flags(void) +{ + compat_mmc_pm_flags = 0; +} + +mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func) +{ + return compat_mmc_pm_flags; +} + +int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) +{ + return -EINVAL; +} -- cgit v1.2.3 From 74a8f3174b1e02bcf43a65edd6ede2b7d2997dc2 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 8 May 2012 00:12:55 -0700 Subject: compat: backport localizing the tty lock Just undo make the lock generic for older kernels. This backports: commit d29f3ef39be4eec0362b985305fc526d9be318cf Author: Alan Cox Date: Thu May 3 22:24:08 2012 +0100 tty_lock: Localise the lock In each remaining case the tty_lock is associated with a specific tty. This means we can now lock on a per tty basis. We do need tty_lock_pair() for the pty case. Uglier but still a step in the right direction. [fixed up calls in 3 missing drivers - gregkh] Signed-off-by: Alan Cox Acked-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 9c10a428..4cd0a0d3 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,9 @@ extern int simple_open(struct inode *inode, struct file *file); +/* Backports tty_lock: Localise the lock */ +#define tty_unlock(__tty) tty_unlock() + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ #endif /* LINUX_3_5_COMPAT_H */ -- cgit v1.2.3 From cf49cd34b9740ecfac145103a0e474e8197ac0c4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 8 May 2012 00:26:43 -0700 Subject: compat: add tty_lock() For the lock, I had only backported the tty_unlock.. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 4cd0a0d3..554d347a 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -9,6 +9,7 @@ extern int simple_open(struct inode *inode, struct file *file); /* Backports tty_lock: Localise the lock */ +#define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ -- cgit v1.2.3 From 15e897766369c32f4787d1e21be0dd682b614f46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Wed, 16 May 2012 12:55:48 +0300 Subject: compat: backport ether_addr_equal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit a599b0f54d233d0f63d6be9a2ff0049d24751669 Author: Joe Perches Date: Tue May 8 18:56:45 2012 +0000 etherdevice.h: Add ether_addr_equal Add a boolean function to check if 2 ethernet addresses are the same. This is to avoid any confusion about compare_ether_addr returning an unsigned, and not being able to use the compare_ether_addr function for sorting ala memcmp. Signed-off-by: Joe Perches Signed-off-by: David S. Miller [root@ozzyfedora compat]# bin/ckmake Trying kernel 3.3.4-5.fc17.x86_64 [OK] mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Tested-by: Luis R. Rodriguez Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 554d347a..a83266be 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -3,6 +3,7 @@ #include #include +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) @@ -12,6 +13,12 @@ extern int simple_open(struct inode *inode, struct file *file); #define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() +/* Backport ether_addr_equal */ +static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) +{ + return !compare_ether_addr(addr1, addr2); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ #endif /* LINUX_3_5_COMPAT_H */ -- cgit v1.2.3 From 0b4430182b0d27ab8fec2d95c35e5315c3056fdd Mon Sep 17 00:00:00 2001 From: Eliad Peller Date: Wed, 16 May 2012 18:28:00 +0300 Subject: compat: backport IS_ENABLED macro IS_ENABLED(option) was backported as defined(option), but because of the indirection, option was evaluated too early, resulting in #if defined(1) for defined options, which failed the compilation with the following error: error: operator "defined" requires an identifier Backport IS_ENABLED from the current kernel instead. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Tested-by: Luis R. Rodriguez Signed-off-by: Eliad Peller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.1.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 1e8e05ed..3fdcbf88 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -18,10 +18,29 @@ static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev return skb; } -#define IS_ENABLED(option) defined(option) - +/* + * Getting something that works in C and CPP for an arg that may or may + * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1" + * we match on the placeholder define, insert the "0," for arg1 and generate + * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one). + * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when + * the last step cherry picks the 2nd arg, we get a zero. + */ +#define __ARG_PLACEHOLDER_1 0, +#define config_enabled(cfg) _config_enabled(cfg) +#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) +#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) +#define ___config_enabled(__ignored, val, ...) val #define genl_dump_check_consistent(cb, user_hdr, family) +/* + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm', + * 0 otherwise. + * + */ +#define IS_ENABLED(option) \ + (config_enabled(option) || config_enabled(option##_MODULE)) + #define IFF_TX_SKB_SHARING 0x10000 /* The interface supports sharing * skbs on transmit */ -- cgit v1.2.3 From cbc64a7f0986aadf310ffd153e002c6e6dc46e7f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 16 May 2012 19:29:24 -0700 Subject: compat: add COMPAT_BASE tag I'm going to start adding tags to compat.git. This tag will also be printed upon loading of the compat module. This is useful to annotating what release of compat.git was used exactly. Moving forward the goal will be to try to add a tag only once a full version of linux-next.git with a respective date tag from that release has been addressed for backporting. Right now the only consumer of compat.git that I am aware of is compat-wireless (soon to be renamed to compat-drivers) so what this means in practice is I will only add a tag to compat.git once ckmake is used to verify compilation against all supported kernels. This means there are two tasks when backporting: * compat.git work * compat-wireless.git work The compat.git work will likely be finished first than the compat-wireless.git work. Older compat.git versions should work with newer versions of tags from compat-wireless.git, however, I may still add tags to compat.git to annotate that that release (even if no changes were made) has also been used and tested. Every single release of compat.git and compat-wireless.git that has a tag means that that tag has been tested with ckmake to cross compile against all supported kernels. Signed-off-by: Luis R. Rodriguez --- Makefile | 5 +++++ compat/main.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/Makefile b/Makefile index 8775294c..05a7d725 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ export COMPAT_BASE_TREE := "linux-next.git" export COMPAT_BASE_TREE_VERSION := "next-20100517" export COMPAT_VERSION := $(shell git describe) +# This is used to annotate what version of +# compat.git was used. +export COMPAT_BASE := $(shell git describe) + # to check config and compat autoconf export COMPAT_CONFIG=$(PWD)/.config export COMPAT_AUTOCONF=$(PWD)/include/linux/compat_autoconf.h @@ -33,6 +37,7 @@ else NOSTDINC_FLAGS := -I$(M)/include/ \ -include $(M)/include/linux/compat-2.6.h \ $(CFLAGS) \ + -DCOMPAT_BASE="\"$(COMPAT_BASE)\"" \ -DCOMPAT_BASE_TREE="\"$(COMPAT_BASE_TREE)\"" \ -DCOMPAT_BASE_TREE_VERSION="\"$(COMPAT_BASE_TREE_VERSION)\"" \ -DCOMPAT_PROJECT="\"Generic kernel\"" \ diff --git a/compat/main.c b/compat/main.c index e04cc88a..9141858a 100644 --- a/compat/main.c +++ b/compat/main.c @@ -4,6 +4,10 @@ MODULE_AUTHOR("Luis R. Rodriguez"); MODULE_DESCRIPTION("Kernel compatibility module"); MODULE_LICENSE("GPL"); +#ifndef COMPAT_BASE +#error "You need a COMPAT_BASE" +#endif + #ifndef COMPAT_BASE_TREE #error "You need a COMPAT_BASE_TREE" #endif @@ -16,10 +20,15 @@ MODULE_LICENSE("GPL"); #error "You need a COMPAT_VERSION" #endif +static char *compat_base = COMPAT_BASE; static char *compat_base_tree = COMPAT_BASE_TREE; static char *compat_base_tree_version = COMPAT_BASE_TREE_VERSION; static char *compat_version = COMPAT_VERSION; +module_param(compat_base, charp, 0400); +MODULE_PARM_DESC(compat_base_tree, + "The upstream verion of compat.git used"); + module_param(compat_base_tree, charp, 0400); MODULE_PARM_DESC(compat_base_tree, "The upstream tree used as base for this backport"); @@ -52,6 +61,8 @@ static int __init compat_init(void) printk(KERN_INFO "Backport based on " COMPAT_BASE_TREE " " COMPAT_BASE_TREE_VERSION "\n"); + printk(KERN_INFO "compat.git: " + COMPAT_BASE_TREE "\n"); return 0; } -- cgit v1.2.3 From 5aea6c47b59aec7b60b1c57391b981524f2a7207 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 16 May 2012 19:34:58 -0700 Subject: compat: remove obvious comment upon loading compat The comment was there to make it clear that upon init a few routines would be no-ops. This should be obvious by now. Signed-off-by: Luis R. Rodriguez --- compat/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compat/main.c b/compat/main.c index 9141858a..972c142d 100644 --- a/compat/main.c +++ b/compat/main.c @@ -49,7 +49,6 @@ EXPORT_SYMBOL_GPL(compat_dependency_symbol); static int __init compat_init(void) { - /* pm-qos for kernels <= 2.6.24, this is a no-op on newer kernels */ compat_pm_qos_power_init(); compat_system_workqueue_create(); init_compat_mmc_pm_flags(); -- cgit v1.2.3 From 621195cb683a97c5233fb036adb9e6c3af416e54 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 16 May 2012 21:03:59 -0700 Subject: compat: backport net_ratelimited_function() This backports this patch: From 3a3bfb61e64476ff1e4ac3122cb6dec9c79b795c Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Sun, 13 May 2012 21:56:25 +0000 Subject: [PATCH] net: Add net_ratelimited_function and net__ratelimited macros __ratelimit() can be considered an inverted bool test because it returns true when not ratelimited. Several tests in the kernel tree use this __ratelimit() function incorrectly. No net_ratelimit uses are incorrect currently though. Most uses of net_ratelimit are to log something via printk or pr_. In order to minimize the uses of net_ratelimit, and to start standardizing the code style used for __ratelimit() and net_ratelimit(), add a net_ratelimited_function() macro and net__ratelimited() logging macros similar to pr__ratelimited that use the global net_ratelimit instead of a static per call site "struct ratelimit_state". Signed-off-by: Joe Perches Signed-off-by: David S. Miller mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.0-030300rc2-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index a83266be..c837deb3 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -4,6 +4,7 @@ #include #include #include +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) @@ -19,6 +20,29 @@ static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) return !compare_ether_addr(addr1, addr2); } +#define net_ratelimited_function(function, ...) \ +do { \ + if (net_ratelimit()) \ + function(__VA_ARGS__); \ +} while (0) + +#define net_emerg_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__) +#define net_alert_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__) +#define net_crit_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__) +#define net_err_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__) +#define net_notice_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__) +#define net_warn_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__) +#define net_info_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__) +#define net_dbg_ratelimited(fmt, ...) \ + net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ #endif /* LINUX_3_5_COMPAT_H */ -- cgit v1.2.3 From 3f130994178234860910abc43cac9bc809dddfe5 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 24 May 2012 15:29:28 +0200 Subject: compat: rename compat-3.5.c to compat-3.4.c It only contains simple_open, which is already available on Linux 3.4. Fixes duplicate symbol issues on 3.4 mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Felix Fietkau Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 2 +- compat/compat-3.4.c | 20 ++++++++++++++++++++ compat/compat-3.5.c | 20 -------------------- include/linux/compat-3.4.h | 2 ++ include/linux/compat-3.5.h | 2 -- 5 files changed, 23 insertions(+), 23 deletions(-) create mode 100644 compat/compat-3.4.c delete mode 100644 compat/compat-3.5.c diff --git a/compat/Makefile b/compat/Makefile index bda677b6..667e7276 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -37,7 +37,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += compat-3.3.o -compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o +compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.4.c b/compat/compat-3.4.c new file mode 100644 index 00000000..5d516f0e --- /dev/null +++ b/compat/compat-3.4.c @@ -0,0 +1,20 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.5. + */ + +#include +#include + +int simple_open(struct inode *inode, struct file *file) +{ + if (inode->i_private) + file->private_data = inode->i_private; + return 0; +} +EXPORT_SYMBOL_GPL(simple_open); diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c deleted file mode 100644 index 5d516f0e..00000000 --- a/compat/compat-3.5.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2012 Luis R. Rodriguez - * - * 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 3.5. - */ - -#include -#include - -int simple_open(struct inode *inode, struct file *file) -{ - if (inode->i_private) - file->private_data = inode->i_private; - return 0; -} -EXPORT_SYMBOL_GPL(simple_open); diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 1b723742..f3437959 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -8,6 +8,8 @@ #include #include +extern int simple_open(struct inode *inode, struct file *file); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) #define skb_add_rx_frag(skb, i, page, off, size, truesize) \ v2_6_28_skb_add_rx_frag(skb, i, page, off, size) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index c837deb3..0bb35bb5 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,8 +8,6 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) -extern int simple_open(struct inode *inode, struct file *file); - /* Backports tty_lock: Localise the lock */ #define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() -- cgit v1.2.3 From edfd7a1bc68be4cf67a1c19fc95a2e7e322eff88 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 24 May 2012 17:31:17 -0700 Subject: compat: add CoDel upstream code This just drags in the code and dumps it in place, without adding it to the build system. We'll add backport support next to make the changes required more easily visible to reviewers. Just to be sure, here's the ckmake log result: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/sch_codel.c | 276 ++++++++++++++++++++++++++++++++++++++++++ include/net/codel.h | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 618 insertions(+) create mode 100644 compat/sch_codel.c create mode 100644 include/net/codel.h diff --git a/compat/sch_codel.c b/compat/sch_codel.c new file mode 100644 index 00000000..2f9ab17d --- /dev/null +++ b/compat/sch_codel.c @@ -0,0 +1,276 @@ +/* + * Codel - The Controlled-Delay Active Queue Management algorithm + * + * Copyright (C) 2011-2012 Kathleen Nichols + * Copyright (C) 2011-2012 Van Jacobson + * + * Implemented on linux by : + * Copyright (C) 2012 Michael D. Taht + * Copyright (C) 2012 Eric Dumazet + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The names of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, provided that this notice is retained in full, this + * software may be distributed under the terms of the GNU General + * Public License ("GPL") version 2, in which case the provisions of the + * GPL apply INSTEAD OF those given above. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +#define DEFAULT_CODEL_LIMIT 1000 + +struct codel_sched_data { + struct codel_params params; + struct codel_vars vars; + struct codel_stats stats; + u32 drop_overlimit; +}; + +/* This is the specific function called from codel_dequeue() + * to dequeue a packet from queue. Note: backlog is handled in + * codel, we dont need to reduce it here. + */ +static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) +{ + struct sk_buff *skb = __skb_dequeue(&sch->q); + + prefetch(&skb->end); /* we'll need skb_shinfo() */ + return skb; +} + +static struct sk_buff *codel_qdisc_dequeue(struct Qdisc *sch) +{ + struct codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + + skb = codel_dequeue(sch, &q->params, &q->vars, &q->stats, dequeue); + + /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, + * or HTB crashes. Defer it for next round. + */ + if (q->stats.drop_count && sch->q.qlen) { + qdisc_tree_decrease_qlen(sch, q->stats.drop_count); + q->stats.drop_count = 0; + } + if (skb) + qdisc_bstats_update(sch, skb); + return skb; +} + +static int codel_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct codel_sched_data *q; + + if (likely(qdisc_qlen(sch) < sch->limit)) { + codel_set_enqueue_time(skb); + return qdisc_enqueue_tail(skb, sch); + } + q = qdisc_priv(sch); + q->drop_overlimit++; + return qdisc_drop(skb, sch); +} + +static const struct nla_policy codel_policy[TCA_CODEL_MAX + 1] = { + [TCA_CODEL_TARGET] = { .type = NLA_U32 }, + [TCA_CODEL_LIMIT] = { .type = NLA_U32 }, + [TCA_CODEL_INTERVAL] = { .type = NLA_U32 }, + [TCA_CODEL_ECN] = { .type = NLA_U32 }, +}; + +static int codel_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct codel_sched_data *q = qdisc_priv(sch); + struct nlattr *tb[TCA_CODEL_MAX + 1]; + unsigned int qlen; + int err; + + if (!opt) + return -EINVAL; + + err = nla_parse_nested(tb, TCA_CODEL_MAX, opt, codel_policy); + if (err < 0) + return err; + + sch_tree_lock(sch); + + if (tb[TCA_CODEL_TARGET]) { + u32 target = nla_get_u32(tb[TCA_CODEL_TARGET]); + + q->params.target = ((u64)target * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_CODEL_INTERVAL]) { + u32 interval = nla_get_u32(tb[TCA_CODEL_INTERVAL]); + + q->params.interval = ((u64)interval * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_CODEL_LIMIT]) + sch->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]); + + if (tb[TCA_CODEL_ECN]) + q->params.ecn = !!nla_get_u32(tb[TCA_CODEL_ECN]); + + qlen = sch->q.qlen; + while (sch->q.qlen > sch->limit) { + struct sk_buff *skb = __skb_dequeue(&sch->q); + + sch->qstats.backlog -= qdisc_pkt_len(skb); + qdisc_drop(skb, sch); + } + qdisc_tree_decrease_qlen(sch, qlen - sch->q.qlen); + + sch_tree_unlock(sch); + return 0; +} + +static int codel_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct codel_sched_data *q = qdisc_priv(sch); + + sch->limit = DEFAULT_CODEL_LIMIT; + + codel_params_init(&q->params); + codel_vars_init(&q->vars); + codel_stats_init(&q->stats); + + if (opt) { + int err = codel_change(sch, opt); + + if (err) + return err; + } + + if (sch->limit >= 1) + sch->flags |= TCQ_F_CAN_BYPASS; + else + sch->flags &= ~TCQ_F_CAN_BYPASS; + + return 0; +} + +static int codel_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct codel_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_CODEL_TARGET, + codel_time_to_us(q->params.target)) || + nla_put_u32(skb, TCA_CODEL_LIMIT, + sch->limit) || + nla_put_u32(skb, TCA_CODEL_INTERVAL, + codel_time_to_us(q->params.interval)) || + nla_put_u32(skb, TCA_CODEL_ECN, + q->params.ecn)) + goto nla_put_failure; + + return nla_nest_end(skb, opts); + +nla_put_failure: + nla_nest_cancel(skb, opts); + return -1; +} + +static int codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + const struct codel_sched_data *q = qdisc_priv(sch); + struct tc_codel_xstats st = { + .maxpacket = q->stats.maxpacket, + .count = q->vars.count, + .lastcount = q->vars.lastcount, + .drop_overlimit = q->drop_overlimit, + .ldelay = codel_time_to_us(q->vars.ldelay), + .dropping = q->vars.dropping, + .ecn_mark = q->stats.ecn_mark, + }; + + if (q->vars.dropping) { + codel_tdiff_t delta = q->vars.drop_next - codel_get_time(); + + if (delta >= 0) + st.drop_next = codel_time_to_us(delta); + else + st.drop_next = -codel_time_to_us(-delta); + } + + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static void codel_reset(struct Qdisc *sch) +{ + struct codel_sched_data *q = qdisc_priv(sch); + + qdisc_reset_queue(sch); + codel_vars_init(&q->vars); +} + +static struct Qdisc_ops codel_qdisc_ops __read_mostly = { + .id = "codel", + .priv_size = sizeof(struct codel_sched_data), + + .enqueue = codel_qdisc_enqueue, + .dequeue = codel_qdisc_dequeue, + .peek = qdisc_peek_dequeued, + .init = codel_init, + .reset = codel_reset, + .change = codel_change, + .dump = codel_dump, + .dump_stats = codel_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init codel_module_init(void) +{ + return register_qdisc(&codel_qdisc_ops); +} + +static void __exit codel_module_exit(void) +{ + unregister_qdisc(&codel_qdisc_ops); +} + +module_init(codel_module_init) +module_exit(codel_module_exit) + +MODULE_DESCRIPTION("Controlled Delay queue discipline"); +MODULE_AUTHOR("Dave Taht"); +MODULE_AUTHOR("Eric Dumazet"); +MODULE_LICENSE("Dual BSD/GPL"); diff --git a/include/net/codel.h b/include/net/codel.h new file mode 100644 index 00000000..550debfc --- /dev/null +++ b/include/net/codel.h @@ -0,0 +1,342 @@ +#ifndef __NET_SCHED_CODEL_H +#define __NET_SCHED_CODEL_H + +/* + * Codel - The Controlled-Delay Active Queue Management algorithm + * + * Copyright (C) 2011-2012 Kathleen Nichols + * Copyright (C) 2011-2012 Van Jacobson + * Copyright (C) 2012 Michael D. Taht + * Copyright (C) 2012 Eric Dumazet + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions, and the following disclaimer, + * without modification. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The names of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * Alternatively, provided that this notice is retained in full, this + * software may be distributed under the terms of the GNU General + * Public License ("GPL") version 2, in which case the provisions of the + * GPL apply INSTEAD OF those given above. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + */ + +#include +#include +#include +#include +#include +#include + +/* Controlling Queue Delay (CoDel) algorithm + * ========================================= + * Source : Kathleen Nichols and Van Jacobson + * http://queue.acm.org/detail.cfm?id=2209336 + * + * Implemented on linux by Dave Taht and Eric Dumazet + */ + + +/* CoDel uses a 1024 nsec clock, encoded in u32 + * This gives a range of 2199 seconds, because of signed compares + */ +typedef u32 codel_time_t; +typedef s32 codel_tdiff_t; +#define CODEL_SHIFT 10 +#define MS2TIME(a) ((a * NSEC_PER_MSEC) >> CODEL_SHIFT) + +static inline codel_time_t codel_get_time(void) +{ + u64 ns = ktime_to_ns(ktime_get()); + + return ns >> CODEL_SHIFT; +} + +#define codel_time_after(a, b) ((s32)(a) - (s32)(b) > 0) +#define codel_time_after_eq(a, b) ((s32)(a) - (s32)(b) >= 0) +#define codel_time_before(a, b) ((s32)(a) - (s32)(b) < 0) +#define codel_time_before_eq(a, b) ((s32)(a) - (s32)(b) <= 0) + +/* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */ +struct codel_skb_cb { + codel_time_t enqueue_time; +}; + +static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb) +{ + qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb)); + return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data; +} + +static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb) +{ + return get_codel_cb(skb)->enqueue_time; +} + +static void codel_set_enqueue_time(struct sk_buff *skb) +{ + get_codel_cb(skb)->enqueue_time = codel_get_time(); +} + +static inline u32 codel_time_to_us(codel_time_t val) +{ + u64 valns = ((u64)val << CODEL_SHIFT); + + do_div(valns, NSEC_PER_USEC); + return (u32)valns; +} + +/** + * struct codel_params - contains codel parameters + * @target: target queue size (in time units) + * @interval: width of moving time window + * @ecn: is Explicit Congestion Notification enabled + */ +struct codel_params { + codel_time_t target; + codel_time_t interval; + bool ecn; +}; + +/** + * struct codel_vars - contains codel variables + * @count: how many drops we've done since the last time we + * entered dropping state + * @lastcount: count at entry to dropping state + * @dropping: set to true if in dropping state + * @rec_inv_sqrt: reciprocal value of sqrt(count) >> 1 + * @first_above_time: when we went (or will go) continuously above target + * for interval + * @drop_next: time to drop next packet, or when we dropped last + * @ldelay: sojourn time of last dequeued packet + */ +struct codel_vars { + u32 count; + u32 lastcount; + bool dropping; + u16 rec_inv_sqrt; + codel_time_t first_above_time; + codel_time_t drop_next; + codel_time_t ldelay; +}; + +#define REC_INV_SQRT_BITS (8 * sizeof(u16)) /* or sizeof_in_bits(rec_inv_sqrt) */ +/* needed shift to get a Q0.32 number from rec_inv_sqrt */ +#define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS) + +/** + * struct codel_stats - contains codel shared variables and stats + * @maxpacket: largest packet we've seen so far + * @drop_count: temp count of dropped packets in dequeue() + * ecn_mark: number of packets we ECN marked instead of dropping + */ +struct codel_stats { + u32 maxpacket; + u32 drop_count; + u32 ecn_mark; +}; + +static void codel_params_init(struct codel_params *params) +{ + params->interval = MS2TIME(100); + params->target = MS2TIME(5); + params->ecn = false; +} + +static void codel_vars_init(struct codel_vars *vars) +{ + memset(vars, 0, sizeof(*vars)); +} + +static void codel_stats_init(struct codel_stats *stats) +{ + stats->maxpacket = 256; +} + +/* + * http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots + * new_invsqrt = (invsqrt / 2) * (3 - count * invsqrt^2) + * + * Here, invsqrt is a fixed point number (< 1.0), 32bit mantissa, aka Q0.32 + */ +static void codel_Newton_step(struct codel_vars *vars) +{ + u32 invsqrt = ((u32)vars->rec_inv_sqrt) << REC_INV_SQRT_SHIFT; + u32 invsqrt2 = ((u64)invsqrt * invsqrt) >> 32; + u64 val = (3LL << 32) - ((u64)vars->count * invsqrt2); + + val >>= 2; /* avoid overflow in following multiply */ + val = (val * invsqrt) >> (32 - 2 + 1); + + vars->rec_inv_sqrt = val >> REC_INV_SQRT_SHIFT; +} + +/* + * CoDel control_law is t + interval/sqrt(count) + * We maintain in rec_inv_sqrt the reciprocal value of sqrt(count) to avoid + * both sqrt() and divide operation. + */ +static codel_time_t codel_control_law(codel_time_t t, + codel_time_t interval, + u32 rec_inv_sqrt) +{ + return t + reciprocal_divide(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT); +} + + +static bool codel_should_drop(const struct sk_buff *skb, + struct Qdisc *sch, + struct codel_vars *vars, + struct codel_params *params, + struct codel_stats *stats, + codel_time_t now) +{ + bool ok_to_drop; + + if (!skb) { + vars->first_above_time = 0; + return false; + } + + vars->ldelay = now - codel_get_enqueue_time(skb); + sch->qstats.backlog -= qdisc_pkt_len(skb); + + if (unlikely(qdisc_pkt_len(skb) > stats->maxpacket)) + stats->maxpacket = qdisc_pkt_len(skb); + + if (codel_time_before(vars->ldelay, params->target) || + sch->qstats.backlog <= stats->maxpacket) { + /* went below - stay below for at least interval */ + vars->first_above_time = 0; + return false; + } + ok_to_drop = false; + if (vars->first_above_time == 0) { + /* just went above from below. If we stay above + * for at least interval we'll say it's ok to drop + */ + vars->first_above_time = now + params->interval; + } else if (codel_time_after(now, vars->first_above_time)) { + ok_to_drop = true; + } + return ok_to_drop; +} + +typedef struct sk_buff * (*codel_skb_dequeue_t)(struct codel_vars *vars, + struct Qdisc *sch); + +static struct sk_buff *codel_dequeue(struct Qdisc *sch, + struct codel_params *params, + struct codel_vars *vars, + struct codel_stats *stats, + codel_skb_dequeue_t dequeue_func) +{ + struct sk_buff *skb = dequeue_func(vars, sch); + codel_time_t now; + bool drop; + + if (!skb) { + vars->dropping = false; + return skb; + } + now = codel_get_time(); + drop = codel_should_drop(skb, sch, vars, params, stats, now); + if (vars->dropping) { + if (!drop) { + /* sojourn time below target - leave dropping state */ + vars->dropping = false; + } else if (codel_time_after_eq(now, vars->drop_next)) { + /* It's time for the next drop. Drop the current + * packet and dequeue the next. The dequeue might + * take us out of dropping state. + * If not, schedule the next drop. + * A large backlog might result in drop rates so high + * that the next drop should happen now, + * hence the while loop. + */ + while (vars->dropping && + codel_time_after_eq(now, vars->drop_next)) { + vars->count++; /* dont care of possible wrap + * since there is no more divide + */ + codel_Newton_step(vars); + if (params->ecn && INET_ECN_set_ce(skb)) { + stats->ecn_mark++; + vars->drop_next = + codel_control_law(vars->drop_next, + params->interval, + vars->rec_inv_sqrt); + goto end; + } + qdisc_drop(skb, sch); + stats->drop_count++; + skb = dequeue_func(vars, sch); + if (!codel_should_drop(skb, sch, + vars, params, stats, now)) { + /* leave dropping state */ + vars->dropping = false; + } else { + /* and schedule the next drop */ + vars->drop_next = + codel_control_law(vars->drop_next, + params->interval, + vars->rec_inv_sqrt); + } + } + } + } else if (drop) { + if (params->ecn && INET_ECN_set_ce(skb)) { + stats->ecn_mark++; + } else { + qdisc_drop(skb, sch); + stats->drop_count++; + + skb = dequeue_func(vars, sch); + drop = codel_should_drop(skb, sch, vars, params, + stats, now); + } + vars->dropping = true; + /* if min went above target close to when we last went below it + * assume that the drop rate that controlled the queue on the + * last cycle is a good starting point to control it now. + */ + if (codel_time_before(now - vars->drop_next, + 16 * params->interval)) { + vars->count = (vars->count - vars->lastcount) | 1; + /* we dont care if rec_inv_sqrt approximation + * is not very precise : + * Next Newton steps will correct it quadratically. + */ + codel_Newton_step(vars); + } else { + vars->count = 1; + vars->rec_inv_sqrt = ~0U >> REC_INV_SQRT_SHIFT; + } + vars->lastcount = vars->count; + vars->drop_next = codel_control_law(now, params->interval, + vars->rec_inv_sqrt); + } +end: + return skb; +} +#endif -- cgit v1.2.3 From f1b306ec5ff4303b185b2f4df0503d2c1e9e25a0 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 24 May 2012 17:33:39 -0700 Subject: compat: backport CoDel support down to 2.6.25 This is available as a module called sch_codel. For details on CoDel see: http://lwn.net/Articles/496509/ This goes only compile tested against all the below kernels, run time test results would be appreciated. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/sch_codel.c | 32 +++++++++++++++++++++++++++++++- include/linux/compat-2.6.27.h | 15 +++++++++++++++ include/linux/compat-2.6.32.h | 8 ++++++++ include/linux/compat-2.6.38.h | 32 ++++++++++++++++++++++++++++++++ include/linux/compat-3.3.h | 13 +++++++++++++ include/linux/compat-3.5.h | 37 +++++++++++++++++++++++++++++++++++++ include/net/codel.h | 20 ++++++++++++++++++++ scripts/gen-compat-config.sh | 12 ++++++++++++ 9 files changed, 169 insertions(+), 1 deletion(-) diff --git a/compat/Makefile b/compat/Makefile index 667e7276..83977146 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -2,6 +2,7 @@ obj-m += compat.o #compat-objs := obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o +obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o compat-y += main.o diff --git a/compat/sch_codel.c b/compat/sch_codel.c index 2f9ab17d..5ad66fbc 100644 --- a/compat/sch_codel.c +++ b/compat/sch_codel.c @@ -58,6 +58,9 @@ struct codel_sched_data { struct codel_vars vars; struct codel_stats stats; u32 drop_overlimit; +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + u32 limit; +#endif }; /* This is the specific function called from codel_dequeue() @@ -95,11 +98,16 @@ static int codel_qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) { struct codel_sched_data *q; + q = qdisc_priv(sch); + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (likely(qdisc_qlen(sch) < q->limit)) { +#else if (likely(qdisc_qlen(sch) < sch->limit)) { +#endif codel_set_enqueue_time(skb); return qdisc_enqueue_tail(skb, sch); } - q = qdisc_priv(sch); q->drop_overlimit++; return qdisc_drop(skb, sch); } @@ -140,13 +148,21 @@ static int codel_change(struct Qdisc *sch, struct nlattr *opt) } if (tb[TCA_CODEL_LIMIT]) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]); +#else sch->limit = nla_get_u32(tb[TCA_CODEL_LIMIT]); +#endif if (tb[TCA_CODEL_ECN]) q->params.ecn = !!nla_get_u32(tb[TCA_CODEL_ECN]); qlen = sch->q.qlen; +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + while (sch->q.qlen > q->limit) { +#else while (sch->q.qlen > sch->limit) { +#endif struct sk_buff *skb = __skb_dequeue(&sch->q); sch->qstats.backlog -= qdisc_pkt_len(skb); @@ -162,7 +178,11 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt) { struct codel_sched_data *q = qdisc_priv(sch); +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = DEFAULT_CODEL_LIMIT; +#else sch->limit = DEFAULT_CODEL_LIMIT; +#endif codel_params_init(&q->params); codel_vars_init(&q->vars); @@ -175,7 +195,11 @@ static int codel_init(struct Qdisc *sch, struct nlattr *opt) return err; } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (q->limit >= 1) +#else if (sch->limit >= 1) +#endif sch->flags |= TCQ_F_CAN_BYPASS; else sch->flags &= ~TCQ_F_CAN_BYPASS; @@ -195,7 +219,11 @@ static int codel_dump(struct Qdisc *sch, struct sk_buff *skb) if (nla_put_u32(skb, TCA_CODEL_TARGET, codel_time_to_us(q->params.target)) || nla_put_u32(skb, TCA_CODEL_LIMIT, +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit) || +#else sch->limit) || +#endif nla_put_u32(skb, TCA_CODEL_INTERVAL, codel_time_to_us(q->params.interval)) || nla_put_u32(skb, TCA_CODEL_ECN, @@ -248,7 +276,9 @@ static struct Qdisc_ops codel_qdisc_ops __read_mostly = { .enqueue = codel_qdisc_enqueue, .dequeue = codel_qdisc_dequeue, +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) .peek = qdisc_peek_dequeued, +#endif .init = codel_init, .reset = codel_reset, .change = codel_change, diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 1e2af806..106e7ee2 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -22,6 +22,21 @@ #include #include +struct qdisc_skb_cb { + unsigned int pkt_len; + char data[]; +}; + +static inline struct qdisc_skb_cb *qdisc_skb_cb(struct sk_buff *skb) +{ + return (struct qdisc_skb_cb *)skb->cb; +} + +static inline unsigned int qdisc_pkt_len(struct sk_buff *skb) +{ + return qdisc_skb_cb(skb)->pkt_len; +} + #define PCI_PM_CAP_PME_SHIFT 11 /* I can't find a more suitable replacement... */ diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index b0c699a6..9d41fc85 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -10,6 +10,14 @@ #include #include #include +#include + +#define TCQ_F_CAN_BYPASS 4 + +static inline int qdisc_qlen(const struct Qdisc *q) +{ + return q->q.qlen; +} #define SDIO_VENDOR_ID_INTEL 0x0089 #define SDIO_DEVICE_ID_INTEL_IWMC3200WIMAX 0x1402 diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 63f9dd6a..0a86468b 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -8,6 +8,38 @@ #include #include #include +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) +static inline void bstats_update(struct gnet_stats_basic_packed *bstats, + const struct sk_buff *skb) +{ + bstats->bytes += qdisc_pkt_len((struct sk_buff *) skb); + bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1; +} +static inline void qdisc_bstats_update(struct Qdisc *sch, + const struct sk_buff *skb) +{ + bstats_update(&sch->bstats, skb); +} +#else +/* + * kernels <= 2.6.30 do not pass a const skb to qdisc_pkt_len, and + * gnet_stats_basic_packed did not exist (see c1a8f1f1c8) + */ +static inline void bstats_update(struct gnet_stats_basic *bstats, + struct sk_buff *skb) +{ + bstats->bytes += qdisc_pkt_len(skb); + bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1; +} +static inline void qdisc_bstats_update(struct Qdisc *sch, + struct sk_buff *skb) +{ + bstats_update(&sch->bstats, skb); +} +#endif + /* rename member in struct mmc_host in include/linux/mmc/host.h */ #define max_segs max_hw_segs diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 69bdcd0b..1eb873d6 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -8,6 +8,19 @@ /* include to override NL80211_FEATURE_SK_TX_STATUS */ #include #include +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) +static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) +{ + BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct qdisc_skb_cb) + sz); +} +#else +static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) +{ + /* XXX ? */ +} +#endif extern struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 0bb35bb5..c6d478e8 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,43 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) +#include + +/* + * This backports: + * + * From 76e3cc126bb223013a6b9a0e2a51238d1ef2e409 Mon Sep 17 00:00:00 2001 + * From: Eric Dumazet + * Date: Thu, 10 May 2012 07:51:25 +0000 + * Subject: [PATCH] codel: Controlled Delay AQM + */ + +/* CODEL */ + +enum { + TCA_CODEL_UNSPEC, + TCA_CODEL_TARGET, + TCA_CODEL_LIMIT, + TCA_CODEL_INTERVAL, + TCA_CODEL_ECN, + __TCA_CODEL_MAX +}; + +#define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1) + +struct tc_codel_xstats { + __u32 maxpacket; /* largest packet we've seen so far */ + __u32 count; /* how many drops we've done since the last time we + * entered dropping state + */ + __u32 lastcount; /* count at entry to dropping state */ + __u32 ldelay; /* in-queue delay seen by most recently dequeued packet */ + __s32 drop_next; /* time to drop next packet */ + __u32 drop_overlimit; /* number of time max qdisc packet limit was hit */ + __u32 ecn_mark; /* number of packets we ECN marked instead of dropped */ + __u32 dropping; /* are we in dropping state ? */ +}; + /* Backports tty_lock: Localise the lock */ #define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() diff --git a/include/net/codel.h b/include/net/codel.h index 550debfc..128082ed 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -1,3 +1,9 @@ +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) +#include_next +#else + #ifndef __NET_SCHED_CODEL_H #define __NET_SCHED_CODEL_H @@ -85,7 +91,11 @@ struct codel_skb_cb { static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb) { qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb)); +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37)) + return (struct codel_skb_cb *)qdisc_skb_cb((struct sk_buff *) skb)->data; +#else return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data; +#endif } static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb) @@ -219,10 +229,19 @@ static bool codel_should_drop(const struct sk_buff *skb, } vars->ldelay = now - codel_get_enqueue_time(skb); +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37)) + sch->qstats.backlog -= qdisc_pkt_len((struct sk_buff *)skb); +#else sch->qstats.backlog -= qdisc_pkt_len(skb); +#endif +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,37)) + if (unlikely(qdisc_pkt_len((struct sk_buff *)skb) > stats->maxpacket)) + stats->maxpacket = qdisc_pkt_len((struct sk_buff *)skb); +#else if (unlikely(qdisc_pkt_len(skb) > stats->maxpacket)) stats->maxpacket = qdisc_pkt_len(skb); +#endif if (codel_time_before(vars->ldelay, params->target) || sch->qstats.backlog <= stats->maxpacket) { @@ -340,3 +359,4 @@ end: return skb; } #endif +#endif diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index f56cbfc8..be90fdbd 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -62,3 +62,15 @@ fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then echo "export CONFIG_COMPAT_KFIFO=y" fi + +if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then + # We don't have 2.6.24 backport support yet for Codel + # For those who want to try this is what is required that I can tell + # so far: + # * struct Qdisc_ops + # - init and change callback ops use a different argument dataype + # - you need to parse data received from userspace differently + if [[ ${CONFIG_COMPAT_KERNEL_2_6_25} != "y" ]]; then + echo "export CONFIG_COMPAT_NET_SCH_CODEL=m" + fi +fi -- cgit v1.2.3 From 7262ba08e64c68ed59de044b56874ff33eb678c1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 24 May 2012 17:57:17 -0700 Subject: compat: add FQ CoDel code from upstream This is taken from next-20120524. This does not yet add any backport code to it, not have we integrated it into the build system. The backport work will be done next to make the changes more easily visible to reviewers. This also adds flow_dissector.c from net/core/ as well, but we'll backport any changes required next. Just to be sure, here's the ckmake log: mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/flow_dissector.c | 144 +++++++++++ compat/sch_fq_codel.c | 626 ++++++++++++++++++++++++++++++++++++++++++++++++ include/net/flow_keys.h | 16 ++ 3 files changed, 786 insertions(+) create mode 100644 compat/flow_dissector.c create mode 100644 compat/sch_fq_codel.c create mode 100644 include/net/flow_keys.h diff --git a/compat/flow_dissector.c b/compat/flow_dissector.c new file mode 100644 index 00000000..a225089d --- /dev/null +++ b/compat/flow_dissector.c @@ -0,0 +1,144 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* copy saddr & daddr, possibly using 64bit load/store + * Equivalent to : flow->src = iph->saddr; + * flow->dst = iph->daddr; + */ +static void iph_to_flow_copy_addrs(struct flow_keys *flow, const struct iphdr *iph) +{ + BUILD_BUG_ON(offsetof(typeof(*flow), dst) != + offsetof(typeof(*flow), src) + sizeof(flow->src)); + memcpy(&flow->src, &iph->saddr, sizeof(flow->src) + sizeof(flow->dst)); +} + +bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow) +{ + int poff, nhoff = skb_network_offset(skb); + u8 ip_proto; + __be16 proto = skb->protocol; + + memset(flow, 0, sizeof(*flow)); + +again: + switch (proto) { + case __constant_htons(ETH_P_IP): { + const struct iphdr *iph; + struct iphdr _iph; +ip: + iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); + if (!iph) + return false; + + if (ip_is_fragment(iph)) + ip_proto = 0; + else + ip_proto = iph->protocol; + iph_to_flow_copy_addrs(flow, iph); + nhoff += iph->ihl * 4; + break; + } + case __constant_htons(ETH_P_IPV6): { + const struct ipv6hdr *iph; + struct ipv6hdr _iph; +ipv6: + iph = skb_header_pointer(skb, nhoff, sizeof(_iph), &_iph); + if (!iph) + return false; + + ip_proto = iph->nexthdr; + flow->src = iph->saddr.s6_addr32[3]; + flow->dst = iph->daddr.s6_addr32[3]; + nhoff += sizeof(struct ipv6hdr); + break; + } + case __constant_htons(ETH_P_8021Q): { + const struct vlan_hdr *vlan; + struct vlan_hdr _vlan; + + vlan = skb_header_pointer(skb, nhoff, sizeof(_vlan), &_vlan); + if (!vlan) + return false; + + proto = vlan->h_vlan_encapsulated_proto; + nhoff += sizeof(*vlan); + goto again; + } + case __constant_htons(ETH_P_PPP_SES): { + struct { + struct pppoe_hdr hdr; + __be16 proto; + } *hdr, _hdr; + hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr); + if (!hdr) + return false; + proto = hdr->proto; + nhoff += PPPOE_SES_HLEN; + switch (proto) { + case __constant_htons(PPP_IP): + goto ip; + case __constant_htons(PPP_IPV6): + goto ipv6; + default: + return false; + } + } + default: + return false; + } + + switch (ip_proto) { + case IPPROTO_GRE: { + struct gre_hdr { + __be16 flags; + __be16 proto; + } *hdr, _hdr; + + hdr = skb_header_pointer(skb, nhoff, sizeof(_hdr), &_hdr); + if (!hdr) + return false; + /* + * Only look inside GRE if version zero and no + * routing + */ + if (!(hdr->flags & (GRE_VERSION|GRE_ROUTING))) { + proto = hdr->proto; + nhoff += 4; + if (hdr->flags & GRE_CSUM) + nhoff += 4; + if (hdr->flags & GRE_KEY) + nhoff += 4; + if (hdr->flags & GRE_SEQ) + nhoff += 4; + goto again; + } + break; + } + case IPPROTO_IPIP: + goto again; + default: + break; + } + + flow->ip_proto = ip_proto; + poff = proto_ports_offset(ip_proto); + if (poff >= 0) { + __be32 *ports, _ports; + + nhoff += poff; + ports = skb_header_pointer(skb, nhoff, sizeof(_ports), &_ports); + if (ports) + flow->ports = *ports; + } + + return true; +} +EXPORT_SYMBOL(skb_flow_dissect); diff --git a/compat/sch_fq_codel.c b/compat/sch_fq_codel.c new file mode 100644 index 00000000..9fc1c62e --- /dev/null +++ b/compat/sch_fq_codel.c @@ -0,0 +1,626 @@ +/* + * Fair Queue CoDel discipline + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Copyright (C) 2012 Eric Dumazet + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Fair Queue CoDel. + * + * Principles : + * Packets are classified (internal classifier or external) on flows. + * This is a Stochastic model (as we use a hash, several flows + * might be hashed on same slot) + * Each flow has a CoDel managed queue. + * Flows are linked onto two (Round Robin) lists, + * so that new flows have priority on old ones. + * + * For a given flow, packets are not reordered (CoDel uses a FIFO) + * head drops only. + * ECN capability is on by default. + * Low memory footprint (64 bytes per flow) + */ + +struct fq_codel_flow { + struct sk_buff *head; + struct sk_buff *tail; + struct list_head flowchain; + int deficit; + u32 dropped; /* number of drops (or ECN marks) on this flow */ + struct codel_vars cvars; +}; /* please try to keep this structure <= 64 bytes */ + +struct fq_codel_sched_data { + struct tcf_proto *filter_list; /* optional external classifier */ + struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ + u32 *backlogs; /* backlog table [flows_cnt] */ + u32 flows_cnt; /* number of flows */ + u32 perturbation; /* hash perturbation */ + u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ + struct codel_params cparams; + struct codel_stats cstats; + u32 drop_overlimit; + u32 new_flow_count; + + struct list_head new_flows; /* list of new flows */ + struct list_head old_flows; /* list of old flows */ +}; + +static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, + const struct sk_buff *skb) +{ + struct flow_keys keys; + unsigned int hash; + + skb_flow_dissect(skb, &keys); + hash = jhash_3words((__force u32)keys.dst, + (__force u32)keys.src ^ keys.ip_proto, + (__force u32)keys.ports, q->perturbation); + return ((u64)hash * q->flows_cnt) >> 32; +} + +static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, + int *qerr) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tcf_result res; + int result; + + if (TC_H_MAJ(skb->priority) == sch->handle && + TC_H_MIN(skb->priority) > 0 && + TC_H_MIN(skb->priority) <= q->flows_cnt) + return TC_H_MIN(skb->priority); + + if (!q->filter_list) + return fq_codel_hash(q, skb) + 1; + + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + result = tc_classify(skb, q->filter_list, &res); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return 0; + } +#endif + if (TC_H_MIN(res.classid) <= q->flows_cnt) + return TC_H_MIN(res.classid); + } + return 0; +} + +/* helper functions : might be changed when/if skb use a standard list_head */ + +/* remove one skb from head of slot queue */ +static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) +{ + struct sk_buff *skb = flow->head; + + flow->head = skb->next; + skb->next = NULL; + return skb; +} + +/* add skb to flow queue (tail add) */ +static inline void flow_queue_add(struct fq_codel_flow *flow, + struct sk_buff *skb) +{ + if (flow->head == NULL) + flow->head = skb; + else + flow->tail->next = skb; + flow->tail = skb; + skb->next = NULL; +} + +static unsigned int fq_codel_drop(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + unsigned int maxbacklog = 0, idx = 0, i, len; + struct fq_codel_flow *flow; + + /* Queue is full! Find the fat flow and drop packet from it. + * This might sound expensive, but with 1024 flows, we scan + * 4KB of memory, and we dont need to handle a complex tree + * in fast path (packet queue/enqueue) with many cache misses. + */ + for (i = 0; i < q->flows_cnt; i++) { + if (q->backlogs[i] > maxbacklog) { + maxbacklog = q->backlogs[i]; + idx = i; + } + } + flow = &q->flows[idx]; + skb = dequeue_head(flow); + len = qdisc_pkt_len(skb); + q->backlogs[idx] -= len; + kfree_skb(skb); + sch->q.qlen--; + sch->qstats.drops++; + sch->qstats.backlog -= len; + flow->dropped++; + return idx; +} + +static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int idx; + struct fq_codel_flow *flow; + int uninitialized_var(ret); + + idx = fq_codel_classify(skb, sch, &ret); + if (idx == 0) { + if (ret & __NET_XMIT_BYPASS) + sch->qstats.drops++; + kfree_skb(skb); + return ret; + } + idx--; + + codel_set_enqueue_time(skb); + flow = &q->flows[idx]; + flow_queue_add(flow, skb); + q->backlogs[idx] += qdisc_pkt_len(skb); + sch->qstats.backlog += qdisc_pkt_len(skb); + + if (list_empty(&flow->flowchain)) { + list_add_tail(&flow->flowchain, &q->new_flows); + codel_vars_init(&flow->cvars); + q->new_flow_count++; + flow->deficit = q->quantum; + flow->dropped = 0; + } + if (++sch->q.qlen < sch->limit) + return NET_XMIT_SUCCESS; + + q->drop_overlimit++; + /* Return Congestion Notification only if we dropped a packet + * from this flow. + */ + if (fq_codel_drop(sch) == idx) + return NET_XMIT_CN; + + /* As we dropped a packet, better let upper stack know this */ + qdisc_tree_decrease_qlen(sch, 1); + return NET_XMIT_SUCCESS; +} + +/* This is the specific function called from codel_dequeue() + * to dequeue a packet from queue. Note: backlog is handled in + * codel, we dont need to reduce it here. + */ +static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct fq_codel_flow *flow; + struct sk_buff *skb = NULL; + + flow = container_of(vars, struct fq_codel_flow, cvars); + if (flow->head) { + skb = dequeue_head(flow); + q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); + sch->q.qlen--; + } + return skb; +} + +static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + struct fq_codel_flow *flow; + struct list_head *head; + u32 prev_drop_count, prev_ecn_mark; + +begin: + head = &q->new_flows; + if (list_empty(head)) { + head = &q->old_flows; + if (list_empty(head)) + return NULL; + } + flow = list_first_entry(head, struct fq_codel_flow, flowchain); + + if (flow->deficit <= 0) { + flow->deficit += q->quantum; + list_move_tail(&flow->flowchain, &q->old_flows); + goto begin; + } + + prev_drop_count = q->cstats.drop_count; + prev_ecn_mark = q->cstats.ecn_mark; + + skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, + dequeue); + + flow->dropped += q->cstats.drop_count - prev_drop_count; + flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; + + if (!skb) { + /* force a pass through old_flows to prevent starvation */ + if ((head == &q->new_flows) && !list_empty(&q->old_flows)) + list_move_tail(&flow->flowchain, &q->old_flows); + else + list_del_init(&flow->flowchain); + goto begin; + } + qdisc_bstats_update(sch, skb); + flow->deficit -= qdisc_pkt_len(skb); + /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, + * or HTB crashes. Defer it for next round. + */ + if (q->cstats.drop_count && sch->q.qlen) { + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + } + return skb; +} + +static void fq_codel_reset(struct Qdisc *sch) +{ + struct sk_buff *skb; + + while ((skb = fq_codel_dequeue(sch)) != NULL) + kfree_skb(skb); +} + +static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { + [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, +}; + +static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; + int err; + + if (!opt) + return -EINVAL; + + err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); + if (err < 0) + return err; + if (tb[TCA_FQ_CODEL_FLOWS]) { + if (q->flows) + return -EINVAL; + q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); + if (!q->flows_cnt || + q->flows_cnt > 65536) + return -EINVAL; + } + sch_tree_lock(sch); + + if (tb[TCA_FQ_CODEL_TARGET]) { + u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); + + q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_INTERVAL]) { + u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); + + q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_LIMIT]) + sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); + + if (tb[TCA_FQ_CODEL_ECN]) + q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); + + if (tb[TCA_FQ_CODEL_QUANTUM]) + q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); + + while (sch->q.qlen > sch->limit) { + struct sk_buff *skb = fq_codel_dequeue(sch); + + kfree_skb(skb); + q->cstats.drop_count++; + } + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + + sch_tree_unlock(sch); + return 0; +} + +static void *fq_codel_zalloc(size_t sz) +{ + void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); + + if (!ptr) + ptr = vzalloc(sz); + return ptr; +} + +static void fq_codel_free(void *addr) +{ + if (addr) { + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); + } +} + +static void fq_codel_destroy(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + + tcf_destroy_chain(&q->filter_list); + fq_codel_free(q->backlogs); + fq_codel_free(q->flows); +} + +static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + int i; + + sch->limit = 10*1024; + q->flows_cnt = 1024; + q->quantum = psched_mtu(qdisc_dev(sch)); + q->perturbation = net_random(); + INIT_LIST_HEAD(&q->new_flows); + INIT_LIST_HEAD(&q->old_flows); + codel_params_init(&q->cparams); + codel_stats_init(&q->cstats); + q->cparams.ecn = true; + + if (opt) { + int err = fq_codel_change(sch, opt); + if (err) + return err; + } + + if (!q->flows) { + q->flows = fq_codel_zalloc(q->flows_cnt * + sizeof(struct fq_codel_flow)); + if (!q->flows) + return -ENOMEM; + q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); + if (!q->backlogs) { + fq_codel_free(q->flows); + return -ENOMEM; + } + for (i = 0; i < q->flows_cnt; i++) { + struct fq_codel_flow *flow = q->flows + i; + + INIT_LIST_HEAD(&flow->flowchain); + } + } + if (sch->limit >= 1) + sch->flags |= TCQ_F_CAN_BYPASS; + else + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, + codel_time_to_us(q->cparams.target)) || + nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, + sch->limit) || + nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, + codel_time_to_us(q->cparams.interval)) || + nla_put_u32(skb, TCA_FQ_CODEL_ECN, + q->cparams.ecn) || + nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, + q->quantum) || + nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, + q->flows_cnt)) + goto nla_put_failure; + + nla_nest_end(skb, opts); + return skb->len; + +nla_put_failure: + return -1; +} + +static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tc_fq_codel_xstats st = { + .type = TCA_FQ_CODEL_XSTATS_QDISC, + }; + struct list_head *pos; + + st.qdisc_stats.maxpacket = q->cstats.maxpacket; + st.qdisc_stats.drop_overlimit = q->drop_overlimit; + st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; + st.qdisc_stats.new_flow_count = q->new_flow_count; + + list_for_each(pos, &q->new_flows) + st.qdisc_stats.new_flows_len++; + + list_for_each(pos, &q->old_flows) + st.qdisc_stats.old_flows_len++; + + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) +{ + return NULL; +} + +static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) +{ + return 0; +} + +static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + /* we cannot bypass queue discipline anymore */ + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static void fq_codel_put(struct Qdisc *q, unsigned long cl) +{ +} + +static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + + if (cl) + return NULL; + return &q->filter_list; +} + +static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, + struct sk_buff *skb, struct tcmsg *tcm) +{ + tcm->tcm_handle |= TC_H_MIN(cl); + return 0; +} + +static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, + struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + u32 idx = cl - 1; + struct gnet_stats_queue qs = { 0 }; + struct tc_fq_codel_xstats xstats; + + if (idx < q->flows_cnt) { + const struct fq_codel_flow *flow = &q->flows[idx]; + const struct sk_buff *skb = flow->head; + + memset(&xstats, 0, sizeof(xstats)); + xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; + xstats.class_stats.deficit = flow->deficit; + xstats.class_stats.ldelay = + codel_time_to_us(flow->cvars.ldelay); + xstats.class_stats.count = flow->cvars.count; + xstats.class_stats.lastcount = flow->cvars.lastcount; + xstats.class_stats.dropping = flow->cvars.dropping; + if (flow->cvars.dropping) { + codel_tdiff_t delta = flow->cvars.drop_next - + codel_get_time(); + + xstats.class_stats.drop_next = (delta >= 0) ? + codel_time_to_us(delta) : + -codel_time_to_us(-delta); + } + while (skb) { + qs.qlen++; + skb = skb->next; + } + qs.backlog = q->backlogs[idx]; + qs.drops = flow->dropped; + } + if (gnet_stats_copy_queue(d, &qs) < 0) + return -1; + if (idx < q->flows_cnt) + return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); + return 0; +} + +static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int i; + + if (arg->stop) + return; + + for (i = 0; i < q->flows_cnt; i++) { + if (list_empty(&q->flows[i].flowchain) || + arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +static const struct Qdisc_class_ops fq_codel_class_ops = { + .leaf = fq_codel_leaf, + .get = fq_codel_get, + .put = fq_codel_put, + .tcf_chain = fq_codel_find_tcf, + .bind_tcf = fq_codel_bind, + .unbind_tcf = fq_codel_put, + .dump = fq_codel_dump_class, + .dump_stats = fq_codel_dump_class_stats, + .walk = fq_codel_walk, +}; + +static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { + .cl_ops = &fq_codel_class_ops, + .id = "fq_codel", + .priv_size = sizeof(struct fq_codel_sched_data), + .enqueue = fq_codel_enqueue, + .dequeue = fq_codel_dequeue, + .peek = qdisc_peek_dequeued, + .drop = fq_codel_drop, + .init = fq_codel_init, + .reset = fq_codel_reset, + .destroy = fq_codel_destroy, + .change = fq_codel_change, + .dump = fq_codel_dump, + .dump_stats = fq_codel_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init fq_codel_module_init(void) +{ + return register_qdisc(&fq_codel_qdisc_ops); +} + +static void __exit fq_codel_module_exit(void) +{ + unregister_qdisc(&fq_codel_qdisc_ops); +} + +module_init(fq_codel_module_init) +module_exit(fq_codel_module_exit) +MODULE_AUTHOR("Eric Dumazet"); +MODULE_LICENSE("GPL"); diff --git a/include/net/flow_keys.h b/include/net/flow_keys.h new file mode 100644 index 00000000..80461c1a --- /dev/null +++ b/include/net/flow_keys.h @@ -0,0 +1,16 @@ +#ifndef _NET_FLOW_KEYS_H +#define _NET_FLOW_KEYS_H + +struct flow_keys { + /* (src,dst) must be grouped, in the same way than in IP header */ + __be32 src; + __be32 dst; + union { + __be32 ports; + __be16 port16[2]; + }; + u8 ip_proto; +}; + +extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow); +#endif -- cgit v1.2.3 From f01a2930b7e73055405f9ca89bab342f67ccdc63 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 24 May 2012 19:53:15 -0700 Subject: compat: backport FQ CoDel support down to 2.6.25 FQ CoDel is available as a module, sch_fq_codel. This backports: commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe Author: Eric Dumazet Date: Fri May 11 09:30:50 2012 +0000 fq_codel: Fair Queue Codel AQM Fair Queue Codel packet scheduler Principles : - Packets are classified (internal classifier or external) on flows. - This is a Stochastic model (as we use a hash, several flows might be hashed on same slot) - Each flow has a CoDel managed queue. - Flows are linked onto two (Round Robin) lists, so that new flows have priority on old ones. - For a given flow, packets are not reordered (CoDel uses a FIFO) - head drops only. - ECN capability is on by default. - Very low memory footprint (64 bytes per flow) I should note that this is different than CoDel. This code is GPL, CoDel is Dual BSD/GPL licensed. This goes only compile tested against all the below kernels, run time test results would be appreciated. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 5 +++- compat/flow_dissector.c | 2 +- compat/sch_fq_codel.c | 33 +++++++++++++++++++++++ include/linux/compat-2.6.25.h | 1 - include/linux/compat-2.6.27.h | 14 ++++++++++ include/linux/compat-2.6.37.h | 19 +++++++++++++ include/linux/compat-3.1.h | 7 +++++ include/linux/compat-3.5.h | 63 +++++++++++++++++++++++++++++++++++++++++++ include/net/flow_keys.h | 5 ++++ scripts/gen-compat-config.sh | 3 ++- 10 files changed, 148 insertions(+), 4 deletions(-) diff --git a/compat/Makefile b/compat/Makefile index 83977146..eb4eda1c 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -3,6 +3,7 @@ obj-m += compat.o obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o +obj-$(CONFIG_COMPAT_NET_SCH_FQ_CODEL) += sch_fq_codel.o compat-y += main.o @@ -37,7 +38,9 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o -compat-$(CONFIG_COMPAT_KERNEL_3_3) += compat-3.3.o +compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ + compat-3.3.o \ + flow_dissector.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o diff --git a/compat/flow_dissector.c b/compat/flow_dissector.c index a225089d..8affda0b 100644 --- a/compat/flow_dissector.c +++ b/compat/flow_dissector.c @@ -141,4 +141,4 @@ ipv6: return true; } -EXPORT_SYMBOL(skb_flow_dissect); +EXPORT_SYMBOL_GPL(skb_flow_dissect); diff --git a/compat/sch_fq_codel.c b/compat/sch_fq_codel.c index 9fc1c62e..f03df2ab 100644 --- a/compat/sch_fq_codel.c +++ b/compat/sch_fq_codel.c @@ -65,6 +65,9 @@ struct fq_codel_sched_data { struct list_head new_flows; /* list of new flows */ struct list_head old_flows; /* list of old flows */ +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + u32 limit; +#endif }; static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, @@ -196,7 +199,11 @@ static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) flow->deficit = q->quantum; flow->dropped = 0; } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (++sch->q.qlen < q->limit) +#else if (++sch->q.qlen < sch->limit) +#endif return NET_XMIT_SUCCESS; q->drop_overlimit++; @@ -334,7 +341,11 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) } if (tb[TCA_FQ_CODEL_LIMIT]) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#else sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#endif if (tb[TCA_FQ_CODEL_ECN]) q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); @@ -342,7 +353,11 @@ static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) if (tb[TCA_FQ_CODEL_QUANTUM]) q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + while (sch->q.qlen > q->limit) { +#else while (sch->q.qlen > sch->limit) { +#endif struct sk_buff *skb = fq_codel_dequeue(sch); kfree_skb(skb); @@ -378,7 +393,11 @@ static void fq_codel_destroy(struct Qdisc *sch) { struct fq_codel_sched_data *q = qdisc_priv(sch); +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) tcf_destroy_chain(&q->filter_list); +#else + tcf_destroy_chain(q->filter_list); +#endif fq_codel_free(q->backlogs); fq_codel_free(q->flows); } @@ -388,7 +407,11 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) struct fq_codel_sched_data *q = qdisc_priv(sch); int i; +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = 10*1024; +#else sch->limit = 10*1024; +#endif q->flows_cnt = 1024; q->quantum = psched_mtu(qdisc_dev(sch)); q->perturbation = net_random(); @@ -420,7 +443,11 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) INIT_LIST_HEAD(&flow->flowchain); } } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (q->limit >= 1) +#else if (sch->limit >= 1) +#endif sch->flags |= TCQ_F_CAN_BYPASS; else sch->flags &= ~TCQ_F_CAN_BYPASS; @@ -439,7 +466,11 @@ static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, codel_time_to_us(q->cparams.target)) || nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit) || +#else sch->limit) || +#endif nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, codel_time_to_us(q->cparams.interval)) || nla_put_u32(skb, TCA_FQ_CODEL_ECN, @@ -599,7 +630,9 @@ static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { .priv_size = sizeof(struct fq_codel_sched_data), .enqueue = fq_codel_enqueue, .dequeue = fq_codel_dequeue, +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) .peek = qdisc_peek_dequeued, +#endif .drop = fq_codel_drop, .init = fq_codel_init, .reset = fq_codel_reset, diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 356186d1..563b65f7 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -36,7 +36,6 @@ int __must_check pci_enable_device_mem(struct pci_dev *dev); /* * backports 2658fa803111dae1353602e7f586de8e537803e2 - * We skip proto_ports_offset() as I'm lazy. */ static inline bool ipv4_is_loopback(__be32 addr) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 106e7ee2..ece825de 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -22,6 +22,20 @@ #include #include +static inline struct net_device *qdisc_dev(const struct Qdisc *qdisc) +{ + return qdisc->dev; +} + +/* + * Backports 378a2f09 and c27f339a + * This may need a bit more work. + */ +enum net_xmit_qdisc_t { + __NET_XMIT_STOLEN = 0x00010000, + __NET_XMIT_BYPASS = 0x00020000, +}; + struct qdisc_skb_cb { unsigned int pkt_len; char data[]; diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index c19e7818..7e14853b 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -7,6 +7,25 @@ #include #include +#include +#include + +static inline int proto_ports_offset(int proto) +{ + switch (proto) { + case IPPROTO_TCP: + case IPPROTO_UDP: + case IPPROTO_DCCP: + case IPPROTO_ESP: /* SPI */ + case IPPROTO_SCTP: + case IPPROTO_UDPLITE: + return 0; + case IPPROTO_AH: /* SPI */ + return 4; + default: + return -EINVAL; + } +} #define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 3fdcbf88..fdd27d48 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -7,6 +7,13 @@ #include #include +#include + +/* Backports 56f8a75c */ +static inline bool ip_is_fragment(const struct iphdr *iph) +{ + return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0; +} static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length, gfp_t gfp) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index c6d478e8..c9ba6af8 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -45,6 +45,69 @@ struct tc_codel_xstats { __u32 dropping; /* are we in dropping state ? */ }; +/* This backports: + * + * commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe + * Author: Eric Dumazet + * Date: Fri May 11 09:30:50 2012 +0000 + * fq_codel: Fair Queue Codel AQM + */ + +/* FQ_CODEL */ + +enum { + TCA_FQ_CODEL_UNSPEC, + TCA_FQ_CODEL_TARGET, + TCA_FQ_CODEL_LIMIT, + TCA_FQ_CODEL_INTERVAL, + TCA_FQ_CODEL_ECN, + TCA_FQ_CODEL_FLOWS, + TCA_FQ_CODEL_QUANTUM, + __TCA_FQ_CODEL_MAX +}; + +#define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1) + +enum { + TCA_FQ_CODEL_XSTATS_QDISC, + TCA_FQ_CODEL_XSTATS_CLASS, +}; + +struct tc_fq_codel_qd_stats { + __u32 maxpacket; /* largest packet we've seen so far */ + __u32 drop_overlimit; /* number of time max qdisc + * packet limit was hit + */ + __u32 ecn_mark; /* number of packets we ECN marked + * instead of being dropped + */ + __u32 new_flow_count; /* number of time packets + * created a 'new flow' + */ + __u32 new_flows_len; /* count of flows in new list */ + __u32 old_flows_len; /* count of flows in old list */ +}; + +struct tc_fq_codel_cl_stats { + __s32 deficit; + __u32 ldelay; /* in-queue delay seen by most recently + * dequeued packet + */ + __u32 count; + __u32 lastcount; + __u32 dropping; + __s32 drop_next; +}; + +struct tc_fq_codel_xstats { + __u32 type; + union { + struct tc_fq_codel_qd_stats qdisc_stats; + struct tc_fq_codel_cl_stats class_stats; + }; +}; + + /* Backports tty_lock: Localise the lock */ #define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() diff --git a/include/net/flow_keys.h b/include/net/flow_keys.h index 80461c1a..a875ee6e 100644 --- a/include/net/flow_keys.h +++ b/include/net/flow_keys.h @@ -1,3 +1,7 @@ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,3,0)) +#include_next +#else + #ifndef _NET_FLOW_KEYS_H #define _NET_FLOW_KEYS_H @@ -14,3 +18,4 @@ struct flow_keys { extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow); #endif +#endif diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index be90fdbd..3eba34ef 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -64,7 +64,7 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then fi if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then - # We don't have 2.6.24 backport support yet for Codel + # We don't have 2.6.24 backport support yet for Codel / FQ CoDel # For those who want to try this is what is required that I can tell # so far: # * struct Qdisc_ops @@ -72,5 +72,6 @@ if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then # - you need to parse data received from userspace differently if [[ ${CONFIG_COMPAT_KERNEL_2_6_25} != "y" ]]; then echo "export CONFIG_COMPAT_NET_SCH_CODEL=m" + echo "export CONFIG_COMPAT_NET_SCH_FQ_CODEL=m" fi fi -- cgit v1.2.3 From 7c56986d0f10c978a7455c7f2b4a686a43731cef Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 30 May 2012 00:41:45 +0200 Subject: compat: do not include qdisc_cb_private_validate with every kernel This method got backported into kernel 3.2.9 and 3.0.23. Compat should not provide it for these kernel versions as it will cause some compile errors. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 1eb873d6..620e661c 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -10,6 +10,7 @@ #include #include +#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) { @@ -21,6 +22,7 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) /* XXX ? */ } #endif +#endif extern struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask); -- cgit v1.2.3 From 257909c222631cd09dc07182abe7cceed0bb4064 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 30 May 2012 00:41:46 +0200 Subject: comapt: add skb_queue_walk_from Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.28.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 3980989e..9b6b9580 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -214,6 +214,10 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list, } } +#define skb_queue_walk_from(queue, skb) \ + for (; skb != (struct sk_buff *)(queue); \ + skb = skb->next) + #ifndef DECLARE_TRACE #define TP_PROTO(args...) args -- cgit v1.2.3 From 3aac76da04396297e2ea87351b37b02a430b5769 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 30 May 2012 00:41:47 +0200 Subject: compat: remove hci_mon.h compat-wireless should copy this file from the kernel Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/net/bluetooth/hci_mon.h | 51 ----------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 include/net/bluetooth/hci_mon.h diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h deleted file mode 100644 index 07a25c92..00000000 --- a/include/net/bluetooth/hci_mon.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - BlueZ - Bluetooth protocol stack for Linux - - Copyright (C) 2011-2012 Intel Corporation - - 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; - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. - IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY - CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, - COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS - SOFTWARE IS DISCLAIMED. -*/ - -#ifndef __HCI_MON_H -#define __HCI_MON_H - -struct hci_mon_hdr { - __le16 opcode; - __le16 index; - __le16 len; -} __packed; -#define HCI_MON_HDR_SIZE 6 - -#define HCI_MON_NEW_INDEX 0 -#define HCI_MON_DEL_INDEX 1 -#define HCI_MON_COMMAND_PKT 2 -#define HCI_MON_EVENT_PKT 3 -#define HCI_MON_ACL_TX_PKT 4 -#define HCI_MON_ACL_RX_PKT 5 -#define HCI_MON_SCO_TX_PKT 6 -#define HCI_MON_SCO_RX_PKT 7 - -struct hci_mon_new_index { - __u8 type; - __u8 bus; - bdaddr_t bdaddr; - char name[8]; -} __packed; -#define HCI_MON_NEW_INDEX_SIZE 16 - -#endif /* __HCI_MON_H */ -- cgit v1.2.3 From 59bcb973016c077cfa4990429f37e69b99a47d8e Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 30 May 2012 00:41:48 +0200 Subject: compat: add ida_simple_{get,remove} This is needed by net/bluetooth/hci_core.c mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.1.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.1.h | 5 +++ 3 files changed, 89 insertions(+) create mode 100644 compat/compat-3.1.c diff --git a/compat/Makefile b/compat/Makefile index eb4eda1c..c661f5da 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -37,6 +37,7 @@ compat-$(CONFIG_COMPAT_KERNEL_2_6_39) += \ compat-2.6.39.o \ kstrtox.o compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o +compat-$(CONFIG_COMPAT_KERNEL_3_1) += compat-3.1.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ compat-3.3.o \ diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c new file mode 100644 index 00000000..d427dd3d --- /dev/null +++ b/compat/compat-3.1.c @@ -0,0 +1,83 @@ +/* + * Copyright 2012 Hauke Mehrtens + * + * 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 3.1. + */ + +#include + +static DEFINE_SPINLOCK(simple_ida_lock); + +/** + * ida_simple_get - get a new id. + * @ida: the (initialized) ida. + * @start: the minimum id (inclusive, < 0x8000000) + * @end: the maximum id (exclusive, < 0x8000000 or 0) + * @gfp_mask: memory allocation flags + * + * Allocates an id in the range start <= id < end, or returns -ENOSPC. + * On memory allocation failure, returns -ENOMEM. + * + * Use ida_simple_remove() to get rid of an id. + */ +int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, + gfp_t gfp_mask) +{ + int ret, id; + unsigned int max; + unsigned long flags; + + BUG_ON((int)start < 0); + BUG_ON((int)end < 0); + + if (end == 0) + max = 0x80000000; + else { + BUG_ON(end < start); + max = end - 1; + } + +again: + if (!ida_pre_get(ida, gfp_mask)) + return -ENOMEM; + + spin_lock_irqsave(&simple_ida_lock, flags); + ret = ida_get_new_above(ida, start, &id); + if (!ret) { + if (id > max) { + ida_remove(ida, id); + ret = -ENOSPC; + } else { + ret = id; + } + } + spin_unlock_irqrestore(&simple_ida_lock, flags); + + if (unlikely(ret == -EAGAIN)) + goto again; + + return ret; +} +EXPORT_SYMBOL(ida_simple_get); + +/** + * ida_simple_remove - remove an allocated id. + * @ida: the (initialized) ida. + * @id: the id returned by ida_simple_get. + */ +void ida_simple_remove(struct ida *ida, unsigned int id) +{ + unsigned long flags; + + BUG_ON((int)id < 0); + spin_lock_irqsave(&simple_ida_lock, flags); + ida_remove(ida, id); + spin_unlock_irqrestore(&simple_ida_lock, flags); +} +EXPORT_SYMBOL(ida_simple_remove); +/* source lib/idr.c */ + diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index fdd27d48..da8e971c 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -8,6 +8,7 @@ #include #include #include +#include /* Backports 56f8a75c */ static inline bool ip_is_fragment(const struct iphdr *iph) @@ -83,6 +84,10 @@ static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) #include #endif +int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, + gfp_t gfp_mask); +void ida_simple_remove(struct ida *ida, unsigned int id); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From 5e0c5b47852bad1b910e69f65dfed54dc5cfbbfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 12 Jun 2012 00:31:55 +0300 Subject: compat: bin/get-compat-kernels: Update 3.3 and add 3.4 kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ubdate 3.3 kernel to the latest one and add 3.4 kernel. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 7a253c2c..e6c586da 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -108,9 +108,13 @@ function get_ubuntu_kernels() { KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2_3.3.0-030300rc2.201201311735_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-headers-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.3-rc2-precise/linux-image-3.3.0-030300rc2-generic_3.3.0-030300rc2.201201311735_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" + + KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb" for i in $KERNELS; do FILE=$(basename $i) -- cgit v1.2.3 From fdbea5a6ce2cba6d6c8fb3eb998cffa5a9e3bf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 12 Jun 2012 00:45:35 +0300 Subject: compat: bin/get-compat-kernels: Do not depend on Ubuntu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use Ubuntu PPA vanilla kernels on other distributions too. The .deb files are extracted using 'ar' and 'tar'. Also check if the target directory exists before downloading the deb files. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 67 ++++++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 24 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index e6c586da..6ebaa0c0 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -10,6 +10,9 @@ # to test compile the Linux kernel compatibility module. You can # then use ckmake to cross compile against all supported kernels. +KERNELS="" +KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" + function get_ubuntu_kernels() { ARCH=$(uname -m) @@ -28,10 +31,6 @@ function get_ubuntu_kernels() { ;; esac - KERNELS="" - - KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" @@ -125,19 +124,49 @@ function get_ubuntu_kernels() { continue fi - if [[ ! -f $FILE ]]; then + # Do not download if installed or deb exists + if [[ ! -d /usr/src/$PKG && ! -f $FILE ]]; then wget -c $i fi done - # Let dpkg figure out dependency magic. - # - # XXX: I tried adding some magic to not install a package if - # if its already presently installed but then had to deal - # with the dependency mess. I welcome someone else to - # figure this out. Running this can come in handy once - # a new public kernel gets released. - sudo dpkg -i *.deb + LSB_RED_ID=$(/usr/bin/lsb_release -i -s) + case $LSB_RED_ID in + "Ubuntu") + # Install with dpkg + sudo dpkg -i *.deb + ;; + *) + # For every other distribution around + + # Create a temporary directory first + TEMP_DIR=`mktemp -d` + + for deb in $(ls linux-*.deb); do + DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') + if [[ ! -d /usr/src/$DIR_NAME ]]; then + echo "Extracting $deb..." + ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR + fi + done + + # Move the extracted folders into the system + if [[ -d $TEMP_DIR/lib/modules ]]; then + mv $TEMP_DIR/lib/modules/* /lib/modules + fi + if [[ -d $TEMP_DIR/usr/src ]]; then + # Because of a bug in make < 3.82, mixed implicit and normal + # rules do not cause harm. Since the bug is fixed in the new make + # we have to adjust older kernel's Makefiles to fix the bug. + sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null + + mv $TEMP_DIR/usr/src/* /usr/src + fi + + # Remove the temporary directory + rm -rf $TEMP_DIR + ;; + esac } function usage() { @@ -162,14 +191,4 @@ if [[ $# -eq 1 && $1 = "-i" ]]; then INSTALL_IMAGES="y" fi - -LSB_RED_ID=$(/usr/bin/lsb_release -i -s) -case $LSB_RED_ID in -"Ubuntu") - get_ubuntu_kernels - ;; -*) - echo -e "Unsupported distribution" - exit - ;; -esac +get_ubuntu_kernels -- cgit v1.2.3 From c37c46c4ab5085ba50f650d15854404983b8d09b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 12 Jun 2012 00:46:19 +0300 Subject: compat: bin/ckmake: Drop Ubuntu check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't check for distribution as it is now possible to use ckmake on every distribution. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 2d422af9..9956cf1c 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -31,18 +31,9 @@ ARGS="" RET="" -LSB_RED_ID=$(/usr/bin/lsb_release -i -s) -case $LSB_RED_ID in -"Ubuntu") - for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do - KLIBS="$KLIBS $i" - done - ;; -*) - echo -e "Unsupported distribution" - exit - ;; -esac +for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do + KLIBS="$KLIBS $i" +done function tee_color_split() { -- cgit v1.2.3 From 1f397f91dc96a7be090829a69579e463e9eb48f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Wed, 13 Jun 2012 02:00:16 +0300 Subject: compat: Add SIZE_MAX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 From: Xi Wang Date: Thu, 31 May 2012 16:26:04 -0700 Subject: [PATCH] introduce SIZE_MAX This is needed by include/drm/drm_mem_util.h Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index c9ba6af8..3f97a3d5 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,18 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) +/* + * This backports: + * + * From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 2001 + * From: Xi Wang + * Date: Thu, 31 May 2012 16:26:04 -0700 + * Subject: [PATCH] introduce SIZE_MAX + */ + +#define SIZE_MAX (~(size_t)0) + + #include /* -- cgit v1.2.3 From 00c3d024ae12bc36428174fdb224c46b4ef3efc2 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 12 Jun 2012 19:23:38 -0700 Subject: compat: add SDIO_CCCR_REV_3_00 and SDIO_SDIO_REV_3_00 This backports: commit b4625dab2c618eb87e177761dda3182b4cfaa604 Author: Bing Zhao Date: Thu Oct 20 19:16:32 2011 -0700 mmc: recognise SDIO cards with SDIO_CCCR_REV 3.00 Table 6-2: CCCR bit Definitions, address 00h. Part E1 SDIO Simplified Specification Version 3.00, Feb. 25, 2011. This patch has been tested with Marvell WLAN device SD8797. Signed-off-by: Bing Zhao Signed-off-by: Chris Ball Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index cb14f0b1..ef275664 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -8,6 +8,10 @@ #include #include +/* backports b4625dab */ +#define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */ +#define SDIO_SDIO_REV_3_00 4 /* SDIO Spec Version 3.00 */ + #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) /** -- cgit v1.2.3 From e22d12757f178773b024f95fc05bb3ba2aff366a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 14 Jun 2012 20:52:44 +0300 Subject: compat: Backport vga_switcheroo_client_ops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: From 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 Mon Sep 17 00:00:00 From: Takashi Iwai Date: Fri, 11 May 2012 07:51:17 +0200 Subject: [PATCH] vga_switcheroo: Introduce struct vga_switcheroo_client_ops only for kernels >= 2.6.34 in which vga_switcheroo is available. Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 3f97a3d5..1d9128a0 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,26 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) +/* switcheroo is available on >= 2.6.34 */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +#include +/* + * This backports: + * + * From 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 Mon Sep 17 00:00:00 2001 + * From: Takashi Iwai + * Date: Fri, 11 May 2012 07:51:17 +0200 + * Subject: [PATCH] vga_switcheroo: Introduce struct vga_switcheroo_client_ops + * + */ + +struct vga_switcheroo_client_ops { + void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); + void (*reprobe)(struct pci_dev *dev); + bool (*can_switch)(struct pci_dev *dev); +}; +#endif + /* * This backports: * -- cgit v1.2.3 From 6bcaefb7c4e8a025bcbc473de81bf50bd6b10521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 14 Jun 2012 20:52:45 +0300 Subject: compat: Fix cosmetic typo in compat-3.4.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit compat-3.4.c is for kernel version 3.4 not 3.5. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- compat/compat-3.4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-3.4.c b/compat/compat-3.4.c index 5d516f0e..4721fa2d 100644 --- a/compat/compat-3.4.c +++ b/compat/compat-3.4.c @@ -5,7 +5,7 @@ * 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 3.5. + * Compatibility file for Linux wireless for kernels 3.4. */ #include -- cgit v1.2.3 From 5a218cdb48fab47d6c0aea76ede99b415f02bc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 14 Jun 2012 20:52:46 +0300 Subject: compat: Backport fault_in_multipages_{writeable,readable} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit f56f821feb7b36223f309e0ec05986bb137ce418 Author: Daniel Vetter Date: Sun Mar 25 19:47:41 2012 +0200 mm: extend prefault helpers to fault in more than PAGE_SIZE The new functions are used by drm/i915 driver. Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 1d9128a0..74c8176d 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,73 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) +/* + * This backports: + * + * commit f56f821feb7b36223f309e0ec05986bb137ce418 + * Author: Daniel Vetter + * Date: Sun Mar 25 19:47:41 2012 +0200 + * + * mm: extend prefault helpers to fault in more than PAGE_SIZE + * + * The new functions are used by drm/i915 driver. + * + */ + +static inline int fault_in_multipages_writeable(char __user *uaddr, int size) +{ + int ret = 0; + char __user *end = uaddr + size - 1; + + if (unlikely(size == 0)) + return ret; + + /* + * Writing zeroes into userspace here is OK, because we know that if + * the zero gets there, we'll be overwriting it. + */ + while (uaddr <= end) { + ret = __put_user(0, uaddr); + if (ret != 0) + return ret; + uaddr += PAGE_SIZE; + } + + /* Check whether the range spilled into the next page. */ + if (((unsigned long)uaddr & PAGE_MASK) == + ((unsigned long)end & PAGE_MASK)) + ret = __put_user(0, end); + + return ret; +} + +static inline int fault_in_multipages_readable(const char __user *uaddr, + int size) +{ + volatile char c; + int ret = 0; + const char __user *end = uaddr + size - 1; + + if (unlikely(size == 0)) + return ret; + + while (uaddr <= end) { + ret = __get_user(c, uaddr); + if (ret != 0) + return ret; + uaddr += PAGE_SIZE; + } + + /* Check whether the range spilled into the next page. */ + if (((unsigned long)uaddr & PAGE_MASK) == + ((unsigned long)end & PAGE_MASK)) { + ret = __get_user(c, end); + (void)c; + } + + return ret; +} + /* switcheroo is available on >= 2.6.34 */ #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) #include -- cgit v1.2.3 From 4a9e9a2466dc816b7634054294382380ea6a06c3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Jun 2012 15:28:54 -0700 Subject: compat: improve ckmake to add short report A short report is added now at the end of the cmake.log and also a new file ckmake-report.log if you want only the short summary. Tabs are now broken on the report but I prefer this over not having this short report. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 9956cf1c..b6780e54 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -25,6 +25,8 @@ UNDERLINE="\033[02m" KERNEL_DIR="/lib/modules" KLIBS="" LOG="ckmake.log" +LOG_TMP="ckmake-tmp.log" +REPORT="ckmake-report.log" TIME="0" QUIET="" ARGS="" @@ -38,7 +40,7 @@ done function tee_color_split() { while read; do - echo -e $REPLY | ./scripts/skip-colors >> $LOG + echo -e $REPLY | ./scripts/skip-colors >> $1 echo -e $REPLY done } @@ -112,9 +114,9 @@ function run_ckmake() fi if [[ $CUR_RET -eq 0 ]]; then - echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split + echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split $LOG else - echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split + echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split $LOG RET=$CUR_RET fi @@ -122,14 +124,28 @@ function run_ckmake() done } +for i in $LOG $LOG_TMP $REPORT; do + echo > $i +done + nice make clean 2>&1 > $LOG if [[ $TIME != "1" ]]; then - run_ckmake + run_ckmake | tee_color_split $REPORT + + cat $LOG $REPORT > $LOG_TMP + mv $LOG_TMP $LOG + rm -f $LOG_TMP + exit $RET fi -time $0 $QUIET $ARGS -time $0 $QUIET $ARGS | egrep "real|user|sys" +time $0 $QUIET $ARGS | tee_color_split $REPORT +time $0 $QUIET $ARGS | egrep "real|user|sys" | tee_color_split $REPORT + +cat $LOG $REPORT > $LOG_TMP +mv $LOG_TMP $LOG + +rm -f $LOG_TMP exit $RET -- cgit v1.2.3 From c5b4fb0088e54eda4333386315c6134435c6f8c3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 Jun 2012 11:48:29 -0700 Subject: compat: backport rename of led_brightness_set() to led_set_brightness() This backports this commit from linux-next: commit 959d62fa865d2e616b61a509e1cc5b88741f065e Author: Shuah Khan Date: Thu Jun 14 04:34:30 2012 +0800 leds: Rename led_brightness_set() to led_set_brightness() Rename leds external interface led_brightness_set() to led_set_brightness(). This is the second phase of the change to reduce confusion between the leds internal and external interfaces that set brightness. With this change, now the external interface is led_set_brightness(). The first phase renamed the internal interface led_set_brightness() to __led_set_brightness(). There are no changes to the interface implementations. Signed-off-by: Shuah Khan Signed-off-by: Bryan Wu Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.6.h | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 include/linux/compat-3.6.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 17905598..7aaa8483 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -63,5 +63,6 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h new file mode 100644 index 00000000..8cdfa877 --- /dev/null +++ b/include/linux/compat-3.6.h @@ -0,0 +1,31 @@ +#ifndef LINUX_3_6_COMPAT_H +#define LINUX_3_6_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) + +/* + * Backports + * + * commit 959d62fa865d2e616b61a509e1cc5b88741f065e + * Author: Shuah Khan + * Date: Thu Jun 14 04:34:30 2012 +0800 + * + * leds: Rename led_brightness_set() to led_set_brightness() + * + * Rename leds external interface led_brightness_set() to led_set_brightness(). + * This is the second phase of the change to reduce confusion between the + * leds internal and external interfaces that set brightness. With this change, + * now the external interface is led_set_brightness(). The first phase renamed + * the internal interface led_set_brightness() to __led_set_brightness(). + * There are no changes to the interface implementations. + * + * Signed-off-by: Shuah Khan + * Signed-off-by: Bryan Wu + */ +#define led_set_brightness(_dev, _switch) led_brightness_set(_dev, _switch) + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) */ + +#endif /* LINUX_3_6_COMPAT_H */ -- cgit v1.2.3 From 489c635300c38540bcad5afa7c01cfde9857059a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 25 Jun 2012 13:08:32 +0300 Subject: compat: Define include guard for vga_switcheroo.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check is missing in upstream. Patch sent but until this gets merged, define it in compat tree for fixing compat-drm builds. Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/vga_switcheroo.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 include/linux/vga_switcheroo.h diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h new file mode 100644 index 00000000..4bda17bf --- /dev/null +++ b/include/linux/vga_switcheroo.h @@ -0,0 +1,12 @@ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +/* + * XXX: The include guard was sent upstream, drop this + * once the guard is merged. + */ +#ifndef LINUX_VGA_SWITCHEROO_H /* in case this gets upstream */ +#include_next +#ifndef LINUX_VGA_SWITCHEROO_H /* do not redefine once this gets upstream */ +#define LINUX_VGA_SWITCHEROO_H +#endif /* case 1 LINUX_VGA_SWITCHEROO_H */ +#endif /* case 2 LINUX_VGA_SWITCHEROO_H */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) */ -- cgit v1.2.3 From ffb22eb100d5176ac66abf89055280ec3a43a002 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 Jun 2012 16:48:18 -0700 Subject: compat: remove unused-but-set-variable I am getting quite a bit of compile errors with this option enabled right now. This forces a compile error when a warning is found... lets skip that for our releases. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index b6780e54..d3be52b6 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -106,7 +106,8 @@ function run_ckmake() log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG log_try_kernel $KERNEL - ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG + #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG + ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 $ARGS &>> $LOG CUR_RET=$? if [[ $RET = "" ]]; then -- cgit v1.2.3 From 45099856da0cfb47bd18ac0c0710dea73031c1fe Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 29 Jun 2012 11:31:07 -0700 Subject: compat: fix error propagation on ckmake Bash was not doing what was expected... You can now rely on ckmake returning a non 0 value if a build fails. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bin/ckmake b/bin/ckmake index d3be52b6..da4ce8c9 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -30,6 +30,7 @@ REPORT="ckmake-report.log" TIME="0" QUIET="" ARGS="" +RET_FILE="ret-tmp.txt" RET="" @@ -123,6 +124,10 @@ function run_ckmake() nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG done + # Bash doesn't do what we expect with the variables... + # and using return $RET here won't work here either given + # that we end up piping the result anyway. + echo $RET > $RET_FILE } for i in $LOG $LOG_TMP $REPORT; do @@ -138,6 +143,8 @@ if [[ $TIME != "1" ]]; then mv $LOG_TMP $LOG rm -f $LOG_TMP + RET=$(cat $RET_FILE) + rm -f $RET_FILE exit $RET fi @@ -149,4 +156,7 @@ mv $LOG_TMP $LOG rm -f $LOG_TMP +RET=$(cat $RET_FILE) +rm -f $RET_FILE + exit $RET -- cgit v1.2.3 From 16bb4451eef7a9dcf238a9d16ca2483997863d10 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 29 Jun 2012 13:40:15 -0700 Subject: compat: backport definition of NLMSG_DEFAULT_SIZE This backports the definition of NLMSG_DEFAULT_SIZE defined in this commit: commit 58050fce3530939372e6c2f4b4beb76fcb4caa65 Author: Thomas Graf Date: Thu Jun 28 03:57:45 2012 +0000 net: Use NLMSG_DEFAULT_SIZE in combination with nlmsg_new() Using NLMSG_GOODSIZE results in multiple pages being used as nlmsg_new() will automatically add the size of the netlink header to the payload thus exceeding the page limit. NLMSG_DEFAULT_SIZE takes this into account. Signed-off-by: Thomas Graf Cc: Jiri Pirko Cc: Dmitry Eremin-Solenikov Cc: Sergey Lapin Cc: Johannes Berg Cc: Lauro Ramos Venancio Cc: Aloisio Almeida Jr Cc: Samuel Ortiz Reviewed-by: Jiri Pirko Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.6.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 8cdfa877..9da8ec50 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -5,6 +5,10 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) +#include + +#define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN) + /* * Backports * -- cgit v1.2.3 From 59e4c328b7e7ac04537c277cd8a637e1d3ceb162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 2 Jul 2012 17:22:10 +0300 Subject: compat: Make use of the vga_switcheroo_register_client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If kernel version is older than 3.5, call vga_switcheroo_register_client with the old parameters using a compat_ wrapper. .reprobe was added in 2.6.38 so before that do not pass it to the underlying vga_switcheroo_register_client() function. Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 74c8176d..7855ac98 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -93,6 +93,24 @@ struct vga_switcheroo_client_ops { void (*reprobe)(struct pci_dev *dev); bool (*can_switch)(struct pci_dev *dev); }; + +/* Wrap around the old code and redefine vga_switcheroo_register_client() + * for older kernels < 3.5.0. + */ +static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev, + const struct vga_switcheroo_client_ops *ops) { + + return vga_switcheroo_register_client(dev, + ops->set_gpu_state, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) + ops->reprobe, +#endif + ops->can_switch); +} + +#define vga_switcheroo_register_client(_dev, _ops) \ + compat_vga_switcheroo_register_client(_dev, _ops) + #endif /* -- cgit v1.2.3 From 9d45bfb312778bfe0f3b02fc6d2bb6f87747d7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 2 Jul 2012 17:22:11 +0300 Subject: compat: Backport shmem_read_mapping_page() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit d9d90e5eb70e09903dadff42099b6c948f814050 Author: Hugh Dickins Date: Mon Jun 27 16:18:04 2011 -0700 tmpfs: add shmem_read_mapping_page_gfp shmem_read_mapping_page() is a wrapper around shmem_read_mapping_page_gfp(). Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- compat/compat-3.0.c | 23 +++++++++++++++++++++++ include/linux/compat-3.0.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/compat/compat-3.0.c b/compat/compat-3.0.c index 1da45ac1..e8413730 100644 --- a/compat/compat-3.0.c +++ b/compat/compat-3.0.c @@ -12,6 +12,29 @@ #include #include +/* This pulls-in a lot of non-exported symbol backports + * on kernels older than 2.6.32. There's no harm for not + * making this available on kernels < 2.6.32. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) +#include + +/* This backports: + * + * commit d9d90e5eb70e09903dadff42099b6c948f814050 + * Author: Hugh Dickins + * Date: Mon Jun 27 16:18:04 2011 -0700 + * + * tmpfs: add shmem_read_mapping_page_gfp + */ + +struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, + pgoff_t index, gfp_t gfp) +{ + return read_cache_page_gfp(mapping, index, gfp); +} +EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); +#endif + int mac_pton(const char *s, u8 *mac) { int i; diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index 22ab5399..ba25846a 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -7,6 +7,35 @@ #include +/* This pulls-in a lot of non-exported symbol backports + * on kernels older than 2.6.32. There's no harm for not + * making this available on kernels < 2.6.32. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) +#include + +/* This backports the 2nd part of: + * + * commit d9d90e5eb70e09903dadff42099b6c948f814050 + * Author: Hugh Dickins + * Date: Mon Jun 27 16:18:04 2011 -0700 + * + * tmpfs: add shmem_read_mapping_page_gfp + * + * First part is in compat-3.0.c. + */ +extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, + pgoff_t index, gfp_t gfp); + + +static inline struct page *shmem_read_mapping_page( + struct address_space *mapping, pgoff_t index) +{ + return shmem_read_mapping_page_gfp(mapping, index, + mapping_gfp_mask(mapping)); +} +#endif + + /* * since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171 * "net: call dev_alloc_name from register_netdevice" dev_alloc_name is -- cgit v1.2.3 From d01997e6d0692882700d9deb985cebcd5424dcdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 2 Jul 2012 17:22:12 +0300 Subject: compat: Define I2C_FUNC_NOSTART MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit 14674e70119ea01549ce593d8901a797f8a90f74 Author: Mark Brown Date: Wed May 30 10:55:34 2012 +0200 i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 7855ac98..6bb450da 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -113,6 +113,17 @@ static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev, #endif +/* This backports + * + * commit 14674e70119ea01549ce593d8901a797f8a90f74 + * Author: Mark Brown + * Date: Wed May 30 10:55:34 2012 +0200 + * + * i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING + */ + +#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */ + /* * This backports: * -- cgit v1.2.3 From d5a1a5df5ae2c5f8b2161a7980d4c77622a210be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 2 Jul 2012 17:22:13 +0300 Subject: compat: Backport i2c_bit_algo structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports all the necessary helpers for being able to export i2c-bit_algo structure. This is currently only used by drivers/gpu/drm/i915/intel_i2c.c. This is only enabled for kernels >= 2.6.34. Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- compat/compat-3.4.c | 442 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.4.h | 4 + 2 files changed, 446 insertions(+) diff --git a/compat/compat-3.4.c b/compat/compat-3.4.c index 4721fa2d..4ff439b9 100644 --- a/compat/compat-3.4.c +++ b/compat/compat-3.4.c @@ -11,6 +11,448 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +#include +#include +#include + +#define setsda(adap, val) adap->setsda(adap->data, val) +#define setscl(adap, val) adap->setscl(adap->data, val) +#define getsda(adap) adap->getsda(adap->data) +#define getscl(adap) adap->getscl(adap->data) + +#define bit_dbg(level, dev, format, args...) \ + do {} while (0) + +static inline void sdalo(struct i2c_algo_bit_data *adap) +{ + setsda(adap, 0); + udelay((adap->udelay + 1) / 2); +} + +static inline void sdahi(struct i2c_algo_bit_data *adap) +{ + setsda(adap, 1); + udelay((adap->udelay + 1) / 2); +} + +static inline void scllo(struct i2c_algo_bit_data *adap) +{ + setscl(adap, 0); + udelay(adap->udelay / 2); +} + +static int sclhi(struct i2c_algo_bit_data *adap) +{ + unsigned long start; + + setscl(adap, 1); + + /* Not all adapters have scl sense line... */ + if (!adap->getscl) + goto done; + + start = jiffies; + while (!getscl(adap)) { + /* This hw knows how to read the clock line, so we wait + * until it actually gets high. This is safer as some + * chips may hold it low ("clock stretching") while they + * are processing data internally. + */ + if (time_after(jiffies, start + adap->timeout)) { + /* Test one last time, as we may have been preempted + * between last check and timeout test. + */ + if (getscl(adap)) + break; + return -ETIMEDOUT; + } + cpu_relax(); + } +#ifdef DEBUG + if (jiffies != start && i2c_debug >= 3) + pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go " + "high\n", jiffies - start); +#endif + +done: + udelay(adap->udelay); + return 0; +} + +static void i2c_start(struct i2c_algo_bit_data *adap) +{ + /* assert: scl, sda are high */ + setsda(adap, 0); + udelay(adap->udelay); + scllo(adap); +} + +static void i2c_repstart(struct i2c_algo_bit_data *adap) +{ + /* assert: scl is low */ + sdahi(adap); + sclhi(adap); + setsda(adap, 0); + udelay(adap->udelay); + scllo(adap); +} + + +static void i2c_stop(struct i2c_algo_bit_data *adap) +{ + /* assert: scl is low */ + sdalo(adap); + sclhi(adap); + setsda(adap, 1); + udelay(adap->udelay); +} + +static int i2c_outb(struct i2c_adapter *i2c_adap, unsigned char c) +{ + int i; + int sb; + int ack; + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + + /* assert: scl is low */ + for (i = 7; i >= 0; i--) { + sb = (c >> i) & 1; + setsda(adap, sb); + udelay((adap->udelay + 1) / 2); + if (sclhi(adap) < 0) { /* timed out */ + bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, " + "timeout at bit #%d\n", (int)c, i); + return -ETIMEDOUT; + } + /* FIXME do arbitration here: + * if (sb && !getsda(adap)) -> ouch! Get out of here. + * + * Report a unique code, so higher level code can retry + * the whole (combined) message and *NOT* issue STOP. + */ + scllo(adap); + } + sdahi(adap); + if (sclhi(adap) < 0) { /* timeout */ + bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, " + "timeout at ack\n", (int)c); + return -ETIMEDOUT; + } + + /* read ack: SDA should be pulled down by slave, or it may + * NAK (usually to report problems with the data we wrote). + */ + ack = !getsda(adap); /* ack: sda is pulled low -> success */ + bit_dbg(2, &i2c_adap->dev, "i2c_outb: 0x%02x %s\n", (int)c, + ack ? "A" : "NA"); + + scllo(adap); + return ack; + /* assert: scl is low (sda undef) */ +} + +static int i2c_inb(struct i2c_adapter *i2c_adap) +{ + /* read byte via i2c port, without start/stop sequence */ + /* acknowledge is sent in i2c_read. */ + int i; + unsigned char indata = 0; + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + + /* assert: scl is low */ + sdahi(adap); + for (i = 0; i < 8; i++) { + if (sclhi(adap) < 0) { /* timeout */ + bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit " + "#%d\n", 7 - i); + return -ETIMEDOUT; + } + indata *= 2; + if (getsda(adap)) + indata |= 0x01; + setscl(adap, 0); + udelay(i == 7 ? adap->udelay / 2 : adap->udelay); + } + /* assert: scl is low */ + return indata; +} + +static int try_address(struct i2c_adapter *i2c_adap, + unsigned char addr, int retries) +{ + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + int i, ret = 0; + + for (i = 0; i <= retries; i++) { + ret = i2c_outb(i2c_adap, addr); + if (ret == 1 || i == retries) + break; + bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n"); + i2c_stop(adap); + udelay(adap->udelay); + yield(); + bit_dbg(3, &i2c_adap->dev, "emitting start condition\n"); + i2c_start(adap); + } + if (i && ret) + bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at " + "0x%02x: %s\n", i + 1, + addr & 1 ? "read from" : "write to", addr >> 1, + ret == 1 ? "success" : "failed, timeout?"); + return ret; +} + +static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) +{ + unsigned short flags = msg->flags; + unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + + unsigned char addr; + int ret, retries; + + retries = nak_ok ? 0 : i2c_adap->retries; + + if (flags & I2C_M_TEN) { + /* a ten bit address */ + addr = 0xf0 | ((msg->addr >> 7) & 0x06); + bit_dbg(2, &i2c_adap->dev, "addr0: %d\n", addr); + /* try extended address code...*/ + ret = try_address(i2c_adap, addr, retries); + if ((ret != 1) && !nak_ok) { + dev_err(&i2c_adap->dev, + "died at extended address code\n"); + return -ENXIO; + } + /* the remaining 8 bit address */ + ret = i2c_outb(i2c_adap, msg->addr & 0xff); + if ((ret != 1) && !nak_ok) { + /* the chip did not ack / xmission error occurred */ + dev_err(&i2c_adap->dev, "died at 2nd address code\n"); + return -ENXIO; + } + if (flags & I2C_M_RD) { + bit_dbg(3, &i2c_adap->dev, "emitting repeated " + "start condition\n"); + i2c_repstart(adap); + /* okay, now switch into reading mode */ + addr |= 0x01; + ret = try_address(i2c_adap, addr, retries); + if ((ret != 1) && !nak_ok) { + dev_err(&i2c_adap->dev, + "died at repeated address code\n"); + return -EIO; + } + } + } else { /* normal 7bit address */ + addr = msg->addr << 1; + if (flags & I2C_M_RD) + addr |= 1; + if (flags & I2C_M_REV_DIR_ADDR) + addr ^= 1; + ret = try_address(i2c_adap, addr, retries); + if ((ret != 1) && !nak_ok) + return -ENXIO; + } + + return 0; +} + +static int sendbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) +{ + const unsigned char *temp = msg->buf; + int count = msg->len; + unsigned short nak_ok = msg->flags & I2C_M_IGNORE_NAK; + int retval; + int wrcount = 0; + + while (count > 0) { + retval = i2c_outb(i2c_adap, *temp); + + /* OK/ACK; or ignored NAK */ + if ((retval > 0) || (nak_ok && (retval == 0))) { + count--; + temp++; + wrcount++; + + /* A slave NAKing the master means the slave didn't like + * something about the data it saw. For example, maybe + * the SMBus PEC was wrong. + */ + } else if (retval == 0) { + dev_err(&i2c_adap->dev, "sendbytes: NAK bailout.\n"); + return -EIO; + + /* Timeout; or (someday) lost arbitration + * + * FIXME Lost ARB implies retrying the transaction from + * the first message, after the "winning" master issues + * its STOP. As a rule, upper layer code has no reason + * to know or care about this ... it is *NOT* an error. + */ + } else { + dev_err(&i2c_adap->dev, "sendbytes: error %d\n", + retval); + return retval; + } + } + return wrcount; +} + +static int acknak(struct i2c_adapter *i2c_adap, int is_ack) +{ + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + + /* assert: sda is high */ + if (is_ack) /* send ack */ + setsda(adap, 0); + udelay((adap->udelay + 1) / 2); + if (sclhi(adap) < 0) { /* timeout */ + dev_err(&i2c_adap->dev, "readbytes: ack/nak timeout\n"); + return -ETIMEDOUT; + } + scllo(adap); + return 0; +} + +static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) +{ + int inval; + int rdcount = 0; /* counts bytes read */ + unsigned char *temp = msg->buf; + int count = msg->len; + const unsigned flags = msg->flags; + + while (count > 0) { + inval = i2c_inb(i2c_adap); + if (inval >= 0) { + *temp = inval; + rdcount++; + } else { /* read timed out */ + break; + } + + temp++; + count--; + + /* Some SMBus transactions require that we receive the + transaction length as the first read byte. */ + if (rdcount == 1 && (flags & I2C_M_RECV_LEN)) { + if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { + if (!(flags & I2C_M_NO_RD_ACK)) + acknak(i2c_adap, 0); + dev_err(&i2c_adap->dev, "readbytes: invalid " + "block length (%d)\n", inval); + return -EPROTO; + } + /* The original count value accounts for the extra + bytes, that is, either 1 for a regular transaction, + or 2 for a PEC transaction. */ + count += inval; + msg->len += inval; + } + + bit_dbg(2, &i2c_adap->dev, "readbytes: 0x%02x %s\n", + inval, + (flags & I2C_M_NO_RD_ACK) + ? "(no ack/nak)" + : (count ? "A" : "NA")); + + if (!(flags & I2C_M_NO_RD_ACK)) { + inval = acknak(i2c_adap, count); + if (inval < 0) + return inval; + } + } + return rdcount; +} + + +static u32 bit_func(struct i2c_adapter *adap) +{ + return I2C_FUNC_I2C | I2C_FUNC_NOSTART | I2C_FUNC_SMBUS_EMUL | + I2C_FUNC_SMBUS_READ_BLOCK_DATA | + I2C_FUNC_SMBUS_BLOCK_PROC_CALL | + I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; +} + +static int bit_xfer(struct i2c_adapter *i2c_adap, + struct i2c_msg msgs[], int num) +{ + struct i2c_msg *pmsg; + struct i2c_algo_bit_data *adap = i2c_adap->algo_data; + int i, ret; + unsigned short nak_ok; + + if (adap->pre_xfer) { + ret = adap->pre_xfer(i2c_adap); + if (ret < 0) + return ret; + } + + bit_dbg(3, &i2c_adap->dev, "emitting start condition\n"); + i2c_start(adap); + for (i = 0; i < num; i++) { + pmsg = &msgs[i]; + nak_ok = pmsg->flags & I2C_M_IGNORE_NAK; + if (!(pmsg->flags & I2C_M_NOSTART)) { + if (i) { + bit_dbg(3, &i2c_adap->dev, "emitting " + "repeated start condition\n"); + i2c_repstart(adap); + } + ret = bit_doAddress(i2c_adap, pmsg); + if ((ret != 0) && !nak_ok) { + bit_dbg(1, &i2c_adap->dev, "NAK from " + "device addr 0x%02x msg #%d\n", + msgs[i].addr, i); + goto bailout; + } + } + if (pmsg->flags & I2C_M_RD) { + /* read bytes into buffer*/ + ret = readbytes(i2c_adap, pmsg); + if (ret >= 1) + bit_dbg(2, &i2c_adap->dev, "read %d byte%s\n", + ret, ret == 1 ? "" : "s"); + if (ret < pmsg->len) { + if (ret >= 0) + ret = -EIO; + goto bailout; + } + } else { + /* write bytes from buffer */ + ret = sendbytes(i2c_adap, pmsg); + if (ret >= 1) + bit_dbg(2, &i2c_adap->dev, "wrote %d byte%s\n", + ret, ret == 1 ? "" : "s"); + if (ret < pmsg->len) { + if (ret >= 0) + ret = -EIO; + goto bailout; + } + } + } + ret = i; + +bailout: + bit_dbg(3, &i2c_adap->dev, "emitting stop condition\n"); + i2c_stop(adap); + + if (adap->post_xfer) + adap->post_xfer(i2c_adap); + return ret; +} + + +const struct i2c_algorithm i2c_bit_algo = { + .master_xfer = bit_xfer, + .functionality = bit_func, +}; +EXPORT_SYMBOL(i2c_bit_algo); +#endif + int simple_open(struct inode *inode, struct file *file) { if (inode->i_private) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index f3437959..e603f4c2 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -8,6 +8,10 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +extern const struct i2c_algorithm i2c_bit_algo; +#endif + extern int simple_open(struct inode *inode, struct file *file); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) -- cgit v1.2.3 From 175c4e6276344a788e13c67704bb6aaf4228676e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 2 Jul 2012 17:22:14 +0300 Subject: compat: Backport DIV_ROUND_UP_DLL macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit 36a26c69b4c70396ef569c3452690fba0c1dec08 Author: Nicholas Bellinger Date: Tue Jul 26 00:35:26 2011 -0700 kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.1.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index da8e971c..5998bb16 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -9,6 +9,20 @@ #include #include #include +#include + + +/* This backports: + * + * commit 36a26c69b4c70396ef569c3452690fba0c1dec08 + * Author: Nicholas Bellinger + * Date: Tue Jul 26 00:35:26 2011 -0700 + * + * kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage + */ + +#define DIV_ROUND_UP_ULL(ll,d) \ + ({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; }) /* Backports 56f8a75c */ static inline bool ip_is_fragment(const struct iphdr *iph) -- cgit v1.2.3 From 8a6154ef64056cb2ff42418234b3af9f91590f89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 3 Jul 2012 23:03:38 +0300 Subject: compat: Backport cpufreq_quick_get_max() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit 3d73710880afa3d61cf57b5d4eb192e812eb7e4f Author: Jesse Barnes Date: Tue Jun 28 10:59:12 2011 -0700 cpufreq: expose a cpufreq_quick_get_max routine Trying kernel 3.4.0-030400-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- compat/compat-3.1.c | 24 ++++++++++++++++++++++++ include/linux/compat-3.1.h | 1 + 2 files changed, 25 insertions(+) diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index d427dd3d..e81a3e78 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -9,6 +9,30 @@ */ #include +#include + +/* This backports: + * commit 3d73710880afa3d61cf57b5d4eb192e812eb7e4f + * Author: Jesse Barnes + * Date: Tue Jun 28 10:59:12 2011 -0700 + * + * cpufreq: expose a cpufreq_quick_get_max routine + */ + +unsigned int cpufreq_quick_get_max(unsigned int cpu) +{ + struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + unsigned int ret_freq = 0; + + if (policy) { + ret_freq = policy->max; + cpufreq_cpu_put(policy); + } + + return ret_freq; +} +EXPORT_SYMBOL(cpufreq_quick_get_max); + static DEFINE_SPINLOCK(simple_ida_lock); diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 5998bb16..bf8a4ef3 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -102,6 +102,7 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, gfp_t gfp_mask); void ida_simple_remove(struct ida *ida, unsigned int id); +unsigned int cpufreq_quick_get_max(unsigned int cpu); #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From 9b1fe917cb70cccffafdb301ac5e21f1e1d454db Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 4 Jul 2012 16:13:36 -0700 Subject: compat: update the 3.4 PPA kernels Ubuntu has updated their 3.4 vanilla kernel offerings long ago from 3.4.0 to 3.4.4. Update the respective URLs on bin/get-compat-kernels so that new users get this new kernel release. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 6ebaa0c0..fc58dd4c 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -111,9 +111,9 @@ function get_ubuntu_kernels() { KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400_3.4.0-030400.201205210521_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-headers-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.4-precise/linux-image-3.4.0-030400-generic_3.4.0-030400.201205210521_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" + KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" + KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-image-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" for i in $KERNELS; do FILE=$(basename $i) -- cgit v1.2.3 From dca8b51336c2527c1cdf5065339fc72e37bd7da8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 12:15:07 -0700 Subject: compat: fix ckmake -t return file Skip removing the return file early given that we are running twice. The ret-tmp.txt will now exist on if ckmake is run without -t but I can't currently figure out how to properly fix this. I welcome a proper fix. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index da4ce8c9..5468b7af 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -144,7 +144,6 @@ if [[ $TIME != "1" ]]; then rm -f $LOG_TMP RET=$(cat $RET_FILE) - rm -f $RET_FILE exit $RET fi -- cgit v1.2.3 From 39c4a34f725ccf2431237682b4eecf478bd16c97 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 12:58:37 -0700 Subject: compat: explain what bin/get-compat-kernels does upon running This lets the user bail out in case they don't want to do what the script says it does. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index fc58dd4c..3fad1951 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -10,6 +10,16 @@ # to test compile the Linux kernel compatibility module. You can # then use ckmake to cross compile against all supported kernels. +# Pretty colors +GREEN="\033[01;32m" +YELLOW="\033[01;33m" +NORMAL="\033[00m" +BLUE="\033[34m" +RED="\033[31m" +PURPLE="\033[35m" +CYAN="\033[36m" +UNDERLINE="\033[02m" + KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" @@ -191,4 +201,22 @@ if [[ $# -eq 1 && $1 = "-i" ]]; then INSTALL_IMAGES="y" fi +echo -e "This will download ${YELLOW}21${NORMAL} kernel headers to allow you to" +echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." +echo -e "The download payload is about ${YELLOW}~220 ${CYAN}MiB${NORMAL}, once uncompressed" +echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL}" +echo -e "and consume about ${YELLOW}2 ${RED}GiB${NORMAL} of space." +echo -e "" +echo -e "The kernel headers used are from ${PURPLE}${UNDERLINE}Vanilla${NORMAL} kernels" +echo -e "from the Ubuntu mainline / vanilla kernel PPA:" +echo -e "" +echo -e "${BLUE}http://kernel.ubuntu.com/~kernel-ppa/mainline/${NORMAL}" +echo -e "" + +read -p "Do you still want to continue (y/N)? " +if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 +fi + get_ubuntu_kernels -- cgit v1.2.3 From ef9c79c92d067055560c364588f51a9f26f109b7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:05:27 -0700 Subject: compat: add install-ckmake target Lets users quickly install ckmake onto /usr/bin/ with DESTDIR as an option target directory. Signed-off-by: Luis R. Rodriguez --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 05a7d725..cd4fc213 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ export KLIB:= /lib/modules/$(shell uname -r) endif export KLIB_BUILD ?= $(KLIB)/build +DESTDIR?= + ifeq ($(KERNELRELEASE),) export PWD := $(shell pwd) export COMPAT_BASE_TREE := "linux-next.git" @@ -69,6 +71,10 @@ $(COMPAT_CONFIG): install: modules +install-ckmake: + @mkdir -p $(DESTDIR)/usr/bin/ + @install bin/ckmake $(DESTDIR)/usr/bin/ + clean: $(MAKE) -C $(KLIB_BUILD) M=$(PWD) clean -- cgit v1.2.3 From 7b9d7f034f84d73647e22de5be3742fb0768b761 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:24:28 -0700 Subject: compat: bin/get-compat-kernels dump deb packages into debs Don't clutter the home compat base directory. Signed-off-by: Luis R. Rodriguez --- .gitignore | 1 + bin/get-compat-kernels | 3 +++ 2 files changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index 498cb5ad..13317962 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ compat/*.ko modules.order modules *.patch +debs/ diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 3fad1951..f6a7ef48 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -125,6 +125,9 @@ function get_ubuntu_kernels() { KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-image-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" + mkdir -p debs + cd debs + for i in $KERNELS; do FILE=$(basename $i) PKG=$(echo $FILE | awk -F"_" '{print $1}') -- cgit v1.2.3 From 21ca3cc147d129f04fa0c5ec3db5958caf03cdb8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:34:15 -0700 Subject: compat: use a generic install mechanism for bin/get-compat-kernels The script bin/get-compat-kernels used to behave differently depending on the Linux distribution used. Remove this junk given that even on Debian based systems there are "conflicts" being run into when installing all the kernel headers: a higher version of libc is being asked for newer kernels. Dump this stuff and instead use the same mechanism to install the kernel headers for all Linux distributions. This uses ar and tar. If ar is not available warn the user that binutils is required. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 66 ++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 35 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index f6a7ef48..9fa23eb8 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -143,43 +143,32 @@ function get_ubuntu_kernels() { fi done - LSB_RED_ID=$(/usr/bin/lsb_release -i -s) - case $LSB_RED_ID in - "Ubuntu") - # Install with dpkg - sudo dpkg -i *.deb - ;; - *) - # For every other distribution around - - # Create a temporary directory first - TEMP_DIR=`mktemp -d` - - for deb in $(ls linux-*.deb); do - DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') - if [[ ! -d /usr/src/$DIR_NAME ]]; then - echo "Extracting $deb..." - ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR - fi - done - - # Move the extracted folders into the system - if [[ -d $TEMP_DIR/lib/modules ]]; then - mv $TEMP_DIR/lib/modules/* /lib/modules - fi - if [[ -d $TEMP_DIR/usr/src ]]; then - # Because of a bug in make < 3.82, mixed implicit and normal - # rules do not cause harm. Since the bug is fixed in the new make - # we have to adjust older kernel's Makefiles to fix the bug. - sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null - - mv $TEMP_DIR/usr/src/* /usr/src + # Create a temporary directory first + TEMP_DIR=`mktemp -d` + + for deb in $(ls linux-*.deb); do + DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') + if [[ ! -d /usr/src/$DIR_NAME ]]; then + echo "Extracting $deb..." + ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR fi + done - # Remove the temporary directory - rm -rf $TEMP_DIR - ;; - esac + # Move the extracted folders into the system + if [[ -d $TEMP_DIR/lib/modules ]]; then + mv $TEMP_DIR/lib/modules/* /lib/modules + fi + if [[ -d $TEMP_DIR/usr/src ]]; then + # Because of a bug in make < 3.82, mixed implicit and normal + # rules do not cause harm. Since the bug is fixed in the new make + # we have to adjust older kernel's Makefiles to fix the bug. + sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null + + mv $TEMP_DIR/usr/src/* /usr/src + fi + + # Remove the temporary directory + rm -rf $TEMP_DIR } function usage() { @@ -204,6 +193,13 @@ if [[ $# -eq 1 && $1 = "-i" ]]; then INSTALL_IMAGES="y" fi +which ar 2>&1 > /dev/null +if [[ $? -ne 0 ]]; then + echo -e "${GREEN}ar${NORMAL} is not avilable, typically this is available through a package called binutils" + echo -e "Install binutils and run this script again..." + exit 1 +fi + echo -e "This will download ${YELLOW}21${NORMAL} kernel headers to allow you to" echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." echo -e "The download payload is about ${YELLOW}~220 ${CYAN}MiB${NORMAL}, once uncompressed" -- cgit v1.2.3 From 2cd1d4d2792e54b458a856d3f6e83f6cfffe650d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:37:51 -0700 Subject: compat: fix bin/get-compat-kernels install calls The installation requires running sudo on other calls. Fix by adding sudo calls. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 9fa23eb8..61ea40c9 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -156,19 +156,19 @@ function get_ubuntu_kernels() { # Move the extracted folders into the system if [[ -d $TEMP_DIR/lib/modules ]]; then - mv $TEMP_DIR/lib/modules/* /lib/modules + sudo mv $TEMP_DIR/lib/modules/* /lib/modules fi if [[ -d $TEMP_DIR/usr/src ]]; then # Because of a bug in make < 3.82, mixed implicit and normal # rules do not cause harm. Since the bug is fixed in the new make # we have to adjust older kernel's Makefiles to fix the bug. - sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null + sudo sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null - mv $TEMP_DIR/usr/src/* /usr/src + sudo mv $TEMP_DIR/usr/src/* /usr/src fi # Remove the temporary directory - rm -rf $TEMP_DIR + sudo rm -rf $TEMP_DIR } function usage() { -- cgit v1.2.3 From 61077651424add644401b927b52681a191bbd7f1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:44:51 -0700 Subject: compat: unify kernel URLs for bin/get-compat-kernels We're using the same URLs for all Linux distributions now that we have support to install these through a distribution agnostic manner. No need to make the URLs part of the routine. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 156 ++++++++++++++++++++++++------------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 61ea40c9..c0bf8480 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -23,107 +23,107 @@ UNDERLINE="\033[02m" KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" -function get_ubuntu_kernels() { +KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" - ARCH=$(uname -m) - TARGET="" +KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" - case $ARCH in - "x86_64") - TARGET="amd64" - ;; - "i686") - TARGET="i386" - ;; - *) - echo -e "Unsupported architecture" - exit - ;; - esac +KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-image-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" +function get_ubuntu_kernels() { - KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" + ARCH=$(uname -m) + TARGET="" - KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" - KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-image-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" + case $ARCH in + "x86_64") + TARGET="amd64" + ;; + "i686") + TARGET="i386" + ;; + *) + echo -e "Unsupported architecture" + exit + ;; + esac mkdir -p debs cd debs -- cgit v1.2.3 From 1da55a182c1003520275a1bdf656c8deaec6f538 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 13:55:19 -0700 Subject: compat: compute approx space used dynamically for bin/get-compat-kernels This assumes about ~ 101 MiB of space is consumed by each kernel when we uncompress the kernel headers under /usr/src/ and /lib/modules/. It also assumes each kernel requires two deb files to be downloaded locally, each kernel then consuming ~ 13 MiB. When run this currently displays: mcgrof@tux ~/compat (git::master)$ ./bin/get-compat-kernels This will download 21 kernel headers to allow you to cross compile any module over these kernels with ckmake. The download payload is about ~ 273 MiB, once uncompressed it will use sudo to stash kernel header files under /usr/src/ and /lib/modules/ and consume about ~ 2121 MiB of space. The kernel headers used are from Vanilla kernels from the Ubuntu mainline / vanilla kernel PPA: http://kernel.ubuntu.com/~kernel-ppa/mainline/ Do you still want to continue (y/N)? Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index c0bf8480..ed74720a 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -200,11 +200,18 @@ if [[ $? -ne 0 ]]; then exit 1 fi -echo -e "This will download ${YELLOW}21${NORMAL} kernel headers to allow you to" +NUM_KERNELS=$(for i in $KERNELS; do echo $i; done | awk -F"v" '{print $2}' | awk -F"/" '{print $1}'| sort| uniq | wc -l) +# ~ 101 MiB for installed space on /usr/src/ and /lib/modules/ +SPACE_PER_KERNEL="101" + +# ~13 MiB of both deb files +SPACE_PER_KERNEL_DEB="13" + +echo -e "This will download ${YELLOW}${NUM_KERNELS}${NORMAL} kernel headers to allow you to" echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." -echo -e "The download payload is about ${YELLOW}~220 ${CYAN}MiB${NORMAL}, once uncompressed" -echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL}" -echo -e "and consume about ${YELLOW}2 ${RED}GiB${NORMAL} of space." +echo -e "The download payload is about ${YELLOW}~ $((${SPACE_PER_KERNEL_DEB} * ${NUM_KERNELS})) ${CYAN}MiB${NORMAL}, once uncompressed" +echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL} and ${BLUE}/lib/modules/${NORMAL}" +echo -e "and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." echo -e "" echo -e "The kernel headers used are from ${PURPLE}${UNDERLINE}Vanilla${NORMAL} kernels" echo -e "from the Ubuntu mainline / vanilla kernel PPA:" -- cgit v1.2.3 From 47dbccf1c7792c78efa422022ca8118f9824604c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 6 Jul 2012 14:18:39 -0700 Subject: compat: warn libc >= 2.14 is required to compile against 3.4.4 Warn when using bin/get-compat-kernels. We could later add a dynamic distro-agnostic check... Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index ed74720a..d80c0a79 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -210,11 +210,15 @@ SPACE_PER_KERNEL_DEB="13" echo -e "This will download ${YELLOW}${NUM_KERNELS}${NORMAL} kernel headers to allow you to" echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." echo -e "The download payload is about ${YELLOW}~ $((${SPACE_PER_KERNEL_DEB} * ${NUM_KERNELS})) ${CYAN}MiB${NORMAL}, once uncompressed" -echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL} and ${BLUE}/lib/modules/${NORMAL}" -echo -e "and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." +echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL}" +echo -e "and ${BLUE}/lib/modules/${NORMAL} and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." +echo -e "" +echo -e "Note: you will need ${CYAN}libc${NORMAL} > ${GREEN}2.14${NORMAL} otherwise compilation may" +echo -e "fail with Linux ${CYAN}3.4.4${NORMAL}" echo -e "" echo -e "The kernel headers used are from ${PURPLE}${UNDERLINE}Vanilla${NORMAL} kernels" -echo -e "from the Ubuntu mainline / vanilla kernel PPA:" +echo -e "from the Ubuntu mainline / vanilla kernel PPA and are extracted" +echo -e "using ${GREEN}ar${NORMAL} and ${GREEN}tar${NORMAL}:" echo -e "" echo -e "${BLUE}http://kernel.ubuntu.com/~kernel-ppa/mainline/${NORMAL}" echo -e "" -- cgit v1.2.3 From fcbb26df2b1ee826e62664e84b7bca23e32600fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 9 Jul 2012 16:47:03 +0300 Subject: compat: Directly call perl instead of skip-colors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since we can now install ckmake with make, drop dependency on scripts/skip-colors as it is a simple oneliner. Directly call perl instead of using it. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 5468b7af..2a0bb3de 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -41,7 +41,7 @@ done function tee_color_split() { while read; do - echo -e $REPLY | ./scripts/skip-colors >> $1 + echo -e $REPLY | perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' >> $1 echo -e $REPLY done } @@ -104,7 +104,7 @@ function run_ckmake() # We cannot use tee_color_split() as bash read only spits # out output when a newline comes in. We can modif IFS but # I am still not sure how to do this properly. - log_try_kernel $KERNEL | ./scripts/skip-colors >> $LOG + log_try_kernel $KERNEL | perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' >> $LOG log_try_kernel $KERNEL #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG -- cgit v1.2.3 From 8e2dcf0b43daaaf5667da7cba1800d2c9abef126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 9 Jul 2012 17:31:53 +0300 Subject: compat: Don't download ubuntu specific kernel images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The linux-image debs are quite specific to Ubuntu as they will at least require generating a compliant initramfs before being able to boot into them both in Ubuntu and in other distributions. The image installation is also the only part that avoids us from switching to non-root builds. Drop this feature completely. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index d80c0a79..a22814c8 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -25,87 +25,66 @@ KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-image-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-image-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-image-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-image-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-image-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-image-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-image-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-image-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-image-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-image-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-image-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-image-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-image-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-image-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-image-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-image-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-image-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-image-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-image-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-image-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-image-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" function get_ubuntu_kernels() { @@ -132,11 +111,6 @@ function get_ubuntu_kernels() { FILE=$(basename $i) PKG=$(echo $FILE | awk -F"_" '{print $1}') - echo "$i" | grep image 2>&1 > /dev/null - if [[ $? = 0 && $INSTALL_IMAGES != "y" ]]; then - continue - fi - # Do not download if installed or deb exists if [[ ! -d /usr/src/$PKG && ! -f $FILE ]]; then wget -c $i @@ -172,27 +146,14 @@ function get_ubuntu_kernels() { } function usage() { - echo -e "Usage: $0 [ -i ]" - echo -e "" - echo -e "If you specify [ -i ] you will also download all kernel images and install them" + echo -e "Usage: $0" } -INSTALL_IMAGES="n" - if [[ $# -gt 1 ]]; then usage exit fi -if [[ $# -eq 1 && $1 != "-i" ]]; then - usage - exit -fi - -if [[ $# -eq 1 && $1 = "-i" ]]; then - INSTALL_IMAGES="y" -fi - which ar 2>&1 > /dev/null if [[ $? -ne 0 ]]; then echo -e "${GREEN}ar${NORMAL} is not avilable, typically this is available through a package called binutils" -- cgit v1.2.3 From f85bd385bd61a4031640f05a2e3d3be702172629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 10 Jul 2012 15:13:08 +0300 Subject: compat: Don't keep 2 URL's per kernel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generate the filename of ARCH dependent .deb using sed. This is much more cleaner and less error-prone. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 48 ++++++------------------------------------------ 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index a22814c8..3d7a9d74 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -24,67 +24,26 @@ KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624-generic_2.6.24-020624_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625-generic_2.6.25-020625_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626-generic_2.6.26-020626_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627_2.6.27-020627_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.27/linux-headers-2.6.27-020627-generic_2.6.27-020627_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062810_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810-generic_2.6.28-02062810_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906-generic_2.6.29-02062906_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010-generic_2.6.30-02063010_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113-generic_2.6.31-02063113_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255-generic_2.6.32-02063255.201201251735_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305-generic_2.6.33-02063305_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410-generic_2.6.34-02063410.201111101535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512-generic_2.6.35-02063512.201111232118_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604-generic_2.6.36-02063604.201102180911_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706-generic_2.6.37-02063706.201103281005_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808-generic_2.6.38-02063808.201106040910_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904-generic_2.6.39-02063904.201108040905_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018-generic_3.0.18-030018.201201252135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110-generic_3.1.10-030110.201201181135_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202-generic_3.2.2-030202.201201252035_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307-generic_3.3.7-030307.201205211535_${TARGET}.deb" - KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404-generic_3.4.4-030404.201206221555_${TARGET}.deb" function get_ubuntu_kernels() { @@ -113,7 +72,12 @@ function get_ubuntu_kernels() { # Do not download if installed or deb exists if [[ ! -d /usr/src/$PKG && ! -f $FILE ]]; then + # Download the _all.deb wget -c $i + + # Download the generic-ARCH headers + GENERIC_DEB=`echo $i | sed -e "s:\(.*\)_\(.*\)_all.deb:\1-generic_\2_$TARGET.deb:"` + wget -c $GENERIC_DEB fi done @@ -161,7 +125,7 @@ if [[ $? -ne 0 ]]; then exit 1 fi -NUM_KERNELS=$(for i in $KERNELS; do echo $i; done | awk -F"v" '{print $2}' | awk -F"/" '{print $1}'| sort| uniq | wc -l) +NUM_KERNELS=$(echo $KERNELS | wc -w) # ~ 101 MiB for installed space on /usr/src/ and /lib/modules/ SPACE_PER_KERNEL="101" -- cgit v1.2.3 From e7d88d67040bbaa79720fa1b2dfc4fc24e4d004f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Wed, 11 Jul 2012 13:26:56 +0300 Subject: compat: Add ability to run as non-root MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit get-compat-kernels now extracts the kernel headers into $HOME/compat-ksrc if the user is not root. Similarly, ckmake tries first to use $HOME/compat-ksrc if it exists. If not, it fallbacks to system-wide /usr/src silently. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 9 +++++- bin/get-compat-kernels | 76 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 2a0bb3de..72e9b7eb 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -34,7 +34,14 @@ RET_FILE="ret-tmp.txt" RET="" -for i in $(find /lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do +# If $HOME/compat-ksrc is found use that, otherwise use system-wide +# sources in /usr/src. +KSRC_PREFIX= +if [[ -d "$HOME/compat-ksrc" ]]; then + KSRC_PREFIX="$HOME/compat-ksrc" +fi + +for i in $(find $KSRC_PREFIX/lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do KLIBS="$KLIBS $i" done diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 3d7a9d74..6d9d9fe0 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -23,6 +23,18 @@ UNDERLINE="\033[02m" KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" +KSRC_PREFIX= +# Check whether we're running as root or not +# If we're root stuff things into /usr/src and /lib/modules +# else, use $HOME/compat-ksrc for enabling user-mode builds. +if [[ "$EUID" != "0" ]]; then + KSRC_PREFIX="$HOME/compat-ksrc" +fi + +# Create target directories if they doesn't exist +mkdir -p $KSRC_PREFIX/{usr/src,lib/modules} + +# List of currently supported kernels that will be downloaded KERNELS="$KERNELS ${KPATH}/v2.6.24/linux-headers-2.6.24-020624_2.6.24-020624_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.25/linux-headers-2.6.25-020625_2.6.25-020625_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.26/linux-headers-2.6.26-020626_2.6.26-020626_all.deb" @@ -45,6 +57,15 @@ KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-03020 KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" +# Number of kernels +NUM_KERNELS=$(echo $KERNELS | wc -w) + +# ~ 101 MiB for installed space on $KSRC_PREFIX/usr/src/ and $KSRC_PREFIX/lib/modules/ +SPACE_PER_KERNEL="101" + +# ~13 MiB of both deb files +SPACE_PER_KERNEL_DEB="13" + function get_ubuntu_kernels() { ARCH=$(uname -m) @@ -71,7 +92,7 @@ function get_ubuntu_kernels() { PKG=$(echo $FILE | awk -F"_" '{print $1}') # Do not download if installed or deb exists - if [[ ! -d /usr/src/$PKG && ! -f $FILE ]]; then + if [[ ! -d $KSRC_PREFIX/usr/src/$PKG && ! -f $FILE ]]; then # Download the _all.deb wget -c $i @@ -81,32 +102,52 @@ function get_ubuntu_kernels() { fi done + # List of downloaded debs + DEB_LIST=`ls linux-*.deb 2>/dev/null` + + if [[ -z $DEB_LIST ]]; then + echo "All kernel sources are found in $KSRC_PREFIX/usr/src." + exit + fi + # Create a temporary directory first TEMP_DIR=`mktemp -d` - for deb in $(ls linux-*.deb); do + for deb in $DEB_LIST; do DIR_NAME=$(echo $deb | awk -F"_" '{print $1}') - if [[ ! -d /usr/src/$DIR_NAME ]]; then + if [[ ! -d $KSRC_PREFIX/usr/src/$DIR_NAME ]]; then echo "Extracting $deb..." - ar p $deb data.tar.gz | sudo tar xz --exclude=usr/share -C $TEMP_DIR + ar p $deb data.tar.gz | tar xz --exclude=usr/share -C $TEMP_DIR fi done # Move the extracted folders into the system if [[ -d $TEMP_DIR/lib/modules ]]; then - sudo mv $TEMP_DIR/lib/modules/* /lib/modules + + # Relink lib/modules/*/build/ directories relatively to make it work + # for regular user based workflows + if [[ -n $KSRC_PREFIX ]]; then + echo "Adjusting build/ symlinks for non-root installation..." + + for kernel in $(ls -d $TEMP_DIR/lib/modules/*generic); do + unlink $kernel/build + ln -s ../../../usr/src/linux-headers-`basename $kernel` $kernel/build + done + fi + + mv $TEMP_DIR/lib/modules/* $KSRC_PREFIX/lib/modules fi if [[ -d $TEMP_DIR/usr/src ]]; then # Because of a bug in make < 3.82, mixed implicit and normal # rules do not cause harm. Since the bug is fixed in the new make # we have to adjust older kernel's Makefiles to fix the bug. - sudo sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null + sed -i 's#^/ %/:#%/:#' $TEMP_DIR/usr/src/linux-headers-2.6.2[45678]-0*/Makefile &>/dev/null - sudo mv $TEMP_DIR/usr/src/* /usr/src + mv $TEMP_DIR/usr/src/* $KSRC_PREFIX/usr/src fi # Remove the temporary directory - sudo rm -rf $TEMP_DIR + rm -rf $TEMP_DIR } function usage() { @@ -115,9 +156,10 @@ function usage() { if [[ $# -gt 1 ]]; then usage - exit + exit 1 fi +# Check for the availability of 'ar' before continuing which ar 2>&1 > /dev/null if [[ $? -ne 0 ]]; then echo -e "${GREEN}ar${NORMAL} is not avilable, typically this is available through a package called binutils" @@ -125,18 +167,20 @@ if [[ $? -ne 0 ]]; then exit 1 fi -NUM_KERNELS=$(echo $KERNELS | wc -w) -# ~ 101 MiB for installed space on /usr/src/ and /lib/modules/ -SPACE_PER_KERNEL="101" +echo -e "" -# ~13 MiB of both deb files -SPACE_PER_KERNEL_DEB="13" +if [[ -n $KSRC_PREFIX ]]; then + echo -e "** Running as a non-privileged user!" + echo -e "** If you want to force using system-wide ${BLUE}/lib/modules${NORMAL} and ${BLUE}/usr/src${NORMAL}, you have to" + echo -e "** run this script as root or using ${GREEN}sudo${NORMAL}." + echo -e "" +fi echo -e "This will download ${YELLOW}${NUM_KERNELS}${NORMAL} kernel headers to allow you to" echo -e "cross compile any module over these kernels with ${GREEN}ckmake${NORMAL}." echo -e "The download payload is about ${YELLOW}~ $((${SPACE_PER_KERNEL_DEB} * ${NUM_KERNELS})) ${CYAN}MiB${NORMAL}, once uncompressed" -echo -e "it will use ${GREEN}sudo${NORMAL} to stash kernel header files under ${BLUE}/usr/src/${NORMAL}" -echo -e "and ${BLUE}/lib/modules/${NORMAL} and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." +echo -e "it will stash kernel header files under ${BLUE}$KSRC_PREFIX/usr/src/${NORMAL}" +echo -e "and ${BLUE}$KSRC_PREFIX/lib/modules/${NORMAL} and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." echo -e "" echo -e "Note: you will need ${CYAN}libc${NORMAL} > ${GREEN}2.14${NORMAL} otherwise compilation may" echo -e "fail with Linux ${CYAN}3.4.4${NORMAL}" -- cgit v1.2.3 From 23b5738479db1c23fcda16d87c7612c6fe0c63ae Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 13:49:40 -0700 Subject: compat: add bin/get-compat-trees While reviewing ideas of optimizing the time to bring down the compilation time of ckmake from 120 minutes down to something much smaller we're considering both Big Iron (tm) and using distcc. Using disticc won't work well unless you have low latency so the target instead is to build a set of regional clusters which have low latency to enable targeting compilation time down by splitting up the number of kernels each cluster would have to to handle. We'll do this in three steps: 1) Enable getting compat distcc requirements easily 2) Modify ckmake to enable building only a set of kernel ranges 3) Build regional cluster for distcc This patch addresses part of the first objective, to enable build boxen to easily get the requirements needed. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 bin/get-compat-trees diff --git a/bin/get-compat-trees b/bin/get-compat-trees new file mode 100644 index 00000000..78171641 --- /dev/null +++ b/bin/get-compat-trees @@ -0,0 +1,79 @@ +#!/bin/bash +# +# Copyright (C) 2012, Luis R. Rodriguez +# +# 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. +# +# You can use this script to install all mainline kernels used +# to test compile the Linux kernel compatibility module. You can +# then use ckmake to cross compile against all supported kernels. + +# Pretty colors +GREEN="\033[01;32m" +YELLOW="\033[01;33m" +NORMAL="\033[00m" +BLUE="\033[34m" +RED="\033[31m" +PURPLE="\033[35m" +CYAN="\033[36m" +UNDERLINE="\033[02m" + +PREFIX=$HOME/ + +GIT_TREES="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" +GIT_TREES="$GIT_TREES git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git" +GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat.git" +GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-wireless.git" + +LINUX_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" + +echo -e "This will download xxx amount of code from git trees." + +read -p "Do you still want to continue (y/N)? " +if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 +fi + +mkdir -p $PREFIX +cd $PREFIX + +for i in $GIT_TREES; do + TREE=$(echo ${i} | awk -F"/" '{print $NF}') + + if [[ -d $PREFIX/$TREE ]]; then + echo "${GREEN}${TREE}${NORMAL} is already present, skipping..." + continue + fi + + echo -e "Cloning ${GREEN}${TREE}${NORMAL}..." + + case $TREE in + "linux-stable.git") + cd $PREFIX/ + git clone $i + + cd $PREFIX/linux-stable + # This lets us bake releases off of Linus' RC releases by + # simply git fetch'ing "linus" and reseting the tree afterwards. + git remote add linus $LINUX_GIT + ;; + "linux-next.git") + cd $PREFIX + git clone $i --reference $PREFIX/linux-stable/.git/ + ;; + "compat-wireless.git") + # This is just what scripts are tested for. Probably best to + # unify all into one place but this will do for now. + mkdir -p $PREFIX/devel/ + cd $PREFIX/devel/ + git clone $i + ;; + *) + cd $PREFIX + git clone $i + ;; + esac +done -- cgit v1.2.3 From 2ff30918d6bb24e230d0aef6cc2fcf7429eaa409 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 13:56:24 -0700 Subject: compat: chmod 755 bin/get-compat-trees Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/get-compat-trees diff --git a/bin/get-compat-trees b/bin/get-compat-trees old mode 100644 new mode 100755 -- cgit v1.2.3 From 4e9ed3adccf9c30df6c2c2c70683af8136ebacab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 13:59:05 -0700 Subject: compat: check if git is installed on get-compat-trees Bail out if it is not present. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bin/get-compat-trees b/bin/get-compat-trees index 78171641..25425c7a 100755 --- a/bin/get-compat-trees +++ b/bin/get-compat-trees @@ -29,6 +29,12 @@ GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-wireless.git" LINUX_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" +which git +if [[ $? -ne 0 ]]; then + echo -e "You need to install ${PURPLE}git${NORMAL}" + exit 1 +fi + echo -e "This will download xxx amount of code from git trees." read -p "Do you still want to continue (y/N)? " -- cgit v1.2.3 From 933c59e1eb6cccbcf1ec886baa5d055c11714995 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 14:01:55 -0700 Subject: compat: send which output to /dev/null for bin/get-compat-trees Minor cosmetic fix on checking if git is installed. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get-compat-trees b/bin/get-compat-trees index 25425c7a..56ce2290 100755 --- a/bin/get-compat-trees +++ b/bin/get-compat-trees @@ -29,7 +29,7 @@ GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-wireless.git" LINUX_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" -which git +which git 2>&1 > /dev/null if [[ $? -ne 0 ]]; then echo -e "You need to install ${PURPLE}git${NORMAL}" exit 1 -- cgit v1.2.3 From f2e9fa884a4e810ed2268bdc69ce93074aa3717a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 14:25:48 -0700 Subject: compat: update estimates of using get-compat-trees This is what we will output: This will typically take ~ 10 minutes, download about ~ 1 GiB of data over your network, and then consume about ~ 2 GiB of hard drive space. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/get-compat-trees b/bin/get-compat-trees index 56ce2290..00a881ac 100755 --- a/bin/get-compat-trees +++ b/bin/get-compat-trees @@ -35,7 +35,9 @@ if [[ $? -ne 0 ]]; then exit 1 fi -echo -e "This will download xxx amount of code from git trees." +echo -e "This will typically take ~ ${YELLOW}10 ${CYAN}minutes${NORMAL}, download about " +echo -e "~ ${YELLOW}1 ${CYAN}GiB${NORMAL} of data over your network, and then consume about " +echo -e "~ ${YELLOW}2 ${CYAN}GiB${NORMAL} of hard drive space." read -p "Do you still want to continue (y/N)? " if [[ "${REPLY}" != "y" ]]; then -- cgit v1.2.3 From 76ae6b8d930ad4fdc7da0e7c81e1ffdb6c944c3d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 16 Jul 2012 16:58:25 -0700 Subject: compat: add kernel range support to ckmake If we want to redistribute kernel compilation accross a set of build machines ckmake needs to understand which target kernels we want to work on. This enables kernel ranges to be passed on to ckmake. Here's one example, if you use -d it enables debugging to print the kernel version computation: mcgrof@tux ~/compat (git::master)$ ckmake -d 2.6.38..3.1 Going to use kernel ranges: 2.6.38..3.1 2.6.38 132646 <= 3.1.10 196864 <= 3.1 196864 2.6.38 132646 <= 3.0.18 196608 <= 3.1 196864 2.6.38 132646 <= 2.6.39 132647 <= 3.1 196864 2.6.38 132646 <= 2.6.38 132646 <= 3.1 196864 Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] This should enable us to do compilation on a set of kernels across a distributed set of machines now. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 7 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 72e9b7eb..8e98c349 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -29,9 +29,15 @@ LOG_TMP="ckmake-tmp.log" REPORT="ckmake-report.log" TIME="0" QUIET="" +DEBUG="" ARGS="" RET_FILE="ret-tmp.txt" +# First and last kernels to use +FIRST="" +LAST="" +RANGE="" + RET="" # If $HOME/compat-ksrc is found use that, otherwise use system-wide @@ -41,10 +47,6 @@ if [[ -d "$HOME/compat-ksrc" ]]; then KSRC_PREFIX="$HOME/compat-ksrc" fi -for i in $(find $KSRC_PREFIX/lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do - KLIBS="$KLIBS $i" -done - function tee_color_split() { while read; do @@ -62,7 +64,7 @@ function log_try_kernel() function usage() { - echo -e "Usage: $0 [-t] " + echo -e "Usage: $0 [-t] " echo -e "-t will run: 'time ckmake; time ckmake' account for" echo -e " benchmark how long it takes to compile without ccache" echo -e " and a run after cache kicks in" @@ -71,6 +73,10 @@ function usage() echo -e " is the arguments you want to pass to the" echo -e "child make call that ckmake will use. For example if you have" echo -e "a target 'linux' on your Makefile you can run 'cmake linux'" + echo -e "" + echo -e " are the kernels you want to test" + echo -e "compile against. This consists of a range. The third extraversion" + echo -e "number is ignored" } for i in $@ ; do @@ -91,7 +97,20 @@ for i in $@ ; do QUIET="-s" shift ;; + "-d") + DEBUG="1" + shift + ;; *) + echo $i | grep "\.\." 2>&1 > /dev/null + if [[ $? -eq 0 ]]; then + FIRST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $1}') + LAST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $2}') + RANGE="${FIRST}..${LAST}" + echo -e "Going to use kernel ranges: ${BLUE}${FIRST}${NORMAL}..${BLUE}${LAST}${NORMAL}" + shift + fi + ARGS="${ARGS} $1" shift esac @@ -137,6 +156,56 @@ function run_ckmake() echo $RET > $RET_FILE } +# This mimic's the kernel's own algorithm: +# +# KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +function kernel_version_orig { + echo "$@" | awk -F. '{ printf("%d\n", lshift($1,16) + lshift($2, 8) + $3); }' +} + +function kernel_version_26 { + kernel_version_orig $@ +} + +# Ignores the last extraversion number +function kernel_version_30 { + echo "$@" | awk -F. '{ printf("%d\n", lshift($1,16) + lshift($2, 8) ); }' +} + +# If we're using 3.0 kernels we do not require an extraversion, +# although one could be supplied. For purposes of this script +# though the 2.6.29..3.1 ranges are acceptable. If we forced usage +# of kernel_version_orig() for 3.0 it means we'd have to require a user +# to be very specific and specific 2.6.29..3.1.0 or whatever. Lets +# instead be flexible. +function kernel_version { + if [[ $(kernel_version_orig $@ ) -lt $(kernel_version_orig "3.0") ]] ; then + echo $(kernel_version_26 $@) + else + echo $(kernel_version_30 $@) + fi +} + +for i in $(find $KSRC_PREFIX/lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do + KERNEL=$(echo ${i} | awk -F"/" '{print $NF}' | awk -F"-" '{print $1}') + + if [[ ! -z $FIRST && ! -z $LAST ]]; then + if [[ $(kernel_version $KERNEL ) -lt $(kernel_version $FIRST) ]] ; then + continue; + fi + + if [[ $(kernel_version $KERNEL ) -gt $(kernel_version $LAST) ]] ; then + continue; + fi + + if [[ ! -z $DEBUG ]]; then + echo -e "${CYAN}${FIRST}${NORMAL} $(kernel_version $FIRST) <= ${GREEN}${KERNEL}${NORMAL} $(kernel_version $KERNEL) <= ${CYAN}${LAST}${NORMAL} $(kernel_version $LAST)" + fi + fi + + KLIBS="$KLIBS $i" +done + for i in $LOG $LOG_TMP $REPORT; do echo > $i done @@ -154,8 +223,8 @@ if [[ $TIME != "1" ]]; then exit $RET fi -time $0 $QUIET $ARGS | tee_color_split $REPORT -time $0 $QUIET $ARGS | egrep "real|user|sys" | tee_color_split $REPORT +time $0 $QUIET ${RANGE} $ARGS | tee_color_split $REPORT +time $0 $QUIET ${RANGE} $ARGS | egrep "real|user|sys" | tee_color_split $REPORT cat $LOG $REPORT > $LOG_TMP mv $LOG_TMP $LOG -- cgit v1.2.3 From e17d6531decd57c60744c5043f067cfa0c679d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 17 Jul 2012 15:48:22 +0300 Subject: compat: Use a bash function to colorify the messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Declare a prettify() function that takes a color and a message parameter instead of wrapping every message in the script with ANSI codes. Also add a nocolor mode which will be enabled with the -n flag. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 72 +++++++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 8e98c349..d4081607 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -11,15 +11,6 @@ # found. This relies on distribution specific kernels, but can handle # your own custom list of target kernels. Log is setnt to LOG variable. -# Pretty colors -GREEN="\033[01;32m" -YELLOW="\033[01;33m" -NORMAL="\033[00m" -BLUE="\033[34m" -RED="\033[31m" -PURPLE="\033[35m" -CYAN="\033[36m" -UNDERLINE="\033[02m" #export KCFLAGS="-Wno-unused-but-set-variable" KERNEL_DIR="/lib/modules" @@ -28,9 +19,10 @@ LOG="ckmake.log" LOG_TMP="ckmake-tmp.log" REPORT="ckmake-report.log" TIME="0" -QUIET="" -DEBUG="" +DEBUG="0" +NOCOLOR="0" ARGS="" +QUIET="" RET_FILE="ret-tmp.txt" # First and last kernels to use @@ -47,6 +39,42 @@ if [[ -d "$HOME/compat-ksrc" ]]; then KSRC_PREFIX="$HOME/compat-ksrc" fi +# Colorify output if NOCOLOR != 1 or -n is not given +function prettify() +{ + if [[ $NOCOLOR == "1" ]]; then + echo -n "$2" + else + ANSI_CODE= + NORMAL="\033[00m" + case $1 in + "green") + ANSI_CODE="\033[01;32m" + ;; + "yellow") + ANSI_CODE="\033[01;33m" + ;; + "blue") + ANSI_CODE="\033[34m" + ;; + "red") + ANSI_CODE="\033[31m" + ;; + "purple") + ANSI_CODE="\033[35m" + ;; + "cyan") + ANSI_CODE="\033[36m" + ;; + "underline") + ANSI_CODE="\033[02m" + ;; + esac + + echo -e -n "${ANSI_CODE}$2${NORMAL}" + fi +} + function tee_color_split() { while read; do @@ -57,9 +85,7 @@ function tee_color_split() function log_try_kernel() { - echo -en "Trying kernel ${BLUE}" - printf "%40s\t" "${1}" - echo -en "${NORMAL}" + printf "Trying kernel %40s\t" "$(prettify blue $1)" } function usage() @@ -68,6 +94,7 @@ function usage() echo -e "-t will run: 'time ckmake; time ckmake' account for" echo -e " benchmark how long it takes to compile without ccache" echo -e " and a run after cache kicks in" + echo -e "-n Do not use colors in the output" echo -e "-q will ask ckmake to run make with -s to only output errors" echo echo -e " is the arguments you want to pass to the" @@ -93,6 +120,10 @@ for i in $@ ; do TIME="1" shift ;; + "-n") + NOCOLOR="1" + shift + ;; "-s") QUIET="-s" shift @@ -107,7 +138,7 @@ for i in $@ ; do FIRST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $1}') LAST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $2}') RANGE="${FIRST}..${LAST}" - echo -e "Going to use kernel ranges: ${BLUE}${FIRST}${NORMAL}..${BLUE}${LAST}${NORMAL}" + echo -e "Going to use kernel ranges: $(prettify blue $FIRST)..$(prettify blue $LAST)" shift fi @@ -127,10 +158,7 @@ function run_ckmake() continue fi - # We cannot use tee_color_split() as bash read only spits - # out output when a newline comes in. We can modif IFS but - # I am still not sure how to do this properly. - log_try_kernel $KERNEL | perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' >> $LOG + NOCOLOR="1" log_try_kernel $KERNEL >> $LOG log_try_kernel $KERNEL #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG @@ -142,9 +170,9 @@ function run_ckmake() fi if [[ $CUR_RET -eq 0 ]]; then - echo -e "${GREEN}[OK]${NORMAL}" | tee_color_split $LOG + echo -e "$(prettify green [OK])" | tee_color_split $LOG else - echo -e "${RED}[FAILED]${NORMAL}" | tee_color_split $LOG + echo -e "$(prettify red [FAILED])" | tee_color_split $LOG RET=$CUR_RET fi @@ -199,7 +227,7 @@ for i in $(find $KSRC_PREFIX/lib/modules/ -type d -name \*generic\* | sort -n -r fi if [[ ! -z $DEBUG ]]; then - echo -e "${CYAN}${FIRST}${NORMAL} $(kernel_version $FIRST) <= ${GREEN}${KERNEL}${NORMAL} $(kernel_version $KERNEL) <= ${CYAN}${LAST}${NORMAL} $(kernel_version $LAST)" + echo -e "$(prettify cyan $FIRST) $(kernel_version $FIRST) <= $(prettify green $KERNEL) $(kernel_version $KERNEL) <= $(prettify cyan $LAST) $(kernel_version $LAST)" fi fi -- cgit v1.2.3 From 3da0495cf863288b6798e121ccf93c4453c6c768 Mon Sep 17 00:00:00 2001 From: Zefir Kurtisi Date: Fri, 13 Jul 2012 10:38:34 +0200 Subject: compat: fix system crash on 2.6.35 when flushing work Ubuntu 10.10 stock kernel (2.6.35-22-generic) crashes in compat_flush_scheduled_work(), that is called e.g. when mac80211 module is unloaded. The problem was introduced with 80bf8a83 compat: backport system work queues system_wq and system_long_wq The crash happens in compat_flush_scheduled_work() where both flush_workqueue() and flush_scheduled_work() are called successively. Removing one of them resolves the issue. All compat-wireless tarballs after 2012-03-18 are affected. Signed-off-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 9190ecd8..8f25be0a 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -140,7 +140,6 @@ void compat_flush_scheduled_work(void) * go with the old kernel's one first for now (keventd_wq) and * if think its reasonable later we can flip this around. */ - flush_workqueue(system_wq); flush_scheduled_work(); } EXPORT_SYMBOL_GPL(compat_flush_scheduled_work); -- cgit v1.2.3 From 452c560abcccf596891fca10f1e84cf481236211 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 19 Jul 2012 18:22:55 -0700 Subject: compat: backport eth_random_addr() This really was a rename but to make code simpler just reimplement this for all kernels. commit 0a4dd594982a321699000218715e28664ec49169 Author: Joe Perches Date: Thu Jul 12 19:33:05 2012 +0000 etherdevice: Rename random_ether_addr to eth_random_addr Add some API symmetry to eth_broadcast_addr and add a #define to the old name for backward compatibility. Signed-off-by: Joe Perches Signed-off-by: David S. Miller mcgrof@tux ~/compat (git::master)$ ckmake -t Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 4m25.765s user 9m56.460s sys 1m24.650s real 2m7.808s user 3m20.640s sys 0m40.520s Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.6.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 9da8ec50..0b36ca00 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -6,6 +6,21 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) #include +#include + +/** + * eth_random_addr - Generate software assigned random Ethernet address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Generate a random Ethernet address (MAC) that is not multicast + * and has the local assigned bit set. + */ +static inline void eth_random_addr(u8 *addr) +{ + get_random_bytes(addr, ETH_ALEN); + addr[0] &= 0xfe; /* clear multicast bit */ + addr[0] |= 0x02; /* set local assignment bit (IEEE802) */ +} #define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN) -- cgit v1.2.3 From 4ac7e598ebb8d026fc1aa0c464db36a1c7bc18f6 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 19 Jul 2012 20:35:53 -0700 Subject: compat: backport irq_modify_status() irq_modify_status() was added as of 44247184 mcgrof@tux ~/linux-next (git::master)$ git describe --contains 44247184 v2.6.37-rc1~191^2~72 This backported implementation of irq_modify_status() however requires a bit of hacking, namely we need to use the old spin_lock_irqsave() instead of the new raw_spin_unlock_irqrestore() -- but given that the old version was used in older kernels I see no reasons why implement this with the new one the new one just does some typechecking. If someone wants to optimize this further -- be my guest. The irq_to_desc() call was also not available on older kernels so we provide a local translation as I see the desc being accessed on older kernels. mcgrof@tux ~/compat (git::master)$ ckmake Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.37.c | 26 ++++++++++++++++++++++++++ include/linux/compat-2.6.37.h | 11 +++++++++++ 2 files changed, 37 insertions(+) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 24b267a5..d2ee1095 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -13,6 +13,32 @@ #include #include #include +#include +#include +#include + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27) +#define irq_to_desc(irq) (irq_desc + irq) +#endif + +void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) +{ + struct irq_desc *desc = irq_to_desc(irq); + unsigned long flags; + + if (!desc) + return; + + /* Sanitize flags */ + set &= IRQF_MODIFY_MASK; + clr &= IRQF_MODIFY_MASK; + + spin_lock_irqsave(&desc->lock, flags); + desc->status &= ~clr; + desc->status |= set; + spin_unlock_irqrestore(&desc->lock, flags); +} +EXPORT_SYMBOL_GPL(irq_modify_status); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) static const void *net_current_ns(void) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 7e14853b..266772ab 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -9,6 +9,17 @@ #include #include #include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) +#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ +#endif + +#define IRQF_MODIFY_MASK \ + (IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \ + IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL) + +void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set); static inline int proto_ports_offset(int proto) { -- cgit v1.2.3 From 3e3c23e042017eae98774549356e4127dee0a82f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 20 Jul 2012 12:23:52 -0700 Subject: compat: backport irq_set_status_flags() and irq_clear_status_flags() This further backports this patch: commit 442471848f5abb55b99cba1229301655f67492b4 Author: Thomas Gleixner Date: Tue Sep 28 10:40:18 2010 +0200 genirq: Provide status modifier Provide a irq_desc.status modifier function to cleanup the direct access to irq_desc in arch and driver code. Signed-off-by: Thomas Gleixner Reviewed-by: Ingo Molnar The reason is that although irq_modify_status() was backported the commit ee9c8a: commit ee9c8a04666ba15762f736f9030e6e8df02ca1a5 Author: Grazvydas Ignotas Date: Fri May 18 03:04:08 2012 +0300 wl1251: fix oops on early interrupt commit f380f2c4a12e913356bd49f8790ec1063c4fe9f8 upstream. This driver disables interrupt just after requesting it and enables it later, after interface is up. However currently there is a time window between request_irq() and disable_irq() where if interrupt arrives, the driver oopses because it's not yet ready to process it. This can be reproduced by inserting the module, associating and removing the module multiple times. Eliminate this race by setting IRQF_NOAUTOEN flag before request_irq(). Signed-off-by: Grazvydas Ignotas Signed-off-by: John W. Linville Signed-off-by: Greg Kroah-Hartman was backported and merged into v3.4.6 therefore requiring these set of calls onto older kernels as well. This should be merged into the compat linux-3.4.y branch so that a respective compat-wireless based on v3.4.6 can be made. mcgrof@tux ~/compat (git::master)$ ckmake -t Trying kernel 3.4.0-030400rc1-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 2m28.330s user 4m28.170s sys 0m47.580s Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.37.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 266772ab..b87aa2f0 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -21,6 +21,16 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set); +static inline void irq_set_status_flags(unsigned int irq, unsigned long set) +{ + irq_modify_status(irq, 0, set); +} + +static inline void irq_clear_status_flags(unsigned int irq, unsigned long clr) +{ + irq_modify_status(irq, clr, 0); +} + static inline int proto_ports_offset(int proto) { switch (proto) { -- cgit v1.2.3 From 7f71ad622392b61ade745de364c55517c40f0659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Sun, 22 Jul 2012 13:39:11 +0300 Subject: compat: Add 3.5 to the list of kernels MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 3.5 to the list of kernels in bin/get-compat-kernels. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 6d9d9fe0..4479d0f4 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -56,6 +56,7 @@ KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-03 KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.5-quantal/linux-headers-3.5.0-030500_3.5.0-030500.201207211835_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 078f5bfbc3c950203af454cc2233747a5e686fd1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 24 Jul 2012 16:21:45 -0700 Subject: compat: backport u64_stats_sync This was added as of v2.6.36. This is just a set of static inlines we we can easily backport this for older kernels. For newer kernels we just ignore this and include the respective kernel's header. mcgrof@tux ~/linux-next (git::master)$ git describe --contains \ 16b8a4761cbe5082cd35641c066d7c4b6b83cdca v2.6.36-rc1~571^2~512 commit 16b8a4761cbe5082cd35641c066d7c4b6b83cdca Author: Eric Dumazet Date: Tue Jun 22 10:22:17 2010 -0700 net: Introduce u64_stats_sync infrastructure To properly implement 64bits network statistics on 32bit or 64bit hosts, we provide one new type and four methods, to ease conversions. Stats producer should use following template granted it already got an exclusive access to counters (include/linux/u64_stats_sync.h contains some documentation about details) u64_stats_update_begin(&stats->syncp); stats->bytes64 += len; stats->packets64++; u64_stats_update_end(&stats->syncp); While a consumer should use following template to get consistent snapshot : u64 tbytes, tpackets; unsigned int start; do { start = u64_stats_fetch_begin(&stats->syncp); tbytes = stats->bytes64; tpackets = stats->packets64; } while (u64_stats_fetch_retry(&stats->lock, syncp)); Suggested by David Miller, and comments courtesy of Nick Piggin. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/u64_stats_sync.h | 144 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 include/linux/u64_stats_sync.h diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h new file mode 100644 index 00000000..f15116c2 --- /dev/null +++ b/include/linux/u64_stats_sync.h @@ -0,0 +1,144 @@ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) +#include_next +#else +#ifndef _LINUX_U64_STATS_SYNC_H +#define _LINUX_U64_STATS_SYNC_H + +/* + * To properly implement 64bits network statistics on 32bit and 64bit hosts, + * we provide a synchronization point, that is a noop on 64bit or UP kernels. + * + * Key points : + * 1) Use a seqcount on SMP 32bits, with low overhead. + * 2) Whole thing is a noop on 64bit arches or UP kernels. + * 3) Write side must ensure mutual exclusion or one seqcount update could + * be lost, thus blocking readers forever. + * If this synchronization point is not a mutex, but a spinlock or + * spinlock_bh() or disable_bh() : + * 3.1) Write side should not sleep. + * 3.2) Write side should not allow preemption. + * 3.3) If applicable, interrupts should be disabled. + * + * 4) If reader fetches several counters, there is no guarantee the whole values + * are consistent (remember point 1) : this is a noop on 64bit arches anyway) + * + * 5) readers are allowed to sleep or be preempted/interrupted : They perform + * pure reads. But if they have to fetch many values, it's better to not allow + * preemptions/interruptions to avoid many retries. + * + * 6) If counter might be written by an interrupt, readers should block interrupts. + * (On UP, there is no seqcount_t protection, a reader allowing interrupts could + * read partial values) + * + * 7) For softirq uses, readers can use u64_stats_fetch_begin_bh() and + * u64_stats_fetch_retry_bh() helpers + * + * Usage : + * + * Stats producer (writer) should use following template granted it already got + * an exclusive access to counters (a lock is already taken, or per cpu + * data is used [in a non preemptable context]) + * + * spin_lock_bh(...) or other synchronization to get exclusive access + * ... + * u64_stats_update_begin(&stats->syncp); + * stats->bytes64 += len; // non atomic operation + * stats->packets64++; // non atomic operation + * u64_stats_update_end(&stats->syncp); + * + * While a consumer (reader) should use following template to get consistent + * snapshot for each variable (but no guarantee on several ones) + * + * u64 tbytes, tpackets; + * unsigned int start; + * + * do { + * start = u64_stats_fetch_begin(&stats->syncp); + * tbytes = stats->bytes64; // non atomic operation + * tpackets = stats->packets64; // non atomic operation + * } while (u64_stats_fetch_retry(&stats->syncp, start)); + * + * + * Example of use in drivers/net/loopback.c, using per_cpu containers, + * in BH disabled context. + */ +#include + +struct u64_stats_sync { +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + seqcount_t seq; +#endif +}; + +static inline void u64_stats_update_begin(struct u64_stats_sync *syncp) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + write_seqcount_begin(&syncp->seq); +#endif +} + +static inline void u64_stats_update_end(struct u64_stats_sync *syncp) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + write_seqcount_end(&syncp->seq); +#endif +} + +static inline unsigned int u64_stats_fetch_begin(const struct u64_stats_sync *syncp) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + return read_seqcount_begin(&syncp->seq); +#else +#if BITS_PER_LONG==32 + preempt_disable(); +#endif + return 0; +#endif +} + +static inline bool u64_stats_fetch_retry(const struct u64_stats_sync *syncp, + unsigned int start) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + return read_seqcount_retry(&syncp->seq, start); +#else +#if BITS_PER_LONG==32 + preempt_enable(); +#endif + return false; +#endif +} + +/* + * In case softirq handlers can update u64 counters, readers can use following helpers + * - SMP 32bit arches use seqcount protection, irq safe. + * - UP 32bit must disable BH. + * - 64bit have no problem atomically reading u64 values, irq safe. + */ +static inline unsigned int u64_stats_fetch_begin_bh(const struct u64_stats_sync *syncp) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + return read_seqcount_begin(&syncp->seq); +#else +#if BITS_PER_LONG==32 + local_bh_disable(); +#endif + return 0; +#endif +} + +static inline bool u64_stats_fetch_retry_bh(const struct u64_stats_sync *syncp, + unsigned int start) +{ +#if BITS_PER_LONG==32 && defined(CONFIG_SMP) + return read_seqcount_retry(&syncp->seq, start); +#else +#if BITS_PER_LONG==32 + local_bh_enable(); +#endif + return false; +#endif +} + +#endif /* _LINUX_U64_STATS_SYNC_H */ +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */ -- cgit v1.2.3 From b20a27a05241257320f33629069f9a351e88c92e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 25 Jul 2012 09:44:23 -0700 Subject: compat: backport ndo_get_stats64 addition The net_device_ops data structure gets a new ndo_get_stats64 callback through two patches. For newer kernels that actually do have the net_device_ops data structure we have no other option but to #ifdef that code. For older kernels that do not have the net_device_ops we stuff the new callback into this compat module / header files and make netdev_attach_ops() ignore it. And again -- for newer kernels just #ifdef that stuff out. This is an example of a complex data structure series of changes through different sets of collateral evolutions. If we can figure out a way to not requre #ifdef changes for *newer* kernels that *do* have the net_device_ops it would be great. One way to likely accomplish this is to redefine the net_device_ops data structure through a define for all kernels and make it out own and in our own netdev_attach_ops() routine handle the differences. If this would be possible (needs to be proven but I think Ozan has already proven this) I'm hopeful we'll eventually be able to replace net_device_ops() collateral evolutions with 0 lines required to be changed on upstream code! There are two patches that added ndo_get_stats64, fortunately both were implemented during the 2.6.36 deveopment cycle. mcgrof@tux ~/linux-next (git::master)$ git describe --contains be1f3c2c v2.6.36-rc1~571^2~600 mcgrof@tux ~/linux-next (git::master)$ git describe --contains 28172739 v2.6.36-rc1~571^2~334 commit be1f3c2c027cc5ad735df6a45a542ed1db7ec48b Author: Ben Hutchings Date: Tue Jun 8 07:19:54 2010 +0000 net: Enable 64-bit net device statistics on 32-bit architectures Use struct rtnl_link_stats64 as the statistics structure. On 32-bit architectures, insert 32 bits of padding after/before each field of struct net_device_stats to make its layout compatible with struct rtnl_link_stats64. Add an anonymous union in net_device; move stats into the union and add struct rtnl_link_stats64 stats64. Add net_device_ops::ndo_get_stats64, implementations of which will return a pointer to struct rtnl_link_stats64. Drivers that implement this operation must not update the structure asynchronously. Change dev_get_stats() to call ndo_get_stats64 if available, and to return a pointer to struct rtnl_link_stats64. Change callers of dev_get_stats() accordingly. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller commit 28172739f0a276eb8d6ca917b3974c2edb036da3 Author: Eric Dumazet Date: Wed Jul 7 14:58:56 2010 -0700 net: fix 64 bit counters on 32 bit arches There is a small possibility that a reader gets incorrect values on 32 bit arches. SNMP applications could catch incorrect counters when a 32bit high part is changed by another stats consumer/provider. One way to solve this is to add a rtnl_link_stats64 param to all ndo_get_stats64() methods, and also add such a parameter to dev_get_stats(). Rule is that we are not allowed to use dev->stats64 as a temporary storage for 64bit stats, but a caller provided area (usually on stack) Old drivers (only providing get_stats() method) need no changes. Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 48b62e8a..e65c2298 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -184,6 +184,11 @@ struct net_device_ops { struct neigh_parms *); void (*ndo_tx_timeout) (struct net_device *dev); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) + struct rtnl_link_stats64* (*ndo_get_stats64)(struct net_device *dev, + struct rtnl_link_stats64 *storage); +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */ + struct net_device_stats* (*ndo_get_stats)(struct net_device *dev); void (*ndo_vlan_rx_register)(struct net_device *dev, -- cgit v1.2.3 From 8623abc840394f0538bfe2f4895d237f5e8fccc5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Aug 2012 01:05:22 +0200 Subject: compat: add seq_hlist_next and seq_hlist_start_head These functions are copied from the kernel and are needed by net/bluetooth/af_bluetooth.c Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.34.c | 55 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.34.h | 6 +++++ 2 files changed, 61 insertions(+) diff --git a/compat/compat-2.6.34.c b/compat/compat-2.6.34.c index b905a26c..80a61079 100644 --- a/compat/compat-2.6.34.c +++ b/compat/compat-2.6.34.c @@ -28,3 +28,58 @@ int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) { return -EINVAL; } + +/** + * seq_hlist_start - start an iteration of a hlist + * @head: the head of the hlist + * @pos: the start position of the sequence + * + * Called at seq_file->op->start(). + */ +struct hlist_node *seq_hlist_start(struct hlist_head *head, loff_t pos) +{ + struct hlist_node *node; + + hlist_for_each(node, head) + if (pos-- == 0) + return node; + return NULL; +} + +/** + * seq_hlist_start_head - start an iteration of a hlist + * @head: the head of the hlist + * @pos: the start position of the sequence + * + * Called at seq_file->op->start(). Call this function if you want to + * print a header at the top of the output. + */ +struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos) +{ + if (!pos) + return SEQ_START_TOKEN; + + return seq_hlist_start(head, pos - 1); +} +EXPORT_SYMBOL(seq_hlist_start_head); + +/** + * seq_hlist_next - move to the next position of the hlist + * @v: the current iterator + * @head: the head of the hlist + * @ppos: the current position + * + * Called at seq_file->op->next(). + */ +struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, + loff_t *ppos) +{ + struct hlist_node *node = v; + + ++*ppos; + if (v == SEQ_START_TOKEN) + return head->first; + else + return node->next; +} +EXPORT_SYMBOL(seq_hlist_next); diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index b5a40e2a..39bc13b0 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -319,6 +319,12 @@ static inline int lockdep_rtnl_is_held(void) } #endif /* #ifdef CONFIG_PROVE_LOCKING */ +extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head, + loff_t pos); + +extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, + loff_t *ppos); + #else /* Kernels >= 2.6.34 */ static inline void init_compat_mmc_pm_flags(void) -- cgit v1.2.3 From 9afa4a5268e43d6e4db1a8e91d64054df0657d98 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Aug 2012 01:05:23 +0200 Subject: compat: add sk_entry This function is copied from the kernel. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.34.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index 39bc13b0..b8b48c03 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -8,6 +8,7 @@ #include #include #include +#include /* * Backports da68c4eb25 @@ -325,6 +326,11 @@ extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head, extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, loff_t *ppos); +static inline struct sock *sk_entry(const struct hlist_node *node) +{ + return hlist_entry(node, struct sock, sk_node); +} + #else /* Kernels >= 2.6.34 */ static inline void init_compat_mmc_pm_flags(void) -- cgit v1.2.3 From 656d3e6e6b3bfc014b0610031f7e3b0a53da6eb8 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Aug 2012 01:05:24 +0200 Subject: compat: add sk_wmem_alloc_get and sk_has_allocations These functions are copied from the kernel. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.31.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 25db973d..347ae26d 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -11,6 +11,7 @@ #include #include #include +#include /* * These macros allow us to backport rfkill without any @@ -215,6 +216,39 @@ extern long long atomic64_add_return(long long a, atomic64_t *v); #endif +/** + * sk_rmem_alloc_get - returns read allocations + * @sk: socket + * + * Returns sk_rmem_alloc + */ +static inline int sk_rmem_alloc_get(const struct sock *sk) +{ + return atomic_read(&sk->sk_rmem_alloc); +} + +/** + * sk_wmem_alloc_get - returns write allocations + * @sk: socket + * + * Returns sk_wmem_alloc minus initial offset of one + */ +static inline int sk_wmem_alloc_get(const struct sock *sk) +{ + return atomic_read(&sk->sk_wmem_alloc) - 1; +} + +/** + * sk_has_allocations - check if allocations are outstanding + * @sk: socket + * + * Returns true if socket has write or read allocations + */ +static inline bool sk_has_allocations(const struct sock *sk) +{ + return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk); +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ -- cgit v1.2.3 From 67ccbfd69e20856ce41d6b046bb39ea7141040d6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Aug 2012 18:28:00 +0200 Subject: compat: remove backport of irq_modify_status Only kernel >= 2.6.39 irq_to_desc or irq_desc are exporting, so that compat is not able to access this on the kernel versions where it is needed. irq_to_desc and irq_desc are defined in the header files so compilation works, but the module is not loadable because of the missing exported symbol which make compat unusable on all these kernel versions. Remove this function, no driver seams to need it. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.37.c | 26 -------------------------- include/linux/compat-2.6.37.h | 21 --------------------- 2 files changed, 47 deletions(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index d2ee1095..24b267a5 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -13,32 +13,6 @@ #include #include #include -#include -#include -#include - -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27) -#define irq_to_desc(irq) (irq_desc + irq) -#endif - -void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set) -{ - struct irq_desc *desc = irq_to_desc(irq); - unsigned long flags; - - if (!desc) - return; - - /* Sanitize flags */ - set &= IRQF_MODIFY_MASK; - clr &= IRQF_MODIFY_MASK; - - spin_lock_irqsave(&desc->lock, flags); - desc->status &= ~clr; - desc->status |= set; - spin_unlock_irqrestore(&desc->lock, flags); -} -EXPORT_SYMBOL_GPL(irq_modify_status); #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) static const void *net_current_ns(void) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index b87aa2f0..7e14853b 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -9,27 +9,6 @@ #include #include #include -#include - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) -#define IRQ_MOVE_PCNTXT 0x01000000 /* IRQ migration from process context */ -#endif - -#define IRQF_MODIFY_MASK \ - (IRQ_TYPE_SENSE_MASK | IRQ_NOPROBE | IRQ_NOREQUEST | \ - IRQ_NOAUTOEN | IRQ_MOVE_PCNTXT | IRQ_LEVEL) - -void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set); - -static inline void irq_set_status_flags(unsigned int irq, unsigned long set) -{ - irq_modify_status(irq, 0, set); -} - -static inline void irq_clear_status_flags(unsigned int irq, unsigned long clr) -{ - irq_modify_status(irq, clr, 0); -} static inline int proto_ports_offset(int proto) { -- cgit v1.2.3 From 78fda91b330657f1d66afc32d18cae99f4783f21 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 2 Aug 2012 18:28:01 +0200 Subject: compat: fix endless recursion in flush_scheduled_work The hader file defines flush_scheduled_work(a) compat_flush_scheduled_work(a), which causes flush_scheduled_work() and compat_flush_scheduled_work() to be the same function. With this patch it calls the actual function in the kernel. This fixes problems when unloading mac80211 from compat-wireless. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 8f25be0a..05b41c2b 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -133,6 +133,7 @@ int compat_schedule_delayed_work_on(int cpu, } EXPORT_SYMBOL_GPL(compat_schedule_delayed_work_on); +#undef flush_scheduled_work(a) void compat_flush_scheduled_work(void) { /* -- cgit v1.2.3 From 8e661d67b1965afcfd9d3672803e2fc37765f6ef Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 2 Aug 2012 22:15:05 +0200 Subject: compat: handle pci suspend/resume on kernel 2.6.29 Before kernel 2.6.29, we use compat_pci_{suspend,resume} and not the SIMPLE_DEV_PM_OPS, which include the code for PCI device handling. For 2.6.30 and higher, the core PCI code includes the device handling. That leaves 2.6.29 as the odd one out and causes suspend and resume to fail. Fix it by including the PCI device handling code in the definition of SIMPLE_DEV_PM_OPS for that kernel version. Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 47 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index 9d41fc85..ff57dcac 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -124,9 +124,52 @@ typedef enum netdev_tx netdev_tx_t; /* * dev_pm_ops is only available on kernels >= 2.6.29, for * older kernels we rely on reverting the work to old - * power management style stuff. + * power management style stuff. On 2.6.29 the pci calls + * weren't included yet though, so include them here. */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29)) +/* + * Note the lack of "static" in this definition. The code may put + * a "static" in front of using the define, which makes it impossible + * to put static here. We lose that static if it is present (it ends + * up being on the suspend_fn) but that doesn't really matter much + * unless a driver defines multiple pm_ops structs with the same name + * (in which case we'll need to fix it) + */ +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ +int __compat_suspend_fn_ ## name(struct device *dev) \ +{ \ + int ret = suspend_fn(dev); \ + if (ret) \ + return ret; \ + if (dev->bus == &pci_bus_type) { \ + pci_save_state(to_pci_dev(dev)); \ + pci_disable_device(to_pci_dev(dev)); \ + pci_set_power_state(to_pci_dev(dev), PCI_D3hot);\ + } \ + return 0; \ +} \ +int __compat_resume_fn_ ## name(struct device *dev) \ +{ \ + int ret; \ + if (dev->bus == &pci_bus_type) { \ + pci_set_power_state(to_pci_dev(dev), PCI_D0); \ + ret = pci_enable_device(to_pci_dev(dev)); \ + if (ret) \ + return ret; \ + pci_restore_state(to_pci_dev(dev)); \ + } \ + return resume_fn(dev); \ +} \ +struct dev_pm_ops name = { \ + .suspend = __compat_suspend_fn_ ## name, \ + .resume = __compat_resume_fn_ ## name, \ + .freeze = __compat_suspend_fn_ ## name, \ + .thaw = __compat_resume_fn_ ## name, \ + .poweroff = __compat_suspend_fn_ ## name, \ + .restore = __compat_resume_fn_ ## name, \ +} +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) /* * Use this if you want to use the same suspend and resume callbacks for suspend * to RAM and hibernation. -- cgit v1.2.3 From f753843c19d22d2a86b8391ddb6e32ca230db060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 6 Aug 2012 14:06:33 +0300 Subject: compat: backport PCIe register definitions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New DRM core in 3.6 needs these in order to detect the maximum link speed of the underlying bus. This backports: commit cdcac9cd7741af2c2b9255cbf060f772596907bb Author: Dave Airlie Date: Wed Jun 27 08:35:52 2012 +0100 pci_regs: define LNKSTA2 pcie cap + bits. We need these for detecting the max link speed for drm drivers. Acked-by: Bjorn Helgaas Signed-off-by: Dave Airlie [root@ozan linux-2.6]# git describe --contains cdcac9cd v3.6-rc1~83^2~26 Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.6.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 0b36ca00..466975bb 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -5,6 +5,27 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) +/** + * Backports + * + * commit cdcac9cd7741af2c2b9255cbf060f772596907bb + * Author: Dave Airlie + * Date: Wed Jun 27 08:35:52 2012 +0100 + * + * pci_regs: define LNKSTA2 pcie cap + bits. + * + * We need these for detecting the max link speed for drm drivers. + * + * Acked-by: Bjorn Helgaas + * Signed-off-by: Dave Airlie + */ + +#define PCI_EXP_LNKCAP2 44 /* Link Capability 2 */ +#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */ +#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */ +#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x04 /* Current Link Speed 8.0GT/s */ +#define PCI_EXP_LNKCAP2_CROSSLINK 0x100 /* Crosslink supported */ + #include #include -- cgit v1.2.3 From 6260c9b84c5c02981fb02b377fcac477153ef92b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Mon, 6 Aug 2012 16:36:18 +0300 Subject: compat: Backport kmalloc_array() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new radeon DRM driver from 3.6 uses kmalloc_array(). This backports: commit a8203725dfded5c1f79dca3368a4a273e24b59bb Author: Xi Wang Date: Mon Mar 5 15:14:41 2012 -0800 slab: introduce kmalloc_array() [root@ozan linux-2.6]# git describe --contains a8203725 v3.4-rc1~56^2~1 Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index e603f4c2..06a3a07f 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -5,6 +5,24 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +/* This backports: + * + * commit a8203725dfded5c1f79dca3368a4a273e24b59bb + * Author: Xi Wang + * Date: Mon Mar 5 15:14:41 2012 -0800 + * + * slab: introduce kmalloc_array() + */ + +/* SIZE_MAX is backported in compat-3.5.h so include it */ +#include +static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) +{ + if (size != 0 && n > SIZE_MAX / size) + return NULL; + return __kmalloc(n * size, flags); +} + #include #include -- cgit v1.2.3 From 0ab0e31955e0016a4048724f794e8994ed4eec07 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 5 Aug 2012 12:29:41 +0200 Subject: Some distro kernels (in particular the Debian 3.2.0-3 kernel I'm running) backport codel already, so trying to backport it again causes issues. Protect the compat backport with #ifdef TCA_CODEL_MAX. Also link the flow_dissector code into the codel module which then won't be loaded on kernels that already have codel backported. Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 6 +- compat/flow_dissector.c | 1 - compat/sch_fq_codel.c | 659 --------------------------------------------- compat/sch_fq_codel_core.c | 659 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.5.h | 2 + include/net/codel.h | 3 +- 6 files changed, 667 insertions(+), 663 deletions(-) delete mode 100644 compat/sch_fq_codel.c create mode 100644 compat/sch_fq_codel_core.c diff --git a/compat/Makefile b/compat/Makefile index c661f5da..23c1296c 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -3,6 +3,9 @@ obj-m += compat.o obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o + +sch_fq_codel-y = sch_fq_codel_core.o flow_dissector.o + obj-$(CONFIG_COMPAT_NET_SCH_FQ_CODEL) += sch_fq_codel.o compat-y += main.o @@ -40,8 +43,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_1) += compat-3.1.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ - compat-3.3.o \ - flow_dissector.o + compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o diff --git a/compat/flow_dissector.c b/compat/flow_dissector.c index 8affda0b..7dd7ec19 100644 --- a/compat/flow_dissector.c +++ b/compat/flow_dissector.c @@ -141,4 +141,3 @@ ipv6: return true; } -EXPORT_SYMBOL_GPL(skb_flow_dissect); diff --git a/compat/sch_fq_codel.c b/compat/sch_fq_codel.c deleted file mode 100644 index f03df2ab..00000000 --- a/compat/sch_fq_codel.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Fair Queue CoDel discipline - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Copyright (C) 2012 Eric Dumazet - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Fair Queue CoDel. - * - * Principles : - * Packets are classified (internal classifier or external) on flows. - * This is a Stochastic model (as we use a hash, several flows - * might be hashed on same slot) - * Each flow has a CoDel managed queue. - * Flows are linked onto two (Round Robin) lists, - * so that new flows have priority on old ones. - * - * For a given flow, packets are not reordered (CoDel uses a FIFO) - * head drops only. - * ECN capability is on by default. - * Low memory footprint (64 bytes per flow) - */ - -struct fq_codel_flow { - struct sk_buff *head; - struct sk_buff *tail; - struct list_head flowchain; - int deficit; - u32 dropped; /* number of drops (or ECN marks) on this flow */ - struct codel_vars cvars; -}; /* please try to keep this structure <= 64 bytes */ - -struct fq_codel_sched_data { - struct tcf_proto *filter_list; /* optional external classifier */ - struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ - u32 *backlogs; /* backlog table [flows_cnt] */ - u32 flows_cnt; /* number of flows */ - u32 perturbation; /* hash perturbation */ - u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ - struct codel_params cparams; - struct codel_stats cstats; - u32 drop_overlimit; - u32 new_flow_count; - - struct list_head new_flows; /* list of new flows */ - struct list_head old_flows; /* list of old flows */ -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - u32 limit; -#endif -}; - -static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, - const struct sk_buff *skb) -{ - struct flow_keys keys; - unsigned int hash; - - skb_flow_dissect(skb, &keys); - hash = jhash_3words((__force u32)keys.dst, - (__force u32)keys.src ^ keys.ip_proto, - (__force u32)keys.ports, q->perturbation); - return ((u64)hash * q->flows_cnt) >> 32; -} - -static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, - int *qerr) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tcf_result res; - int result; - - if (TC_H_MAJ(skb->priority) == sch->handle && - TC_H_MIN(skb->priority) > 0 && - TC_H_MIN(skb->priority) <= q->flows_cnt) - return TC_H_MIN(skb->priority); - - if (!q->filter_list) - return fq_codel_hash(q, skb) + 1; - - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result = tc_classify(skb, q->filter_list, &res); - if (result >= 0) { -#ifdef CONFIG_NET_CLS_ACT - switch (result) { - case TC_ACT_STOLEN: - case TC_ACT_QUEUED: - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; - case TC_ACT_SHOT: - return 0; - } -#endif - if (TC_H_MIN(res.classid) <= q->flows_cnt) - return TC_H_MIN(res.classid); - } - return 0; -} - -/* helper functions : might be changed when/if skb use a standard list_head */ - -/* remove one skb from head of slot queue */ -static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) -{ - struct sk_buff *skb = flow->head; - - flow->head = skb->next; - skb->next = NULL; - return skb; -} - -/* add skb to flow queue (tail add) */ -static inline void flow_queue_add(struct fq_codel_flow *flow, - struct sk_buff *skb) -{ - if (flow->head == NULL) - flow->head = skb; - else - flow->tail->next = skb; - flow->tail = skb; - skb->next = NULL; -} - -static unsigned int fq_codel_drop(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - unsigned int maxbacklog = 0, idx = 0, i, len; - struct fq_codel_flow *flow; - - /* Queue is full! Find the fat flow and drop packet from it. - * This might sound expensive, but with 1024 flows, we scan - * 4KB of memory, and we dont need to handle a complex tree - * in fast path (packet queue/enqueue) with many cache misses. - */ - for (i = 0; i < q->flows_cnt; i++) { - if (q->backlogs[i] > maxbacklog) { - maxbacklog = q->backlogs[i]; - idx = i; - } - } - flow = &q->flows[idx]; - skb = dequeue_head(flow); - len = qdisc_pkt_len(skb); - q->backlogs[idx] -= len; - kfree_skb(skb); - sch->q.qlen--; - sch->qstats.drops++; - sch->qstats.backlog -= len; - flow->dropped++; - return idx; -} - -static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int idx; - struct fq_codel_flow *flow; - int uninitialized_var(ret); - - idx = fq_codel_classify(skb, sch, &ret); - if (idx == 0) { - if (ret & __NET_XMIT_BYPASS) - sch->qstats.drops++; - kfree_skb(skb); - return ret; - } - idx--; - - codel_set_enqueue_time(skb); - flow = &q->flows[idx]; - flow_queue_add(flow, skb); - q->backlogs[idx] += qdisc_pkt_len(skb); - sch->qstats.backlog += qdisc_pkt_len(skb); - - if (list_empty(&flow->flowchain)) { - list_add_tail(&flow->flowchain, &q->new_flows); - codel_vars_init(&flow->cvars); - q->new_flow_count++; - flow->deficit = q->quantum; - flow->dropped = 0; - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (++sch->q.qlen < q->limit) -#else - if (++sch->q.qlen < sch->limit) -#endif - return NET_XMIT_SUCCESS; - - q->drop_overlimit++; - /* Return Congestion Notification only if we dropped a packet - * from this flow. - */ - if (fq_codel_drop(sch) == idx) - return NET_XMIT_CN; - - /* As we dropped a packet, better let upper stack know this */ - qdisc_tree_decrease_qlen(sch, 1); - return NET_XMIT_SUCCESS; -} - -/* This is the specific function called from codel_dequeue() - * to dequeue a packet from queue. Note: backlog is handled in - * codel, we dont need to reduce it here. - */ -static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct fq_codel_flow *flow; - struct sk_buff *skb = NULL; - - flow = container_of(vars, struct fq_codel_flow, cvars); - if (flow->head) { - skb = dequeue_head(flow); - q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); - sch->q.qlen--; - } - return skb; -} - -static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - struct fq_codel_flow *flow; - struct list_head *head; - u32 prev_drop_count, prev_ecn_mark; - -begin: - head = &q->new_flows; - if (list_empty(head)) { - head = &q->old_flows; - if (list_empty(head)) - return NULL; - } - flow = list_first_entry(head, struct fq_codel_flow, flowchain); - - if (flow->deficit <= 0) { - flow->deficit += q->quantum; - list_move_tail(&flow->flowchain, &q->old_flows); - goto begin; - } - - prev_drop_count = q->cstats.drop_count; - prev_ecn_mark = q->cstats.ecn_mark; - - skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, - dequeue); - - flow->dropped += q->cstats.drop_count - prev_drop_count; - flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; - - if (!skb) { - /* force a pass through old_flows to prevent starvation */ - if ((head == &q->new_flows) && !list_empty(&q->old_flows)) - list_move_tail(&flow->flowchain, &q->old_flows); - else - list_del_init(&flow->flowchain); - goto begin; - } - qdisc_bstats_update(sch, skb); - flow->deficit -= qdisc_pkt_len(skb); - /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, - * or HTB crashes. Defer it for next round. - */ - if (q->cstats.drop_count && sch->q.qlen) { - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - } - return skb; -} - -static void fq_codel_reset(struct Qdisc *sch) -{ - struct sk_buff *skb; - - while ((skb = fq_codel_dequeue(sch)) != NULL) - kfree_skb(skb); -} - -static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { - [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, -}; - -static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; - int err; - - if (!opt) - return -EINVAL; - - err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); - if (err < 0) - return err; - if (tb[TCA_FQ_CODEL_FLOWS]) { - if (q->flows) - return -EINVAL; - q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); - if (!q->flows_cnt || - q->flows_cnt > 65536) - return -EINVAL; - } - sch_tree_lock(sch); - - if (tb[TCA_FQ_CODEL_TARGET]) { - u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); - - q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_INTERVAL]) { - u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); - - q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_LIMIT]) -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#else - sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#endif - - if (tb[TCA_FQ_CODEL_ECN]) - q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); - - if (tb[TCA_FQ_CODEL_QUANTUM]) - q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - while (sch->q.qlen > q->limit) { -#else - while (sch->q.qlen > sch->limit) { -#endif - struct sk_buff *skb = fq_codel_dequeue(sch); - - kfree_skb(skb); - q->cstats.drop_count++; - } - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - - sch_tree_unlock(sch); - return 0; -} - -static void *fq_codel_zalloc(size_t sz) -{ - void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); - - if (!ptr) - ptr = vzalloc(sz); - return ptr; -} - -static void fq_codel_free(void *addr) -{ - if (addr) { - if (is_vmalloc_addr(addr)) - vfree(addr); - else - kfree(addr); - } -} - -static void fq_codel_destroy(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) - tcf_destroy_chain(&q->filter_list); -#else - tcf_destroy_chain(q->filter_list); -#endif - fq_codel_free(q->backlogs); - fq_codel_free(q->flows); -} - -static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - int i; - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = 10*1024; -#else - sch->limit = 10*1024; -#endif - q->flows_cnt = 1024; - q->quantum = psched_mtu(qdisc_dev(sch)); - q->perturbation = net_random(); - INIT_LIST_HEAD(&q->new_flows); - INIT_LIST_HEAD(&q->old_flows); - codel_params_init(&q->cparams); - codel_stats_init(&q->cstats); - q->cparams.ecn = true; - - if (opt) { - int err = fq_codel_change(sch, opt); - if (err) - return err; - } - - if (!q->flows) { - q->flows = fq_codel_zalloc(q->flows_cnt * - sizeof(struct fq_codel_flow)); - if (!q->flows) - return -ENOMEM; - q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); - if (!q->backlogs) { - fq_codel_free(q->flows); - return -ENOMEM; - } - for (i = 0; i < q->flows_cnt; i++) { - struct fq_codel_flow *flow = q->flows + i; - - INIT_LIST_HEAD(&flow->flowchain); - } - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (q->limit >= 1) -#else - if (sch->limit >= 1) -#endif - sch->flags |= TCQ_F_CAN_BYPASS; - else - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *opts; - - opts = nla_nest_start(skb, TCA_OPTIONS); - if (opts == NULL) - goto nla_put_failure; - - if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, - codel_time_to_us(q->cparams.target)) || - nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit) || -#else - sch->limit) || -#endif - nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, - codel_time_to_us(q->cparams.interval)) || - nla_put_u32(skb, TCA_FQ_CODEL_ECN, - q->cparams.ecn) || - nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, - q->quantum) || - nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, - q->flows_cnt)) - goto nla_put_failure; - - nla_nest_end(skb, opts); - return skb->len; - -nla_put_failure: - return -1; -} - -static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tc_fq_codel_xstats st = { - .type = TCA_FQ_CODEL_XSTATS_QDISC, - }; - struct list_head *pos; - - st.qdisc_stats.maxpacket = q->cstats.maxpacket; - st.qdisc_stats.drop_overlimit = q->drop_overlimit; - st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; - st.qdisc_stats.new_flow_count = q->new_flow_count; - - list_for_each(pos, &q->new_flows) - st.qdisc_stats.new_flows_len++; - - list_for_each(pos, &q->old_flows) - st.qdisc_stats.old_flows_len++; - - return gnet_stats_copy_app(d, &st, sizeof(st)); -} - -static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) -{ - return NULL; -} - -static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) -{ - return 0; -} - -static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, - u32 classid) -{ - /* we cannot bypass queue discipline anymore */ - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static void fq_codel_put(struct Qdisc *q, unsigned long cl) -{ -} - -static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - - if (cl) - return NULL; - return &q->filter_list; -} - -static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, - struct sk_buff *skb, struct tcmsg *tcm) -{ - tcm->tcm_handle |= TC_H_MIN(cl); - return 0; -} - -static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, - struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - u32 idx = cl - 1; - struct gnet_stats_queue qs = { 0 }; - struct tc_fq_codel_xstats xstats; - - if (idx < q->flows_cnt) { - const struct fq_codel_flow *flow = &q->flows[idx]; - const struct sk_buff *skb = flow->head; - - memset(&xstats, 0, sizeof(xstats)); - xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; - xstats.class_stats.deficit = flow->deficit; - xstats.class_stats.ldelay = - codel_time_to_us(flow->cvars.ldelay); - xstats.class_stats.count = flow->cvars.count; - xstats.class_stats.lastcount = flow->cvars.lastcount; - xstats.class_stats.dropping = flow->cvars.dropping; - if (flow->cvars.dropping) { - codel_tdiff_t delta = flow->cvars.drop_next - - codel_get_time(); - - xstats.class_stats.drop_next = (delta >= 0) ? - codel_time_to_us(delta) : - -codel_time_to_us(-delta); - } - while (skb) { - qs.qlen++; - skb = skb->next; - } - qs.backlog = q->backlogs[idx]; - qs.drops = flow->dropped; - } - if (gnet_stats_copy_queue(d, &qs) < 0) - return -1; - if (idx < q->flows_cnt) - return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); - return 0; -} - -static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int i; - - if (arg->stop) - return; - - for (i = 0; i < q->flows_cnt; i++) { - if (list_empty(&q->flows[i].flowchain) || - arg->count < arg->skip) { - arg->count++; - continue; - } - if (arg->fn(sch, i + 1, arg) < 0) { - arg->stop = 1; - break; - } - arg->count++; - } -} - -static const struct Qdisc_class_ops fq_codel_class_ops = { - .leaf = fq_codel_leaf, - .get = fq_codel_get, - .put = fq_codel_put, - .tcf_chain = fq_codel_find_tcf, - .bind_tcf = fq_codel_bind, - .unbind_tcf = fq_codel_put, - .dump = fq_codel_dump_class, - .dump_stats = fq_codel_dump_class_stats, - .walk = fq_codel_walk, -}; - -static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { - .cl_ops = &fq_codel_class_ops, - .id = "fq_codel", - .priv_size = sizeof(struct fq_codel_sched_data), - .enqueue = fq_codel_enqueue, - .dequeue = fq_codel_dequeue, -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) - .peek = qdisc_peek_dequeued, -#endif - .drop = fq_codel_drop, - .init = fq_codel_init, - .reset = fq_codel_reset, - .destroy = fq_codel_destroy, - .change = fq_codel_change, - .dump = fq_codel_dump, - .dump_stats = fq_codel_dump_stats, - .owner = THIS_MODULE, -}; - -static int __init fq_codel_module_init(void) -{ - return register_qdisc(&fq_codel_qdisc_ops); -} - -static void __exit fq_codel_module_exit(void) -{ - unregister_qdisc(&fq_codel_qdisc_ops); -} - -module_init(fq_codel_module_init) -module_exit(fq_codel_module_exit) -MODULE_AUTHOR("Eric Dumazet"); -MODULE_LICENSE("GPL"); diff --git a/compat/sch_fq_codel_core.c b/compat/sch_fq_codel_core.c new file mode 100644 index 00000000..f03df2ab --- /dev/null +++ b/compat/sch_fq_codel_core.c @@ -0,0 +1,659 @@ +/* + * Fair Queue CoDel discipline + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Copyright (C) 2012 Eric Dumazet + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Fair Queue CoDel. + * + * Principles : + * Packets are classified (internal classifier or external) on flows. + * This is a Stochastic model (as we use a hash, several flows + * might be hashed on same slot) + * Each flow has a CoDel managed queue. + * Flows are linked onto two (Round Robin) lists, + * so that new flows have priority on old ones. + * + * For a given flow, packets are not reordered (CoDel uses a FIFO) + * head drops only. + * ECN capability is on by default. + * Low memory footprint (64 bytes per flow) + */ + +struct fq_codel_flow { + struct sk_buff *head; + struct sk_buff *tail; + struct list_head flowchain; + int deficit; + u32 dropped; /* number of drops (or ECN marks) on this flow */ + struct codel_vars cvars; +}; /* please try to keep this structure <= 64 bytes */ + +struct fq_codel_sched_data { + struct tcf_proto *filter_list; /* optional external classifier */ + struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ + u32 *backlogs; /* backlog table [flows_cnt] */ + u32 flows_cnt; /* number of flows */ + u32 perturbation; /* hash perturbation */ + u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ + struct codel_params cparams; + struct codel_stats cstats; + u32 drop_overlimit; + u32 new_flow_count; + + struct list_head new_flows; /* list of new flows */ + struct list_head old_flows; /* list of old flows */ +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + u32 limit; +#endif +}; + +static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, + const struct sk_buff *skb) +{ + struct flow_keys keys; + unsigned int hash; + + skb_flow_dissect(skb, &keys); + hash = jhash_3words((__force u32)keys.dst, + (__force u32)keys.src ^ keys.ip_proto, + (__force u32)keys.ports, q->perturbation); + return ((u64)hash * q->flows_cnt) >> 32; +} + +static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, + int *qerr) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tcf_result res; + int result; + + if (TC_H_MAJ(skb->priority) == sch->handle && + TC_H_MIN(skb->priority) > 0 && + TC_H_MIN(skb->priority) <= q->flows_cnt) + return TC_H_MIN(skb->priority); + + if (!q->filter_list) + return fq_codel_hash(q, skb) + 1; + + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + result = tc_classify(skb, q->filter_list, &res); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return 0; + } +#endif + if (TC_H_MIN(res.classid) <= q->flows_cnt) + return TC_H_MIN(res.classid); + } + return 0; +} + +/* helper functions : might be changed when/if skb use a standard list_head */ + +/* remove one skb from head of slot queue */ +static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) +{ + struct sk_buff *skb = flow->head; + + flow->head = skb->next; + skb->next = NULL; + return skb; +} + +/* add skb to flow queue (tail add) */ +static inline void flow_queue_add(struct fq_codel_flow *flow, + struct sk_buff *skb) +{ + if (flow->head == NULL) + flow->head = skb; + else + flow->tail->next = skb; + flow->tail = skb; + skb->next = NULL; +} + +static unsigned int fq_codel_drop(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + unsigned int maxbacklog = 0, idx = 0, i, len; + struct fq_codel_flow *flow; + + /* Queue is full! Find the fat flow and drop packet from it. + * This might sound expensive, but with 1024 flows, we scan + * 4KB of memory, and we dont need to handle a complex tree + * in fast path (packet queue/enqueue) with many cache misses. + */ + for (i = 0; i < q->flows_cnt; i++) { + if (q->backlogs[i] > maxbacklog) { + maxbacklog = q->backlogs[i]; + idx = i; + } + } + flow = &q->flows[idx]; + skb = dequeue_head(flow); + len = qdisc_pkt_len(skb); + q->backlogs[idx] -= len; + kfree_skb(skb); + sch->q.qlen--; + sch->qstats.drops++; + sch->qstats.backlog -= len; + flow->dropped++; + return idx; +} + +static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int idx; + struct fq_codel_flow *flow; + int uninitialized_var(ret); + + idx = fq_codel_classify(skb, sch, &ret); + if (idx == 0) { + if (ret & __NET_XMIT_BYPASS) + sch->qstats.drops++; + kfree_skb(skb); + return ret; + } + idx--; + + codel_set_enqueue_time(skb); + flow = &q->flows[idx]; + flow_queue_add(flow, skb); + q->backlogs[idx] += qdisc_pkt_len(skb); + sch->qstats.backlog += qdisc_pkt_len(skb); + + if (list_empty(&flow->flowchain)) { + list_add_tail(&flow->flowchain, &q->new_flows); + codel_vars_init(&flow->cvars); + q->new_flow_count++; + flow->deficit = q->quantum; + flow->dropped = 0; + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (++sch->q.qlen < q->limit) +#else + if (++sch->q.qlen < sch->limit) +#endif + return NET_XMIT_SUCCESS; + + q->drop_overlimit++; + /* Return Congestion Notification only if we dropped a packet + * from this flow. + */ + if (fq_codel_drop(sch) == idx) + return NET_XMIT_CN; + + /* As we dropped a packet, better let upper stack know this */ + qdisc_tree_decrease_qlen(sch, 1); + return NET_XMIT_SUCCESS; +} + +/* This is the specific function called from codel_dequeue() + * to dequeue a packet from queue. Note: backlog is handled in + * codel, we dont need to reduce it here. + */ +static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct fq_codel_flow *flow; + struct sk_buff *skb = NULL; + + flow = container_of(vars, struct fq_codel_flow, cvars); + if (flow->head) { + skb = dequeue_head(flow); + q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); + sch->q.qlen--; + } + return skb; +} + +static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + struct fq_codel_flow *flow; + struct list_head *head; + u32 prev_drop_count, prev_ecn_mark; + +begin: + head = &q->new_flows; + if (list_empty(head)) { + head = &q->old_flows; + if (list_empty(head)) + return NULL; + } + flow = list_first_entry(head, struct fq_codel_flow, flowchain); + + if (flow->deficit <= 0) { + flow->deficit += q->quantum; + list_move_tail(&flow->flowchain, &q->old_flows); + goto begin; + } + + prev_drop_count = q->cstats.drop_count; + prev_ecn_mark = q->cstats.ecn_mark; + + skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, + dequeue); + + flow->dropped += q->cstats.drop_count - prev_drop_count; + flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; + + if (!skb) { + /* force a pass through old_flows to prevent starvation */ + if ((head == &q->new_flows) && !list_empty(&q->old_flows)) + list_move_tail(&flow->flowchain, &q->old_flows); + else + list_del_init(&flow->flowchain); + goto begin; + } + qdisc_bstats_update(sch, skb); + flow->deficit -= qdisc_pkt_len(skb); + /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, + * or HTB crashes. Defer it for next round. + */ + if (q->cstats.drop_count && sch->q.qlen) { + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + } + return skb; +} + +static void fq_codel_reset(struct Qdisc *sch) +{ + struct sk_buff *skb; + + while ((skb = fq_codel_dequeue(sch)) != NULL) + kfree_skb(skb); +} + +static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { + [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, +}; + +static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; + int err; + + if (!opt) + return -EINVAL; + + err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); + if (err < 0) + return err; + if (tb[TCA_FQ_CODEL_FLOWS]) { + if (q->flows) + return -EINVAL; + q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); + if (!q->flows_cnt || + q->flows_cnt > 65536) + return -EINVAL; + } + sch_tree_lock(sch); + + if (tb[TCA_FQ_CODEL_TARGET]) { + u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); + + q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_INTERVAL]) { + u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); + + q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_LIMIT]) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#else + sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#endif + + if (tb[TCA_FQ_CODEL_ECN]) + q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); + + if (tb[TCA_FQ_CODEL_QUANTUM]) + q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + while (sch->q.qlen > q->limit) { +#else + while (sch->q.qlen > sch->limit) { +#endif + struct sk_buff *skb = fq_codel_dequeue(sch); + + kfree_skb(skb); + q->cstats.drop_count++; + } + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + + sch_tree_unlock(sch); + return 0; +} + +static void *fq_codel_zalloc(size_t sz) +{ + void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); + + if (!ptr) + ptr = vzalloc(sz); + return ptr; +} + +static void fq_codel_free(void *addr) +{ + if (addr) { + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); + } +} + +static void fq_codel_destroy(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) + tcf_destroy_chain(&q->filter_list); +#else + tcf_destroy_chain(q->filter_list); +#endif + fq_codel_free(q->backlogs); + fq_codel_free(q->flows); +} + +static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + int i; + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = 10*1024; +#else + sch->limit = 10*1024; +#endif + q->flows_cnt = 1024; + q->quantum = psched_mtu(qdisc_dev(sch)); + q->perturbation = net_random(); + INIT_LIST_HEAD(&q->new_flows); + INIT_LIST_HEAD(&q->old_flows); + codel_params_init(&q->cparams); + codel_stats_init(&q->cstats); + q->cparams.ecn = true; + + if (opt) { + int err = fq_codel_change(sch, opt); + if (err) + return err; + } + + if (!q->flows) { + q->flows = fq_codel_zalloc(q->flows_cnt * + sizeof(struct fq_codel_flow)); + if (!q->flows) + return -ENOMEM; + q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); + if (!q->backlogs) { + fq_codel_free(q->flows); + return -ENOMEM; + } + for (i = 0; i < q->flows_cnt; i++) { + struct fq_codel_flow *flow = q->flows + i; + + INIT_LIST_HEAD(&flow->flowchain); + } + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (q->limit >= 1) +#else + if (sch->limit >= 1) +#endif + sch->flags |= TCQ_F_CAN_BYPASS; + else + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, + codel_time_to_us(q->cparams.target)) || + nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit) || +#else + sch->limit) || +#endif + nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, + codel_time_to_us(q->cparams.interval)) || + nla_put_u32(skb, TCA_FQ_CODEL_ECN, + q->cparams.ecn) || + nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, + q->quantum) || + nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, + q->flows_cnt)) + goto nla_put_failure; + + nla_nest_end(skb, opts); + return skb->len; + +nla_put_failure: + return -1; +} + +static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tc_fq_codel_xstats st = { + .type = TCA_FQ_CODEL_XSTATS_QDISC, + }; + struct list_head *pos; + + st.qdisc_stats.maxpacket = q->cstats.maxpacket; + st.qdisc_stats.drop_overlimit = q->drop_overlimit; + st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; + st.qdisc_stats.new_flow_count = q->new_flow_count; + + list_for_each(pos, &q->new_flows) + st.qdisc_stats.new_flows_len++; + + list_for_each(pos, &q->old_flows) + st.qdisc_stats.old_flows_len++; + + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) +{ + return NULL; +} + +static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) +{ + return 0; +} + +static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + /* we cannot bypass queue discipline anymore */ + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static void fq_codel_put(struct Qdisc *q, unsigned long cl) +{ +} + +static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + + if (cl) + return NULL; + return &q->filter_list; +} + +static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, + struct sk_buff *skb, struct tcmsg *tcm) +{ + tcm->tcm_handle |= TC_H_MIN(cl); + return 0; +} + +static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, + struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + u32 idx = cl - 1; + struct gnet_stats_queue qs = { 0 }; + struct tc_fq_codel_xstats xstats; + + if (idx < q->flows_cnt) { + const struct fq_codel_flow *flow = &q->flows[idx]; + const struct sk_buff *skb = flow->head; + + memset(&xstats, 0, sizeof(xstats)); + xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; + xstats.class_stats.deficit = flow->deficit; + xstats.class_stats.ldelay = + codel_time_to_us(flow->cvars.ldelay); + xstats.class_stats.count = flow->cvars.count; + xstats.class_stats.lastcount = flow->cvars.lastcount; + xstats.class_stats.dropping = flow->cvars.dropping; + if (flow->cvars.dropping) { + codel_tdiff_t delta = flow->cvars.drop_next - + codel_get_time(); + + xstats.class_stats.drop_next = (delta >= 0) ? + codel_time_to_us(delta) : + -codel_time_to_us(-delta); + } + while (skb) { + qs.qlen++; + skb = skb->next; + } + qs.backlog = q->backlogs[idx]; + qs.drops = flow->dropped; + } + if (gnet_stats_copy_queue(d, &qs) < 0) + return -1; + if (idx < q->flows_cnt) + return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); + return 0; +} + +static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int i; + + if (arg->stop) + return; + + for (i = 0; i < q->flows_cnt; i++) { + if (list_empty(&q->flows[i].flowchain) || + arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +static const struct Qdisc_class_ops fq_codel_class_ops = { + .leaf = fq_codel_leaf, + .get = fq_codel_get, + .put = fq_codel_put, + .tcf_chain = fq_codel_find_tcf, + .bind_tcf = fq_codel_bind, + .unbind_tcf = fq_codel_put, + .dump = fq_codel_dump_class, + .dump_stats = fq_codel_dump_class_stats, + .walk = fq_codel_walk, +}; + +static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { + .cl_ops = &fq_codel_class_ops, + .id = "fq_codel", + .priv_size = sizeof(struct fq_codel_sched_data), + .enqueue = fq_codel_enqueue, + .dequeue = fq_codel_dequeue, +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) + .peek = qdisc_peek_dequeued, +#endif + .drop = fq_codel_drop, + .init = fq_codel_init, + .reset = fq_codel_reset, + .destroy = fq_codel_destroy, + .change = fq_codel_change, + .dump = fq_codel_dump, + .dump_stats = fq_codel_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init fq_codel_module_init(void) +{ + return register_qdisc(&fq_codel_qdisc_ops); +} + +static void __exit fq_codel_module_exit(void) +{ + unregister_qdisc(&fq_codel_qdisc_ops); +} + +module_init(fq_codel_module_init) +module_exit(fq_codel_module_exit) +MODULE_AUTHOR("Eric Dumazet"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 6bb450da..7fadbf2a 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -147,6 +147,7 @@ static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev, * Subject: [PATCH] codel: Controlled Delay AQM */ +#ifndef TCA_CODEL_MAX /* CODEL */ enum { @@ -234,6 +235,7 @@ struct tc_fq_codel_xstats { struct tc_fq_codel_cl_stats class_stats; }; }; +#endif /* TCA_CODEL_MAX */ /* Backports tty_lock: Localise the lock */ diff --git a/include/net/codel.h b/include/net/codel.h index 128082ed..ab901c57 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -1,6 +1,7 @@ #include +#include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) || defined(TCA_CODEL_MAX) #include_next #else -- cgit v1.2.3 From 4dd49c0e893f43fb30341c0ce1fbf4f83119bae8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 6 Aug 2012 14:14:52 -0700 Subject: Revert "Some distro kernels (in particular the Debian 3.2.0-3" This reverts commit 0ab0e31955e0016a4048724f794e8994ed4eec07. --- compat/Makefile | 6 +- compat/flow_dissector.c | 1 + compat/sch_fq_codel.c | 659 +++++++++++++++++++++++++++++++++++++++++++++ compat/sch_fq_codel_core.c | 659 --------------------------------------------- include/linux/compat-3.5.h | 2 - include/net/codel.h | 3 +- 6 files changed, 663 insertions(+), 667 deletions(-) create mode 100644 compat/sch_fq_codel.c delete mode 100644 compat/sch_fq_codel_core.c diff --git a/compat/Makefile b/compat/Makefile index 23c1296c..c661f5da 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -3,9 +3,6 @@ obj-m += compat.o obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o - -sch_fq_codel-y = sch_fq_codel_core.o flow_dissector.o - obj-$(CONFIG_COMPAT_NET_SCH_FQ_CODEL) += sch_fq_codel.o compat-y += main.o @@ -43,7 +40,8 @@ compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_1) += compat-3.1.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ - compat-3.3.o + compat-3.3.o \ + flow_dissector.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o diff --git a/compat/flow_dissector.c b/compat/flow_dissector.c index 7dd7ec19..8affda0b 100644 --- a/compat/flow_dissector.c +++ b/compat/flow_dissector.c @@ -141,3 +141,4 @@ ipv6: return true; } +EXPORT_SYMBOL_GPL(skb_flow_dissect); diff --git a/compat/sch_fq_codel.c b/compat/sch_fq_codel.c new file mode 100644 index 00000000..f03df2ab --- /dev/null +++ b/compat/sch_fq_codel.c @@ -0,0 +1,659 @@ +/* + * Fair Queue CoDel discipline + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Copyright (C) 2012 Eric Dumazet + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Fair Queue CoDel. + * + * Principles : + * Packets are classified (internal classifier or external) on flows. + * This is a Stochastic model (as we use a hash, several flows + * might be hashed on same slot) + * Each flow has a CoDel managed queue. + * Flows are linked onto two (Round Robin) lists, + * so that new flows have priority on old ones. + * + * For a given flow, packets are not reordered (CoDel uses a FIFO) + * head drops only. + * ECN capability is on by default. + * Low memory footprint (64 bytes per flow) + */ + +struct fq_codel_flow { + struct sk_buff *head; + struct sk_buff *tail; + struct list_head flowchain; + int deficit; + u32 dropped; /* number of drops (or ECN marks) on this flow */ + struct codel_vars cvars; +}; /* please try to keep this structure <= 64 bytes */ + +struct fq_codel_sched_data { + struct tcf_proto *filter_list; /* optional external classifier */ + struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ + u32 *backlogs; /* backlog table [flows_cnt] */ + u32 flows_cnt; /* number of flows */ + u32 perturbation; /* hash perturbation */ + u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ + struct codel_params cparams; + struct codel_stats cstats; + u32 drop_overlimit; + u32 new_flow_count; + + struct list_head new_flows; /* list of new flows */ + struct list_head old_flows; /* list of old flows */ +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + u32 limit; +#endif +}; + +static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, + const struct sk_buff *skb) +{ + struct flow_keys keys; + unsigned int hash; + + skb_flow_dissect(skb, &keys); + hash = jhash_3words((__force u32)keys.dst, + (__force u32)keys.src ^ keys.ip_proto, + (__force u32)keys.ports, q->perturbation); + return ((u64)hash * q->flows_cnt) >> 32; +} + +static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, + int *qerr) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tcf_result res; + int result; + + if (TC_H_MAJ(skb->priority) == sch->handle && + TC_H_MIN(skb->priority) > 0 && + TC_H_MIN(skb->priority) <= q->flows_cnt) + return TC_H_MIN(skb->priority); + + if (!q->filter_list) + return fq_codel_hash(q, skb) + 1; + + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + result = tc_classify(skb, q->filter_list, &res); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return 0; + } +#endif + if (TC_H_MIN(res.classid) <= q->flows_cnt) + return TC_H_MIN(res.classid); + } + return 0; +} + +/* helper functions : might be changed when/if skb use a standard list_head */ + +/* remove one skb from head of slot queue */ +static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) +{ + struct sk_buff *skb = flow->head; + + flow->head = skb->next; + skb->next = NULL; + return skb; +} + +/* add skb to flow queue (tail add) */ +static inline void flow_queue_add(struct fq_codel_flow *flow, + struct sk_buff *skb) +{ + if (flow->head == NULL) + flow->head = skb; + else + flow->tail->next = skb; + flow->tail = skb; + skb->next = NULL; +} + +static unsigned int fq_codel_drop(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + unsigned int maxbacklog = 0, idx = 0, i, len; + struct fq_codel_flow *flow; + + /* Queue is full! Find the fat flow and drop packet from it. + * This might sound expensive, but with 1024 flows, we scan + * 4KB of memory, and we dont need to handle a complex tree + * in fast path (packet queue/enqueue) with many cache misses. + */ + for (i = 0; i < q->flows_cnt; i++) { + if (q->backlogs[i] > maxbacklog) { + maxbacklog = q->backlogs[i]; + idx = i; + } + } + flow = &q->flows[idx]; + skb = dequeue_head(flow); + len = qdisc_pkt_len(skb); + q->backlogs[idx] -= len; + kfree_skb(skb); + sch->q.qlen--; + sch->qstats.drops++; + sch->qstats.backlog -= len; + flow->dropped++; + return idx; +} + +static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int idx; + struct fq_codel_flow *flow; + int uninitialized_var(ret); + + idx = fq_codel_classify(skb, sch, &ret); + if (idx == 0) { + if (ret & __NET_XMIT_BYPASS) + sch->qstats.drops++; + kfree_skb(skb); + return ret; + } + idx--; + + codel_set_enqueue_time(skb); + flow = &q->flows[idx]; + flow_queue_add(flow, skb); + q->backlogs[idx] += qdisc_pkt_len(skb); + sch->qstats.backlog += qdisc_pkt_len(skb); + + if (list_empty(&flow->flowchain)) { + list_add_tail(&flow->flowchain, &q->new_flows); + codel_vars_init(&flow->cvars); + q->new_flow_count++; + flow->deficit = q->quantum; + flow->dropped = 0; + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (++sch->q.qlen < q->limit) +#else + if (++sch->q.qlen < sch->limit) +#endif + return NET_XMIT_SUCCESS; + + q->drop_overlimit++; + /* Return Congestion Notification only if we dropped a packet + * from this flow. + */ + if (fq_codel_drop(sch) == idx) + return NET_XMIT_CN; + + /* As we dropped a packet, better let upper stack know this */ + qdisc_tree_decrease_qlen(sch, 1); + return NET_XMIT_SUCCESS; +} + +/* This is the specific function called from codel_dequeue() + * to dequeue a packet from queue. Note: backlog is handled in + * codel, we dont need to reduce it here. + */ +static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct fq_codel_flow *flow; + struct sk_buff *skb = NULL; + + flow = container_of(vars, struct fq_codel_flow, cvars); + if (flow->head) { + skb = dequeue_head(flow); + q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); + sch->q.qlen--; + } + return skb; +} + +static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + struct fq_codel_flow *flow; + struct list_head *head; + u32 prev_drop_count, prev_ecn_mark; + +begin: + head = &q->new_flows; + if (list_empty(head)) { + head = &q->old_flows; + if (list_empty(head)) + return NULL; + } + flow = list_first_entry(head, struct fq_codel_flow, flowchain); + + if (flow->deficit <= 0) { + flow->deficit += q->quantum; + list_move_tail(&flow->flowchain, &q->old_flows); + goto begin; + } + + prev_drop_count = q->cstats.drop_count; + prev_ecn_mark = q->cstats.ecn_mark; + + skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, + dequeue); + + flow->dropped += q->cstats.drop_count - prev_drop_count; + flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; + + if (!skb) { + /* force a pass through old_flows to prevent starvation */ + if ((head == &q->new_flows) && !list_empty(&q->old_flows)) + list_move_tail(&flow->flowchain, &q->old_flows); + else + list_del_init(&flow->flowchain); + goto begin; + } + qdisc_bstats_update(sch, skb); + flow->deficit -= qdisc_pkt_len(skb); + /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, + * or HTB crashes. Defer it for next round. + */ + if (q->cstats.drop_count && sch->q.qlen) { + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + } + return skb; +} + +static void fq_codel_reset(struct Qdisc *sch) +{ + struct sk_buff *skb; + + while ((skb = fq_codel_dequeue(sch)) != NULL) + kfree_skb(skb); +} + +static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { + [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, +}; + +static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; + int err; + + if (!opt) + return -EINVAL; + + err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); + if (err < 0) + return err; + if (tb[TCA_FQ_CODEL_FLOWS]) { + if (q->flows) + return -EINVAL; + q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); + if (!q->flows_cnt || + q->flows_cnt > 65536) + return -EINVAL; + } + sch_tree_lock(sch); + + if (tb[TCA_FQ_CODEL_TARGET]) { + u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); + + q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_INTERVAL]) { + u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); + + q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_LIMIT]) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#else + sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#endif + + if (tb[TCA_FQ_CODEL_ECN]) + q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); + + if (tb[TCA_FQ_CODEL_QUANTUM]) + q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + while (sch->q.qlen > q->limit) { +#else + while (sch->q.qlen > sch->limit) { +#endif + struct sk_buff *skb = fq_codel_dequeue(sch); + + kfree_skb(skb); + q->cstats.drop_count++; + } + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + + sch_tree_unlock(sch); + return 0; +} + +static void *fq_codel_zalloc(size_t sz) +{ + void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); + + if (!ptr) + ptr = vzalloc(sz); + return ptr; +} + +static void fq_codel_free(void *addr) +{ + if (addr) { + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); + } +} + +static void fq_codel_destroy(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) + tcf_destroy_chain(&q->filter_list); +#else + tcf_destroy_chain(q->filter_list); +#endif + fq_codel_free(q->backlogs); + fq_codel_free(q->flows); +} + +static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + int i; + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = 10*1024; +#else + sch->limit = 10*1024; +#endif + q->flows_cnt = 1024; + q->quantum = psched_mtu(qdisc_dev(sch)); + q->perturbation = net_random(); + INIT_LIST_HEAD(&q->new_flows); + INIT_LIST_HEAD(&q->old_flows); + codel_params_init(&q->cparams); + codel_stats_init(&q->cstats); + q->cparams.ecn = true; + + if (opt) { + int err = fq_codel_change(sch, opt); + if (err) + return err; + } + + if (!q->flows) { + q->flows = fq_codel_zalloc(q->flows_cnt * + sizeof(struct fq_codel_flow)); + if (!q->flows) + return -ENOMEM; + q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); + if (!q->backlogs) { + fq_codel_free(q->flows); + return -ENOMEM; + } + for (i = 0; i < q->flows_cnt; i++) { + struct fq_codel_flow *flow = q->flows + i; + + INIT_LIST_HEAD(&flow->flowchain); + } + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (q->limit >= 1) +#else + if (sch->limit >= 1) +#endif + sch->flags |= TCQ_F_CAN_BYPASS; + else + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, + codel_time_to_us(q->cparams.target)) || + nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit) || +#else + sch->limit) || +#endif + nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, + codel_time_to_us(q->cparams.interval)) || + nla_put_u32(skb, TCA_FQ_CODEL_ECN, + q->cparams.ecn) || + nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, + q->quantum) || + nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, + q->flows_cnt)) + goto nla_put_failure; + + nla_nest_end(skb, opts); + return skb->len; + +nla_put_failure: + return -1; +} + +static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tc_fq_codel_xstats st = { + .type = TCA_FQ_CODEL_XSTATS_QDISC, + }; + struct list_head *pos; + + st.qdisc_stats.maxpacket = q->cstats.maxpacket; + st.qdisc_stats.drop_overlimit = q->drop_overlimit; + st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; + st.qdisc_stats.new_flow_count = q->new_flow_count; + + list_for_each(pos, &q->new_flows) + st.qdisc_stats.new_flows_len++; + + list_for_each(pos, &q->old_flows) + st.qdisc_stats.old_flows_len++; + + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) +{ + return NULL; +} + +static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) +{ + return 0; +} + +static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + /* we cannot bypass queue discipline anymore */ + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static void fq_codel_put(struct Qdisc *q, unsigned long cl) +{ +} + +static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + + if (cl) + return NULL; + return &q->filter_list; +} + +static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, + struct sk_buff *skb, struct tcmsg *tcm) +{ + tcm->tcm_handle |= TC_H_MIN(cl); + return 0; +} + +static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, + struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + u32 idx = cl - 1; + struct gnet_stats_queue qs = { 0 }; + struct tc_fq_codel_xstats xstats; + + if (idx < q->flows_cnt) { + const struct fq_codel_flow *flow = &q->flows[idx]; + const struct sk_buff *skb = flow->head; + + memset(&xstats, 0, sizeof(xstats)); + xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; + xstats.class_stats.deficit = flow->deficit; + xstats.class_stats.ldelay = + codel_time_to_us(flow->cvars.ldelay); + xstats.class_stats.count = flow->cvars.count; + xstats.class_stats.lastcount = flow->cvars.lastcount; + xstats.class_stats.dropping = flow->cvars.dropping; + if (flow->cvars.dropping) { + codel_tdiff_t delta = flow->cvars.drop_next - + codel_get_time(); + + xstats.class_stats.drop_next = (delta >= 0) ? + codel_time_to_us(delta) : + -codel_time_to_us(-delta); + } + while (skb) { + qs.qlen++; + skb = skb->next; + } + qs.backlog = q->backlogs[idx]; + qs.drops = flow->dropped; + } + if (gnet_stats_copy_queue(d, &qs) < 0) + return -1; + if (idx < q->flows_cnt) + return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); + return 0; +} + +static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int i; + + if (arg->stop) + return; + + for (i = 0; i < q->flows_cnt; i++) { + if (list_empty(&q->flows[i].flowchain) || + arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +static const struct Qdisc_class_ops fq_codel_class_ops = { + .leaf = fq_codel_leaf, + .get = fq_codel_get, + .put = fq_codel_put, + .tcf_chain = fq_codel_find_tcf, + .bind_tcf = fq_codel_bind, + .unbind_tcf = fq_codel_put, + .dump = fq_codel_dump_class, + .dump_stats = fq_codel_dump_class_stats, + .walk = fq_codel_walk, +}; + +static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { + .cl_ops = &fq_codel_class_ops, + .id = "fq_codel", + .priv_size = sizeof(struct fq_codel_sched_data), + .enqueue = fq_codel_enqueue, + .dequeue = fq_codel_dequeue, +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) + .peek = qdisc_peek_dequeued, +#endif + .drop = fq_codel_drop, + .init = fq_codel_init, + .reset = fq_codel_reset, + .destroy = fq_codel_destroy, + .change = fq_codel_change, + .dump = fq_codel_dump, + .dump_stats = fq_codel_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init fq_codel_module_init(void) +{ + return register_qdisc(&fq_codel_qdisc_ops); +} + +static void __exit fq_codel_module_exit(void) +{ + unregister_qdisc(&fq_codel_qdisc_ops); +} + +module_init(fq_codel_module_init) +module_exit(fq_codel_module_exit) +MODULE_AUTHOR("Eric Dumazet"); +MODULE_LICENSE("GPL"); diff --git a/compat/sch_fq_codel_core.c b/compat/sch_fq_codel_core.c deleted file mode 100644 index f03df2ab..00000000 --- a/compat/sch_fq_codel_core.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Fair Queue CoDel discipline - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Copyright (C) 2012 Eric Dumazet - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Fair Queue CoDel. - * - * Principles : - * Packets are classified (internal classifier or external) on flows. - * This is a Stochastic model (as we use a hash, several flows - * might be hashed on same slot) - * Each flow has a CoDel managed queue. - * Flows are linked onto two (Round Robin) lists, - * so that new flows have priority on old ones. - * - * For a given flow, packets are not reordered (CoDel uses a FIFO) - * head drops only. - * ECN capability is on by default. - * Low memory footprint (64 bytes per flow) - */ - -struct fq_codel_flow { - struct sk_buff *head; - struct sk_buff *tail; - struct list_head flowchain; - int deficit; - u32 dropped; /* number of drops (or ECN marks) on this flow */ - struct codel_vars cvars; -}; /* please try to keep this structure <= 64 bytes */ - -struct fq_codel_sched_data { - struct tcf_proto *filter_list; /* optional external classifier */ - struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ - u32 *backlogs; /* backlog table [flows_cnt] */ - u32 flows_cnt; /* number of flows */ - u32 perturbation; /* hash perturbation */ - u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ - struct codel_params cparams; - struct codel_stats cstats; - u32 drop_overlimit; - u32 new_flow_count; - - struct list_head new_flows; /* list of new flows */ - struct list_head old_flows; /* list of old flows */ -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - u32 limit; -#endif -}; - -static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, - const struct sk_buff *skb) -{ - struct flow_keys keys; - unsigned int hash; - - skb_flow_dissect(skb, &keys); - hash = jhash_3words((__force u32)keys.dst, - (__force u32)keys.src ^ keys.ip_proto, - (__force u32)keys.ports, q->perturbation); - return ((u64)hash * q->flows_cnt) >> 32; -} - -static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, - int *qerr) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tcf_result res; - int result; - - if (TC_H_MAJ(skb->priority) == sch->handle && - TC_H_MIN(skb->priority) > 0 && - TC_H_MIN(skb->priority) <= q->flows_cnt) - return TC_H_MIN(skb->priority); - - if (!q->filter_list) - return fq_codel_hash(q, skb) + 1; - - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result = tc_classify(skb, q->filter_list, &res); - if (result >= 0) { -#ifdef CONFIG_NET_CLS_ACT - switch (result) { - case TC_ACT_STOLEN: - case TC_ACT_QUEUED: - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; - case TC_ACT_SHOT: - return 0; - } -#endif - if (TC_H_MIN(res.classid) <= q->flows_cnt) - return TC_H_MIN(res.classid); - } - return 0; -} - -/* helper functions : might be changed when/if skb use a standard list_head */ - -/* remove one skb from head of slot queue */ -static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) -{ - struct sk_buff *skb = flow->head; - - flow->head = skb->next; - skb->next = NULL; - return skb; -} - -/* add skb to flow queue (tail add) */ -static inline void flow_queue_add(struct fq_codel_flow *flow, - struct sk_buff *skb) -{ - if (flow->head == NULL) - flow->head = skb; - else - flow->tail->next = skb; - flow->tail = skb; - skb->next = NULL; -} - -static unsigned int fq_codel_drop(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - unsigned int maxbacklog = 0, idx = 0, i, len; - struct fq_codel_flow *flow; - - /* Queue is full! Find the fat flow and drop packet from it. - * This might sound expensive, but with 1024 flows, we scan - * 4KB of memory, and we dont need to handle a complex tree - * in fast path (packet queue/enqueue) with many cache misses. - */ - for (i = 0; i < q->flows_cnt; i++) { - if (q->backlogs[i] > maxbacklog) { - maxbacklog = q->backlogs[i]; - idx = i; - } - } - flow = &q->flows[idx]; - skb = dequeue_head(flow); - len = qdisc_pkt_len(skb); - q->backlogs[idx] -= len; - kfree_skb(skb); - sch->q.qlen--; - sch->qstats.drops++; - sch->qstats.backlog -= len; - flow->dropped++; - return idx; -} - -static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int idx; - struct fq_codel_flow *flow; - int uninitialized_var(ret); - - idx = fq_codel_classify(skb, sch, &ret); - if (idx == 0) { - if (ret & __NET_XMIT_BYPASS) - sch->qstats.drops++; - kfree_skb(skb); - return ret; - } - idx--; - - codel_set_enqueue_time(skb); - flow = &q->flows[idx]; - flow_queue_add(flow, skb); - q->backlogs[idx] += qdisc_pkt_len(skb); - sch->qstats.backlog += qdisc_pkt_len(skb); - - if (list_empty(&flow->flowchain)) { - list_add_tail(&flow->flowchain, &q->new_flows); - codel_vars_init(&flow->cvars); - q->new_flow_count++; - flow->deficit = q->quantum; - flow->dropped = 0; - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (++sch->q.qlen < q->limit) -#else - if (++sch->q.qlen < sch->limit) -#endif - return NET_XMIT_SUCCESS; - - q->drop_overlimit++; - /* Return Congestion Notification only if we dropped a packet - * from this flow. - */ - if (fq_codel_drop(sch) == idx) - return NET_XMIT_CN; - - /* As we dropped a packet, better let upper stack know this */ - qdisc_tree_decrease_qlen(sch, 1); - return NET_XMIT_SUCCESS; -} - -/* This is the specific function called from codel_dequeue() - * to dequeue a packet from queue. Note: backlog is handled in - * codel, we dont need to reduce it here. - */ -static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct fq_codel_flow *flow; - struct sk_buff *skb = NULL; - - flow = container_of(vars, struct fq_codel_flow, cvars); - if (flow->head) { - skb = dequeue_head(flow); - q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); - sch->q.qlen--; - } - return skb; -} - -static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - struct fq_codel_flow *flow; - struct list_head *head; - u32 prev_drop_count, prev_ecn_mark; - -begin: - head = &q->new_flows; - if (list_empty(head)) { - head = &q->old_flows; - if (list_empty(head)) - return NULL; - } - flow = list_first_entry(head, struct fq_codel_flow, flowchain); - - if (flow->deficit <= 0) { - flow->deficit += q->quantum; - list_move_tail(&flow->flowchain, &q->old_flows); - goto begin; - } - - prev_drop_count = q->cstats.drop_count; - prev_ecn_mark = q->cstats.ecn_mark; - - skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, - dequeue); - - flow->dropped += q->cstats.drop_count - prev_drop_count; - flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; - - if (!skb) { - /* force a pass through old_flows to prevent starvation */ - if ((head == &q->new_flows) && !list_empty(&q->old_flows)) - list_move_tail(&flow->flowchain, &q->old_flows); - else - list_del_init(&flow->flowchain); - goto begin; - } - qdisc_bstats_update(sch, skb); - flow->deficit -= qdisc_pkt_len(skb); - /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, - * or HTB crashes. Defer it for next round. - */ - if (q->cstats.drop_count && sch->q.qlen) { - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - } - return skb; -} - -static void fq_codel_reset(struct Qdisc *sch) -{ - struct sk_buff *skb; - - while ((skb = fq_codel_dequeue(sch)) != NULL) - kfree_skb(skb); -} - -static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { - [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, -}; - -static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; - int err; - - if (!opt) - return -EINVAL; - - err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); - if (err < 0) - return err; - if (tb[TCA_FQ_CODEL_FLOWS]) { - if (q->flows) - return -EINVAL; - q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); - if (!q->flows_cnt || - q->flows_cnt > 65536) - return -EINVAL; - } - sch_tree_lock(sch); - - if (tb[TCA_FQ_CODEL_TARGET]) { - u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); - - q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_INTERVAL]) { - u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); - - q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_LIMIT]) -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#else - sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#endif - - if (tb[TCA_FQ_CODEL_ECN]) - q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); - - if (tb[TCA_FQ_CODEL_QUANTUM]) - q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - while (sch->q.qlen > q->limit) { -#else - while (sch->q.qlen > sch->limit) { -#endif - struct sk_buff *skb = fq_codel_dequeue(sch); - - kfree_skb(skb); - q->cstats.drop_count++; - } - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - - sch_tree_unlock(sch); - return 0; -} - -static void *fq_codel_zalloc(size_t sz) -{ - void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); - - if (!ptr) - ptr = vzalloc(sz); - return ptr; -} - -static void fq_codel_free(void *addr) -{ - if (addr) { - if (is_vmalloc_addr(addr)) - vfree(addr); - else - kfree(addr); - } -} - -static void fq_codel_destroy(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) - tcf_destroy_chain(&q->filter_list); -#else - tcf_destroy_chain(q->filter_list); -#endif - fq_codel_free(q->backlogs); - fq_codel_free(q->flows); -} - -static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - int i; - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = 10*1024; -#else - sch->limit = 10*1024; -#endif - q->flows_cnt = 1024; - q->quantum = psched_mtu(qdisc_dev(sch)); - q->perturbation = net_random(); - INIT_LIST_HEAD(&q->new_flows); - INIT_LIST_HEAD(&q->old_flows); - codel_params_init(&q->cparams); - codel_stats_init(&q->cstats); - q->cparams.ecn = true; - - if (opt) { - int err = fq_codel_change(sch, opt); - if (err) - return err; - } - - if (!q->flows) { - q->flows = fq_codel_zalloc(q->flows_cnt * - sizeof(struct fq_codel_flow)); - if (!q->flows) - return -ENOMEM; - q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); - if (!q->backlogs) { - fq_codel_free(q->flows); - return -ENOMEM; - } - for (i = 0; i < q->flows_cnt; i++) { - struct fq_codel_flow *flow = q->flows + i; - - INIT_LIST_HEAD(&flow->flowchain); - } - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (q->limit >= 1) -#else - if (sch->limit >= 1) -#endif - sch->flags |= TCQ_F_CAN_BYPASS; - else - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *opts; - - opts = nla_nest_start(skb, TCA_OPTIONS); - if (opts == NULL) - goto nla_put_failure; - - if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, - codel_time_to_us(q->cparams.target)) || - nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit) || -#else - sch->limit) || -#endif - nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, - codel_time_to_us(q->cparams.interval)) || - nla_put_u32(skb, TCA_FQ_CODEL_ECN, - q->cparams.ecn) || - nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, - q->quantum) || - nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, - q->flows_cnt)) - goto nla_put_failure; - - nla_nest_end(skb, opts); - return skb->len; - -nla_put_failure: - return -1; -} - -static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tc_fq_codel_xstats st = { - .type = TCA_FQ_CODEL_XSTATS_QDISC, - }; - struct list_head *pos; - - st.qdisc_stats.maxpacket = q->cstats.maxpacket; - st.qdisc_stats.drop_overlimit = q->drop_overlimit; - st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; - st.qdisc_stats.new_flow_count = q->new_flow_count; - - list_for_each(pos, &q->new_flows) - st.qdisc_stats.new_flows_len++; - - list_for_each(pos, &q->old_flows) - st.qdisc_stats.old_flows_len++; - - return gnet_stats_copy_app(d, &st, sizeof(st)); -} - -static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) -{ - return NULL; -} - -static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) -{ - return 0; -} - -static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, - u32 classid) -{ - /* we cannot bypass queue discipline anymore */ - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static void fq_codel_put(struct Qdisc *q, unsigned long cl) -{ -} - -static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - - if (cl) - return NULL; - return &q->filter_list; -} - -static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, - struct sk_buff *skb, struct tcmsg *tcm) -{ - tcm->tcm_handle |= TC_H_MIN(cl); - return 0; -} - -static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, - struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - u32 idx = cl - 1; - struct gnet_stats_queue qs = { 0 }; - struct tc_fq_codel_xstats xstats; - - if (idx < q->flows_cnt) { - const struct fq_codel_flow *flow = &q->flows[idx]; - const struct sk_buff *skb = flow->head; - - memset(&xstats, 0, sizeof(xstats)); - xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; - xstats.class_stats.deficit = flow->deficit; - xstats.class_stats.ldelay = - codel_time_to_us(flow->cvars.ldelay); - xstats.class_stats.count = flow->cvars.count; - xstats.class_stats.lastcount = flow->cvars.lastcount; - xstats.class_stats.dropping = flow->cvars.dropping; - if (flow->cvars.dropping) { - codel_tdiff_t delta = flow->cvars.drop_next - - codel_get_time(); - - xstats.class_stats.drop_next = (delta >= 0) ? - codel_time_to_us(delta) : - -codel_time_to_us(-delta); - } - while (skb) { - qs.qlen++; - skb = skb->next; - } - qs.backlog = q->backlogs[idx]; - qs.drops = flow->dropped; - } - if (gnet_stats_copy_queue(d, &qs) < 0) - return -1; - if (idx < q->flows_cnt) - return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); - return 0; -} - -static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int i; - - if (arg->stop) - return; - - for (i = 0; i < q->flows_cnt; i++) { - if (list_empty(&q->flows[i].flowchain) || - arg->count < arg->skip) { - arg->count++; - continue; - } - if (arg->fn(sch, i + 1, arg) < 0) { - arg->stop = 1; - break; - } - arg->count++; - } -} - -static const struct Qdisc_class_ops fq_codel_class_ops = { - .leaf = fq_codel_leaf, - .get = fq_codel_get, - .put = fq_codel_put, - .tcf_chain = fq_codel_find_tcf, - .bind_tcf = fq_codel_bind, - .unbind_tcf = fq_codel_put, - .dump = fq_codel_dump_class, - .dump_stats = fq_codel_dump_class_stats, - .walk = fq_codel_walk, -}; - -static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { - .cl_ops = &fq_codel_class_ops, - .id = "fq_codel", - .priv_size = sizeof(struct fq_codel_sched_data), - .enqueue = fq_codel_enqueue, - .dequeue = fq_codel_dequeue, -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) - .peek = qdisc_peek_dequeued, -#endif - .drop = fq_codel_drop, - .init = fq_codel_init, - .reset = fq_codel_reset, - .destroy = fq_codel_destroy, - .change = fq_codel_change, - .dump = fq_codel_dump, - .dump_stats = fq_codel_dump_stats, - .owner = THIS_MODULE, -}; - -static int __init fq_codel_module_init(void) -{ - return register_qdisc(&fq_codel_qdisc_ops); -} - -static void __exit fq_codel_module_exit(void) -{ - unregister_qdisc(&fq_codel_qdisc_ops); -} - -module_init(fq_codel_module_init) -module_exit(fq_codel_module_exit) -MODULE_AUTHOR("Eric Dumazet"); -MODULE_LICENSE("GPL"); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 7fadbf2a..6bb450da 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -147,7 +147,6 @@ static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev, * Subject: [PATCH] codel: Controlled Delay AQM */ -#ifndef TCA_CODEL_MAX /* CODEL */ enum { @@ -235,7 +234,6 @@ struct tc_fq_codel_xstats { struct tc_fq_codel_cl_stats class_stats; }; }; -#endif /* TCA_CODEL_MAX */ /* Backports tty_lock: Localise the lock */ diff --git a/include/net/codel.h b/include/net/codel.h index ab901c57..128082ed 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -1,7 +1,6 @@ #include -#include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) || defined(TCA_CODEL_MAX) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) #include_next #else -- cgit v1.2.3 From 19041dd7befe97f476c187bc15442cd738c67f37 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 7 Aug 2012 00:36:20 +0200 Subject: compat: fix undef syntax Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 05b41c2b..51486b0c 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -133,7 +133,7 @@ int compat_schedule_delayed_work_on(int cpu, } EXPORT_SYMBOL_GPL(compat_schedule_delayed_work_on); -#undef flush_scheduled_work(a) +#undef flush_scheduled_work void compat_flush_scheduled_work(void) { /* -- cgit v1.2.3 From 2f57a7796e381cecf63b75e3a975d5541ab330e0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 7 Aug 2012 00:36:21 +0200 Subject: compat: add include/linux/olpc-ec.h The libertas driver now needs this include file. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/olpc-ec.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 include/linux/olpc-ec.h diff --git a/include/linux/olpc-ec.h b/include/linux/olpc-ec.h new file mode 100644 index 00000000..a5b932a7 --- /dev/null +++ b/include/linux/olpc-ec.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_LINUX_OLPC_EC_H +#define _COMPAT_LINUX_OLPC_EC_H + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) +#include_next +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,6,0)) */ + +#endif /* _COMPAT_LINUX_OLPC_EC_H */ -- cgit v1.2.3 From d192c4b99f9f8afca003fbad3d86d3c28906db2b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 6 Aug 2012 23:23:31 -0700 Subject: compat: revert 3da0495c compat_flush_scheduled_work "fix" This revert: commit 3da0495cf863288b6798e121ccf93c4453c6c768 Author: Zefir Kurtisi Date: Fri Jul 13 10:38:34 2012 +0200 compat: fix system crash on 2.6.35 when flushing work Ubuntu 10.10 stock kernel (2.6.35-22-generic) crashes in compat_flush_scheduled_work(), that is called e.g. when mac80211 module is unloaded. The problem was introduced with 80bf8a83 compat: backport system work queues system_wq and system_long_wq The crash happens in compat_flush_scheduled_work() where both flush_workqueue() and flush_scheduled_work() are called successively. Removing one of them resolves the issue. All compat-wireless tarballs after 2012-03-18 are affected. Signed-off-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez Turns out the real issue was the recursive call to compat_flush_scheduled_work(). Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 1 + 1 file changed, 1 insertion(+) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 51486b0c..72ada4a4 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -141,6 +141,7 @@ void compat_flush_scheduled_work(void) * go with the old kernel's one first for now (keventd_wq) and * if think its reasonable later we can flip this around. */ + flush_workqueue(system_wq); flush_scheduled_work(); } EXPORT_SYMBOL_GPL(compat_flush_scheduled_work); -- cgit v1.2.3 From f3196e963f42d83cdbb32699133636bcf4d03ff5 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Sun, 5 Aug 2012 12:29:41 +0200 Subject: compat: deal with backported codel Some distro kernels (in particular the Debian 3.2.0-3 kernel I'm running) backport codel already, so trying to backport it again causes issues. Protect the compat backport with #ifdef TCA_CODEL_MAX. Also link the flow_dissector code into the codel module which then won't be loaded on kernels that already have codel backported. Signed-off-by: Johannes Berg Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 6 +- compat/flow_dissector.c | 1 - compat/sch_fq_codel.c | 659 --------------------------------------------- compat/sch_fq_codel_core.c | 659 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.5.h | 4 + include/net/codel.h | 3 +- 6 files changed, 669 insertions(+), 663 deletions(-) delete mode 100644 compat/sch_fq_codel.c create mode 100644 compat/sch_fq_codel_core.c diff --git a/compat/Makefile b/compat/Makefile index c661f5da..23c1296c 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -3,6 +3,9 @@ obj-m += compat.o obj-$(CONFIG_COMPAT_FIRMWARE_CLASS) += compat_firmware_class.o obj-$(CONFIG_COMPAT_NET_SCH_CODEL) += sch_codel.o + +sch_fq_codel-y = sch_fq_codel_core.o flow_dissector.o + obj-$(CONFIG_COMPAT_NET_SCH_FQ_CODEL) += sch_fq_codel.o compat-y += main.o @@ -40,8 +43,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_0) += compat-3.0.o compat-$(CONFIG_COMPAT_KERNEL_3_1) += compat-3.1.o compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ - compat-3.3.o \ - flow_dissector.o + compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o diff --git a/compat/flow_dissector.c b/compat/flow_dissector.c index 8affda0b..7dd7ec19 100644 --- a/compat/flow_dissector.c +++ b/compat/flow_dissector.c @@ -141,4 +141,3 @@ ipv6: return true; } -EXPORT_SYMBOL_GPL(skb_flow_dissect); diff --git a/compat/sch_fq_codel.c b/compat/sch_fq_codel.c deleted file mode 100644 index f03df2ab..00000000 --- a/compat/sch_fq_codel.c +++ /dev/null @@ -1,659 +0,0 @@ -/* - * Fair Queue CoDel discipline - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version - * 2 of the License, or (at your option) any later version. - * - * Copyright (C) 2012 Eric Dumazet - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Fair Queue CoDel. - * - * Principles : - * Packets are classified (internal classifier or external) on flows. - * This is a Stochastic model (as we use a hash, several flows - * might be hashed on same slot) - * Each flow has a CoDel managed queue. - * Flows are linked onto two (Round Robin) lists, - * so that new flows have priority on old ones. - * - * For a given flow, packets are not reordered (CoDel uses a FIFO) - * head drops only. - * ECN capability is on by default. - * Low memory footprint (64 bytes per flow) - */ - -struct fq_codel_flow { - struct sk_buff *head; - struct sk_buff *tail; - struct list_head flowchain; - int deficit; - u32 dropped; /* number of drops (or ECN marks) on this flow */ - struct codel_vars cvars; -}; /* please try to keep this structure <= 64 bytes */ - -struct fq_codel_sched_data { - struct tcf_proto *filter_list; /* optional external classifier */ - struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ - u32 *backlogs; /* backlog table [flows_cnt] */ - u32 flows_cnt; /* number of flows */ - u32 perturbation; /* hash perturbation */ - u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ - struct codel_params cparams; - struct codel_stats cstats; - u32 drop_overlimit; - u32 new_flow_count; - - struct list_head new_flows; /* list of new flows */ - struct list_head old_flows; /* list of old flows */ -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - u32 limit; -#endif -}; - -static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, - const struct sk_buff *skb) -{ - struct flow_keys keys; - unsigned int hash; - - skb_flow_dissect(skb, &keys); - hash = jhash_3words((__force u32)keys.dst, - (__force u32)keys.src ^ keys.ip_proto, - (__force u32)keys.ports, q->perturbation); - return ((u64)hash * q->flows_cnt) >> 32; -} - -static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, - int *qerr) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tcf_result res; - int result; - - if (TC_H_MAJ(skb->priority) == sch->handle && - TC_H_MIN(skb->priority) > 0 && - TC_H_MIN(skb->priority) <= q->flows_cnt) - return TC_H_MIN(skb->priority); - - if (!q->filter_list) - return fq_codel_hash(q, skb) + 1; - - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; - result = tc_classify(skb, q->filter_list, &res); - if (result >= 0) { -#ifdef CONFIG_NET_CLS_ACT - switch (result) { - case TC_ACT_STOLEN: - case TC_ACT_QUEUED: - *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; - case TC_ACT_SHOT: - return 0; - } -#endif - if (TC_H_MIN(res.classid) <= q->flows_cnt) - return TC_H_MIN(res.classid); - } - return 0; -} - -/* helper functions : might be changed when/if skb use a standard list_head */ - -/* remove one skb from head of slot queue */ -static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) -{ - struct sk_buff *skb = flow->head; - - flow->head = skb->next; - skb->next = NULL; - return skb; -} - -/* add skb to flow queue (tail add) */ -static inline void flow_queue_add(struct fq_codel_flow *flow, - struct sk_buff *skb) -{ - if (flow->head == NULL) - flow->head = skb; - else - flow->tail->next = skb; - flow->tail = skb; - skb->next = NULL; -} - -static unsigned int fq_codel_drop(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - unsigned int maxbacklog = 0, idx = 0, i, len; - struct fq_codel_flow *flow; - - /* Queue is full! Find the fat flow and drop packet from it. - * This might sound expensive, but with 1024 flows, we scan - * 4KB of memory, and we dont need to handle a complex tree - * in fast path (packet queue/enqueue) with many cache misses. - */ - for (i = 0; i < q->flows_cnt; i++) { - if (q->backlogs[i] > maxbacklog) { - maxbacklog = q->backlogs[i]; - idx = i; - } - } - flow = &q->flows[idx]; - skb = dequeue_head(flow); - len = qdisc_pkt_len(skb); - q->backlogs[idx] -= len; - kfree_skb(skb); - sch->q.qlen--; - sch->qstats.drops++; - sch->qstats.backlog -= len; - flow->dropped++; - return idx; -} - -static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int idx; - struct fq_codel_flow *flow; - int uninitialized_var(ret); - - idx = fq_codel_classify(skb, sch, &ret); - if (idx == 0) { - if (ret & __NET_XMIT_BYPASS) - sch->qstats.drops++; - kfree_skb(skb); - return ret; - } - idx--; - - codel_set_enqueue_time(skb); - flow = &q->flows[idx]; - flow_queue_add(flow, skb); - q->backlogs[idx] += qdisc_pkt_len(skb); - sch->qstats.backlog += qdisc_pkt_len(skb); - - if (list_empty(&flow->flowchain)) { - list_add_tail(&flow->flowchain, &q->new_flows); - codel_vars_init(&flow->cvars); - q->new_flow_count++; - flow->deficit = q->quantum; - flow->dropped = 0; - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (++sch->q.qlen < q->limit) -#else - if (++sch->q.qlen < sch->limit) -#endif - return NET_XMIT_SUCCESS; - - q->drop_overlimit++; - /* Return Congestion Notification only if we dropped a packet - * from this flow. - */ - if (fq_codel_drop(sch) == idx) - return NET_XMIT_CN; - - /* As we dropped a packet, better let upper stack know this */ - qdisc_tree_decrease_qlen(sch, 1); - return NET_XMIT_SUCCESS; -} - -/* This is the specific function called from codel_dequeue() - * to dequeue a packet from queue. Note: backlog is handled in - * codel, we dont need to reduce it here. - */ -static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct fq_codel_flow *flow; - struct sk_buff *skb = NULL; - - flow = container_of(vars, struct fq_codel_flow, cvars); - if (flow->head) { - skb = dequeue_head(flow); - q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); - sch->q.qlen--; - } - return skb; -} - -static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct sk_buff *skb; - struct fq_codel_flow *flow; - struct list_head *head; - u32 prev_drop_count, prev_ecn_mark; - -begin: - head = &q->new_flows; - if (list_empty(head)) { - head = &q->old_flows; - if (list_empty(head)) - return NULL; - } - flow = list_first_entry(head, struct fq_codel_flow, flowchain); - - if (flow->deficit <= 0) { - flow->deficit += q->quantum; - list_move_tail(&flow->flowchain, &q->old_flows); - goto begin; - } - - prev_drop_count = q->cstats.drop_count; - prev_ecn_mark = q->cstats.ecn_mark; - - skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, - dequeue); - - flow->dropped += q->cstats.drop_count - prev_drop_count; - flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; - - if (!skb) { - /* force a pass through old_flows to prevent starvation */ - if ((head == &q->new_flows) && !list_empty(&q->old_flows)) - list_move_tail(&flow->flowchain, &q->old_flows); - else - list_del_init(&flow->flowchain); - goto begin; - } - qdisc_bstats_update(sch, skb); - flow->deficit -= qdisc_pkt_len(skb); - /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, - * or HTB crashes. Defer it for next round. - */ - if (q->cstats.drop_count && sch->q.qlen) { - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - } - return skb; -} - -static void fq_codel_reset(struct Qdisc *sch) -{ - struct sk_buff *skb; - - while ((skb = fq_codel_dequeue(sch)) != NULL) - kfree_skb(skb); -} - -static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { - [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, - [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, -}; - -static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; - int err; - - if (!opt) - return -EINVAL; - - err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); - if (err < 0) - return err; - if (tb[TCA_FQ_CODEL_FLOWS]) { - if (q->flows) - return -EINVAL; - q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); - if (!q->flows_cnt || - q->flows_cnt > 65536) - return -EINVAL; - } - sch_tree_lock(sch); - - if (tb[TCA_FQ_CODEL_TARGET]) { - u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); - - q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_INTERVAL]) { - u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); - - q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; - } - - if (tb[TCA_FQ_CODEL_LIMIT]) -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#else - sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); -#endif - - if (tb[TCA_FQ_CODEL_ECN]) - q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); - - if (tb[TCA_FQ_CODEL_QUANTUM]) - q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - while (sch->q.qlen > q->limit) { -#else - while (sch->q.qlen > sch->limit) { -#endif - struct sk_buff *skb = fq_codel_dequeue(sch); - - kfree_skb(skb); - q->cstats.drop_count++; - } - qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); - q->cstats.drop_count = 0; - - sch_tree_unlock(sch); - return 0; -} - -static void *fq_codel_zalloc(size_t sz) -{ - void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); - - if (!ptr) - ptr = vzalloc(sz); - return ptr; -} - -static void fq_codel_free(void *addr) -{ - if (addr) { - if (is_vmalloc_addr(addr)) - vfree(addr); - else - kfree(addr); - } -} - -static void fq_codel_destroy(struct Qdisc *sch) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) - tcf_destroy_chain(&q->filter_list); -#else - tcf_destroy_chain(q->filter_list); -#endif - fq_codel_free(q->backlogs); - fq_codel_free(q->flows); -} - -static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - int i; - -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit = 10*1024; -#else - sch->limit = 10*1024; -#endif - q->flows_cnt = 1024; - q->quantum = psched_mtu(qdisc_dev(sch)); - q->perturbation = net_random(); - INIT_LIST_HEAD(&q->new_flows); - INIT_LIST_HEAD(&q->old_flows); - codel_params_init(&q->cparams); - codel_stats_init(&q->cstats); - q->cparams.ecn = true; - - if (opt) { - int err = fq_codel_change(sch, opt); - if (err) - return err; - } - - if (!q->flows) { - q->flows = fq_codel_zalloc(q->flows_cnt * - sizeof(struct fq_codel_flow)); - if (!q->flows) - return -ENOMEM; - q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); - if (!q->backlogs) { - fq_codel_free(q->flows); - return -ENOMEM; - } - for (i = 0; i < q->flows_cnt; i++) { - struct fq_codel_flow *flow = q->flows + i; - - INIT_LIST_HEAD(&flow->flowchain); - } - } -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - if (q->limit >= 1) -#else - if (sch->limit >= 1) -#endif - sch->flags |= TCQ_F_CAN_BYPASS; - else - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct nlattr *opts; - - opts = nla_nest_start(skb, TCA_OPTIONS); - if (opts == NULL) - goto nla_put_failure; - - if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, - codel_time_to_us(q->cparams.target)) || - nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, -#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) - q->limit) || -#else - sch->limit) || -#endif - nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, - codel_time_to_us(q->cparams.interval)) || - nla_put_u32(skb, TCA_FQ_CODEL_ECN, - q->cparams.ecn) || - nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, - q->quantum) || - nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, - q->flows_cnt)) - goto nla_put_failure; - - nla_nest_end(skb, opts); - return skb->len; - -nla_put_failure: - return -1; -} - -static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - struct tc_fq_codel_xstats st = { - .type = TCA_FQ_CODEL_XSTATS_QDISC, - }; - struct list_head *pos; - - st.qdisc_stats.maxpacket = q->cstats.maxpacket; - st.qdisc_stats.drop_overlimit = q->drop_overlimit; - st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; - st.qdisc_stats.new_flow_count = q->new_flow_count; - - list_for_each(pos, &q->new_flows) - st.qdisc_stats.new_flows_len++; - - list_for_each(pos, &q->old_flows) - st.qdisc_stats.old_flows_len++; - - return gnet_stats_copy_app(d, &st, sizeof(st)); -} - -static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) -{ - return NULL; -} - -static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) -{ - return 0; -} - -static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, - u32 classid) -{ - /* we cannot bypass queue discipline anymore */ - sch->flags &= ~TCQ_F_CAN_BYPASS; - return 0; -} - -static void fq_codel_put(struct Qdisc *q, unsigned long cl) -{ -} - -static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - - if (cl) - return NULL; - return &q->filter_list; -} - -static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, - struct sk_buff *skb, struct tcmsg *tcm) -{ - tcm->tcm_handle |= TC_H_MIN(cl); - return 0; -} - -static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, - struct gnet_dump *d) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - u32 idx = cl - 1; - struct gnet_stats_queue qs = { 0 }; - struct tc_fq_codel_xstats xstats; - - if (idx < q->flows_cnt) { - const struct fq_codel_flow *flow = &q->flows[idx]; - const struct sk_buff *skb = flow->head; - - memset(&xstats, 0, sizeof(xstats)); - xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; - xstats.class_stats.deficit = flow->deficit; - xstats.class_stats.ldelay = - codel_time_to_us(flow->cvars.ldelay); - xstats.class_stats.count = flow->cvars.count; - xstats.class_stats.lastcount = flow->cvars.lastcount; - xstats.class_stats.dropping = flow->cvars.dropping; - if (flow->cvars.dropping) { - codel_tdiff_t delta = flow->cvars.drop_next - - codel_get_time(); - - xstats.class_stats.drop_next = (delta >= 0) ? - codel_time_to_us(delta) : - -codel_time_to_us(-delta); - } - while (skb) { - qs.qlen++; - skb = skb->next; - } - qs.backlog = q->backlogs[idx]; - qs.drops = flow->dropped; - } - if (gnet_stats_copy_queue(d, &qs) < 0) - return -1; - if (idx < q->flows_cnt) - return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); - return 0; -} - -static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) -{ - struct fq_codel_sched_data *q = qdisc_priv(sch); - unsigned int i; - - if (arg->stop) - return; - - for (i = 0; i < q->flows_cnt; i++) { - if (list_empty(&q->flows[i].flowchain) || - arg->count < arg->skip) { - arg->count++; - continue; - } - if (arg->fn(sch, i + 1, arg) < 0) { - arg->stop = 1; - break; - } - arg->count++; - } -} - -static const struct Qdisc_class_ops fq_codel_class_ops = { - .leaf = fq_codel_leaf, - .get = fq_codel_get, - .put = fq_codel_put, - .tcf_chain = fq_codel_find_tcf, - .bind_tcf = fq_codel_bind, - .unbind_tcf = fq_codel_put, - .dump = fq_codel_dump_class, - .dump_stats = fq_codel_dump_class_stats, - .walk = fq_codel_walk, -}; - -static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { - .cl_ops = &fq_codel_class_ops, - .id = "fq_codel", - .priv_size = sizeof(struct fq_codel_sched_data), - .enqueue = fq_codel_enqueue, - .dequeue = fq_codel_dequeue, -#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) - .peek = qdisc_peek_dequeued, -#endif - .drop = fq_codel_drop, - .init = fq_codel_init, - .reset = fq_codel_reset, - .destroy = fq_codel_destroy, - .change = fq_codel_change, - .dump = fq_codel_dump, - .dump_stats = fq_codel_dump_stats, - .owner = THIS_MODULE, -}; - -static int __init fq_codel_module_init(void) -{ - return register_qdisc(&fq_codel_qdisc_ops); -} - -static void __exit fq_codel_module_exit(void) -{ - unregister_qdisc(&fq_codel_qdisc_ops); -} - -module_init(fq_codel_module_init) -module_exit(fq_codel_module_exit) -MODULE_AUTHOR("Eric Dumazet"); -MODULE_LICENSE("GPL"); diff --git a/compat/sch_fq_codel_core.c b/compat/sch_fq_codel_core.c new file mode 100644 index 00000000..f03df2ab --- /dev/null +++ b/compat/sch_fq_codel_core.c @@ -0,0 +1,659 @@ +/* + * Fair Queue CoDel discipline + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + * + * Copyright (C) 2012 Eric Dumazet + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Fair Queue CoDel. + * + * Principles : + * Packets are classified (internal classifier or external) on flows. + * This is a Stochastic model (as we use a hash, several flows + * might be hashed on same slot) + * Each flow has a CoDel managed queue. + * Flows are linked onto two (Round Robin) lists, + * so that new flows have priority on old ones. + * + * For a given flow, packets are not reordered (CoDel uses a FIFO) + * head drops only. + * ECN capability is on by default. + * Low memory footprint (64 bytes per flow) + */ + +struct fq_codel_flow { + struct sk_buff *head; + struct sk_buff *tail; + struct list_head flowchain; + int deficit; + u32 dropped; /* number of drops (or ECN marks) on this flow */ + struct codel_vars cvars; +}; /* please try to keep this structure <= 64 bytes */ + +struct fq_codel_sched_data { + struct tcf_proto *filter_list; /* optional external classifier */ + struct fq_codel_flow *flows; /* Flows table [flows_cnt] */ + u32 *backlogs; /* backlog table [flows_cnt] */ + u32 flows_cnt; /* number of flows */ + u32 perturbation; /* hash perturbation */ + u32 quantum; /* psched_mtu(qdisc_dev(sch)); */ + struct codel_params cparams; + struct codel_stats cstats; + u32 drop_overlimit; + u32 new_flow_count; + + struct list_head new_flows; /* list of new flows */ + struct list_head old_flows; /* list of old flows */ +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + u32 limit; +#endif +}; + +static unsigned int fq_codel_hash(const struct fq_codel_sched_data *q, + const struct sk_buff *skb) +{ + struct flow_keys keys; + unsigned int hash; + + skb_flow_dissect(skb, &keys); + hash = jhash_3words((__force u32)keys.dst, + (__force u32)keys.src ^ keys.ip_proto, + (__force u32)keys.ports, q->perturbation); + return ((u64)hash * q->flows_cnt) >> 32; +} + +static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch, + int *qerr) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tcf_result res; + int result; + + if (TC_H_MAJ(skb->priority) == sch->handle && + TC_H_MIN(skb->priority) > 0 && + TC_H_MIN(skb->priority) <= q->flows_cnt) + return TC_H_MIN(skb->priority); + + if (!q->filter_list) + return fq_codel_hash(q, skb) + 1; + + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; + result = tc_classify(skb, q->filter_list, &res); + if (result >= 0) { +#ifdef CONFIG_NET_CLS_ACT + switch (result) { + case TC_ACT_STOLEN: + case TC_ACT_QUEUED: + *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; + case TC_ACT_SHOT: + return 0; + } +#endif + if (TC_H_MIN(res.classid) <= q->flows_cnt) + return TC_H_MIN(res.classid); + } + return 0; +} + +/* helper functions : might be changed when/if skb use a standard list_head */ + +/* remove one skb from head of slot queue */ +static inline struct sk_buff *dequeue_head(struct fq_codel_flow *flow) +{ + struct sk_buff *skb = flow->head; + + flow->head = skb->next; + skb->next = NULL; + return skb; +} + +/* add skb to flow queue (tail add) */ +static inline void flow_queue_add(struct fq_codel_flow *flow, + struct sk_buff *skb) +{ + if (flow->head == NULL) + flow->head = skb; + else + flow->tail->next = skb; + flow->tail = skb; + skb->next = NULL; +} + +static unsigned int fq_codel_drop(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + unsigned int maxbacklog = 0, idx = 0, i, len; + struct fq_codel_flow *flow; + + /* Queue is full! Find the fat flow and drop packet from it. + * This might sound expensive, but with 1024 flows, we scan + * 4KB of memory, and we dont need to handle a complex tree + * in fast path (packet queue/enqueue) with many cache misses. + */ + for (i = 0; i < q->flows_cnt; i++) { + if (q->backlogs[i] > maxbacklog) { + maxbacklog = q->backlogs[i]; + idx = i; + } + } + flow = &q->flows[idx]; + skb = dequeue_head(flow); + len = qdisc_pkt_len(skb); + q->backlogs[idx] -= len; + kfree_skb(skb); + sch->q.qlen--; + sch->qstats.drops++; + sch->qstats.backlog -= len; + flow->dropped++; + return idx; +} + +static int fq_codel_enqueue(struct sk_buff *skb, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int idx; + struct fq_codel_flow *flow; + int uninitialized_var(ret); + + idx = fq_codel_classify(skb, sch, &ret); + if (idx == 0) { + if (ret & __NET_XMIT_BYPASS) + sch->qstats.drops++; + kfree_skb(skb); + return ret; + } + idx--; + + codel_set_enqueue_time(skb); + flow = &q->flows[idx]; + flow_queue_add(flow, skb); + q->backlogs[idx] += qdisc_pkt_len(skb); + sch->qstats.backlog += qdisc_pkt_len(skb); + + if (list_empty(&flow->flowchain)) { + list_add_tail(&flow->flowchain, &q->new_flows); + codel_vars_init(&flow->cvars); + q->new_flow_count++; + flow->deficit = q->quantum; + flow->dropped = 0; + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (++sch->q.qlen < q->limit) +#else + if (++sch->q.qlen < sch->limit) +#endif + return NET_XMIT_SUCCESS; + + q->drop_overlimit++; + /* Return Congestion Notification only if we dropped a packet + * from this flow. + */ + if (fq_codel_drop(sch) == idx) + return NET_XMIT_CN; + + /* As we dropped a packet, better let upper stack know this */ + qdisc_tree_decrease_qlen(sch, 1); + return NET_XMIT_SUCCESS; +} + +/* This is the specific function called from codel_dequeue() + * to dequeue a packet from queue. Note: backlog is handled in + * codel, we dont need to reduce it here. + */ +static struct sk_buff *dequeue(struct codel_vars *vars, struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct fq_codel_flow *flow; + struct sk_buff *skb = NULL; + + flow = container_of(vars, struct fq_codel_flow, cvars); + if (flow->head) { + skb = dequeue_head(flow); + q->backlogs[flow - q->flows] -= qdisc_pkt_len(skb); + sch->q.qlen--; + } + return skb; +} + +static struct sk_buff *fq_codel_dequeue(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct sk_buff *skb; + struct fq_codel_flow *flow; + struct list_head *head; + u32 prev_drop_count, prev_ecn_mark; + +begin: + head = &q->new_flows; + if (list_empty(head)) { + head = &q->old_flows; + if (list_empty(head)) + return NULL; + } + flow = list_first_entry(head, struct fq_codel_flow, flowchain); + + if (flow->deficit <= 0) { + flow->deficit += q->quantum; + list_move_tail(&flow->flowchain, &q->old_flows); + goto begin; + } + + prev_drop_count = q->cstats.drop_count; + prev_ecn_mark = q->cstats.ecn_mark; + + skb = codel_dequeue(sch, &q->cparams, &flow->cvars, &q->cstats, + dequeue); + + flow->dropped += q->cstats.drop_count - prev_drop_count; + flow->dropped += q->cstats.ecn_mark - prev_ecn_mark; + + if (!skb) { + /* force a pass through old_flows to prevent starvation */ + if ((head == &q->new_flows) && !list_empty(&q->old_flows)) + list_move_tail(&flow->flowchain, &q->old_flows); + else + list_del_init(&flow->flowchain); + goto begin; + } + qdisc_bstats_update(sch, skb); + flow->deficit -= qdisc_pkt_len(skb); + /* We cant call qdisc_tree_decrease_qlen() if our qlen is 0, + * or HTB crashes. Defer it for next round. + */ + if (q->cstats.drop_count && sch->q.qlen) { + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + } + return skb; +} + +static void fq_codel_reset(struct Qdisc *sch) +{ + struct sk_buff *skb; + + while ((skb = fq_codel_dequeue(sch)) != NULL) + kfree_skb(skb); +} + +static const struct nla_policy fq_codel_policy[TCA_FQ_CODEL_MAX + 1] = { + [TCA_FQ_CODEL_TARGET] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_LIMIT] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_INTERVAL] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_ECN] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_FLOWS] = { .type = NLA_U32 }, + [TCA_FQ_CODEL_QUANTUM] = { .type = NLA_U32 }, +}; + +static int fq_codel_change(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *tb[TCA_FQ_CODEL_MAX + 1]; + int err; + + if (!opt) + return -EINVAL; + + err = nla_parse_nested(tb, TCA_FQ_CODEL_MAX, opt, fq_codel_policy); + if (err < 0) + return err; + if (tb[TCA_FQ_CODEL_FLOWS]) { + if (q->flows) + return -EINVAL; + q->flows_cnt = nla_get_u32(tb[TCA_FQ_CODEL_FLOWS]); + if (!q->flows_cnt || + q->flows_cnt > 65536) + return -EINVAL; + } + sch_tree_lock(sch); + + if (tb[TCA_FQ_CODEL_TARGET]) { + u64 target = nla_get_u32(tb[TCA_FQ_CODEL_TARGET]); + + q->cparams.target = (target * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_INTERVAL]) { + u64 interval = nla_get_u32(tb[TCA_FQ_CODEL_INTERVAL]); + + q->cparams.interval = (interval * NSEC_PER_USEC) >> CODEL_SHIFT; + } + + if (tb[TCA_FQ_CODEL_LIMIT]) +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#else + sch->limit = nla_get_u32(tb[TCA_FQ_CODEL_LIMIT]); +#endif + + if (tb[TCA_FQ_CODEL_ECN]) + q->cparams.ecn = !!nla_get_u32(tb[TCA_FQ_CODEL_ECN]); + + if (tb[TCA_FQ_CODEL_QUANTUM]) + q->quantum = max(256U, nla_get_u32(tb[TCA_FQ_CODEL_QUANTUM])); + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + while (sch->q.qlen > q->limit) { +#else + while (sch->q.qlen > sch->limit) { +#endif + struct sk_buff *skb = fq_codel_dequeue(sch); + + kfree_skb(skb); + q->cstats.drop_count++; + } + qdisc_tree_decrease_qlen(sch, q->cstats.drop_count); + q->cstats.drop_count = 0; + + sch_tree_unlock(sch); + return 0; +} + +static void *fq_codel_zalloc(size_t sz) +{ + void *ptr = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN); + + if (!ptr) + ptr = vzalloc(sz); + return ptr; +} + +static void fq_codel_free(void *addr) +{ + if (addr) { + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); + } +} + +static void fq_codel_destroy(struct Qdisc *sch) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) + tcf_destroy_chain(&q->filter_list); +#else + tcf_destroy_chain(q->filter_list); +#endif + fq_codel_free(q->backlogs); + fq_codel_free(q->flows); +} + +static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + int i; + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit = 10*1024; +#else + sch->limit = 10*1024; +#endif + q->flows_cnt = 1024; + q->quantum = psched_mtu(qdisc_dev(sch)); + q->perturbation = net_random(); + INIT_LIST_HEAD(&q->new_flows); + INIT_LIST_HEAD(&q->old_flows); + codel_params_init(&q->cparams); + codel_stats_init(&q->cstats); + q->cparams.ecn = true; + + if (opt) { + int err = fq_codel_change(sch, opt); + if (err) + return err; + } + + if (!q->flows) { + q->flows = fq_codel_zalloc(q->flows_cnt * + sizeof(struct fq_codel_flow)); + if (!q->flows) + return -ENOMEM; + q->backlogs = fq_codel_zalloc(q->flows_cnt * sizeof(u32)); + if (!q->backlogs) { + fq_codel_free(q->flows); + return -ENOMEM; + } + for (i = 0; i < q->flows_cnt; i++) { + struct fq_codel_flow *flow = q->flows + i; + + INIT_LIST_HEAD(&flow->flowchain); + } + } +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + if (q->limit >= 1) +#else + if (sch->limit >= 1) +#endif + sch->flags |= TCQ_F_CAN_BYPASS; + else + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static int fq_codel_dump(struct Qdisc *sch, struct sk_buff *skb) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct nlattr *opts; + + opts = nla_nest_start(skb, TCA_OPTIONS); + if (opts == NULL) + goto nla_put_failure; + + if (nla_put_u32(skb, TCA_FQ_CODEL_TARGET, + codel_time_to_us(q->cparams.target)) || + nla_put_u32(skb, TCA_FQ_CODEL_LIMIT, +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,39)) + q->limit) || +#else + sch->limit) || +#endif + nla_put_u32(skb, TCA_FQ_CODEL_INTERVAL, + codel_time_to_us(q->cparams.interval)) || + nla_put_u32(skb, TCA_FQ_CODEL_ECN, + q->cparams.ecn) || + nla_put_u32(skb, TCA_FQ_CODEL_QUANTUM, + q->quantum) || + nla_put_u32(skb, TCA_FQ_CODEL_FLOWS, + q->flows_cnt)) + goto nla_put_failure; + + nla_nest_end(skb, opts); + return skb->len; + +nla_put_failure: + return -1; +} + +static int fq_codel_dump_stats(struct Qdisc *sch, struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + struct tc_fq_codel_xstats st = { + .type = TCA_FQ_CODEL_XSTATS_QDISC, + }; + struct list_head *pos; + + st.qdisc_stats.maxpacket = q->cstats.maxpacket; + st.qdisc_stats.drop_overlimit = q->drop_overlimit; + st.qdisc_stats.ecn_mark = q->cstats.ecn_mark; + st.qdisc_stats.new_flow_count = q->new_flow_count; + + list_for_each(pos, &q->new_flows) + st.qdisc_stats.new_flows_len++; + + list_for_each(pos, &q->old_flows) + st.qdisc_stats.old_flows_len++; + + return gnet_stats_copy_app(d, &st, sizeof(st)); +} + +static struct Qdisc *fq_codel_leaf(struct Qdisc *sch, unsigned long arg) +{ + return NULL; +} + +static unsigned long fq_codel_get(struct Qdisc *sch, u32 classid) +{ + return 0; +} + +static unsigned long fq_codel_bind(struct Qdisc *sch, unsigned long parent, + u32 classid) +{ + /* we cannot bypass queue discipline anymore */ + sch->flags &= ~TCQ_F_CAN_BYPASS; + return 0; +} + +static void fq_codel_put(struct Qdisc *q, unsigned long cl) +{ +} + +static struct tcf_proto **fq_codel_find_tcf(struct Qdisc *sch, unsigned long cl) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + + if (cl) + return NULL; + return &q->filter_list; +} + +static int fq_codel_dump_class(struct Qdisc *sch, unsigned long cl, + struct sk_buff *skb, struct tcmsg *tcm) +{ + tcm->tcm_handle |= TC_H_MIN(cl); + return 0; +} + +static int fq_codel_dump_class_stats(struct Qdisc *sch, unsigned long cl, + struct gnet_dump *d) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + u32 idx = cl - 1; + struct gnet_stats_queue qs = { 0 }; + struct tc_fq_codel_xstats xstats; + + if (idx < q->flows_cnt) { + const struct fq_codel_flow *flow = &q->flows[idx]; + const struct sk_buff *skb = flow->head; + + memset(&xstats, 0, sizeof(xstats)); + xstats.type = TCA_FQ_CODEL_XSTATS_CLASS; + xstats.class_stats.deficit = flow->deficit; + xstats.class_stats.ldelay = + codel_time_to_us(flow->cvars.ldelay); + xstats.class_stats.count = flow->cvars.count; + xstats.class_stats.lastcount = flow->cvars.lastcount; + xstats.class_stats.dropping = flow->cvars.dropping; + if (flow->cvars.dropping) { + codel_tdiff_t delta = flow->cvars.drop_next - + codel_get_time(); + + xstats.class_stats.drop_next = (delta >= 0) ? + codel_time_to_us(delta) : + -codel_time_to_us(-delta); + } + while (skb) { + qs.qlen++; + skb = skb->next; + } + qs.backlog = q->backlogs[idx]; + qs.drops = flow->dropped; + } + if (gnet_stats_copy_queue(d, &qs) < 0) + return -1; + if (idx < q->flows_cnt) + return gnet_stats_copy_app(d, &xstats, sizeof(xstats)); + return 0; +} + +static void fq_codel_walk(struct Qdisc *sch, struct qdisc_walker *arg) +{ + struct fq_codel_sched_data *q = qdisc_priv(sch); + unsigned int i; + + if (arg->stop) + return; + + for (i = 0; i < q->flows_cnt; i++) { + if (list_empty(&q->flows[i].flowchain) || + arg->count < arg->skip) { + arg->count++; + continue; + } + if (arg->fn(sch, i + 1, arg) < 0) { + arg->stop = 1; + break; + } + arg->count++; + } +} + +static const struct Qdisc_class_ops fq_codel_class_ops = { + .leaf = fq_codel_leaf, + .get = fq_codel_get, + .put = fq_codel_put, + .tcf_chain = fq_codel_find_tcf, + .bind_tcf = fq_codel_bind, + .unbind_tcf = fq_codel_put, + .dump = fq_codel_dump_class, + .dump_stats = fq_codel_dump_class_stats, + .walk = fq_codel_walk, +}; + +static struct Qdisc_ops fq_codel_qdisc_ops __read_mostly = { + .cl_ops = &fq_codel_class_ops, + .id = "fq_codel", + .priv_size = sizeof(struct fq_codel_sched_data), + .enqueue = fq_codel_enqueue, + .dequeue = fq_codel_dequeue, +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,28)) + .peek = qdisc_peek_dequeued, +#endif + .drop = fq_codel_drop, + .init = fq_codel_init, + .reset = fq_codel_reset, + .destroy = fq_codel_destroy, + .change = fq_codel_change, + .dump = fq_codel_dump, + .dump_stats = fq_codel_dump_stats, + .owner = THIS_MODULE, +}; + +static int __init fq_codel_module_init(void) +{ + return register_qdisc(&fq_codel_qdisc_ops); +} + +static void __exit fq_codel_module_exit(void) +{ + unregister_qdisc(&fq_codel_qdisc_ops); +} + +module_init(fq_codel_module_init) +module_exit(fq_codel_module_exit) +MODULE_AUTHOR("Eric Dumazet"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 6bb450da..3aec3bd6 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -147,8 +147,11 @@ static inline int compat_vga_switcheroo_register_client(struct pci_dev *dev, * Subject: [PATCH] codel: Controlled Delay AQM */ +#ifndef TCA_CODEL_MAX /* CODEL */ +#define COMPAT_CODEL_BACKPORT + enum { TCA_CODEL_UNSPEC, TCA_CODEL_TARGET, @@ -234,6 +237,7 @@ struct tc_fq_codel_xstats { struct tc_fq_codel_cl_stats class_stats; }; }; +#endif /* TCA_CODEL_MAX */ /* Backports tty_lock: Localise the lock */ diff --git a/include/net/codel.h b/include/net/codel.h index 128082ed..eee0359c 100644 --- a/include/net/codel.h +++ b/include/net/codel.h @@ -1,6 +1,7 @@ #include +#include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) || (defined(TCA_CODEL_MAX) && !defined(COMPAT_CODEL_BACKPORT)) #include_next #else -- cgit v1.2.3 From 42faf2dc8d8bbbdc5b8913183fcd021a27e953c9 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 8 Aug 2012 20:22:24 -0700 Subject: compat: fix glibc >= 2.14 requirement This project uses the vanilla kernels from the Ubuntu vanilla kernel PPA. As of >= v3.4 vanilla kernel releases, there are a few files which are binary in the kernel headers which are linked with dynamic libraries. Of interest to us here are the ones required to build external modules. An example: /lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms The folks building these packages are using a glibc >= 2.14 and although the *only* symbol I see being required from glibc >= 2.14 being memcpy(): mcgrof@garbanzo ~/compat (git::master)$ objdump -T /home/mcgrof/compat-ksrc/lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms /home/mcgrof/compat-ksrc/lib/modules/3.4.4-030404-generic/build/scripts/genksyms/genksyms: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __snprintf_chk 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 free 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __vfprintf_chk 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __errno_location 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ferror 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 isatty 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fread 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fclose 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strlen 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.4 __stack_chk_fail 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getopt_long 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strchr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 _IO_putc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fputs 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fgetc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fputc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __strdup 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __libc_start_main 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strcmp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 feof 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strtol 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 clearerr Bleh: 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.14 memcpy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fileno 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 malloc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 _IO_getc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ungetc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 realloc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __printf_chk 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fopen 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 perror 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 exit 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fwrite 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __fprintf_chk 000000000060b160 g DO .bss 0000000000000008 GLIBC_2.2.5 stdout 000000000060b168 g DO .bss 0000000000000008 GLIBC_2.2.5 stdin 000000000060b178 g DO .bss 0000000000000008 GLIBC_2.2.5 stderr 000000000060b170 g DO .bss 0000000000000008 GLIBC_2.2.5 optarg As proposed by Ozan we fix this by re-building some of the required binaries under scripts/ to build external modules. For details see: https://lkml.org/lkml/2012/8/7/489 Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 4479d0f4..7975ccab 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -151,15 +151,47 @@ function get_ubuntu_kernels() { rm -rf $TEMP_DIR } +function rebuild_header_binary_deps() { + if [[ ! -d ${KSRC_PREFIX}/lib/modules/ ]]; then + echo "You do not seem to have any vanilla kernels available to fix" + exit 1 + fi + + COUNT=$(ls -d ${KSRC_PREFIX}/lib/modules/*generic | wc -l) + if [[ $COUNT -le 0 ]]; then + echo "You do not seem to have any vanilla kernels available to fix" + exit 1 + fi + + for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do + echo $kernel + make -C ${kernel}/build/ M=scripts/mod/ + make -C ${kernel}/build/ M=scripts/basic/ + make -C ${kernel}/build/ M=scripts/genksyms + done +} + function usage() { - echo -e "Usage: $0" + echo -e "Usage: $0 [ -r ] " + echo -e "-r Rebuilds binaries required in kernel headers. Use" + echo -e " this option if you've already ran this script and" + echo -e " just need to fix the libc versions against which" + echo -e " the binaries in the headers files are linked against. " + echo -e " This was added since kernels >= 3.4 used require" + echo -e " a glibc >= 2.14 for memcpy(), and not all Linux" + echo -e " Linux distributions have such glibc." } -if [[ $# -gt 1 ]]; then +if [[ $# -gt 2 ]]; then usage exit 1 fi +if [[ $1 == "-r" ]]; then + rebuild_header_binary_deps + exit +fi + # Check for the availability of 'ar' before continuing which ar 2>&1 > /dev/null if [[ $? -ne 0 ]]; then @@ -200,3 +232,7 @@ if [[ "${REPLY}" != "y" ]]; then fi get_ubuntu_kernels +echo -e "Vanilla kernels headers ${BLUE}installed${NORMAL}, " +echo -e "now going to ${GREEN}rebuild${NORMAL} some binary dependencies..." +sleep 1 +rebuild_header_binary_deps -- cgit v1.2.3 From 0026e404500f924114ea2d352a06a3713a84ea61 Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Thu, 9 Aug 2012 00:40:15 -0400 Subject: compat: support RHEL6.3 as a build target This patch allows me to compile and load the latest compat modules on RHEL6.3. Users of compat on RHEL6 should note that you should set CONFIG_COMPAT_KFIFO=n as those bits are not needed at all. These changes seem to pass built-in tests on my system: # ./bin/ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.38.c | 8 ++++---- compat/compat-3.1.c | 22 +++++++++++----------- include/linux/compat-2.6.33.h | 6 ++++++ include/linux/compat-2.6.34.h | 6 ++++++ include/linux/compat-2.6.35.h | 5 +++++ include/linux/compat-2.6.36.h | 2 ++ include/linux/compat-2.6.38.h | 6 ++++++ include/linux/compat-3.1.h | 12 ++++++++++++ include/linux/compat-3.2.h | 9 +++++++++ include/linux/compat-3.3.h | 2 ++ 10 files changed, 63 insertions(+), 15 deletions(-) diff --git a/compat/compat-2.6.38.c b/compat/compat-2.6.38.c index 0074ac62..b5461949 100644 --- a/compat/compat-2.6.38.c +++ b/compat/compat-2.6.38.c @@ -22,14 +22,14 @@ * * Initialize the EWMA parameters for a given struct ewma @avg. */ -void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight) +void compat_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); +EXPORT_SYMBOL_GPL(compat_ewma_init); /** * ewma_add() - Exponentially weighted moving average (EWMA) @@ -38,7 +38,7 @@ EXPORT_SYMBOL_GPL(ewma_init); * * Add a sample to the average. */ -struct ewma *ewma_add(struct ewma *avg, unsigned long val) +struct ewma *compat_ewma_add(struct ewma *avg, unsigned long val) { avg->internal = avg->internal ? (((avg->internal * (avg->weight - 1)) + @@ -46,5 +46,5 @@ struct ewma *ewma_add(struct ewma *avg, unsigned long val) (val * avg->factor); return avg; } -EXPORT_SYMBOL_GPL(ewma_add); +EXPORT_SYMBOL_GPL(compat_ewma_add); diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index e81a3e78..03735f6d 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -19,7 +19,7 @@ * cpufreq: expose a cpufreq_quick_get_max routine */ -unsigned int cpufreq_quick_get_max(unsigned int cpu) +unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); unsigned int ret_freq = 0; @@ -31,10 +31,10 @@ unsigned int cpufreq_quick_get_max(unsigned int cpu) return ret_freq; } -EXPORT_SYMBOL(cpufreq_quick_get_max); +EXPORT_SYMBOL(compat_cpufreq_quick_get_max); -static DEFINE_SPINLOCK(simple_ida_lock); +static DEFINE_SPINLOCK(compat_simple_ida_lock); /** * ida_simple_get - get a new id. @@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(simple_ida_lock); * * Use ida_simple_remove() to get rid of an id. */ -int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, +int compat_ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, gfp_t gfp_mask) { int ret, id; @@ -69,7 +69,7 @@ again: if (!ida_pre_get(ida, gfp_mask)) return -ENOMEM; - spin_lock_irqsave(&simple_ida_lock, flags); + spin_lock_irqsave(&compat_simple_ida_lock, flags); ret = ida_get_new_above(ida, start, &id); if (!ret) { if (id > max) { @@ -79,29 +79,29 @@ again: ret = id; } } - spin_unlock_irqrestore(&simple_ida_lock, flags); + spin_unlock_irqrestore(&compat_simple_ida_lock, flags); if (unlikely(ret == -EAGAIN)) goto again; return ret; } -EXPORT_SYMBOL(ida_simple_get); +EXPORT_SYMBOL(compat_ida_simple_get); /** * ida_simple_remove - remove an allocated id. * @ida: the (initialized) ida. * @id: the id returned by ida_simple_get. */ -void ida_simple_remove(struct ida *ida, unsigned int id) +void compat_ida_simple_remove(struct ida *ida, unsigned int id) { unsigned long flags; BUG_ON((int)id < 0); - spin_lock_irqsave(&simple_ida_lock, flags); + spin_lock_irqsave(&compat_simple_ida_lock, flags); ida_remove(ida, id); - spin_unlock_irqrestore(&simple_ida_lock, flags); + spin_unlock_irqrestore(&compat_simple_ida_lock, flags); } -EXPORT_SYMBOL(ida_simple_remove); +EXPORT_SYMBOL(compat_ida_simple_remove); /* source lib/idr.c */ diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 0c71af99..dcdf765a 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -55,11 +55,17 @@ static inline void compat_release_firmware(const struct firmware *fw) #define KEY_RFKILL 247 /* Key that controls all radios */ #endif +/* mask IFF_DONT_BRIDGE as RHEL6 backports this */ +#if !defined(IFF_DONT_BRIDGE) #define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */ /* source: include/linux/if.h */ +#endif +/* mask NETDEV_POST_INIT as RHEL6 backports this */ /* this will never happen on older kernels */ +#if !defined(NETDEV_POST_INIT) #define NETDEV_POST_INIT 0xffff +#endif /* mask netdev_alloc_skb_ip_align as debian squeeze also backports this */ #define netdev_alloc_skb_ip_align(a, b) compat_netdev_alloc_skb_ip_align(a, b) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index b8b48c03..eb228652 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -30,8 +30,11 @@ void init_compat_mmc_pm_flags(void); #define netdev_mc_count(dev) ((dev)->mc_count) #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) +/* mask netdev_for_each_mc_addr as RHEL6 backports this */ +#if !defined(netdev_for_each_mc_addr) #define netdev_for_each_mc_addr(mclist, dev) \ for (mclist = dev->mc_list; mclist; mclist = mclist->next) +#endif /* source: include/linux/netdevice.h */ @@ -235,6 +238,8 @@ do { \ #define sysfs_attr_init(attr) do {} while(0) #endif +/* mask sysfs_bin_attr_init as RHEL6 backports this */ +#if !defined(sysfs_bin_attr_init) /** * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute * @attr: struct bin_attribute to initialize @@ -246,6 +251,7 @@ do { \ * added to sysfs if you don't have this. */ #define sysfs_bin_attr_init(bin_attr) sysfs_attr_init(&(bin_attr)->attr) +#endif #define usb_alloc_coherent(dev, size, mem_flags, dma) usb_buffer_alloc(dev, size, mem_flags, dma) #define usb_free_coherent(dev, size, addr, dma) usb_buffer_free(dev, size, addr, dma) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 58141239..d184f00e 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -19,6 +19,8 @@ #define netdev_hw_addr dev_mc_list +/* mask irq_set_affinity_hint as RHEL6 backports this */ +#define irq_set_affinity_hint(a,b) compat_irq_set_affinity_hint(a,b) /* * We cannot backport this guy as the IRQ data structure * was modified in the kernel itself to support this. We @@ -46,6 +48,9 @@ extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); #define pm_qos_request(_qos) pm_qos_requirement(_qos) +/* mask usb_pipe_endpoint as RHEL6 backports this */ +#define usb_pipe_endpoint(a,b) compat_usb_pipe_endpoint(a,b) + static inline struct usb_host_endpoint * usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) { diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 56d59619..8b022603 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -98,6 +98,8 @@ struct pm_qos_request_list { * Dummy printk for disabled debugging statements to use whilst maintaining * gcc's format and side-effect checking. */ +/* mask no_printk as RHEL6 backports this */ +#define no_printk(...) compat_no_printk(...) static inline __attribute__ ((format (printf, 1, 2))) int no_printk(const char *s, ...) { return 0; } diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 0a86468b..1d725231 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -55,9 +55,15 @@ struct ewma { unsigned long weight; }; +/* mask ewma_init as RHEL6 backports this */ +#define ewma_init(a,b,c) compat_ewma_init(a,b,c) + extern void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight); +/* mask ewma_add as RHEL6 backports this */ +#define ewma_add(a,b) compat_ewma_add(a,b) + extern struct ewma *ewma_add(struct ewma *avg, unsigned long val); /** diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index bf8a4ef3..dfd87a35 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -30,6 +30,8 @@ static inline bool ip_is_fragment(const struct iphdr *iph) return (iph->frag_off & htons(IP_MF | IP_OFFSET)) != 0; } +/* mask __netdev_alloc_skb_ip_align as RHEL6 backports this */ +#define __netdev_alloc_skb_ip_align(a,b,c) compat__netdev_alloc_skb_ip_align(a,b,c) static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev, unsigned int length, gfp_t gfp) { @@ -98,10 +100,20 @@ static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) #include #endif +/* mask ida_simple_get as RHEL6 backports this */ +#define ida_simple_get(a,b,c,d) compat_ida_simple_get(a,b,c,d) + int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, gfp_t gfp_mask); + +/* mask ida_simple_remove as RHEL6 backports this */ +#define ida_simple_remove(a,b) compat_ida_simple_remove(a,b) + void ida_simple_remove(struct ida *ida, unsigned int id); +/* mask cpufreq_quick_get_max as RHEL6 backports this */ +#define cpufreq_quick_get_max(a) compat_cpufreq_quick_get_max(a) + unsigned int cpufreq_quick_get_max(unsigned int cpu); #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index ef275664..cde86b56 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -14,6 +14,9 @@ #define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0) +/* mask skb_frag_page as RHEL6 backports this */ +#define skb_frag_page(a) compat_skb_frag_page(a) + /** * skb_frag_page - retrieve the page refered to by a paged fragment * @frag: the paged fragment @@ -25,6 +28,9 @@ static inline struct page *skb_frag_page(const skb_frag_t *frag) return frag->page; } +/* mask skb_frag_dma_map as RHEL6 backports this */ +#define skb_frag_dma_map(a,b,c,d,e) compat_skb_frag_dma_map(a,b,c,d,e) + /** * skb_frag_dma_map - maps a paged fragment via the DMA API * @device: the device to map the fragment to @@ -47,6 +53,9 @@ static inline dma_addr_t skb_frag_dma_map(struct device *dev, #define ETH_P_TDLS 0x890D /* TDLS */ +/* mask skb_frag_size as RHEL6 backports this */ +#define skb_frag_size(a) compat_skb_frag_size(a) + static inline unsigned int skb_frag_size(const skb_frag_t *frag) { return frag->size; diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 620e661c..956d4c04 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -10,6 +10,8 @@ #include #include +/* mask qdisc_cb_private_validate as RHEL6 backports this */ +#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b) #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) -- cgit v1.2.3 From e773e455cab00080b3ab91c0d1bfcffdc4f111de Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 9 Aug 2012 02:00:39 -0700 Subject: compat: typo fixes for bin/get-compat-kernels Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 7975ccab..41078280 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -177,9 +177,9 @@ function usage() { echo -e " this option if you've already ran this script and" echo -e " just need to fix the libc versions against which" echo -e " the binaries in the headers files are linked against. " - echo -e " This was added since kernels >= 3.4 used require" + echo -e " This was added since kernels >= 3.4 require" echo -e " a glibc >= 2.14 for memcpy(), and not all Linux" - echo -e " Linux distributions have such glibc." + echo -e " distributions have such versions of glibc." } if [[ $# -gt 2 ]]; then -- cgit v1.2.3 From af95815d4a5770a6ce1185a9afea8c48deac6859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 9 Aug 2012 15:52:23 +0300 Subject: compat: Drop glibc 2.14 warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is not the case anymore as we rebuild the binaries. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 41078280..2003cd35 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -215,9 +215,6 @@ echo -e "The download payload is about ${YELLOW}~ $((${SPACE_PER_KERNEL_DEB} * $ echo -e "it will stash kernel header files under ${BLUE}$KSRC_PREFIX/usr/src/${NORMAL}" echo -e "and ${BLUE}$KSRC_PREFIX/lib/modules/${NORMAL} and consume about ~ ${YELLOW}$((${NUM_KERNELS} * ${SPACE_PER_KERNEL})) ${RED}MiB${NORMAL} of space." echo -e "" -echo -e "Note: you will need ${CYAN}libc${NORMAL} > ${GREEN}2.14${NORMAL} otherwise compilation may" -echo -e "fail with Linux ${CYAN}3.4.4${NORMAL}" -echo -e "" echo -e "The kernel headers used are from ${PURPLE}${UNDERLINE}Vanilla${NORMAL} kernels" echo -e "from the Ubuntu mainline / vanilla kernel PPA and are extracted" echo -e "using ${GREEN}ar${NORMAL} and ${GREEN}tar${NORMAL}:" -- cgit v1.2.3 From 117058a8fc003ea2036a2900848449962b80f130 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 9 Aug 2012 18:21:25 -0700 Subject: compat: remove autoconf inclusion on compat-2.6.33.c The inclusion of the appropriate kernel for autoconf varies depending on the Linux kernel version used. This magic is already dealt for us on compat-2.6.h and since all files include that we don't need to be including this header file. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.33.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 04e2fd09..365a1a6c 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -9,7 +9,6 @@ */ #include -#include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) -- cgit v1.2.3 From 2d5b6f3980d573dfad593f1e3480d854e1788160 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 9 Aug 2012 18:23:25 -0700 Subject: compat: fix no_printk() definition The definition was supposed to define compat_no_prinkt() given that RHEL already defines no_printk(). Reported-by: Zefir Kurtisi Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.36.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index 8b022603..b6757c39 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -101,7 +101,7 @@ struct pm_qos_request_list { /* mask no_printk as RHEL6 backports this */ #define no_printk(...) compat_no_printk(...) static inline __attribute__ ((format (printf, 1, 2))) -int no_printk(const char *s, ...) { return 0; } +int compat_no_printk(const char *s, ...) { return 0; } #ifndef alloc_workqueue #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0) -- cgit v1.2.3 From c860c5e7310fcb43a099ef8ffde3706592658c13 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 9 Aug 2012 18:24:54 -0700 Subject: compat: backport mod_delayed_work() usage instead of cancel + queue The patch below is backported by using cancel_delayed_work() followed by mod_delayed_work(). mod_delayed_work() will be introduced on v3.7, so we add this backport onto the 3.7 backport files. The commit that inroduced mod_delayed_work(): mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 8376fe22 next-20120809~16^2~2 The reason we are backporting this: commit 7adf612cacb5d49778201eb06cc54281570eeb21 Author: Tejun Heo Date: Fri Aug 3 10:30:47 2012 -0700 workqueue: use mod_delayed_work() instead of cancel + queue Convert delayed_work users doing cancel_delayed_work() followed by queue_delayed_work() to mod_delayed_work(). Most conversions are straight-forward. Ones worth mentioning are, * drivers/edac/edac_mc.c: edac_mc_workq_setup() converted to always use mod_delayed_work() and cancel loop in edac_mc_reset_delay_period() is dropped. * drivers/platform/x86/thinkpad_acpi.c: No need to remember whether watchdog is active or not. @fan_watchdog_active and related code dropped. * drivers/power/charger-manager.c: Seemingly a lot of delayed_work_pending() abuse going on here. [delayed_]work_pending() are unsynchronized and racy when used like this. I converted one instance in fullbatt_handler(). Please conver the rest so that it invokes workqueue APIs for the intended target state rather than trying to game work item pending state transitions. e.g. if timer should be modified - call mod_delayed_work(), canceled - call cancel_delayed_work[_sync](). * drivers/thermal/thermal_sys.c: thermal_zone_device_set_polling() simplified. Note that round_jiffies() calls in this function are meaningless. round_jiffies() work on absolute jiffies not delta delay used by delayed_work. v2: Tomi pointed out that __cancel_delayed_work() users can't be safely converted to mod_delayed_work(). They could be calling it from irq context and if that happens while delayed_work_timer_fn() is running, it could deadlock. __cancel_delayed_work() users are dropped. Signed-off-by: Tejun Heo Acked-by: Henrique de Moraes Holschuh Acked-by: Dmitry Torokhov Acked-by: Anton Vorontsov Cc: Tomi Valkeinen Cc: Jens Axboe Cc: Jiri Kosina Cc: Doug Thompson Cc: David Airlie Cc: Roland Dreier Cc: "John W. Linville" Cc: Zhang Rui Cc: Len Brown Cc: David Howells Cc: "J. Bruce Fields" Cc: Johannes Berg mcgrof@garbanzo ~/compat (git::master)$ gcc --version gcc (Debian 4.7.1-2) 4.7.1 Copyright (C) 2012 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. mcgrof@garbanzo ~/compat (git::master)$ ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.7.c | 19 +++++++++++++++++++ include/linux/compat-2.6.h | 1 + include/linux/compat-3.7.h | 15 +++++++++++++++ 4 files changed, 36 insertions(+) create mode 100644 compat/compat-3.7.c create mode 100644 include/linux/compat-3.7.h diff --git a/compat/Makefile b/compat/Makefile index 23c1296c..a44b3459 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -45,6 +45,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o +compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c new file mode 100644 index 00000000..8fd07ff9 --- /dev/null +++ b/compat/compat-3.7.c @@ -0,0 +1,19 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.7. + */ + +#include + +bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, + unsigned long delay) +{ + cancel_delayed_work(dwork); + queue_delayed_work(wq, dwork, delay); +} +EXPORT_SYMBOL_GPL(mod_delayed_work); diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 7aaa8483..46ae6541 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -64,5 +64,6 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h new file mode 100644 index 00000000..e113e80d --- /dev/null +++ b/include/linux/compat-3.7.h @@ -0,0 +1,15 @@ +#ifndef LINUX_3_7_COMPAT_H +#define LINUX_3_7_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) + +#include + +bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, + unsigned long delay); + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ + +#endif /* LINUX_3_7_COMPAT_H */ -- cgit v1.2.3 From 92aaac94204a178c40aee939f7f3beeb067c5902 Mon Sep 17 00:00:00 2001 From: Andy Gospodreak Date: Fri, 10 Aug 2012 16:57:16 -0400 Subject: compat: fixup error in no_printk definition What initially looked like a valid definition for the #define for no_printk was not. This corrects the problem and the change that was thought to correct it. Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.36.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index b6757c39..cd5e37ca 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -99,9 +99,9 @@ struct pm_qos_request_list { * gcc's format and side-effect checking. */ /* mask no_printk as RHEL6 backports this */ -#define no_printk(...) compat_no_printk(...) +#define no_printk(a, ...) compat_no_printk(a, ##__VA_ARGS__) static inline __attribute__ ((format (printf, 1, 2))) -int compat_no_printk(const char *s, ...) { return 0; } +int no_printk(const char *s, ...) { return 0; } #ifndef alloc_workqueue #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active, 0) -- cgit v1.2.3 From e5fe9f6397822bb0d0a1a8440ec6489592b210c6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Aug 2012 02:30:04 +0200 Subject: compat: fix SIMPLE_DEV_PM_OPS() on kernel 2.6.29 This patch reworks this commit: commit 8e661d67b1965afcfd9d3672803e2fc37765f6ef Author: Johannes Berg Date: Thu Aug 2 22:15:05 2012 +0200 compat: handle pci suspend/resume on kernel 2.6.29 The functions for pci suspend and resume are now created by compat_pci_suspend and compat_pci_resume and then used by SIMPLE_DEV_PM_OPS. This way attributes like static, const and so on are forwarded in the struct dev_pm_ops define on all kernel versions. In addition this patch adds an own SIMPLE_DEV_PM_OPS() for kernel 2.6.32 overwriting the original, because in kernel 2.6.32 const is needed for struct dev_pm_ops in pci drivers. This is based on work done by Johannes Berg. CC: Johannes Berg Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 80 ++++++++++++++++++++++++++++++------------- include/linux/compat-2.6.32.h | 44 ++++-------------------- include/linux/compat-2.6.33.h | 13 +++++++ 3 files changed, 76 insertions(+), 61 deletions(-) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index e65c2298..e859a190 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -325,6 +325,30 @@ static inline struct net *read_pnet(struct net * const *pnet) extern int init_dummy_netdev(struct net_device *dev); +#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ + +/* Kernels >= 2.6.29 follows */ + +/* XXX: this can probably just go upstream ! */ +static inline void netdev_attach_ops(struct net_device *dev, + const struct net_device_ops *ops) +{ + dev->netdev_ops = ops; +} + +/* XXX: this can probably just go upstream! */ +static inline int ndo_do_ioctl(struct net_device *dev, + struct ifreq *ifr, + int cmd) +{ + if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl) + return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); + return -EOPNOTSUPP; +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) #define compat_pci_suspend(fn) \ int fn##_compat(struct pci_dev *pdev, pm_message_t state) \ { \ @@ -354,31 +378,41 @@ extern int init_dummy_netdev(struct net_device *dev); \ return fn(&pdev->dev); \ } +#elif LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29) +#define compat_pci_suspend(fn) \ + int fn##_compat(struct device *dev) \ + { \ + struct pci_dev *pdev = to_pci_dev(dev); \ + int r; \ + \ + r = fn(&pdev->dev); \ + if (r) \ + return r; \ + \ + pci_save_state(pdev); \ + pci_disable_device(pdev); \ + pci_set_power_state(pdev, PCI_D3hot); \ + \ + return 0; \ + } -#else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ - -/* Kernels >= 2.6.29 follows */ - -/* XXX: this can probably just go upstream ! */ -static inline void netdev_attach_ops(struct net_device *dev, - const struct net_device_ops *ops) -{ - dev->netdev_ops = ops; -} - -/* XXX: this can probably just go upstream! */ -static inline int ndo_do_ioctl(struct net_device *dev, - struct ifreq *ifr, - int cmd) -{ - if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl) - return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd); - return -EOPNOTSUPP; -} - +#define compat_pci_resume(fn) \ + int fn##_compat(struct device *dev) \ + { \ + struct pci_dev *pdev = to_pci_dev(dev); \ + int r; \ + \ + pci_set_power_state(pdev, PCI_D0); \ + r = pci_enable_device(pdev); \ + if (r) \ + return r; \ + pci_restore_state(pdev); \ + \ + return fn(&pdev->dev); \ + } +#else #define compat_pci_suspend(fn) #define compat_pci_resume(fn) - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ +#endif #endif /* LINUX_26_29_COMPAT_H */ diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index ff57dcac..f8320cf0 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -128,46 +128,14 @@ typedef enum netdev_tx netdev_tx_t; * weren't included yet though, so include them here. */ #if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29)) -/* - * Note the lack of "static" in this definition. The code may put - * a "static" in front of using the define, which makes it impossible - * to put static here. We lose that static if it is present (it ends - * up being on the suspend_fn) but that doesn't really matter much - * unless a driver defines multiple pm_ops structs with the same name - * (in which case we'll need to fix it) - */ #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ -int __compat_suspend_fn_ ## name(struct device *dev) \ -{ \ - int ret = suspend_fn(dev); \ - if (ret) \ - return ret; \ - if (dev->bus == &pci_bus_type) { \ - pci_save_state(to_pci_dev(dev)); \ - pci_disable_device(to_pci_dev(dev)); \ - pci_set_power_state(to_pci_dev(dev), PCI_D3hot);\ - } \ - return 0; \ -} \ -int __compat_resume_fn_ ## name(struct device *dev) \ -{ \ - int ret; \ - if (dev->bus == &pci_bus_type) { \ - pci_set_power_state(to_pci_dev(dev), PCI_D0); \ - ret = pci_enable_device(to_pci_dev(dev)); \ - if (ret) \ - return ret; \ - pci_restore_state(to_pci_dev(dev)); \ - } \ - return resume_fn(dev); \ -} \ struct dev_pm_ops name = { \ - .suspend = __compat_suspend_fn_ ## name, \ - .resume = __compat_resume_fn_ ## name, \ - .freeze = __compat_suspend_fn_ ## name, \ - .thaw = __compat_resume_fn_ ## name, \ - .poweroff = __compat_suspend_fn_ ## name, \ - .restore = __compat_resume_fn_ ## name, \ + .suspend = suspend_fn ## _compat, \ + .resume = resume_fn ## _compat, \ + .freeze = suspend_fn ## _compat, \ + .thaw = resume_fn ## _compat, \ + .poweroff = suspend_fn ## _compat, \ + .restore = resume_fn ## _compat, \ } #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)) /* diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index dcdf765a..381146d3 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -173,6 +173,19 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr) return !ptr || IS_ERR_VALUE((unsigned long)ptr); } +#if (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32)) +#undef SIMPLE_DEV_PM_OPS +#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ +const struct dev_pm_ops name = { \ + .suspend = suspend_fn, \ + .resume = resume_fn, \ + .freeze = suspend_fn, \ + .thaw = resume_fn, \ + .poweroff = suspend_fn, \ + .restore = resume_fn, \ +} +#endif /* (LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32)) */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */ #endif /* LINUX_26_33_COMPAT_H */ -- cgit v1.2.3 From f9cb1ab988cc4fd658074f225310b9395877bb8c Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Aug 2012 02:30:05 +0200 Subject: compat: generate CONFIG_COMPAT_KERNEL_3_7 Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 3eba34ef..391a75d0 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -17,7 +17,7 @@ fi KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') # 3.0 kernel stuff -COMPAT_LATEST_VERSION="5" +COMPAT_LATEST_VERSION="7" KERNEL_SUBLEVEL="-1" # Note that this script will export all variables explicitly, -- cgit v1.2.3 From fac67cbf7a86d53718506b97754bc81462e7538a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Aug 2012 02:30:06 +0200 Subject: compat: fix mod_delayed_work * Add return value to function * make EXPORT_SYMBOL_GPL work by including the needed header file Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-3.7.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c index 8fd07ff9..f251788f 100644 --- a/compat/compat-3.7.c +++ b/compat/compat-3.7.c @@ -9,11 +9,13 @@ */ #include +#include bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay) { cancel_delayed_work(dwork); queue_delayed_work(wq, dwork, delay); + return false; } EXPORT_SYMBOL_GPL(mod_delayed_work); -- cgit v1.2.3 From 22048609b18cfc7d51b316d223440a71bdd19309 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 11 Aug 2012 02:30:07 +0200 Subject: compat: move RHEL mask for qdisc_cb_private_validate Move the mask for qdisc_cb_private_validate directly in front of the function to it is only included when this function is really used from compat. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 956d4c04..61d33b03 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -10,15 +10,17 @@ #include #include -/* mask qdisc_cb_private_validate as RHEL6 backports this */ -#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b) #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) +/* mask qdisc_cb_private_validate as RHEL6 backports this */ +#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b) static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) { BUILD_BUG_ON(sizeof(skb->cb) < sizeof(struct qdisc_skb_cb) + sz); } #else +/* mask qdisc_cb_private_validate as RHEL6 backports this */ +#define qdisc_cb_private_validate(a,b) compat_qdisc_cb_private_validate(a,b) static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) { /* XXX ? */ -- cgit v1.2.3 From 8fb380c74a5e0b8548daf7d52ff5fe6cbcdd4153 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 13 Aug 2012 21:59:01 +0200 Subject: compat: add tty_{un}lock() for kernel < 3.7 The change of tty_{un}lock() in kernel 3.5 was reverted, but now it was added again for kernel 3.7. This patch does the needed changes to backport this commit: commit 89c8d91e31f267703e365593f6bfebb9f6d2ad01 Author: Alan Cox Date: Wed Aug 8 16:30:13 2012 +0100 tty: localise the lock Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.5.h | 5 ----- include/linux/compat-3.7.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 3aec3bd6..9cffead2 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -239,11 +239,6 @@ struct tc_fq_codel_xstats { }; #endif /* TCA_CODEL_MAX */ - -/* Backports tty_lock: Localise the lock */ -#define tty_lock(__tty) tty_lock() -#define tty_unlock(__tty) tty_unlock() - /* Backport ether_addr_equal */ static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2) { diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index e113e80d..9271c2e9 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -6,10 +6,15 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) #include +#include bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); +/* Backports tty_lock: Localise the lock */ +#define tty_lock(__tty) tty_lock() +#define tty_unlock(__tty) tty_unlock() + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ #endif /* LINUX_3_7_COMPAT_H */ -- cgit v1.2.3 From 69703371f3e2594a44c3e7fb5bcee1748b2e8f14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 14 Aug 2012 12:06:04 +0300 Subject: compat: Drop redundant udev rules file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit udev rules for Ubuntu and the-rest-of-world are the same. Drop one of them and use the other one. Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- scripts/compat_firmware_install | 2 +- udev/ubuntu/50-compat_firmware.rules | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 udev/ubuntu/50-compat_firmware.rules diff --git a/scripts/compat_firmware_install b/scripts/compat_firmware_install index 33e4fde8..e4b9fb03 100755 --- a/scripts/compat_firmware_install +++ b/scripts/compat_firmware_install @@ -10,7 +10,7 @@ case $LSB_RED_ID in "Ubuntu") mkdir -p /lib/udev/ /lib/udev/rules.d/ cp udev/ubuntu/compat_firmware.sh /lib/udev/ - cp udev/ubuntu/50-compat_firmware.rules /lib/udev/rules.d/ + cp udev/50-compat_firmware.rules /lib/udev/rules.d/ ;; *) mkdir -p /lib/udev/ /lib/udev/rules.d/ diff --git a/udev/ubuntu/50-compat_firmware.rules b/udev/ubuntu/50-compat_firmware.rules deleted file mode 100644 index 6473788e..00000000 --- a/udev/ubuntu/50-compat_firmware.rules +++ /dev/null @@ -1,4 +0,0 @@ -# do not edit this file, it will be overwritten on update - -# compat_firmware-class requests, copies files into the kernel -SUBSYSTEM=="compat_firmware", ACTION=="add", RUN+="compat_firmware.sh" -- cgit v1.2.3 From 1c5b7feac358c27feedbd0a3e37853a97d99a6e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Tue, 14 Aug 2012 19:20:25 +0300 Subject: compat: Backport __wake_up_all_locked() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit 63b2001169e75cd71e917ec953fdab572e3f944a Author: Thomas Gleixner Date: Thu Dec 1 00:04:00 2011 +0100 sched/wait: Add __wake_up_all_locked() API $ git describe --contains 63b2001169e75cd71e917ec953fdab572e3f944a v3.4-rc1~3^2~24 This is used by the 3.6-rcX radeon DRM driver (radeon_sa.c) and will probably be used by other drivers in the near future. __wake_up_all_locked() is a preprocessor macro around __wake_up_locked() which gained a 3rd parameter in 3.4. That's why I backported the new __wake_up_locked() as compat_wake_up_locked() to avoid name conflicts. This new function uses the internal __wake_up_common() function which needed a backport too. I backported it as compat_wake_up_common() as __wake_up_common() was made available in kernels between 2.6.28 <= x <= 2.6.30 through wait.h and dropped after 2.6.30. Renaming fixes build problems of compat for those kernels. Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- compat/compat-3.4.c | 29 +++++++++++++++++++++++++++++ include/linux/compat-3.4.h | 13 +++++++++++++ 2 files changed, 42 insertions(+) diff --git a/compat/compat-3.4.c b/compat/compat-3.4.c index 4ff439b9..a771260e 100644 --- a/compat/compat-3.4.c +++ b/compat/compat-3.4.c @@ -10,6 +10,35 @@ #include #include +#include + +/* __wake_up_common was declared as part of the wait.h until + * 2.6.31 in which they made it private to the scheduler. Prefix it with + * compat to avoid double declaration issues. + */ +static void compat_wake_up_common(wait_queue_head_t *q, unsigned int mode, + int nr_exclusive, int wake_flags, void *key) +{ + wait_queue_t *curr, *next; + + list_for_each_entry_safe(curr, next, &q->task_list, task_list) { + unsigned flags = curr->flags; + + if (curr->func(curr, mode, wake_flags, key) && + (flags & WQ_FLAG_EXCLUSIVE) && !--nr_exclusive) + break; + } +} + +/* The last 'nr' parameter was added to the __wake_up_locked() function + * in 3.4 kernel. Define a new one prefixed with compat_ for the new API. + */ +void compat_wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr) +{ + compat_wake_up_common(q, mode, nr, 0, NULL); +} +EXPORT_SYMBOL_GPL(compat_wake_up_locked); + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) #include diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 06a3a07f..07bfa53f 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -5,6 +5,19 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) + +/* This backports: + * + * commit 63b2001169e75cd71e917ec953fdab572e3f944a + * Author: Thomas Gleixner + * Date: Thu Dec 1 00:04:00 2011 +0100 + + * sched/wait: Add __wake_up_all_locked() API + */ +#include +extern void compat_wake_up_locked(wait_queue_head_t *q, unsigned int mode, int nr); +#define wake_up_all_locked(x) compat_wake_up_locked((x), TASK_NORMAL, 0) + /* This backports: * * commit a8203725dfded5c1f79dca3368a4a273e24b59bb -- cgit v1.2.3 From 48a8076679b9da14f42a59bb3593c260978d84eb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 14 Aug 2012 10:40:24 -0700 Subject: compat: rename compat-wireless to compat-drivers The git tree name has changed. New documentation: https://backports.wiki.kernel.org Signed-off-by: Luis R. Rodriguez --- bin/get-compat-trees | 4 ++-- compat/compat-2.6.27.c | 2 +- compat/kstrtox.c | 2 +- include/linux/compat-2.6.39.h | 2 +- scripts/gen-compat-config.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/get-compat-trees b/bin/get-compat-trees index 00a881ac..d7812457 100755 --- a/bin/get-compat-trees +++ b/bin/get-compat-trees @@ -25,7 +25,7 @@ PREFIX=$HOME/ GIT_TREES="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git" GIT_TREES="$GIT_TREES git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git" GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat.git" -GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-wireless.git" +GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-drivers.git" LINUX_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" @@ -72,7 +72,7 @@ for i in $GIT_TREES; do cd $PREFIX git clone $i --reference $PREFIX/linux-stable/.git/ ;; - "compat-wireless.git") + "compat-drivers.git") # This is just what scripts are tested for. Probably best to # unify all into one place but this will do for now. mkdir -p $PREFIX/devel/ diff --git a/compat/compat-2.6.27.c b/compat/compat-2.6.27.c index 762f0ca1..084bdf6d 100644 --- a/compat/compat-2.6.27.c +++ b/compat/compat-2.6.27.c @@ -34,7 +34,7 @@ * @dev: PCI device to handle. * @state: PCI state from which device will issue PME#. * - * This is the backport code for older kernels for compat-wireless, we read stuff + * This is the backport code for older kernels for compat-drivers, we read stuff * from the initialization stuff from pci_pm_init(). */ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) diff --git a/compat/kstrtox.c b/compat/kstrtox.c index 44859d19..266ffbc9 100644 --- a/compat/kstrtox.c +++ b/compat/kstrtox.c @@ -14,7 +14,7 @@ #include /* * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the - * version included in compat-wireless. We use strict_strtol to check if + * version included in compat-drivers. We use strict_strtol to check if * kstrto* is already available. */ #ifndef strict_strtol diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 406f8ebf..7ec34fd9 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -99,7 +99,7 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) /* * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the - * version included in compat-wireless. We use strict_strtol to check if + * version included in compat-drivers. We use strict_strtol to check if * kstrto* is already available. */ #ifndef strict_strtol diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 391a75d0..b70ef035 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -6,7 +6,7 @@ # CONFIG_COMPAT_KERNEL_3_0 .. etc for each kernel release you need an object # for. # -# Note: this is part of the compat.git project, not compat-wireless.git, +# Note: this is part of the compat.git project, not compat-drivers, # send patches against compat.git. if [[ ! -f ${KLIB_BUILD}/Makefile ]]; then -- cgit v1.2.3 From 3144653fe541c6db82aa07c3fa8ae48b0bb0d4ab Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Tue, 14 Aug 2012 14:59:45 -0400 Subject: compat: RHEL build script fixup from upstream There are parentheses where there should be curly braces. This is a patch that Phillip Perry posted to the list, but it was never integrated. Signed-off-by: Philip J Perry Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index b70ef035..a3ebf082 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -48,7 +48,7 @@ done # The RHEL checks seem to annotate the existance of RHEL minor versions. RHEL_MAJOR=$(grep ^RHEL_MAJOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/p') if [[ ! -z ${RHEL_MAJOR} ]]; then - RHEL_MINOR=$(grep ^RHEL_MINOR $(KLIB_BUILD)/Makefile | sed -n 's/.*= *\(.*\)/\1/p') + RHEL_MINOR=$(grep ^RHEL_MINOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/p') for i in $(seq 0 ${RHEL_MINOR}); do eval CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y echo "export CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" -- cgit v1.2.3 From 269518f8545d1356fe64441acdf633eac32a2808 Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Tue, 14 Aug 2012 14:59:46 -0400 Subject: compat: fix defines for RHEL by adding RHEL to string The .config file contains 'CONFIG_COMPAT_6_1,' when it should contain, 'CONFIG_COMPAT_RHEL_6_1.' This fixes that by adding the 'RHEL' in the proper spot. Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index a3ebf082..54f053d4 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -50,8 +50,8 @@ RHEL_MAJOR=$(grep ^RHEL_MAJOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/ if [[ ! -z ${RHEL_MAJOR} ]]; then RHEL_MINOR=$(grep ^RHEL_MINOR ${KLIB_BUILD}/Makefile | sed -n 's/.*= *\(.*\)/\1/p') for i in $(seq 0 ${RHEL_MINOR}); do - eval CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y - echo "export CONFIG_COMPAT_${RHEL_MAJOR}_${i}=y" + eval CONFIG_COMPAT_RHEL_${RHEL_MAJOR}_${i}=y + echo "export CONFIG_COMPAT_RHEL_${RHEL_MAJOR}_${i}=y" done fi -- cgit v1.2.3 From f5a828b76a2704930093a568ca36c91ab6826eab Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Tue, 14 Aug 2012 14:59:47 -0400 Subject: compat: disable KFIFO on RHEL6.1 and later Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 54f053d4..c6368f31 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -60,7 +60,9 @@ if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then - echo "export CONFIG_COMPAT_KFIFO=y" + if [[ ! ${CONFIG_COMPAT_RHEL_6_1} = "y" ]]; then + echo "export CONFIG_COMPAT_KFIFO=y" + fi fi if [[ ${CONFIG_COMPAT_KERNEL_3_5} = "y" ]]; then -- cgit v1.2.3 From 4f6d36f812665732f78eac92299832b302060938 Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Tue, 14 Aug 2012 14:59:48 -0400 Subject: compat: disable compat firmware module on RHEL6.0 and later Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index c6368f31..810c51b4 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -56,7 +56,9 @@ if [[ ! -z ${RHEL_MAJOR} ]]; then fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_33} = "y" ]]; then - echo "export CONFIG_COMPAT_FIRMWARE_CLASS=m" + if [[ ! ${CONFIG_COMPAT_RHEL_6_0} = "y" ]]; then + echo "export CONFIG_COMPAT_FIRMWARE_CLASS=m" + fi fi if [[ ${CONFIG_COMPAT_KERNEL_2_6_36} = "y" ]]; then -- cgit v1.2.3 From b8cbff4cc53357e9495b09d08238231f29f15ec0 Mon Sep 17 00:00:00 2001 From: Andy Gospodarek Date: Tue, 14 Aug 2012 14:59:49 -0400 Subject: compat: fixup firmware defines on RHEL6 Commit 182630e0f686a569aaf9b34781b08f27dc0ab1bb changed the way the firmware code was handled to create new definitions based on config options, not based on whether or not CONFIG_COMPAT_FIRMWARE_CLASS was set. Both need to be included to make this work properly in environments like RHEL6 that do not need CONFIG_COMPAT_FIRMWARE_CLASS to be set, but have CONFIG_FW_LOADER or CONFIG_FW_LOADER_MODULE set. Signed-off-by: Andy Gospodarek Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 381146d3..60caab0a 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -15,6 +15,7 @@ #include #include +#if defined(CONFIG_COMPAT_FIRMWARE_CLASS) #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) #define release_firmware compat_release_firmware #define request_firmware compat_request_firmware @@ -49,6 +50,7 @@ static inline void compat_release_firmware(const struct firmware *fw) { } #endif +#endif /* mask KEY_RFKILL as RHEL6 backports this */ #if !defined(KEY_RFKILL) -- cgit v1.2.3 From b8471d8a73c9dd1002b335f8f756257bc542ddeb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sat, 18 Aug 2012 13:46:54 +0200 Subject: compat: add tty_port_register_device tty_register_device was replaced by tty_port_register_device in this commit: commit 734cc1783816ae358cef45673a29bf7af974e147 Author: Jiri Slaby Date: Tue Aug 7 21:47:47 2012 +0200 TTY: use tty_port_register_device Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 9271c2e9..22a7f9f6 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -15,6 +15,9 @@ bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, #define tty_lock(__tty) tty_lock() #define tty_unlock(__tty) tty_unlock() +#define tty_port_register_device(port, driver, index, device) \ + tty_register_device(driver, index, device) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ #endif /* LINUX_3_7_COMPAT_H */ -- cgit v1.2.3 From 3a718efb0754ab0b75ecd15a4de73f39ad543c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 23 Aug 2012 14:37:26 +0300 Subject: compat: Backport USB_VENDOR_AND_INTERFACE_INFO() macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit d81a5d1956731c453b85c141458d4ff5d6cc5366 Author: Gustavo Padovan Date: Tue Jul 10 19:10:06 2012 -0300 USB: add USB_VENDOR_AND_INTERFACE_INFO() macro which is now used in btusb driver. $ git describe --contains d81a5d1956731c453b85c141458d4ff5d6cc5366 v3.6-rc1~101^2~4 Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.6.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 466975bb..63753cde 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -5,6 +5,24 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) +/** + * Backports + * + * commit d81a5d1956731c453b85c141458d4ff5d6cc5366 + * Author: Gustavo Padovan + * Date: Tue Jul 10 19:10:06 2012 -0300 + * + * USB: add USB_VENDOR_AND_INTERFACE_INFO() macro + */ +#include +#define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ + | USB_DEVICE_ID_MATCH_VENDOR, \ + .idVendor = (vend), \ + .bInterfaceClass = (cl), \ + .bInterfaceSubClass = (sc), \ + .bInterfaceProtocol = (pr) + /** * Backports * -- cgit v1.2.3 From 99d7ff910e3c38efadacbc6506cd898afcbf9b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ozan=20=C3=87a=C4=9Flayan?= Date: Thu, 23 Aug 2012 14:37:27 +0300 Subject: compat: Backport eth_broadcast_addr() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This backports: commit ad7eee98bef92481581060801bdfd1b25a6106c0 Author: Johannes Berg Commit: David S. Miller etherdevice: introduce eth_broadcast_addr A lot of code has either the memset or an inefficient copy from a static array that contains the all-ones broadcast address. Introduce eth_broadcast_addr() to fill an address with all ones, making the code clearer and allowing us to get rid of some constant arrays. Signed-off-by: Johannes Berg Signed-off-by: David S. Miller $ git describe --contains ad7eee98bef92481581060801bdfd1b25a6106c0 v3.6-rc1~125^2~252 Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] Signed-off-by: Ozan Ƈağlayan Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.6.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 63753cde..97b59933 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -47,6 +47,17 @@ #include #include +/** + * eth_broadcast_addr - Assign broadcast address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Assign the broadcast address to the given address array. + */ +static inline void eth_broadcast_addr(u8 *addr) +{ + memset(addr, 0xff, ETH_ALEN); +} + /** * eth_random_addr - Generate software assigned random Ethernet address * @addr: Pointer to a six-byte array containing the Ethernet address -- cgit v1.2.3 From fbc930e41dabb4f7c56dd432e374c223ab02cb76 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 Sep 2012 18:15:30 -0700 Subject: compat: backport PCI: Add accessors for PCI Express Capability This backports this patch: commit 8c0d3a02c1309eb6112d2e7c8172e8ceb26ecfca Author: Jiang Liu Date: Tue Jul 24 17:20:05 2012 +0800 PCI: Add accessors for PCI Express Capability The PCI Express Capability (PCIe spec r3.0, sec 7.8) comes in two versions, v1 and v2. In v1 Capability structures (PCIe spec r1.0 and r1.1), some fields are optional, so the structure size depends on the device type. This patch adds functions to access this capability so drivers don't have to be aware of the differences between v1 and v2. Note that these new functions apply only to the "PCI Express Capability," not to any of the other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.) Function pcie_capability_read_word/dword() reads the PCIe Capabilities register and returns the value in the reference parameter "val". If the PCIe Capabilities register is not implemented on the PCIe device, "val" is set to 0. Function pcie_capability_write_word/dword() writes the value to the specified PCIe Capability register. Function pcie_capability_clear_and_set_word/dword() sets and/or clears bits of a PCIe Capability register. [bhelgaas: changelog, drop "pci_" prefixes, don't export pcie_capability_reg_implemented()] Signed-off-by: Jiang Liu Signed-off-by: Yijing Wang Signed-off-by: Bjorn Helgaas This is not yet upstream into a public release but based on star alignments I can confidently say this will be part of the v3.7-rc1 release unless Linus throws a shit fit over it. Worth mentioning is that the pci_dev->pcie_flags_reg is not available on older kernels so we had to write a pcie_flags_reg() helper. Additionally a lot of pci_reg.h updates were made into the respective header file as they were introduced. mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 0m59.966s user 3m12.628s sys 0m29.542s Signed-off-by: Luis R. Rodriguez --- compat/compat-3.7.c | 230 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.28.h | 6 ++ include/linux/compat-2.6.29.h | 3 + include/linux/compat-2.6.30.h | 4 + include/linux/compat-3.3.h | 21 ++++ include/linux/compat-3.7.h | 37 +++++++ 6 files changed, 301 insertions(+) diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c index f251788f..b37b73a3 100644 --- a/compat/compat-3.7.c +++ b/compat/compat-3.7.c @@ -19,3 +19,233 @@ bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, return false; } EXPORT_SYMBOL_GPL(mod_delayed_work); + +/* + * Kernels >= 3.7 get their PCI-E Capabilities Register cached + * via the pci_dev->pcie_flags_reg so for older kernels we have + * no other option but to read this every single time we need + * it accessed. If we really cared to improve the efficiency + * of this we could try to find an unused u16 varible on the + * pci_dev but if we found it we likely would remove it from + * the kernel anyway right? Bite me. + */ +static inline u16 pcie_flags_reg(const struct pci_dev *dev) +{ + int pos; + u16 reg16; + + pos = pci_find_capability(dev, PCI_CAP_ID_EXP); + if (!pos) + return 0; + + pci_read_config_word(dev, pos + PCI_EXP_FLAGS, ®16); + + return reg16; +} + +static inline int pci_pcie_type(const struct pci_dev *dev) +{ + return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; +} + +static inline int pcie_cap_version(const struct pci_dev *dev) +{ + return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS; +} + +static inline bool pcie_cap_has_devctl(const struct pci_dev *dev) +{ + return true; +} + +static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev) +{ + int type = pci_pcie_type(dev); + + return pcie_cap_version(dev) > 1 || + type == PCI_EXP_TYPE_ROOT_PORT || + type == PCI_EXP_TYPE_ENDPOINT || + type == PCI_EXP_TYPE_LEG_END; +} + +static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) +{ + int type = pci_pcie_type(dev); + + return pcie_cap_version(dev) > 1 || + type == PCI_EXP_TYPE_ROOT_PORT || + (type == PCI_EXP_TYPE_DOWNSTREAM && + pcie_flags_reg(dev) & PCI_EXP_FLAGS_SLOT); +} + +static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev) +{ + int type = pci_pcie_type(dev); + + return pcie_cap_version(dev) > 1 || + type == PCI_EXP_TYPE_ROOT_PORT || + type == PCI_EXP_TYPE_RC_EC; +} + +static bool pcie_capability_reg_implemented(struct pci_dev *dev, int pos) +{ + if (!pci_is_pcie(dev)) + return false; + + switch (pos) { + case PCI_EXP_FLAGS_TYPE: + return true; + case PCI_EXP_DEVCAP: + case PCI_EXP_DEVCTL: + case PCI_EXP_DEVSTA: + return pcie_cap_has_devctl(dev); + case PCI_EXP_LNKCAP: + case PCI_EXP_LNKCTL: + case PCI_EXP_LNKSTA: + return pcie_cap_has_lnkctl(dev); + case PCI_EXP_SLTCAP: + case PCI_EXP_SLTCTL: + case PCI_EXP_SLTSTA: + return pcie_cap_has_sltctl(dev); + case PCI_EXP_RTCTL: + case PCI_EXP_RTCAP: + case PCI_EXP_RTSTA: + return pcie_cap_has_rtctl(dev); + case PCI_EXP_DEVCAP2: + case PCI_EXP_DEVCTL2: + case PCI_EXP_LNKCAP2: + case PCI_EXP_LNKCTL2: + case PCI_EXP_LNKSTA2: + return pcie_cap_version(dev) > 1; + default: + return false; + } +} + +/* + * Note that these accessor functions are only for the "PCI Express + * Capability" (see PCIe spec r3.0, sec 7.8). They do not apply to the + * other "PCI Express Extended Capabilities" (AER, VC, ACS, MFVC, etc.) + */ +int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val) +{ + int ret; + + *val = 0; + if (pos & 1) + return -EINVAL; + + if (pcie_capability_reg_implemented(dev, pos)) { + ret = pci_read_config_word(dev, pci_pcie_cap(dev) + pos, val); + /* + * Reset *val to 0 if pci_read_config_word() fails, it may + * have been written as 0xFFFF if hardware error happens + * during pci_read_config_word(). + */ + if (ret) + *val = 0; + return ret; + } + + /* + * For Functions that do not implement the Slot Capabilities, + * Slot Status, and Slot Control registers, these spaces must + * be hardwired to 0b, with the exception of the Presence Detect + * State bit in the Slot Status register of Downstream Ports, + * which must be hardwired to 1b. (PCIe Base Spec 3.0, sec 7.8) + */ + if (pci_is_pcie(dev) && pos == PCI_EXP_SLTSTA && + pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) { + *val = PCI_EXP_SLTSTA_PDS; + } + + return 0; +} +EXPORT_SYMBOL(pcie_capability_read_word); + +int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) +{ + int ret; + + *val = 0; + if (pos & 3) + return -EINVAL; + + if (pcie_capability_reg_implemented(dev, pos)) { + ret = pci_read_config_dword(dev, pci_pcie_cap(dev) + pos, val); + /* + * Reset *val to 0 if pci_read_config_dword() fails, it may + * have been written as 0xFFFFFFFF if hardware error happens + * during pci_read_config_dword(). + */ + if (ret) + *val = 0; + return ret; + } + + if (pci_is_pcie(dev) && pos == PCI_EXP_SLTCTL && + pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) { + *val = PCI_EXP_SLTSTA_PDS; + } + + return 0; +} +EXPORT_SYMBOL(pcie_capability_read_dword); + +int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) +{ + if (pos & 1) + return -EINVAL; + + if (!pcie_capability_reg_implemented(dev, pos)) + return 0; + + return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val); +} +EXPORT_SYMBOL(pcie_capability_write_word); + +int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) +{ + if (pos & 3) + return -EINVAL; + + if (!pcie_capability_reg_implemented(dev, pos)) + return 0; + + return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val); +} +EXPORT_SYMBOL(pcie_capability_write_dword); + +int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, + u16 clear, u16 set) +{ + int ret; + u16 val; + + ret = pcie_capability_read_word(dev, pos, &val); + if (!ret) { + val &= ~clear; + val |= set; + ret = pcie_capability_write_word(dev, pos, val); + } + + return ret; +} +EXPORT_SYMBOL(pcie_capability_clear_and_set_word); + +int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, + u32 clear, u32 set) +{ + int ret; + u32 val; + + ret = pcie_capability_read_dword(dev, pos, &val); + if (!ret) { + val &= ~clear; + val |= set; + ret = pcie_capability_write_dword(dev, pos, val); + } + + return ret; +} +EXPORT_SYMBOL(pcie_capability_clear_and_set_dword); diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 9b6b9580..8df4e461 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -17,6 +17,7 @@ #endif #include +#include typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t; @@ -267,6 +268,11 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable); #define pr_fmt(fmt) fmt #endif +#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */ +#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */ +#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ +#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) */ #endif /* LINUX_26_28_COMPAT_H */ diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index e859a190..4becc7e1 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -17,6 +17,7 @@ #include #include #include +#include /* backports */ static inline void usb_autopm_put_interface_async(struct usb_interface *intf) @@ -415,4 +416,6 @@ static inline int ndo_do_ioctl(struct net_device *dev, #define compat_pci_resume(fn) #endif +#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */ + #endif /* LINUX_26_29_COMPAT_H */ diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h index 28f3d54a..b4aafaec 100644 --- a/include/linux/compat-2.6.30.h +++ b/include/linux/compat-2.6.30.h @@ -6,6 +6,7 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) #include +#include #ifndef TP_PROTO #define TP_PROTO(args...) TPPROTO(args) @@ -42,6 +43,9 @@ static inline void dev_set_uevent_suppress(struct device *dev, int val) } \ }) +#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */ +#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)) */ #endif /* LINUX_26_30_COMPAT_H */ diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 61d33b03..3cbbaceb 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -5,6 +5,8 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) +#include + /* include to override NL80211_FEATURE_SK_TX_STATUS */ #include #include @@ -74,6 +76,25 @@ module_exit(__driver##_exit); module_driver(__usb_driver, usb_register, \ usb_deregister) + +/* + * PCI_EXP_TYPE_RC_EC was added via 1b6b8ce2 on v2.6.30-rc4~20 : + * + * mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 1b6b8ce2 + * v2.6.30-rc4~20^2 + * + * but the fix for its definition was merged on v3.3-rc1~101^2~67 + * + * mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 1830ea91 + * v3.3-rc1~101^2~67 + * + * while we can assume it got merged and backported on v3.2.28 (which it did + * see c1c3cd9) we cannot assume every kernel has it fixed so lets just undef + * it here and redefine it. + */ +#undef PCI_EXP_TYPE_RC_EC +#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */ #endif /* LINUX_3_3_COMPAT_H */ diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 22a7f9f6..6cee7879 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -7,6 +7,8 @@ #include #include +#include +#include bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); @@ -18,6 +20,41 @@ bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, #define tty_port_register_device(port, driver, index, device) \ tty_register_device(driver, index, device) +int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); +int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val); +int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val); +int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val); +int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, + u16 clear, u16 set); +int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, + u32 clear, u32 set); + +static inline int pcie_capability_set_word(struct pci_dev *dev, int pos, + u16 set) +{ + return pcie_capability_clear_and_set_word(dev, pos, 0, set); +} + +static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos, + u32 set) +{ + return pcie_capability_clear_and_set_dword(dev, pos, 0, set); +} + +static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos, + u16 clear) +{ + return pcie_capability_clear_and_set_word(dev, pos, clear, 0); +} + +static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos, + u32 clear) +{ + return pcie_capability_clear_and_set_dword(dev, pos, clear, 0); +} + +#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ #endif /* LINUX_3_7_COMPAT_H */ -- cgit v1.2.3 From 169203f10a669d1f4735090380351186b763fbd8 Mon Sep 17 00:00:00 2001 From: Mridula Prakash Date: Wed, 5 Sep 2012 13:17:29 -0700 Subject: compat: fix ARM architecture support for atomic_t and atomic64_t changes This ammends the patch below to extend support for ARM. commit e079e9b66ea06373a3be82f9bed1702082a69310 Author: Luis R. Rodriguez Date: Tue Feb 7 19:22:02 2012 -0800 compat: backport making atomic_t and atomic64_t universal mcgrof@tux ~/linux-next (git::master)$ \ git describe --contains ea435467500612636f8f4fb639ff6e76b2496e4b v2.6.29-rc1~390 This commit moved atomic_t and atomic64_t to a generic place, but some archs already had it defined. Just include that header for the archs that had it. Signed-off-by: Luis R. Rodriguez ARM also had atomic.h before that commit upstream. Signed-off-by: Mridula Prakash Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 4becc7e1..e6215190 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -35,7 +35,8 @@ static inline int usb_autopm_get_interface_async(struct usb_interface *intf) defined(CONFIG_SUPERH) || defined(CONFIG_SPARC) || \ defined(CONFIG_FRV) || defined(CONFIG_X86) || \ defined(CONFIG_M32R) || defined(CONFIG_M68K) || \ - defined(CONFIG_MN10300) || defined(CONFIG_XTENSA) + defined(CONFIG_MN10300) || defined(CONFIG_XTENSA) \ + defined(CONFIG_ARM) #include #else typedef struct { -- cgit v1.2.3 From be1c0302f921192158a018ed6c4b3c0c290e66ab Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 6 Sep 2012 16:54:44 -0700 Subject: compat: fix typo on previous atomic changes Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index e6215190..d95b00e1 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -35,7 +35,7 @@ static inline int usb_autopm_get_interface_async(struct usb_interface *intf) defined(CONFIG_SUPERH) || defined(CONFIG_SPARC) || \ defined(CONFIG_FRV) || defined(CONFIG_X86) || \ defined(CONFIG_M32R) || defined(CONFIG_M68K) || \ - defined(CONFIG_MN10300) || defined(CONFIG_XTENSA) \ + defined(CONFIG_MN10300) || defined(CONFIG_XTENSA) || \ defined(CONFIG_ARM) #include #else -- cgit v1.2.3 From 677e8952a93c14b17e8dede03eafa5f1fb16d97e Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Fri, 7 Sep 2012 09:56:14 +0200 Subject: compat: drop const to fix compiler warnings When calling pci_find_capability and pci_read_config_word, struct pci_dev needs to be passed without const. Signed-off-by: Felix Fietkau Signed-off-by: Luis R. Rodriguez --- compat/compat-3.7.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c index b37b73a3..f591f163 100644 --- a/compat/compat-3.7.c +++ b/compat/compat-3.7.c @@ -29,7 +29,7 @@ EXPORT_SYMBOL_GPL(mod_delayed_work); * pci_dev but if we found it we likely would remove it from * the kernel anyway right? Bite me. */ -static inline u16 pcie_flags_reg(const struct pci_dev *dev) +static inline u16 pcie_flags_reg(struct pci_dev *dev) { int pos; u16 reg16; @@ -43,12 +43,12 @@ static inline u16 pcie_flags_reg(const struct pci_dev *dev) return reg16; } -static inline int pci_pcie_type(const struct pci_dev *dev) +static inline int pci_pcie_type(struct pci_dev *dev) { return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4; } -static inline int pcie_cap_version(const struct pci_dev *dev) +static inline int pcie_cap_version(struct pci_dev *dev) { return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS; } @@ -58,7 +58,7 @@ static inline bool pcie_cap_has_devctl(const struct pci_dev *dev) return true; } -static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev) +static inline bool pcie_cap_has_lnkctl(struct pci_dev *dev) { int type = pci_pcie_type(dev); @@ -68,7 +68,7 @@ static inline bool pcie_cap_has_lnkctl(const struct pci_dev *dev) type == PCI_EXP_TYPE_LEG_END; } -static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) +static inline bool pcie_cap_has_sltctl(struct pci_dev *dev) { int type = pci_pcie_type(dev); @@ -78,7 +78,7 @@ static inline bool pcie_cap_has_sltctl(const struct pci_dev *dev) pcie_flags_reg(dev) & PCI_EXP_FLAGS_SLOT); } -static inline bool pcie_cap_has_rtctl(const struct pci_dev *dev) +static inline bool pcie_cap_has_rtctl(struct pci_dev *dev) { int type = pci_pcie_type(dev); -- cgit v1.2.3 From 22e6331ef33f90c28f5b299d82983fdca12645b7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Sep 2012 17:39:59 -0700 Subject: compat: backport netlink pid to portid rename The patch: commit 15e473046cb6e5d18a4d0057e61d76315230382b Author: Eric W. Biederman Date: Fri Sep 7 20:12:54 2012 +0000 netlink: Rename pid to portid to avoid confusion It is a frequent mistake to confuse the netlink port identifier with a process identifier. Try to reduce this confusion by renaming fields that hold port identifiers portid instead of pid. I have carefully avoided changing the structures exported to userspace to avoid changing the userspace API. I have successfully built an allyesconfig kernel with this change. Signed-off-by: "Eric W. Biederman" Acked-by: Stephen Hemminger Signed-off-by: David S. Miller Changed the struct members: struct netlink_notify->pid to struct netlink_notify->portid struct genl_info->snd_pid to struct genl_info->snd_portid This adds helpers to help reduce the overhead cost to backport this collateral evolution. mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m0.017s user 3m12.748s sys 0m30.274s Cc: Eric W. Biederman Cc: Stephen Hemminger Cc: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 6cee7879..e4e126ca 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -10,6 +10,10 @@ #include #include +#define netlink_notify_portid(__notify) (__notify->pid) +#define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid) +#define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).pid + bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); @@ -55,6 +59,10 @@ static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos, #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ +#else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ +#define netlink_notify_portid(__notify) (__notify->portid) +#define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) +#define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).portid #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) */ #endif /* LINUX_3_7_COMPAT_H */ -- cgit v1.2.3 From 59c869722d2e1ed90493fc5bd814f03e6cd15993 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 28 Sep 2012 10:47:31 -0700 Subject: compat: backport uidgid.h kuid_t and kgid_t addition mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains \ 7a4e7408c5cadb240e068a662251754a562355e3 v3.5-rc1~107^2~33 This backports: commit 7a4e7408c5cadb240e068a662251754a562355e3 Author: Eric W. Biederman Date: Mon Nov 14 14:29:51 2011 -0800 userns: Add kuid_t and kgid_t and associated infrastructure in uidgid.h Start distinguishing between internal kernel uids and gids and values that userspace can use. This is done by introducing two new types: kuid_t and kgid_t. These types and their associated functions are infrastructure are declared in the new header uidgid.h. Ultimately there will be a different implementation of the mapping functions for use with user namespaces. But to keep it simple we introduce the mapping functions first to separate the meat from the mechanical code conversions. Export overflowuid and overflowgid so we can use from_kuid_munged and from_kgid_munged in modular code. Acked-by: Serge Hallyn Signed-off-by: Eric W. Biederman The uidgid.h header file is provided for older kernels and for newer kernels we use include_next trick. The only difference here is that compat-3.5.c now exports overflowuid and overflowgid in the case that CONFIG_UID16 was not defined given that on older kernels these were not exported although linux/highuid.h always has historically provided the extern declaration for them. Apart from all this we also force inclusion of uidgid.h within the compat framework now given that in newer kernels its expected to be included by many header files and modules without them having included it in upstream code already. mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m0.411s user 3m18.060s sys 0m30.686s Cc: Serge Hallyn Cc: Eric W. Biederman Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 3 + compat/compat-3.5.c | 30 +++++++ compat/user_namespace.c | 68 +++++++++++++++ include/linux/compat-2.6.h | 1 + include/linux/uidgid.h | 205 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 307 insertions(+) create mode 100644 compat/compat-3.5.c create mode 100644 compat/user_namespace.c create mode 100644 include/linux/uidgid.h diff --git a/compat/Makefile b/compat/Makefile index a44b3459..e9c6e1f2 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -45,6 +45,9 @@ compat-$(CONFIG_COMPAT_KERNEL_3_2) += compat-3.2.o compat-$(CONFIG_COMPAT_KERNEL_3_3) += \ compat-3.3.o compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o +compat-$(CONFIG_COMPAT_KERNEL_3_5) += \ + compat-3.5.o \ + user_namespace.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c new file mode 100644 index 00000000..a6b174d5 --- /dev/null +++ b/compat/compat-3.5.c @@ -0,0 +1,30 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 3.5. + */ + +#include +#include + +/* + * Commit 7a4e7408c5cadb240e068a662251754a562355e3 + * exported overflowuid and overflowgid for all + * kernel configurations, prior to that we only + * had it exported when CONFIG_UID16 was enabled. + * We are technically redefining it here but + * nothing seems to be changing it, except + * kernel/ code does epose it via sysctl and + * proc... if required later we can add that here. + */ +#ifndef CONFIG_UID16 +int overflowuid = DEFAULT_OVERFLOWUID; +int overflowgid = DEFAULT_OVERFLOWGID; + +EXPORT_SYMBOL(overflowuid); +EXPORT_SYMBOL(overflowgid); +#endif diff --git a/compat/user_namespace.c b/compat/user_namespace.c new file mode 100644 index 00000000..a7cebd56 --- /dev/null +++ b/compat/user_namespace.c @@ -0,0 +1,68 @@ +/* + * Copyright 2012 Luis R. Rodriguez + * + * 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 backporting + * user_namespace.c + */ + +#include +#include +#include + +#ifdef CONFIG_USER_NS + +kuid_t make_kuid(struct user_namespace *ns, uid_t uid) +{ + /* Map the uid to a global kernel uid */ + return KUIDT_INIT(uid); +} +EXPORT_SYMBOL(make_kuid); + +uid_t from_kuid(struct user_namespace *targ, kuid_t kuid) +{ + /* Map the uid from a global kernel uid */ + return __kuid_val(kuid); +} +EXPORT_SYMBOL(from_kuid); + +uid_t from_kuid_munged(struct user_namespace *targ, kuid_t kuid) +{ + uid_t uid; + uid = from_kuid(targ, kuid); + + if (uid == (uid_t) -1) + uid = overflowuid; + return uid; +} +EXPORT_SYMBOL(from_kuid_munged); + +kgid_t make_kgid(struct user_namespace *ns, gid_t gid) +{ + /* Map the gid to a global kernel gid */ + return KGIDT_INIT(gid); +} +EXPORT_SYMBOL(make_kgid); + +gid_t from_kgid(struct user_namespace *targ, kgid_t kgid) +{ + /* Map the gid from a global kernel gid */ + return __kgid_val(kgid); +} +EXPORT_SYMBOL(from_kgid); + +gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid) +{ + gid_t gid; + gid = from_kgid(targ, kgid); + + if (gid == (gid_t) -1) + gid = overflowgid; + return gid; +} +EXPORT_SYMBOL(from_kgid_munged); + +#endif /* CONFIG_USER_NS */ diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 46ae6541..f26489c3 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -11,6 +11,7 @@ #endif #include #include +#include /* * The define overwriting module_init is based on the original module_init diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h new file mode 100644 index 00000000..d9e4224e --- /dev/null +++ b/include/linux/uidgid.h @@ -0,0 +1,205 @@ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) +#include_next +#else + +#ifndef _LINUX_UIDGID_H +#define _LINUX_UIDGID_H + +/* + * A set of types for the internal kernel types representing uids and gids. + * + * The types defined in this header allow distinguishing which uids and gids in + * the kernel are values used by userspace and which uid and gid values are + * the internal kernel values. With the addition of user namespaces the values + * can be different. Using the type system makes it possible for the compiler + * to detect when we overlook these differences. + * + */ +#include +#include + +struct user_namespace; +extern struct user_namespace init_user_ns; + +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS + +typedef struct { + uid_t val; +} kuid_t; + + +typedef struct { + gid_t val; +} kgid_t; + +#define KUIDT_INIT(value) (kuid_t){ value } +#define KGIDT_INIT(value) (kgid_t){ value } + +static inline uid_t __kuid_val(kuid_t uid) +{ + return uid.val; +} + +static inline gid_t __kgid_val(kgid_t gid) +{ + return gid.val; +} + +#else + +typedef uid_t kuid_t; +typedef gid_t kgid_t; + +static inline uid_t __kuid_val(kuid_t uid) +{ + return uid; +} + +static inline gid_t __kgid_val(kgid_t gid) +{ + return gid; +} + +#define KUIDT_INIT(value) ((kuid_t) value ) +#define KGIDT_INIT(value) ((kgid_t) value ) + +#endif + +#define GLOBAL_ROOT_UID KUIDT_INIT(0) +#define GLOBAL_ROOT_GID KGIDT_INIT(0) + +#define INVALID_UID KUIDT_INIT(-1) +#define INVALID_GID KGIDT_INIT(-1) + +static inline bool uid_eq(kuid_t left, kuid_t right) +{ + return __kuid_val(left) == __kuid_val(right); +} + +static inline bool gid_eq(kgid_t left, kgid_t right) +{ + return __kgid_val(left) == __kgid_val(right); +} + +static inline bool uid_gt(kuid_t left, kuid_t right) +{ + return __kuid_val(left) > __kuid_val(right); +} + +static inline bool gid_gt(kgid_t left, kgid_t right) +{ + return __kgid_val(left) > __kgid_val(right); +} + +static inline bool uid_gte(kuid_t left, kuid_t right) +{ + return __kuid_val(left) >= __kuid_val(right); +} + +static inline bool gid_gte(kgid_t left, kgid_t right) +{ + return __kgid_val(left) >= __kgid_val(right); +} + +static inline bool uid_lt(kuid_t left, kuid_t right) +{ + return __kuid_val(left) < __kuid_val(right); +} + +static inline bool gid_lt(kgid_t left, kgid_t right) +{ + return __kgid_val(left) < __kgid_val(right); +} + +static inline bool uid_lte(kuid_t left, kuid_t right) +{ + return __kuid_val(left) <= __kuid_val(right); +} + +static inline bool gid_lte(kgid_t left, kgid_t right) +{ + return __kgid_val(left) <= __kgid_val(right); +} + +static inline bool uid_valid(kuid_t uid) +{ + return !uid_eq(uid, INVALID_UID); +} + +static inline bool gid_valid(kgid_t gid) +{ + return !gid_eq(gid, INVALID_GID); +} + +#ifdef CONFIG_USER_NS + +extern kuid_t make_kuid(struct user_namespace *from, uid_t uid); +extern kgid_t make_kgid(struct user_namespace *from, gid_t gid); + +extern uid_t from_kuid(struct user_namespace *to, kuid_t uid); +extern gid_t from_kgid(struct user_namespace *to, kgid_t gid); +extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid); +extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid); + +static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) +{ + return from_kuid(ns, uid) != (uid_t) -1; +} + +static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) +{ + return from_kgid(ns, gid) != (gid_t) -1; +} + +#else + +static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid) +{ + return KUIDT_INIT(uid); +} + +static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid) +{ + return KGIDT_INIT(gid); +} + +static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid) +{ + return __kuid_val(kuid); +} + +static inline gid_t from_kgid(struct user_namespace *to, kgid_t kgid) +{ + return __kgid_val(kgid); +} + +static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid) +{ + uid_t uid = from_kuid(to, kuid); + if (uid == (uid_t)-1) + uid = overflowuid; + return uid; +} + +static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid) +{ + gid_t gid = from_kgid(to, kgid); + if (gid == (gid_t)-1) + gid = overflowgid; + return gid; +} + +static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) +{ + return true; +} + +static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) +{ + return true; +} + +#endif /* CONFIG_USER_NS */ + +#endif /* _LINUX_UIDGID_H */ +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */ -- cgit v1.2.3 From 64eac2cd257e5155ac0e8d519277e87ea4a2ab0c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 28 Sep 2012 11:06:14 -0700 Subject: compat: backport definition of VM_NODUMP and VM_DONTDUMP Commit accb61fe defined and added VM_NODUMP so we backport that but later VM_NODUMP was renamed to VM_DONTDUMP via commit cdaaa7003. We backport that definition declaration as well. Note though that commit 909af768e removed the usage of the same bit field and it was used previously for VM_ALWAYSDUMP... given that we want to backport support for it but we can't we make this flag now a no-op for older kernels. Usage of VM_NODUMP or VM_DONTDUMP on older kernels will simply yield in a no-op for memory regions. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains \ 909af768e88867016f427264ae39d27a57b6a8ed v3.4-rc1~109^2~7 commit 909af768e88867016f427264ae39d27a57b6a8ed Author: Jason Baron Date: Fri Mar 23 15:02:51 2012 -0700 coredump: remove VM_ALWAYSDUMP flag The motivation for this patchset was that I was looking at a way for a qemu-kvm process, to exclude the guest memory from its core dump, which can be quite large. There are already a number of filter flags in /proc//coredump_filter, however, these allow one to specify 'types' of kernel memory, not specific address ranges (which is needed in this case). Since there are no more vma flags available, the first patch eliminates the need for the 'VM_ALWAYSDUMP' flag. The flag is used internally by the kernel to mark vdso and vsyscall pages. However, it is simple enough to check if a vma covers a vdso or vsyscall page without the need for this flag. The second patch then replaces the 'VM_ALWAYSDUMP' flag with a new 'VM_NODUMP' flag, which can be set by userspace using new madvise flags: 'MADV_DONTDUMP', and unset via 'MADV_DODUMP'. The core dump filters continue to work the same as before unless 'MADV_DONTDUMP' is set on the region. The qemu code which implements this features is at: http://people.redhat.com/~jbaron/qemu-dump/qemu-dump.patch In my testing the qemu core dump shrunk from 383MB -> 13MB with this patch. I also believe that the 'MADV_DONTDUMP' flag might be useful for security sensitive apps, which might want to select which areas are dumped. This patch: The VM_ALWAYSDUMP flag is currently used by the coredump code to indicate that a vma is part of a vsyscall or vdso section. However, we can determine if a vma is in one these sections by checking it against the gate_vma and checking for a non-NULL return value from arch_vma_name(). Thus, freeing a valuable vma bit. Signed-off-by: Jason Baron Acked-by: Roland McGrath Cc: Chris Metcalf Cc: Avi Kivity Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds mcgrof@frijol ~/linux-next (git::master)$ git describe --contains accb61fe v3.4-rc1~109^2~6 commit accb61fe7bb0f5c2a4102239e4981650f9048519 Author: Jason Baron Date: Fri Mar 23 15:02:51 2012 -0700 coredump: add VM_NODUMP, MADV_NODUMP, MADV_CLEAR_NODUMP Since we no longer need the VM_ALWAYSDUMP flag, let's use the freed bit for 'VM_NODUMP' flag. The idea is is to add a new madvise() flag: MADV_DONTDUMP, which can be set by applications to specifically request memory regions which should not dump core. The specific application I have in mind is qemu: we can add a flag there that wouldn't dump all of guest memory when qemu dumps core. This flag might also be useful for security sensitive apps that want to absolutely make sure that parts of memory are not dumped. To clear the flag use: MADV_DODUMP. [akpm@linux-foundation.org: s/MADV_NODUMP/MADV_DONTDUMP/, s/MADV_CLEAR_NODUMP/MADV_DODUMP/, per Roland] [akpm@linux-foundation.org: fix up the architectures which broke] Signed-off-by: Jason Baron Acked-by: Roland McGrath Cc: Chris Metcalf Cc: Avi Kivity Cc: Ralf Baechle Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: "James E.J. Bottomley" Cc: Helge Deller Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds VM_NODUMP was renamed to VM_DONTDUMP so for older kernels just use the old declaration. This commit is not yet on Linus' tree so in linux-next we trust it will be on v3.7-rc1. commit cdaaa7003e855fb50be3a566ac8ef96c6ff138cd Author: Konstantin Khlebnikov Date: Wed Sep 26 11:33:12 2012 +1000 mm: prepare VM_DONTDUMP for using in drivers Rename VM_NODUMP into VM_DONTDUMP: this name matches other negative flags: VM_DONTEXPAND, VM_DONTCOPY. Currently this flag used only for sys_madvise. The next patch will use it for replacing the outdated flag VM_RESERVED. Also forbid madvise(MADV_DODUMP) for special kernel mappings VM_SPECIAL (VM_IO | VM_DONTEXPAND | VM_RESERVED | VM_PFNMAP) Signed-off-by: Konstantin Khlebnikov Cc: Alexander Viro Cc: Carsten Otte Cc: Chris Metcalf Cc: Cyrill Gorcunov Cc: Eric Paris Cc: H. Peter Anvin Cc: Hugh Dickins Cc: Ingo Molnar Cc: James Morris Cc: Jason Baron Cc: Kentaro Takeda Cc: Matt Helsley Cc: Nick Piggin Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Robert Richter Cc: Suresh Siddha Cc: Tetsuo Handa Cc: Venkatesh Pallipadi Acked-by: Linus Torvalds Signed-off-by: Andrew Morton Cc: Jason Baron Cc: Roland McGrath Cc: Chris Metcalf Cc: Avi Kivity Cc: Ralf Baechle Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: "James E.J. Bottomley" Cc: Helge Deller Cc: Andrew Morton Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 11 +++++++++++ include/linux/compat-3.7.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 07bfa53f..887293da 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -5,6 +5,17 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) +/* + * defined here to allow things to compile but technically + * using this for memory regions will yield in a no-op on newer + * kernels but on older kernels (v3.3 and older) this bit was used + * for VM_ALWAYSDUMP. The goal was to remove this bit moving forward + * and since we can't skip the core dump on old kernels we just make + * this bit name now a no-op. + * + * For details see commits: 909af7 accb61fe cdaaa7003 + */ +#define VM_NODUMP 0x0 /* This backports: * diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index e4e126ca..80c2aada 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -9,6 +9,9 @@ #include #include #include +#include + +#define VM_DONTDUMP VM_NODUMP #define netlink_notify_portid(__notify) (__notify->pid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid) -- cgit v1.2.3 From fb4936e53a0e279de369fd4490eb234f122926f4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 28 Sep 2012 15:03:55 -0700 Subject: compat: backport seq_file's user namespace addition Commit adb37c4, which as per linux-next may get to v3.7-rc1, introduced adding a user namespace to a struct seq_file. For older kernels with CONFIG_USER_NS support just access the user_name space via the struct file. For kernels without CONFIG_USER_NS pass the init_user_ns. There is a special case to handle for kernels with CONFIG_USER_NS prior to v2.6.38 -- see commit 47a150ed which added a struct user_namespace to struct cred. This backports: commit adb37c4c67f807f16beb222028fb3ce9a354dc2b Author: Eric W. Biederman Date: Wed May 23 18:01:20 2012 -0600 userns: Make seq_file's user namespace accessible struct file already has a user namespace associated with it in file->f_cred->user_ns, unfortunately because struct seq_file has no struct file backpointer associated with it, it is difficult to get at the user namespace in seq_file context. Therefore add a helper function seq_user_ns to return the associated user namespace and a user_ns field to struct seq_file to be used in implementing seq_user_ns. Cc: Al Viro Cc: Eric Dumazet Cc: KAMEZAWA Hiroyuki Cc: Alexey Dobriyan Acked-by: David S. Miller Acked-by: Serge Hallyn Signed-off-by: Eric W. Biederman And for kernels older than v2.6.38 this is relevant to review: commit 47a150edc2ae734c0f4bf50aa19499e23b9a46f8 Author: Serge E. Hallyn Date: Fri May 13 04:27:54 2011 +0100 Cache user_ns in struct cred If !CONFIG_USERNS, have current_user_ns() defined to (&init_user_ns). Get rid of _current_user_ns. This requires nsown_capable() to be defined in capability.c rather than as static inline in capability.h, so do that. Request_key needs init_user_ns defined at current_user_ns if !CONFIG_USERNS, so forward-declare that in cred.h if !CONFIG_USERNS at current_user_ns() define. Compile-tested with and without CONFIG_USERNS. Signed-off-by: Serge E. Hallyn [ This makes a huge performance difference for acl_permission_check(), up to 30%. And that is one of the hottest kernel functions for loads that are pathname-lookup heavy. ] Signed-off-by: Linus Torvalds mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m1.219s user 3m19.912s sys 0m31.102s Cc: Eric W. Biederman Cc: Al Viro Cc: Eric Dumazet Cc: KAMEZAWA Hiroyuki Cc: Alexey Dobriyan Cc: David S. Miller Cc: Serge Hallyn Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 80c2aada..2d7b6ddb 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -10,9 +10,36 @@ #include #include #include +#include +#include +#include #define VM_DONTDUMP VM_NODUMP +#ifdef CONFIG_USER_NS + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) +static inline struct user_namespace *seq_user_ns(struct seq_file *seq) +{ + struct file *f = container_of((void *) seq, struct file, private_data); + + return f->f_cred->user_ns; +} +#else +static inline struct user_namespace *seq_user_ns(struct seq_file *seq) +{ + return current_user_ns(); +} +#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38)) */ + +#else +static inline struct user_namespace *seq_user_ns(struct seq_file *seq) +{ + extern struct user_namespace init_user_ns; + return &init_user_ns; +} +#endif /* CONFIG_USER_NS */ + #define netlink_notify_portid(__notify) (__notify->pid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid) #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).pid -- cgit v1.2.3 From 1e9bddfd1d152e2cb133c53fe8b812945896f6d4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 18 Oct 2012 14:06:36 -0700 Subject: compat: backport usb_autopm_[get|put]_interface_no_[resume|suspend]() This backports these two routines: * usb_autopm_get_interface_no_resume() * usb_autopm_put_interface_no_suspend() These routines simply increment or decrement the USB pm usage counter without trying to either suspend or resume. mcgrof@garbanzo ~/compat (git::master)$ time ckmake Trying kernel 3.5.0-030500-generic [OK] Trying kernel 3.4.4-030404-generic [OK] Trying kernel 3.3.7-030307-generic [OK] Trying kernel 3.2.2-030202-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.18-030018-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063512-generic [OK] Trying kernel 2.6.34-02063410-generic [OK] Trying kernel 2.6.33-02063305-generic [OK] Trying kernel 2.6.32-02063255-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m2.113s user 3m30.573s sys 0m31.922s Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.33.c | 43 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.33.h | 15 +++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 365a1a6c..6e68db4b 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -9,6 +9,49 @@ */ #include +#include +#include +#include + +#ifdef CONFIG_USB_SUSPEND +/** + * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter + * @intf: the usb_interface whose counter should be incremented + * + * This routine increments @intf's usage counter but does not carry out an + * autoresume. + * + * This routine can run in atomic context. + */ +void usb_autopm_get_interface_no_resume(struct usb_interface *intf) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_mark_last_busy(udev); + atomic_inc(&intf->pm_usage_cnt); + pm_runtime_get_noresume(&intf->dev); +} +EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume); + +/** + * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter + * @intf: the usb_interface whose counter should be decremented + * + * This routine decrements @intf's usage counter but does not carry out an + * autosuspend. + * + * This routine can run in atomic context. + */ +void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) +{ + struct usb_device *udev = interface_to_usbdev(intf); + + usb_mark_last_busy(udev); + atomic_dec(&intf->pm_usage_cnt); + pm_runtime_put_noidle(&intf->dev); +} +EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend); +#endif /* CONFIG_USB_SUSPEND */ #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 60caab0a..307834ad 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -7,6 +7,7 @@ #include #include +#include #if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) #include #include @@ -15,6 +16,20 @@ #include #include +#ifdef CONFIG_USB_SUSPEND +extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); +extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); +#else +static inline void usb_autopm_get_interface_no_resume(struct usb_interface *intf) +{ + atomic_inc(&intf->pm_usage_cnt); +} +static inline void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) +{ + atomic_dec(&intf->pm_usage_cnt); +} +#endif /* CONFIG_USB_SUSPEND */ + #if defined(CONFIG_COMPAT_FIRMWARE_CLASS) #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) #define release_firmware compat_release_firmware -- cgit v1.2.3 From c57b539b1e32769fb3bd0ca52ff4318c8f205592 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 18 Oct 2012 15:13:34 -0700 Subject: compat: fix first ckmake make clean assumption Any directory should be used to make the first 'make clean' but we should get that from the KLIBS variable. Use the first kernel found that we can use. This fixes a complaint when your current kernel has no kernel headers installed but you do have some present on the compat-ksrc dir. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index d4081607..f1746962 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -238,7 +238,8 @@ for i in $LOG $LOG_TMP $REPORT; do echo > $i done -nice make clean 2>&1 > $LOG +DIR="$(echo $KLIBS | awk '{print $1}')/build" +nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG if [[ $TIME != "1" ]]; then run_ckmake | tee_color_split $REPORT -- cgit v1.2.3 From 45ca8f675c312de51fabc0ae35a5587f4ae5afea Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 19 Oct 2012 14:21:52 -0700 Subject: compat: add v3.6.2 vanilla kernels to bin/get-compat-kernels Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 2003cd35..2fbb371a 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -57,6 +57,7 @@ KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-03020 KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" KERNELS="$KERNELS ${KPATH}/v3.5-quantal/linux-headers-3.5.0-030500_3.5.0-030500.201207211835_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.6.2-quantal/linux-headers-3.6.2-030602_3.6.2-030602.201210121823_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 8de8ebb2e585aa72b36ee748260da264b6f84778 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 19 Oct 2012 14:22:18 -0700 Subject: compat: encourage non-root use of bin/get-compat-kernels Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 2fbb371a..30f5dfe5 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -203,11 +203,16 @@ fi echo -e "" -if [[ -n $KSRC_PREFIX ]]; then - echo -e "** Running as a non-privileged user!" - echo -e "** If you want to force using system-wide ${BLUE}/lib/modules${NORMAL} and ${BLUE}/usr/src${NORMAL}, you have to" - echo -e "** run this script as root or using ${GREEN}sudo${NORMAL}." +if [[ ! -n $KSRC_PREFIX ]]; then + echo -e "** Running as a privileged user!" + echo -e "** You are trying to force using system-wide ${BLUE}/lib/modules${NORMAL} and ${BLUE}/usr/src${NORMAL} ..." + echo -e "** This is a terrible idea. Consider running as a regular user." echo -e "" + read -p "Do you still want to continue (y/N)? " + if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 + fi fi echo -e "This will download ${YELLOW}${NUM_KERNELS}${NORMAL} kernel headers to allow you to" -- cgit v1.2.3 From 28c4eaf5a5b0371081e752707c499d42067ebcf7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 1 Nov 2012 20:05:31 +0100 Subject: compat: update list of kernel headers With this patch get-compat-kernels fetches the most recent minor versions of the kernel headers from the Ubuntu mainline repository. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 30f5dfe5..55974f7c 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -43,21 +43,21 @@ KERNELS="$KERNELS ${KPATH}/v2.6.28.10/linux-headers-2.6.28-02062810_2.6.28-02062 KERNELS="$KERNELS ${KPATH}/v2.6.29.6/linux-headers-2.6.29-02062906_2.6.29-02062906_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063010_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.32.55-lucid/linux-headers-2.6.32-02063255_2.6.32-02063255.201201251735_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.33.5-lucid/linux-headers-2.6.33-02063305_2.6.33-02063305_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.34.10-maverick/linux-headers-2.6.34-02063410_2.6.34-02063410.201111101535_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.35.13-maverick/linux-headers-2.6.35-02063512_2.6.35-02063512.201111232118_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.32.60-lucid/linux-headers-2.6.32-02063260_2.6.32-02063260.201210082135_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.33.20-maverick/linux-headers-2.6.33-02063320_2.6.33-02063320.201111071735_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.34.13-maverick/linux-headers-2.6.34-02063413_2.6.34-02063413.201208201835_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.35.13-original-maverick/linux-headers-2.6.35-02063513_2.6.35-02063513.201107261012_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.18-oneiric/linux-headers-3.0.18-030018_3.0.18-030018.201201252135_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.50-oneiric/linux-headers-3.0.50-030050_3.0.50-030050.201210311335_all.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.2.2-precise/linux-headers-3.2.2-030202_3.2.2-030202.201201252035_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.3.7-precise/linux-headers-3.3.7-030307_3.3.7-030307.201205211535_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.4-quantal/linux-headers-3.4.4-030404_3.4.4-030404.201206221555_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.5-quantal/linux-headers-3.5.0-030500_3.5.0-030500.201207211835_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.6.2-quantal/linux-headers-3.6.2-030602_3.6.2-030602.201210121823_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.33-precise/linux-headers-3.2.33-030233_3.2.33-030233.201210310701_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.3.8-quantal/linux-headers-3.3.8-030308_3.3.8-030308.201206041356_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.17-quantal/linux-headers-3.4.17-030417_3.4.17-030417.201210311354_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-030507.201210130556_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.6.5-raring/linux-headers-3.6.5-030605_3.6.5-030605.201211011211_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 08703d7cb6faae7575cbcd512d0a1673f18b97f4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 9 Nov 2012 18:58:39 +0100 Subject: compat: fix libc dependency on bin/get-compat-kernels To really hash out the issues with requirements of newer libc we force clean, and build twice. I haven't figured out a cleaner way to do this. If you have a better way please send a patch. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 55974f7c..eb896c05 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -166,9 +166,18 @@ function rebuild_header_binary_deps() { for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do echo $kernel - make -C ${kernel}/build/ M=scripts/mod/ - make -C ${kernel}/build/ M=scripts/basic/ - make -C ${kernel}/build/ M=scripts/genksyms + + for i mod basic genksyms; do + make -C ${kernel}/build/ M=scripts/${i}/ clean > /dev/null 2>&1 + done + + for i mod basic genksyms; do + make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 + done + + for i mod basic genksyms; do + make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 + done done } -- cgit v1.2.3 From 5bf068f8c852d8de8e0214f0bcd79f2440827fde Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 9 Nov 2012 19:03:27 +0100 Subject: compat: fix typo in bin/get-compat-kernels Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index eb896c05..fa09e6e2 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -167,15 +167,15 @@ function rebuild_header_binary_deps() { for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do echo $kernel - for i mod basic genksyms; do + for i in mod basic genksyms; do make -C ${kernel}/build/ M=scripts/${i}/ clean > /dev/null 2>&1 done - for i mod basic genksyms; do + for i in mod basic genksyms; do make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 done - for i mod basic genksyms; do + for i in mod basic genksyms; do make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 done done -- cgit v1.2.3 From 00220491896ba9c8e0c9a38a519938bc1ff98d52 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 9 Nov 2012 19:08:36 +0100 Subject: compat: run ckmake with num cpu threads Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index f1746962..5fd3e7f3 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -31,6 +31,7 @@ LAST="" RANGE="" RET="" +NUM_CPUS=$(echo $(($(cat /proc/cpuinfo | grep processor | tail -1 | awk '{print $3}')+1))) # If $HOME/compat-ksrc is found use that, otherwise use system-wide # sources in /usr/src. @@ -161,8 +162,8 @@ function run_ckmake() NOCOLOR="1" log_try_kernel $KERNEL >> $LOG log_try_kernel $KERNEL - #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 -Wunused-but-set-variable $ARGS &>> $LOG - ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j6 $ARGS &>> $LOG + #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j${NUM_CPUS} -Wunused-but-set-variable $ARGS &>> $LOG + ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j${NUM_CPUS} $ARGS &>> $LOG CUR_RET=$? if [[ $RET = "" ]]; then -- cgit v1.2.3 From d9b6a4c9e9c75e8b64e0de57ddb4bbad5aa230b9 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 15 Nov 2012 21:06:22 -0800 Subject: compat: fix get-compat-kernels for libc issue again It turns out the right approach is to make clean and then to be sure (as in some kernels it fails if run only once) run twice make. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index fa09e6e2..ab9f4669 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -167,16 +167,15 @@ function rebuild_header_binary_deps() { for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do echo $kernel - for i in mod basic genksyms; do - make -C ${kernel}/build/ M=scripts/${i}/ clean > /dev/null 2>&1 - done - - for i in mod basic genksyms; do - make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 - done - - for i in mod basic genksyms; do - make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 + count=0 + while [[ $count -ne 3 ]]; do + for i in basic mod genksyms; do + if [[ $count -eq 0 ]]; then + make -C ${kernel}/build/ M=scripts/${i}/ clean > /dev/null 2>&1 + fi + make -C ${kernel}/build/ M=scripts/${i}/ > /dev/null 2>&1 + done + let count=$count+1 done done } -- cgit v1.2.3 From 2821ec16a9473a0cdbe25770324a7a657ad3e90d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 15 Nov 2012 21:26:09 -0800 Subject: compat: change count to 4 for glibc kernel fix I've tested this a number of times now and at least kernel 3.2.33-030233-generic requires the loop to run 4 times. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index ab9f4669..ff5f1bdb 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -168,7 +168,7 @@ function rebuild_header_binary_deps() { echo $kernel count=0 - while [[ $count -ne 3 ]]; do + while [[ $count -ne 4 ]]; do for i in basic mod genksyms; do if [[ $count -eq 0 ]]; then make -C ${kernel}/build/ M=scripts/${i}/ clean > /dev/null 2>&1 -- cgit v1.2.3 From 2306855ebe36516914ae56c74e9ae094471062c6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 6 Nov 2012 00:12:28 +0100 Subject: compat: add USB_SUBCLASS_VENDOR_SPEC Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.31.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 347ae26d..6e513ef9 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -249,6 +249,7 @@ static inline bool sk_has_allocations(const struct sock *sk) return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk); } +#define USB_SUBCLASS_VENDOR_SPEC 0xff #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */ -- cgit v1.2.3 From 866f95144fb3069a7ed32cb49dbae0b2e87443af Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Nov 2012 23:57:37 +0100 Subject: compat: make compat load without CONFIG_CPU_FREQ If the kernel was compiled without CONFIG_CPU_FREQ cpufreq_cpu_put() is not available, this is the case for some ARM kernels. In this case do not add the backport function compat_cpufreq_quick_get_max to compat.ko. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-3.1.c | 4 ++-- include/linux/compat-3.1.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index 03735f6d..354a8a3a 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -18,7 +18,7 @@ * * cpufreq: expose a cpufreq_quick_get_max routine */ - +#ifdef CONFIG_CPU_FREQ unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); @@ -32,7 +32,7 @@ unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) return ret_freq; } EXPORT_SYMBOL(compat_cpufreq_quick_get_max); - +#endif static DEFINE_SPINLOCK(compat_simple_ida_lock); diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index dfd87a35..fc052453 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -111,10 +111,12 @@ int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, void ida_simple_remove(struct ida *ida, unsigned int id); +#ifdef CONFIG_CPU_FREQ /* mask cpufreq_quick_get_max as RHEL6 backports this */ #define cpufreq_quick_get_max(a) compat_cpufreq_quick_get_max(a) unsigned int cpufreq_quick_get_max(unsigned int cpu); +#endif #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From 296a769e30752c469ca4f4dd88b80f1dd0731c57 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Nov 2012 23:57:38 +0100 Subject: compat: add eth_zero_addr() Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 2d7b6ddb..9e8d6750 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -89,6 +89,25 @@ static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos, #define PCI_EXP_LNKSTA2 50 /* Link Status 2 */ +/* This backports: + * + * commit 6d57e9078e880a3dd232d579f42ac437a8f1ef7b + * Author: Duan Jiong + * Date: Sat Sep 8 16:32:28 2012 +0000 + * + * etherdevice: introduce help function eth_zero_addr() + */ +/** + * eth_zero_addr - Assign zero address + * @addr: Pointer to a six-byte array containing the Ethernet address + * + * Assign the zero address to the given address array. + */ +static inline void eth_zero_addr(u8 *addr) +{ + memset(addr, 0x00, ETH_ALEN); +} + #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ #define netlink_notify_portid(__notify) (__notify->portid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) -- cgit v1.2.3 From 2fdcdb11c804b2176a5a743b4421b1b3d3709ec3 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Nov 2012 23:57:39 +0100 Subject: compat: add kref_get_unless_zero() Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.8.h | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 include/linux/compat-3.8.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index f26489c3..00a5edaa 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -66,5 +66,6 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* LINUX_26_COMPAT_H */ diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h new file mode 100644 index 00000000..e451c515 --- /dev/null +++ b/include/linux/compat-3.8.h @@ -0,0 +1,38 @@ +#ifndef LINUX_3_8_COMPAT_H +#define LINUX_3_8_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) + +/* This backports: + * + * commit 4b20db3de8dab005b07c74161cb041db8c5ff3a7 + * Author: Thomas Hellstrom + * Date: Tue Nov 6 11:31:49 2012 +0000 + * + * kref: Implement kref_get_unless_zero v3 + */ +/** + * kref_get_unless_zero - Increment refcount for object unless it is zero. + * @kref: object. + * + * Return non-zero if the increment succeeded. Otherwise return 0. + * + * This function is intended to simplify locking around refcounting for + * objects that can be looked up from a lookup structure, and which are + * removed from that lookup structure in the object destructor. + * Operations on such objects require at least a read lock around + * lookup + kref_get, and a write lock around kref_put + remove from lookup + * structure. Furthermore, RCU implementations become extremely tricky. + * With a lookup followed by a kref_get_unless_zero *with return value check* + * locking in the kref_put path can be deferred to the actual removal from + * the lookup structure and RCU lookups become trivial. + */ +static inline int __must_check kref_get_unless_zero(struct kref *kref) +{ + return atomic_add_unless(&kref->refcount, 1, 0); +} +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ + +#endif /* LINUX_3_8_COMPAT_H */ -- cgit v1.2.3 From 4292914d15181ad06aba9db77cc706c0374ada0a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 28 Nov 2012 23:57:40 +0100 Subject: compat: move config_enabled to compat-3.4.h config_enabled() was introduced in kernel version 3.4 and not in version 3.1. Now some driver uses this directly and this fails without this patch. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.1.h | 13 ------------- include/linux/compat-3.4.h | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index fc052453..3afca9a6 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -42,19 +42,6 @@ static inline struct sk_buff *__netdev_alloc_skb_ip_align(struct net_device *dev return skb; } -/* - * Getting something that works in C and CPP for an arg that may or may - * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1" - * we match on the placeholder define, insert the "0," for arg1 and generate - * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one). - * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when - * the last step cherry picks the 2nd arg, we get a zero. - */ -#define __ARG_PLACEHOLDER_1 0, -#define config_enabled(cfg) _config_enabled(cfg) -#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) -#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) -#define ___config_enabled(__ignored, val, ...) val #define genl_dump_check_consistent(cb, user_hdr, family) /* diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 887293da..fbd92a2a 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -123,6 +123,20 @@ static inline void eth_hw_addr_random(struct net_device *dev) module_driver(__pci_driver, pci_register_driver, \ pci_unregister_driver) +/* + * Getting something that works in C and CPP for an arg that may or may + * not be defined is tricky. Here, if we have "#define CONFIG_BOOGER 1" + * we match on the placeholder define, insert the "0," for arg1 and generate + * the triplet (0, 1, 0). Then the last step cherry picks the 2nd arg (a one). + * When CONFIG_BOOGER is not defined, we generate a (... 1, 0) pair, and when + * the last step cherry picks the 2nd arg, we get a zero. + */ +#define __ARG_PLACEHOLDER_1 0, +#define config_enabled(cfg) _config_enabled(cfg) +#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value) +#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0) +#define ___config_enabled(__ignored, val, ...) val + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)) */ #endif /* LINUX_5_4_COMPAT_H */ -- cgit v1.2.3 From 721497a9d3c2b621e6a5a983325544aff27e54a8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 29 Nov 2012 14:45:54 -0800 Subject: compat: add gpio header for kernels older than 2.6.24 Just include_next for newer kernels and for older kernels do not do anything. Signed-off-by: Luis R. Rodriguez --- include/linux/gpio.h | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 include/linux/gpio.h diff --git a/include/linux/gpio.h b/include/linux/gpio.h new file mode 100644 index 00000000..d31e14ee --- /dev/null +++ b/include/linux/gpio.h @@ -0,0 +1,10 @@ +#ifndef _COMPAT_LINUX_GPIO_H +#define _COMPAT_LINUX_GPIO_H 1 + +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) +#include_next +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */ + +#endif /* _COMPAT_LINUX_GPIO_H */ -- cgit v1.2.3 From b27ce1c3f64db4e287ccefb51adcd61c98ebfb6b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Nov 2012 17:10:35 -0800 Subject: compat: backport ethtool_rxfh_indir_default() This was added via commit 278bc429: mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 278bc429 v3.3-rc1~182^2~191 commit 278bc4296bd64ffd1d3913b487dc8a520e423a7a Author: Ben Hutchings Date: Thu Dec 15 13:56:49 2011 +0000 ethtool: Define and apply a default policy for RX flow hash indirection All drivers that support modification of the RX flow hash indirection table initialise it in the same way: RX rings are assigned to table entries in rotation. Make that default policy explicit by having them call a ethtool_rxfh_indir_default() function. In the ethtool core, add support for a zero size value for ETHTOOL_SRXFHINDIR, which resets the table to this default. Partly-suggested-by: Matt Carlson Signed-off-by: Ben Hutchings Acked-by: Shreyas N Bhatewara Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 3cbbaceb..9bf97dec 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -12,6 +12,18 @@ #include #include +/** + * ethtool_rxfh_indir_default - get default value for RX flow hash indirection + * @index: Index in RX flow hash indirection table + * @n_rx_rings: Number of RX rings to use + * + * This function provides the default policy for RX flow hash indirection. + */ +static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) +{ + return index % n_rx_rings; +} + #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) /* mask qdisc_cb_private_validate as RHEL6 backports this */ -- cgit v1.2.3 From 91b7fa31f9c2011e7e14c33f0baa4c8194abf786 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 30 Nov 2012 17:18:50 -0800 Subject: compat: backport ethtool to mii advertisment conversion helpers Commit 28011cf1 added ethtool to mii advertisment conversion helpers. We backport these here. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 28011cf1 v3.3-rc1~182^2~564 commit 28011cf19b75df9d3f35489a7599a97ec0b3f1a0 Author: Matt Carlson Date: Wed Nov 16 18:36:59 2011 -0500 net: Add ethtool to mii advertisment conversion helpers Translating between ethtool advertisement settings and MII advertisements are common operations for ethernet drivers. This patch adds a set of helper functions that implements the conversion. The patch then modifies a couple of the drivers to use the new functions. Signed-off-by: Matt Carlson Signed-off-by: Michael Chan Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 200 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 9bf97dec..93a1af25 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -11,6 +11,206 @@ #include #include #include +#include + +/** + * ethtool_adv_to_mii_adv_t + * @ethadv: the ethtool advertisement settings + * + * A small helper function that translates ethtool advertisement + * settings to phy autonegotiation advertisements for the + * MII_ADVERTISE register. + */ +static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv) +{ + u32 result = 0; + + if (ethadv & ADVERTISED_10baseT_Half) + result |= ADVERTISE_10HALF; + if (ethadv & ADVERTISED_10baseT_Full) + result |= ADVERTISE_10FULL; + if (ethadv & ADVERTISED_100baseT_Half) + result |= ADVERTISE_100HALF; + if (ethadv & ADVERTISED_100baseT_Full) + result |= ADVERTISE_100FULL; + if (ethadv & ADVERTISED_Pause) + result |= ADVERTISE_PAUSE_CAP; + if (ethadv & ADVERTISED_Asym_Pause) + result |= ADVERTISE_PAUSE_ASYM; + + return result; +} + +/** + * mii_adv_to_ethtool_adv_t + * @adv: value of the MII_ADVERTISE register + * + * A small helper function that translates MII_ADVERTISE bits + * to ethtool advertisement settings. + */ +static inline u32 mii_adv_to_ethtool_adv_t(u32 adv) +{ + u32 result = 0; + + if (adv & ADVERTISE_10HALF) + result |= ADVERTISED_10baseT_Half; + if (adv & ADVERTISE_10FULL) + result |= ADVERTISED_10baseT_Full; + if (adv & ADVERTISE_100HALF) + result |= ADVERTISED_100baseT_Half; + if (adv & ADVERTISE_100FULL) + result |= ADVERTISED_100baseT_Full; + if (adv & ADVERTISE_PAUSE_CAP) + result |= ADVERTISED_Pause; + if (adv & ADVERTISE_PAUSE_ASYM) + result |= ADVERTISED_Asym_Pause; + + return result; +} + +/** + * ethtool_adv_to_mii_ctrl1000_t + * @ethadv: the ethtool advertisement settings + * + * A small helper function that translates ethtool advertisement + * settings to phy autonegotiation advertisements for the + * MII_CTRL1000 register when in 1000T mode. + */ +static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv) +{ + u32 result = 0; + + if (ethadv & ADVERTISED_1000baseT_Half) + result |= ADVERTISE_1000HALF; + if (ethadv & ADVERTISED_1000baseT_Full) + result |= ADVERTISE_1000FULL; + + return result; +} + +/** + * mii_ctrl1000_to_ethtool_adv_t + * @adv: value of the MII_CTRL1000 register + * + * A small helper function that translates MII_CTRL1000 + * bits, when in 1000Base-T mode, to ethtool + * advertisement settings. + */ +static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv) +{ + u32 result = 0; + + if (adv & ADVERTISE_1000HALF) + result |= ADVERTISED_1000baseT_Half; + if (adv & ADVERTISE_1000FULL) + result |= ADVERTISED_1000baseT_Full; + + return result; +} + +/** + * mii_lpa_to_ethtool_lpa_t + * @adv: value of the MII_LPA register + * + * A small helper function that translates MII_LPA + * bits, when in 1000Base-T mode, to ethtool + * LP advertisement settings. + */ +static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa) +{ + u32 result = 0; + + if (lpa & LPA_LPACK) + result |= ADVERTISED_Autoneg; + + return result | mii_adv_to_ethtool_adv_t(lpa); +} + +/** + * mii_stat1000_to_ethtool_lpa_t + * @adv: value of the MII_STAT1000 register + * + * A small helper function that translates MII_STAT1000 + * bits, when in 1000Base-T mode, to ethtool + * advertisement settings. + */ +static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa) +{ + u32 result = 0; + + if (lpa & LPA_1000HALF) + result |= ADVERTISED_1000baseT_Half; + if (lpa & LPA_1000FULL) + result |= ADVERTISED_1000baseT_Full; + + return result; +} + +/** + * ethtool_adv_to_mii_adv_x + * @ethadv: the ethtool advertisement settings + * + * A small helper function that translates ethtool advertisement + * settings to phy autonegotiation advertisements for the + * MII_CTRL1000 register when in 1000Base-X mode. + */ +static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv) +{ + u32 result = 0; + + if (ethadv & ADVERTISED_1000baseT_Half) + result |= ADVERTISE_1000XHALF; + if (ethadv & ADVERTISED_1000baseT_Full) + result |= ADVERTISE_1000XFULL; + if (ethadv & ADVERTISED_Pause) + result |= ADVERTISE_1000XPAUSE; + if (ethadv & ADVERTISED_Asym_Pause) + result |= ADVERTISE_1000XPSE_ASYM; + + return result; +} + +/** + * mii_adv_to_ethtool_adv_x + * @adv: value of the MII_CTRL1000 register + * + * A small helper function that translates MII_CTRL1000 + * bits, when in 1000Base-X mode, to ethtool + * advertisement settings. + */ +static inline u32 mii_adv_to_ethtool_adv_x(u32 adv) +{ + u32 result = 0; + + if (adv & ADVERTISE_1000XHALF) + result |= ADVERTISED_1000baseT_Half; + if (adv & ADVERTISE_1000XFULL) + result |= ADVERTISED_1000baseT_Full; + if (adv & ADVERTISE_1000XPAUSE) + result |= ADVERTISED_Pause; + if (adv & ADVERTISE_1000XPSE_ASYM) + result |= ADVERTISED_Asym_Pause; + + return result; +} + +/** + * mii_lpa_to_ethtool_lpa_x + * @adv: value of the MII_LPA register + * + * A small helper function that translates MII_LPA + * bits, when in 1000Base-X mode, to ethtool + * LP advertisement settings. + */ +static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa) +{ + u32 result = 0; + + if (lpa & LPA_LPACK) + result |= ADVERTISED_Autoneg; + + return result | mii_adv_to_ethtool_adv_x(lpa); +} /** * ethtool_rxfh_indir_default - get default value for RX flow hash indirection -- cgit v1.2.3 From 9ccdeba32ee02965020a6b00271a523a3ad1a41d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 1 Dec 2012 09:58:24 -0800 Subject: compat: backport BQL helpers This backports the addition of Byte Queue Limit functional helpers. BQL was added as of v3.3 but some Linux distributions have backported BQL to their v3.2 kernels or older. To address this we assume that they also enabled CONFIG_BQL and test for that and simply avoid adding the BWL work if CONFIG_BQL is defined. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains c5d67bd7 v3.3-rc1~182^2~426 commit c5d67bd78c5dc540e3461c36fb3d389fbe0de4c3 Author: Tom Herbert Date: Mon Nov 28 16:32:52 2011 +0000 net: Add netdev interfaces for recording sends/comp Add interfaces for drivers to call for recording number of packets and bytes at send time and transmit completion. Also, added a function to "reset" a queue. These will be used by Byte Queue Limits. Signed-off-by: Tom Herbert Acked-by: Eric Dumazet Signed-off-by: David S. Miller mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 2m2.691s user 8m34.724s sys 2m7.708s Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 93a1af25..a8a1d7e8 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -12,6 +12,43 @@ #include #include #include +#include + +/* + * BQL was added as of v3.3 but some Linux distributions + * have backported BQL to their v3.2 kernels or older. To + * address this we assume that they also enabled CONFIG_BQL + * and test for that here and simply avoid adding the static + * inlines if it was defined + */ +#ifndef CONFIG_BQL +static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue, + unsigned int bytes) +{ +} + +static inline void netdev_sent_queue(struct net_device *dev, unsigned int bytes) +{ +} + +static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue, + unsigned pkts, unsigned bytes) +{ +} + +static inline void netdev_completed_queue(struct net_device *dev, + unsigned pkts, unsigned bytes) +{ +} + +static inline void netdev_tx_reset_queue(struct netdev_queue *q) +{ +} + +static inline void netdev_reset_queue(struct net_device *dev_queue) +{ +} +#endif /* CONFIG_BQL */ /** * ethtool_adv_to_mii_adv_t -- cgit v1.2.3 From a95c15688ff3e7faa56b00fa38e8952196891e19 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 1 Dec 2012 10:33:41 -0800 Subject: compat: define NETIF_F_RXCSUM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can't really backport this so just define it. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains e83d360d v2.6.39-rc1~468^2~336 commit e83d360d9a7e5d71d55c13e96b19109a2ea23bf0 Author: Michał Mirosław Date: Tue Feb 15 16:59:18 2011 +0000 net: introduce NETIF_F_RXCSUM Introduce NETIF_F_RXCSUM to replace device-private flags for RX checksum offload. Integrate it with ndo_fix_features. ethtool_op_get_rx_csum() is removed altogether as nothing in-tree uses it. Signed-off-by: Michał Mirosław Signed-off-by: David S. Miller mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m59.783s user 8m11.111s sys 1m56.675s Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.39.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 7ec34fd9..4909c460 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -9,6 +9,8 @@ #include #include +#define NETIF_F_RXCSUM + #define tiocmget(tty) tiocmget(tty, NULL) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) -- cgit v1.2.3 From f54c031909079057832aa824b20faadab42b792c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 1 Dec 2012 10:50:33 -0800 Subject: compat: fix addition of NETIF_F_RXCSUM This needs to be defined to something and although ckmake passed, no code was using it so we were unable to test it at compile time really. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.39.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 4909c460..e02ac9b6 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -9,7 +9,7 @@ #include #include -#define NETIF_F_RXCSUM +#define NETIF_F_RXCSUM 0 #define tiocmget(tty) tiocmget(tty, NULL) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) -- cgit v1.2.3 From 71273f810fe2698015a3dcb0e6323aeed4bc3e9d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Sat, 1 Dec 2012 11:22:09 -0800 Subject: compat: backport PCI MSI-X entry definitions The PCI MSI-X entries were moved to uapi headers on v2.6.38 to allow drivers to use it. Older kernels will need this. mcgrof@frijol ~/linux-stable (git::linux-3.2.y)$ git describe --contains 00aaaef9 v2.6.38-rc1~55^2~15 commit 00aaaef9a51a1a25c5d6d52ce510772f149a0eb0 Author: Sheng Yang Date: Thu Nov 11 15:46:54 2010 +0800 PCI: MSI: Move MSI-X entry definition to pci_regs.h Then it can be used by others. Reviewed-by: Hidetoshi Seto Reviewed-by: Matthew Wilcox Signed-off-by: Sheng Yang Signed-off-by: Jesse Barnes Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.38.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 1d725231..676d5540 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -10,6 +10,13 @@ #include #include +/* MSI-X entry's format */ +#define PCI_MSIX_ENTRY_SIZE 16 +#define PCI_MSIX_ENTRY_LOWER_ADDR 0 +#define PCI_MSIX_ENTRY_UPPER_ADDR 4 +#define PCI_MSIX_ENTRY_DATA 8 +#define PCI_MSIX_ENTRY_VECTOR_CTRL 12 + #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30)) static inline void bstats_update(struct gnet_stats_basic_packed *bstats, const struct sk_buff *skb) -- cgit v1.2.3 From 2786ec9e2ec5d5ee6c6e6ce23feb82228fbc1568 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 11:38:20 -0800 Subject: compat: backport alloc_etherdev_mqs() This backports support for alloc_netdev_mqs(). The routine adds support for specifying different TX queues and RX queues. In older kernels we were only able to request the equal amount of queues for both TX and RX. To backport this simply ignore the RX queue count. The commit that added alloc_netdev_mq() with equal amount of TX and RX queues was added via f25f4e44 onto kernel v2.6.23. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 36909ea4 v2.6.38-rc1~50^2~46 mcgrof@frijol ~/linux-next (git::master)$ git describe --contains f25f4e44 v2.6.23-rc1~1109^2~115 commit 36909ea43814cba34f7c921e99cba33d770a54e1 Author: Tom Herbert Date: Sun Jan 9 19:36:31 2011 +0000 net: Add alloc_netdev_mqs function Added alloc_netdev_mqs function which allows the number of transmit and receive queues to be specified independenty. alloc_netdev_mq was changed to a macro to call the new function. Also added alloc_etherdev_mqs with same purpose. Signed-off-by: Tom Herbert Signed-off-by: David S. Miller commit f25f4e44808f0f6c9875d94ef1c41ef86c288eb2 Author: Peter P Waskiewicz Jr Date: Fri Jul 6 13:36:20 2007 -0700 [CORE] Stack changes to add multiqueue hardware support API Add the multiqueue hardware device support API to the core network stack. Allow drivers to allocate multiple queues and manage them at the netdev level if they choose to do so. Added a new field to sk_buff, namely queue_mapping, for drivers to know which tx_ring to select based on OS classification of the flow. Signed-off-by: Peter P Waskiewicz Jr Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.38.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 676d5540..b397c74d 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -10,6 +10,8 @@ #include #include +#define alloc_etherdev_mqs(sizeof_priv, tx_q, rx_q) alloc_etherdev_mq(sizeof_priv, tx_q) + /* MSI-X entry's format */ #define PCI_MSIX_ENTRY_SIZE 16 #define PCI_MSIX_ENTRY_LOWER_ADDR 0 -- cgit v1.2.3 From 7ace4e4795b51dd7fb60a749fe767a8187a0f86d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 11:50:49 -0800 Subject: compat: backport definition of PCI_MSIX_ENTRY_CTRL_MASKBIT This backports the addition of PCI_MSIX_ENTRY_CTRL_MASKBIT. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 8d805286968811223cca002134ba3d81244d5313 v2.6.38-rc1~55^2~14 commit 8d805286968811223cca002134ba3d81244d5313 Author: Sheng Yang Date: Thu Nov 11 15:46:55 2010 +0800 PCI: Add mask bit definition for MSI-X table Then we can use it instead of magic number 1. Reviewed-by: Hidetoshi Seto Cc: Matthew Wilcox Signed-off-by: Sheng Yang Signed-off-by: Jesse Barnes Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.38.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index b397c74d..0aa5d9b7 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -10,6 +10,8 @@ #include #include +#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1 + #define alloc_etherdev_mqs(sizeof_priv, tx_q, rx_q) alloc_etherdev_mq(sizeof_priv, tx_q) /* MSI-X entry's format */ -- cgit v1.2.3 From abad6211abfe5325beb34167e1700f361098483c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 13:23:12 -0800 Subject: compat: backport PTR_RET() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcgrof@frijol ~/linux-next (git::master)$ git describe --contains fa9ee9c4 v2.6.39-rc1~267 commit fa9ee9c4b9885dfdf8eccac19b8b4fc8a7c53288 Author: Uwe Kleine-Kƶnig Date: Tue Mar 22 16:34:05 2011 -0700 include/linux/err.h: add a function to cast error-pointers to a return value PTR_RET() can be used if you have an error-pointer and are only interested in the eventual error value, but not the pointer. Yields the usual 0 for no error, -ESOMETHING otherwise. Signed-off-by: Uwe Kleine-Kƶnig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.39.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index e02ac9b6..8ff08ba3 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -8,6 +8,15 @@ #include #include #include +#include + +static inline int __must_check PTR_RET(const void *ptr) +{ + if (IS_ERR(ptr)) + return PTR_ERR(ptr); + else + return 0; +} #define NETIF_F_RXCSUM 0 -- cgit v1.2.3 From 7060437bc1f81856b91248d7decd32e87dcd2550 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 15:40:21 -0800 Subject: compat: backport netif_set_real_num_tx_queues() This was added as of v2.6.35. We implement a slightly modified version given that this was later changed to return int through commit e6484930. The changes on e6484930 however were added due to some internal changes on core networking, we'll leave in place a simpler implementation for older kernels. Note that for older kernels than 2.6.27 we use the netdev egress_subqueue_count to set the TX queue count. Commit fd2ea0a7 added real_num_tx_queues to the netdevice when Multiqueue was added. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains f0796d5c73e59786d09a1e617689d1d415f2db44 v2.6.35-rc5~14^2~14 mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 3171d026 v2.6.37-rc1~147^2~339 mcgrof@frijol ~/linux-next (git::master)$ git describe --contains fd2ea0a7 v2.6.27-rc1~964^2~78 commit f0796d5c73e59786d09a1e617689d1d415f2db44 Author: John Fastabend Date: Thu Jul 1 13:21:57 2010 +0000 net: decreasing real_num_tx_queues needs to flush qdisc Reducing real_num_queues needs to flush the qdisc otherwise skbs with queue_mappings greater then real_num_tx_queues can be sent to the underlying driver. The flow for this is, dev_queue_xmit() dev_pick_tx() skb_tx_hash() => hash using real_num_tx_queues skb_set_queue_mapping() ... qdisc_enqueue_root() => enqueue skb on txq from hash ... dev->real_num_tx_queues -= n ... sch_direct_xmit() dev_hard_start_xmit() ndo_start_xmit(skb,dev) => skb queue set with old hash skbs are enqueued on the qdisc with skb->queue_mapping set 0 < queue_mappings < real_num_tx_queues. When the driver decreases real_num_tx_queues skb's may be dequeued from the qdisc with a queue_mapping greater then real_num_tx_queues. This fixes a case in ixgbe where this was occurring with DCB and FCoE. Because the driver is using queue_mapping to map skbs to tx descriptor rings we can potentially map skbs to rings that no longer exist. Signed-off-by: John Fastabend Tested-by: Ross Brattain Signed-off-by: Jeff Kirsher Signed-off-by: David S. Miller commit e6484930d7c73d324bccda7d43d131088da697b9 Author: Tom Herbert Date: Mon Oct 18 18:04:39 2010 +0000 net: allocate tx queues in register_netdevice This patch introduces netif_alloc_netdev_queues which is called from register_device instead of alloc_netdev_mq. This makes TX queue allocation symmetric with RX allocation. Also, queue locks allocation is done in netdev_init_one_queue. Change set_real_num_tx_queues to fail if requested number < 1 or greater than number of allocated queues. Signed-off-by: Tom Herbert Acked-by: Eric Dumazet Signed-off-by: David S. Miller commit fd2ea0a79faad824258af5dcec1927aa24d81c16 Author: David S. Miller Date: Thu Jul 17 01:56:23 2008 -0700 net: Use queue aware tests throughout. This effectively "flips the switch" by making the core networking and multiqueue-aware drivers use the new TX multiqueue structures. Non-multiqueue drivers need no changes. The interfaces they use such as netif_stop_queue() degenerate into an operation on TX queue zero. So everything "just works" for them. Code that really wants to do "X" to all TX queues now invokes a routine that does so, such as netif_tx_wake_all_queues(), netif_tx_stop_all_queues(), etc. pktgen and netpoll required a little bit more surgery than the others. In particular the pktgen changes, whilst functional, could be largely improved. The initial check in pktgen_xmit() will sometimes check the wrong queue, which is mostly harmless. The thing to do is probably to invoke fill_packet() earlier. The bulk of the netpoll changes is to make the code operate solely on the TX queue indicated by by the SKB queue mapping. Setting of the SKB queue mapping is entirely confined inside of net/core/dev.c:dev_pick_tx(). If we end up needing any kind of special semantics (drops, for example) it will be implemented here. Finally, we now have a "real_num_tx_queues" which is where the driver indicates how many TX queues are actually active. With IGB changes from Jeff Kirsher. Signed-off-by: David S. Miller mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m51.110s user 4m58.571s sys 1m39.282s Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 28 ++++++++++++++++++++++++++++ include/linux/compat-2.6.35.h | 26 ++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 24551722..c2c54bb8 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -1,5 +1,6 @@ /* * Copyright 2010 Kshitij Kulshreshtha + * Copyright 2012 Luis R. Rodriguez * * 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 @@ -11,6 +12,33 @@ #include #include +/* + * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues + * greater then real_num_tx_queues stale skbs on the qdisc must be flushed. + */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) +int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) +{ + unsigned int real_num = dev->real_num_tx_queues; + + if (unlikely(txq > dev->num_tx_queues)) + return -EINVAL; + else if (txq > real_num) + dev->real_num_tx_queues = txq; + else if (txq < real_num) { + dev->real_num_tx_queues = txq; + qdisc_reset_all_tx_gt(dev, txq); + } +} +#else +int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) +{ + dev->egress_subqueue_count = txq; + /* XXX: consider qdisc reset for older kernels */ +} +#endif +EXPORT_SYMBOL_GPL(netif_set_real_num_tx_queues); + /** * hex_to_bin - convert a hex digit to its real value * @ch: ascii character represents hex digit diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index d184f00e..22981a94 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include /* added on linux/kernel.h */ #define USHRT_MAX ((u16)(~0U)) @@ -19,6 +21,30 @@ #define netdev_hw_addr dev_mc_list +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) +/* Reset all TX qdiscs greater then index of a device. */ +static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) +{ + struct Qdisc *qdisc; + + for (; i < dev->num_tx_queues; i++) { + qdisc = netdev_get_tx_queue(dev, i)->qdisc; + if (qdisc) { + spin_lock_bh(qdisc_lock(qdisc)); + qdisc_reset(qdisc); + spin_unlock_bh(qdisc_lock(qdisc)); + } + } +} +#else +static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) +{ +} +#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ + +extern int netif_set_real_num_tx_queues(struct net_device *dev, + unsigned int txq); + /* mask irq_set_affinity_hint as RHEL6 backports this */ #define irq_set_affinity_hint(a,b) compat_irq_set_affinity_hint(a,b) /* -- cgit v1.2.3 From 398882cbddd79534b8068a94f279caf115583de7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 3 Dec 2012 17:36:15 -0800 Subject: compat: backport netif_set_real_num_rx_queues() netif_set_real_num_rx_queues() was added on v2.6.37 but requires CONFIG_RPS support which was added on v2.6.35. A few updates were done on the net core though to support changing the number of RX queues if the device was already registered. We can't support this on older kernels though so the best we can do is for kernels >= 2.6.35 simply try to update the num_rx_queues and if the device is registered fail. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 62fe0b40 v2.6.37-rc1~147^2~340 commit 62fe0b40abb3484413800edaef9b087a20059acf Author: Ben Hutchings Date: Mon Sep 27 08:24:33 2010 +0000 net: Allow changing number of RX queues after device allocation For RPS, we create a kobject for each RX queue based on the number of queues passed to alloc_netdev_mq(). However, drivers generally do not determine the numbers of hardware queues to use until much later, so this usually represents the maximum number the driver may use and not the actual number in use. For TX queues, drivers can update the actual number using netif_set_real_num_tx_queues(). Add a corresponding function for RX queues, netif_set_real_num_rx_queues(). Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 2m5.270s user 8m51.501s sys 2m1.576s Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 13 +++++++++++++ include/linux/compat-2.6.37.h | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index c2c54bb8..d33db464 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -12,6 +12,19 @@ #include #include +#ifdef CONFIG_RPS +int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) +{ + int rc; + + /* we can't update the sysfs object for older kernels */ + if (dev->reg_state == NETREG_REGISTERED) + return -EINVAL; + dev->num_rx_queues = rxq; + return 0; +} +#endif + /* * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues * greater then real_num_tx_queues stale skbs on the qdisc must be flushed. diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index 7e14853b..d1e7db95 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -9,6 +9,18 @@ #include #include #include +#include + +#ifdef CONFIG_RPS +extern int netif_set_real_num_rx_queues(struct net_device *dev, + unsigned int rxq); +#else +static inline int netif_set_real_num_rx_queues(struct net_device *dev, + unsigned int rxq) +{ + return 0; +} +#endif static inline int proto_ports_offset(int proto) { -- cgit v1.2.3 From 291c8560741b4fe0a9af81234316cd953cab2af6 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 Dec 2012 21:12:46 +0000 Subject: compat: rename MDIO exported symbols compat-drivers now has support for carrying over the MDIO module. To help it avoid clashes with already in place drivers that rely on the older MDIO module we rename the exported symbols of the shinier module with a compat_ prefix. An alternative to this strategy is to have compat-drivers work under a separate namespace but we have yet to receive patches for that, although we hear someone did it. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.31.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index 6e513ef9..cfa34dfa 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -51,6 +51,30 @@ #endif #endif +/* + * These changes allow us to backport and forward port + * the driver/net/mdio module. What we do is simply + * rename the exported symbols to other symbols and + * rely on the fact that compat-drivers will take care + * of renaming that module. This allows in-place drivers + * to use the old module and have the newer supplied + * drivers through compat-drivers to use the new bacported + * module. + * + * XXX: maybe we should have a COMPAT_EXPORT_SYMBOL() that + * takes care of renaming the symbols with a compat_ prefix? + * There are other ideas of using a separate namespace for + * modules supplied by compat -- someone already did the work + * but never sent the patches ;) who are you out there ? + */ +#define mdio45_probe compat_mdio45_probe +#define mdio_set_flag compat_mdio_set_flag +#define mdio45_links_ok compat_mdio45_links_ok +#define mdio45_nway_restart compat_mdio45_nway_restart +#define mdio45_ethtool_gset_npage compat_mdio45_ethtool_gset_npage +#define mdio45_ethtool_spauseparam_an compat_mdio45_ethtool_spauseparam_an +#define mdio_mii_ioctl compat_mdio_mii_ioctl + #ifndef NETDEV_PRE_UP #define NETDEV_PRE_UP 0x000D #endif -- cgit v1.2.3 From 7fda12b5fd257467346a9120a4e1a4aa9310e123 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 Dec 2012 21:46:45 +0000 Subject: compat: backplane mode negotiation ethtool definitions This backports the ethtool definitions implemented on commit 894b19a6. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 894b19a6 v2.6.31-rc1~14^2~577 commit 894b19a6b343ce3589237167a56e6df0fe72ef0d Author: Ben Hutchings Date: Wed Apr 29 08:25:57 2009 +0000 ethtool/mdio: Support backplane mode negotiation Compile-tested only. Signed-off-by: Ben Hutchings Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.31.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index cfa34dfa..ce90f0a6 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -13,6 +13,18 @@ #include #include +#define SUPPORTED_Backplane (1 << 16) +#define SUPPORTED_1000baseKX_Full (1 << 17) +#define SUPPORTED_10000baseKX4_Full (1 << 18) +#define SUPPORTED_10000baseKR_Full (1 << 19) +#define SUPPORTED_10000baseR_FEC (1 << 20) + +#define ADVERTISED_Backplane (1 << 16) +#define ADVERTISED_1000baseKX_Full (1 << 17) +#define ADVERTISED_10000baseKX4_Full (1 << 18) +#define ADVERTISED_10000baseKR_Full (1 << 19) +#define ADVERTISED_10000baseR_FEC (1 << 20) + /* * These macros allow us to backport rfkill without any * changes on cfg80211 through compat.diff. Note that this -- cgit v1.2.3 From 94feb7e181a89d822c7ed265cf6004a65ba42595 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 4 Dec 2012 16:32:46 -0800 Subject: compat: backport napi_gro_receive() Just call netif_receive_skb() for kernels older than v2.6.29. If Enterprise Linux distributions decided to backport GRO support onto a kernel older than 2.6.29, they'll likely want #ifdef this out accordingly. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains d565b0a1 v2.6.29-rc1~581^2~181 commit d565b0a1a9b6ee7dff46e1f68b26b526ac11ae50 Author: Herbert Xu Date: Mon Dec 15 23:38:52 2008 -0800 net: Add Generic Receive Offload infrastructure This patch adds the top-level GRO (Generic Receive Offload) infrastructure. This is pretty similar to LRO except that this is protocol-independent. Instead of holding packets in an lro_mgr structure, they're now held in napi_struct. For drivers that intend to use this, they can set the NETIF_F_GRO bit and call napi_gro_receive instead of netif_receive_skb or just call netif_rx. The latter will call napi_receive_skb automatically. When napi_gro_receive is used, the driver must either call napi_complete/napi_rx_complete, or call napi_gro_flush in softirq context if the driver uses the primitives __napi_complete/__napi_rx_complete. Protocols will set the gro_receive and gro_complete function pointers in order to participate in this scheme. In addition to the packet, gro_receive will get a list of currently held packets. Each packet in the list has a same_flow field which is non-zero if it is a potential match for the new packet. For each packet that may match, they also have a flush field which is non-zero if the held packet must not be merged with the new packet. Once gro_receive has determined that the new skb matches a held packet, the held packet may be processed immediately if the new skb cannot be merged with it. In this case gro_receive should return the pointer to the existing skb in gro_list. Otherwise the new skb should be merged into the existing packet and NULL should be returned, unless the new skb makes it impossible for any further merges to be made (e.g., FIN packet) where the merged skb should be returned. Whenever the skb is merged into an existing entry, the gro_receive function should set NAPI_GRO_CB(skb)->same_flow. Note that if an skb merely matches an existing entry but can't be merged with it, then this shouldn't be set. If gro_receive finds it pointless to hold the new skb for future merging, it should set NAPI_GRO_CB(skb)->flush. Held packets will be flushed by napi_gro_flush which is called by napi_complete and napi_rx_complete. Currently held packets are stored in a singly liked list just like LRO. The list is limited to a maximum of 8 entries. In future, this may be expanded to use a hash table to allow more flows to be held for merging. Signed-off-by: Herbert Xu Signed-off-by: David S. Miller Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index d95b00e1..9ebc5d5d 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -19,6 +19,8 @@ #include #include +#define napi_gro_receive(napi, skb) netif_receive_skb(skb) + /* backports */ static inline void usb_autopm_put_interface_async(struct usb_interface *intf) { } -- cgit v1.2.3 From 3a85112cbc780562f34fff5b97e6ce5f75b5cd45 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 6 Dec 2012 17:05:16 -0800 Subject: compat: backport unsigned netlink attribute accessors These were added upstream in commit 4778e0be16c291ba6d9d55eeff3a6764fc84a071. Signed-off-by: Johannes Berg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 85 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 9e8d6750..bac76a3a 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -13,6 +13,7 @@ #include #include #include +#include #define VM_DONTDUMP VM_NODUMP @@ -108,6 +109,90 @@ static inline void eth_zero_addr(u8 *addr) memset(addr, 0x00, ETH_ALEN); } +/** + * nla_put_s8 - Add a s8 netlink attribute to a socket buffer + * @skb: socket buffer to add attribute to + * @attrtype: attribute type + * @value: numeric value + */ +static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) +{ + return nla_put(skb, attrtype, sizeof(s8), &value); +} + +/** + * nla_put_s16 - Add a s16 netlink attribute to a socket buffer + * @skb: socket buffer to add attribute to + * @attrtype: attribute type + * @value: numeric value + */ +static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) +{ + return nla_put(skb, attrtype, sizeof(s16), &value); +} + +/** + * nla_put_s32 - Add a s32 netlink attribute to a socket buffer + * @skb: socket buffer to add attribute to + * @attrtype: attribute type + * @value: numeric value + */ +static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) +{ + return nla_put(skb, attrtype, sizeof(s32), &value); +} + +/** + * nla_put_s64 - Add a s64 netlink attribute to a socket buffer + * @skb: socket buffer to add attribute to + * @attrtype: attribute type + * @value: numeric value + */ +static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value) +{ + return nla_put(skb, attrtype, sizeof(s64), &value); +} + +/** + * nla_get_s32 - return payload of s32 attribute + * @nla: s32 netlink attribute + */ +static inline s32 nla_get_s32(const struct nlattr *nla) +{ + return *(s32 *) nla_data(nla); +} + +/** + * nla_get_s16 - return payload of s16 attribute + * @nla: s16 netlink attribute + */ +static inline s16 nla_get_s16(const struct nlattr *nla) +{ + return *(s16 *) nla_data(nla); +} + +/** + * nla_get_s8 - return payload of s8 attribute + * @nla: s8 netlink attribute + */ +static inline s8 nla_get_s8(const struct nlattr *nla) +{ + return *(s8 *) nla_data(nla); +} + +/** + * nla_get_s64 - return payload of s64 attribute + * @nla: s64 netlink attribute + */ +static inline s64 nla_get_s64(const struct nlattr *nla) +{ + s64 tmp; + + nla_memcpy(&tmp, nla, sizeof(tmp)); + + return tmp; +} + #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ #define netlink_notify_portid(__notify) (__notify->portid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) -- cgit v1.2.3 From fe3b56a35301a2612910c7365ecf7f63f9865758 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Dec 2012 18:05:49 -0800 Subject: compat: generate CONFIG_COMPAT_KERNEL_3_8 Signed-off-by: Luis R. Rodriguez --- scripts/gen-compat-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 810c51b4..00511c51 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -17,7 +17,7 @@ fi KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') # 3.0 kernel stuff -COMPAT_LATEST_VERSION="7" +COMPAT_LATEST_VERSION="8" KERNEL_SUBLEVEL="-1" # Note that this script will export all variables explicitly, -- cgit v1.2.3 From ab02b3223c209b3137855749e297fc7768599ad3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Dec 2012 18:09:10 -0800 Subject: compat: backport hid_ignore() We backport hid_ignore() as of next-20121211, that is now used by other drivers. mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 2m9.630s user 8m55.525s sys 2m2.460s Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 2 + compat/compat-3.8.c | 341 ++++++++++++++++++ compat/hid-ids.h | 866 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.8.h | 7 + 4 files changed, 1216 insertions(+) create mode 100644 compat/compat-3.8.c create mode 100644 compat/hid-ids.h diff --git a/compat/Makefile b/compat/Makefile index e9c6e1f2..3b9bfdeb 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -1,3 +1,4 @@ +ccflags-y += -I$(src) obj-m += compat.o #compat-objs := @@ -49,6 +50,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_5) += \ compat-3.5.o \ user_namespace.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o +compat-$(CONFIG_COMPAT_KERNEL_3_8) += compat-3.8.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c new file mode 100644 index 00000000..c7df1743 --- /dev/null +++ b/compat/compat-3.8.c @@ -0,0 +1,341 @@ +/* + * Copyright (c) 1999 Andreas Gal + * Copyright (c) 2000-2005 Vojtech Pavlik + * Copyright (c) 2005 Michael Haboustak for Concept2, Inc + * Copyright (c) 2006-2012 Jiri Kosina + * Copyright (c) 2012 Luis R. Rodriguez + * + * Compatibility file for Linux wireless for kernels 3.8. + * + * 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. + */ + +#include +#include +#include +#include "hid-ids.h" + +/* a list of devices that shouldn't be handled by HID core at all */ +static const struct hid_device_id hid_ignore_list[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_FLAIR) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ACECAD, USB_DEVICE_ID_ACECAD_302) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ADS_TECH, USB_DEVICE_ID_ADS_TECH_RADIO_SI470X) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_01) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_10) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_21) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_22) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_23) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIPTEK, USB_DEVICE_ID_AIPTEK_24) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AIRCABLE, USB_DEVICE_ID_AIRCABLE1) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_USBRS232) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM)}, + { HID_USB_DEVICE(USB_VENDOR_ID_ASUSTEK, USB_DEVICE_ID_ASUSTEK_LCM2)}, + { HID_USB_DEVICE(USB_VENDOR_ID_AVERMEDIA, USB_DEVICE_ID_AVER_FM_MR800) }, + { HID_USB_DEVICE(USB_VENDOR_ID_AXENTIA, USB_DEVICE_ID_AXENTIA_FM_RADIO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_BERKSHIRE, USB_DEVICE_ID_BERKSHIRE_PCWD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CIDC, 0x0103) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_RADIO_SI470X) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CMEDIA, USB_DEVICE_ID_CM109) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_HIDCOM) }, + { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_ULTRAMOUSE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DEALEXTREAME, USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EARTHMATE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DELORME, USB_DEVICE_ID_DELORME_EM_LT20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x0004) }, + { HID_USB_DEVICE(USB_VENDOR_ID_DREAM_CHEEKY, 0x000a) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ESSENTIAL_REALITY, USB_DEVICE_ID_ESSENTIAL_REALITY_P5) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC5UH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ETT, USB_DEVICE_ID_TC4UM) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0001) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0002) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GENERAL_TOUCH, 0x0004) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_4_PHIDGETSERVO_30) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_1_PHIDGETSERVO_30) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_0_4_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_16_16_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_8_8_8_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_7_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_0_8_8_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GLAB, USB_DEVICE_ID_PHIDGET_MOTORCONTROL) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_SUPER_Q2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_GOGOPEN) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GOTOP, USB_DEVICE_ID_PENPOWER) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GRETAGMACBETH, USB_DEVICE_ID_GRETAGMACBETH_HUEY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_POWERMATE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_SOUNDKNOB) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GRIFFIN, USB_DEVICE_ID_RADIOSHARK) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_90) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_100) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_101) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_103) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_104) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_105) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_106) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_107) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_108) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_200) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_201) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_202) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_203) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_204) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_205) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_206) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_207) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_300) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_301) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_302) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_303) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_304) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_305) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_306) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_307) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_308) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_309) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_400) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_401) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_402) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_403) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_404) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_405) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_500) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_501) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_502) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_503) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_504) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1000) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1001) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1002) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1003) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1004) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1005) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1006) }, + { HID_USB_DEVICE(USB_VENDOR_ID_GTCO, USB_DEVICE_ID_GTCO_1007) }, + { HID_USB_DEVICE(USB_VENDOR_ID_IMATION, USB_DEVICE_ID_DISC_STAKKA) }, + { HID_USB_DEVICE(USB_VENDOR_ID_KBGEAR, USB_DEVICE_ID_KBGEAR_JAMSTUDIO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_KWORLD, USB_DEVICE_ID_KWORLD_RADIO_FM700) }, + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_GPEN_560) }, + { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_KYE, 0x0058) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_CASSY2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POCKETCASSY2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOBILECASSY2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYVOLTAGE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYCURRENT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTIME) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MICROCASSYPH) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_JWM) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_DMMP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIC) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_UMIB) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_XRAY2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_VIDEOCOM) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOTOR) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_COM3LAB) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_TELEPORT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_NETWORKANALYSER) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_POWERCONTROL) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MACHINETEST) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MOSTANALYSER2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_ABSESP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_AUTODATABUS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_MCT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) }, + { HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) }, + { HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT2) }, + { HID_USB_DEVICE(USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR, USB_DEVICE_ID_N_S_HARMONY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 30) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 100) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 108) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 118) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 200) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 300) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 400) }, + { HID_USB_DEVICE(USB_VENDOR_ID_ONTRAK, USB_DEVICE_ID_ONTRAK_ADU100 + 500) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0001) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0002) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0003) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PANJIT, 0x0004) }, + { HID_USB_DEVICE(USB_VENDOR_ID_PHILIPS, USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE) }, + { HID_USB_DEVICE(USB_VENDOR_ID_POWERCOM, USB_DEVICE_ID_POWERCOM_UPS) }, +#if defined(CONFIG_MOUSE_SYNAPTICS_USB) || defined(CONFIG_MOUSE_SYNAPTICS_USB_MODULE) + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_INT_TP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_CPAD) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_STICK) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_COMP_TP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_WTP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_DPAD) }, +#endif + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LABPRO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_GOTEMP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) }, + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) }, + { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) }, + { HID_USB_DEVICE(USB_VENDOR_ID_YEALINK, USB_DEVICE_ID_YEALINK_P1K_P4K_B2K) }, + { } +}; + +/** + * hid_mouse_ignore_list - mouse devices which should not be handled by the hid layer + * + * There are composite devices for which we want to ignore only a certain + * interface. This is a list of devices for which only the mouse interface will + * be ignored. This allows a dedicated driver to take care of the interface. + */ +static const struct hid_device_id hid_mouse_ignore_list[] = { + /* appletouch driver */ + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING2_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING3_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY) }, + { HID_USB_DEVICE(USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY) }, + { } +}; + +static bool hid_match_one_id(struct hid_device *hdev, + const struct hid_device_id *id) +{ + return (id->bus == HID_BUS_ANY || id->bus == hdev->bus) && +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) + (id->group == HID_GROUP_ANY || id->group == hdev->group) && +#endif + (id->vendor == HID_ANY_ID || id->vendor == hdev->vendor) && + (id->product == HID_ANY_ID || id->product == hdev->product); +} + +const struct hid_device_id *hid_match_id(struct hid_device *hdev, + const struct hid_device_id *id) +{ + for (; id->bus; id++) + if (hid_match_one_id(hdev, id)) + return id; + + return NULL; +} + +bool hid_ignore(struct hid_device *hdev) +{ + if (hdev->quirks & HID_QUIRK_NO_IGNORE) + return false; + if (hdev->quirks & HID_QUIRK_IGNORE) + return true; + + switch (hdev->vendor) { + case USB_VENDOR_ID_CODEMERCS: + /* ignore all Code Mercenaries IOWarrior devices */ + if (hdev->product >= USB_DEVICE_ID_CODEMERCS_IOW_FIRST && + hdev->product <= USB_DEVICE_ID_CODEMERCS_IOW_LAST) + return true; + break; + case USB_VENDOR_ID_LOGITECH: + if (hdev->product >= USB_DEVICE_ID_LOGITECH_HARMONY_FIRST && + hdev->product <= USB_DEVICE_ID_LOGITECH_HARMONY_LAST) + return true; + /* + * The Keene FM transmitter USB device has the same USB ID as + * the Logitech AudioHub Speaker, but it should ignore the hid. + * Check if the name is that of the Keene device. + * For reference: the name of the AudioHub is + * "HOLTEK AudioHub Speaker". + */ + if (hdev->product == USB_DEVICE_ID_LOGITECH_AUDIOHUB && + !strcmp(hdev->name, "HOLTEK B-LINK USB Audio ")) + return true; + break; + case USB_VENDOR_ID_SOUNDGRAPH: + if (hdev->product >= USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST && + hdev->product <= USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST) + return true; + break; + case USB_VENDOR_ID_HANWANG: + if (hdev->product >= USB_DEVICE_ID_HANWANG_TABLET_FIRST && + hdev->product <= USB_DEVICE_ID_HANWANG_TABLET_LAST) + return true; + break; + case USB_VENDOR_ID_JESS: + if (hdev->product == USB_DEVICE_ID_JESS_YUREX && + hdev->type == HID_TYPE_USBNONE) + return true; + break; + case USB_VENDOR_ID_DWAV: + /* These are handled by usbtouchscreen. hdev->type is probably + * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match + * usbtouchscreen. */ + if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER || + hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) && + hdev->type != HID_TYPE_USBMOUSE) + return true; + break; + } + + if (hdev->type == HID_TYPE_USBMOUSE && + hid_match_id(hdev, hid_mouse_ignore_list)) + return true; + + return !!hid_match_id(hdev, hid_ignore_list); +} +EXPORT_SYMBOL_GPL(hid_ignore); diff --git a/compat/hid-ids.h b/compat/hid-ids.h new file mode 100644 index 00000000..c147dc06 --- /dev/null +++ b/compat/hid-ids.h @@ -0,0 +1,866 @@ +/* + * USB HID quirks support for Linux + * + * Copyright (c) 1999 Andreas Gal + * Copyright (c) 2000-2005 Vojtech Pavlik + * Copyright (c) 2005 Michael Haboustak for Concept2, Inc + * Copyright (c) 2006-2007 Jiri Kosina + */ + +/* + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + */ + +#ifndef HID_IDS_H_FILE +#define HID_IDS_H_FILE + +#define USB_VENDOR_ID_3M 0x0596 +#define USB_DEVICE_ID_3M1968 0x0500 +#define USB_DEVICE_ID_3M2256 0x0502 +#define USB_DEVICE_ID_3M3266 0x0506 + +#define USB_VENDOR_ID_A4TECH 0x09da +#define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 +#define USB_DEVICE_ID_A4TECH_X5_005D 0x000a +#define USB_DEVICE_ID_A4TECH_RP_649 0x001a + +#define USB_VENDOR_ID_AASHIMA 0x06d6 +#define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 +#define USB_DEVICE_ID_AASHIMA_PREDATOR 0x0026 + +#define USB_VENDOR_ID_ACECAD 0x0460 +#define USB_DEVICE_ID_ACECAD_FLAIR 0x0004 +#define USB_DEVICE_ID_ACECAD_302 0x0008 + +#define USB_VENDOR_ID_ACRUX 0x1a34 + +#define USB_VENDOR_ID_ACTIONSTAR 0x2101 +#define USB_DEVICE_ID_ACTIONSTAR_1011 0x1011 + +#define USB_VENDOR_ID_ADS_TECH 0x06e1 +#define USB_DEVICE_ID_ADS_TECH_RADIO_SI470X 0xa155 + +#define USB_VENDOR_ID_AFATECH 0x15a4 +#define USB_DEVICE_ID_AFATECH_AF9016 0x9016 + +#define USB_VENDOR_ID_AIPTEK 0x08ca +#define USB_DEVICE_ID_AIPTEK_01 0x0001 +#define USB_DEVICE_ID_AIPTEK_10 0x0010 +#define USB_DEVICE_ID_AIPTEK_20 0x0020 +#define USB_DEVICE_ID_AIPTEK_21 0x0021 +#define USB_DEVICE_ID_AIPTEK_22 0x0022 +#define USB_DEVICE_ID_AIPTEK_23 0x0023 +#define USB_DEVICE_ID_AIPTEK_24 0x0024 + +#define USB_VENDOR_ID_AIRCABLE 0x16CA +#define USB_DEVICE_ID_AIRCABLE1 0x1502 + +#define USB_VENDOR_ID_AIREN 0x1a2c +#define USB_DEVICE_ID_AIREN_SLIMPLUS 0x0002 + +#define USB_VENDOR_ID_ALCOR 0x058f +#define USB_DEVICE_ID_ALCOR_USBRS232 0x9720 + +#define USB_VENDOR_ID_ALPS 0x0433 +#define USB_DEVICE_ID_IBM_GAMEPAD 0x1101 + +#define USB_VENDOR_ID_APPLE 0x05ac +#define USB_DEVICE_ID_APPLE_MIGHTYMOUSE 0x0304 +#define USB_DEVICE_ID_APPLE_MAGICMOUSE 0x030d +#define USB_DEVICE_ID_APPLE_MAGICTRACKPAD 0x030e +#define USB_DEVICE_ID_APPLE_FOUNTAIN_ANSI 0x020e +#define USB_DEVICE_ID_APPLE_FOUNTAIN_ISO 0x020f +#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214 +#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215 +#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216 +#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217 +#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218 +#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219 +#define USB_DEVICE_ID_APPLE_GEYSER4_ANSI 0x021a +#define USB_DEVICE_ID_APPLE_GEYSER4_ISO 0x021b +#define USB_DEVICE_ID_APPLE_GEYSER4_JIS 0x021c +#define USB_DEVICE_ID_APPLE_ALU_MINI_ANSI 0x021d +#define USB_DEVICE_ID_APPLE_ALU_MINI_ISO 0x021e +#define USB_DEVICE_ID_APPLE_ALU_MINI_JIS 0x021f +#define USB_DEVICE_ID_APPLE_ALU_ANSI 0x0220 +#define USB_DEVICE_ID_APPLE_ALU_ISO 0x0221 +#define USB_DEVICE_ID_APPLE_ALU_JIS 0x0222 +#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223 +#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224 +#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225 +#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ANSI 0x0229 +#define USB_DEVICE_ID_APPLE_GEYSER4_HF_ISO 0x022a +#define USB_DEVICE_ID_APPLE_GEYSER4_HF_JIS 0x022b +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ANSI 0x022c +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_ISO 0x022d +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_JIS 0x022e +#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 +#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 +#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 +#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 +#define USB_DEVICE_ID_APPLE_WELLSPRING4_ANSI 0x023f +#define USB_DEVICE_ID_APPLE_WELLSPRING4_ISO 0x0240 +#define USB_DEVICE_ID_APPLE_WELLSPRING4_JIS 0x0241 +#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ANSI 0x0242 +#define USB_DEVICE_ID_APPLE_WELLSPRING4A_ISO 0x0243 +#define USB_DEVICE_ID_APPLE_WELLSPRING4A_JIS 0x0244 +#define USB_DEVICE_ID_APPLE_WELLSPRING5_ANSI 0x0245 +#define USB_DEVICE_ID_APPLE_WELLSPRING5_ISO 0x0246 +#define USB_DEVICE_ID_APPLE_WELLSPRING5_JIS 0x0247 +#define USB_DEVICE_ID_APPLE_ALU_REVB_ANSI 0x024f +#define USB_DEVICE_ID_APPLE_ALU_REVB_ISO 0x0250 +#define USB_DEVICE_ID_APPLE_ALU_REVB_JIS 0x0251 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ANSI 0x0252 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_ISO 0x0253 +#define USB_DEVICE_ID_APPLE_WELLSPRING5A_JIS 0x0254 +#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ANSI 0x0259 +#define USB_DEVICE_ID_APPLE_WELLSPRING7A_ISO 0x025a +#define USB_DEVICE_ID_APPLE_WELLSPRING7A_JIS 0x025b +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ANSI 0x0249 +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_ISO 0x024a +#define USB_DEVICE_ID_APPLE_WELLSPRING6A_JIS 0x024b +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ANSI 0x024c +#define USB_DEVICE_ID_APPLE_WELLSPRING6_ISO 0x024d +#define USB_DEVICE_ID_APPLE_WELLSPRING6_JIS 0x024e +#define USB_DEVICE_ID_APPLE_WELLSPRING7_ANSI 0x0262 +#define USB_DEVICE_ID_APPLE_WELLSPRING7_ISO 0x0263 +#define USB_DEVICE_ID_APPLE_WELLSPRING7_JIS 0x0264 +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ANSI 0x0239 +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_ISO 0x023a +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2009_JIS 0x023b +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ANSI 0x0255 +#define USB_DEVICE_ID_APPLE_ALU_WIRELESS_2011_ISO 0x0256 +#define USB_DEVICE_ID_APPLE_FOUNTAIN_TP_ONLY 0x030a +#define USB_DEVICE_ID_APPLE_GEYSER1_TP_ONLY 0x030b +#define USB_DEVICE_ID_APPLE_ATV_IRCONTROL 0x8241 +#define USB_DEVICE_ID_APPLE_IRCONTROL4 0x8242 + +#define USB_VENDOR_ID_ASUS 0x0486 +#define USB_DEVICE_ID_ASUS_T91MT 0x0185 +#define USB_DEVICE_ID_ASUSTEK_MULTITOUCH_YFO 0x0186 + +#define USB_VENDOR_ID_ASUSTEK 0x0b05 +#define USB_DEVICE_ID_ASUSTEK_LCM 0x1726 +#define USB_DEVICE_ID_ASUSTEK_LCM2 0x175b + +#define USB_VENDOR_ID_ATEN 0x0557 +#define USB_DEVICE_ID_ATEN_UC100KM 0x2004 +#define USB_DEVICE_ID_ATEN_CS124U 0x2202 +#define USB_DEVICE_ID_ATEN_2PORTKVM 0x2204 +#define USB_DEVICE_ID_ATEN_4PORTKVM 0x2205 +#define USB_DEVICE_ID_ATEN_4PORTKVMC 0x2208 + +#define USB_VENDOR_ID_ATMEL 0x03eb +#define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c +#define USB_DEVICE_ID_ATMEL_MXT_DIGITIZER 0x2118 + +#define USB_VENDOR_ID_AUREAL 0x0755 +#define USB_DEVICE_ID_AUREAL_W01RN 0x2626 + +#define USB_VENDOR_ID_AVERMEDIA 0x07ca +#define USB_DEVICE_ID_AVER_FM_MR800 0xb800 + +#define USB_VENDOR_ID_AXENTIA 0x12cf +#define USB_DEVICE_ID_AXENTIA_FM_RADIO 0x7111 + +#define USB_VENDOR_ID_BAANTO 0x2453 +#define USB_DEVICE_ID_BAANTO_MT_190W2 0x0100 + +#define USB_VENDOR_ID_BELKIN 0x050d +#define USB_DEVICE_ID_FLIP_KVM 0x3201 + +#define USB_VENDOR_ID_BERKSHIRE 0x0c98 +#define USB_DEVICE_ID_BERKSHIRE_PCWD 0x1140 + +#define USB_VENDOR_ID_BTC 0x046e +#define USB_DEVICE_ID_BTC_EMPREX_REMOTE 0x5578 +#define USB_DEVICE_ID_BTC_EMPREX_REMOTE_2 0x5577 + +#define USB_VENDOR_ID_CANDO 0x2087 +#define USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH 0x0703 +#define USB_DEVICE_ID_CANDO_MULTI_TOUCH 0x0a01 +#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_10_1 0x0a02 +#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_11_6 0x0b03 +#define USB_DEVICE_ID_CANDO_MULTI_TOUCH_15_6 0x0f01 + +#define USB_VENDOR_ID_CH 0x068e +#define USB_DEVICE_ID_CH_PRO_THROTTLE 0x00f1 +#define USB_DEVICE_ID_CH_PRO_PEDALS 0x00f2 +#define USB_DEVICE_ID_CH_FIGHTERSTICK 0x00f3 +#define USB_DEVICE_ID_CH_COMBATSTICK 0x00f4 +#define USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE 0x0051 +#define USB_DEVICE_ID_CH_FLIGHT_SIM_YOKE 0x00ff +#define USB_DEVICE_ID_CH_3AXIS_5BUTTON_STICK 0x00d3 +#define USB_DEVICE_ID_CH_AXIS_295 0x001c + +#define USB_VENDOR_ID_CHERRY 0x046a +#define USB_DEVICE_ID_CHERRY_CYMOTION 0x0023 +#define USB_DEVICE_ID_CHERRY_CYMOTION_SOLAR 0x0027 + +#define USB_VENDOR_ID_CHIC 0x05fe +#define USB_DEVICE_ID_CHIC_GAMEPAD 0x0014 + +#define USB_VENDOR_ID_CHICONY 0x04f2 +#define USB_DEVICE_ID_CHICONY_TACTICAL_PAD 0x0418 +#define USB_DEVICE_ID_CHICONY_MULTI_TOUCH 0xb19d +#define USB_DEVICE_ID_CHICONY_WIRELESS 0x0618 +#define USB_DEVICE_ID_CHICONY_WIRELESS2 0x1123 +#define USB_DEVICE_ID_CHICONY_AK1D 0x1125 + +#define USB_VENDOR_ID_CHUNGHWAT 0x2247 +#define USB_DEVICE_ID_CHUNGHWAT_MULTITOUCH 0x0001 + +#define USB_VENDOR_ID_CIDC 0x1677 + +#define USB_VENDOR_ID_CMEDIA 0x0d8c +#define USB_DEVICE_ID_CM109 0x000e + +#define USB_VENDOR_ID_CODEMERCS 0x07c0 +#define USB_DEVICE_ID_CODEMERCS_IOW_FIRST 0x1500 +#define USB_DEVICE_ID_CODEMERCS_IOW_LAST 0x15ff + +#define USB_VENDOR_ID_CREATIVELABS 0x041e +#define USB_DEVICE_ID_PRODIKEYS_PCMIDI 0x2801 + +#define USB_VENDOR_ID_CVTOUCH 0x1ff7 +#define USB_DEVICE_ID_CVTOUCH_SCREEN 0x0013 + +#define USB_VENDOR_ID_CYGNAL 0x10c4 +#define USB_DEVICE_ID_CYGNAL_RADIO_SI470X 0x818a + +#define USB_VENDOR_ID_CYPRESS 0x04b4 +#define USB_DEVICE_ID_CYPRESS_MOUSE 0x0001 +#define USB_DEVICE_ID_CYPRESS_HIDCOM 0x5500 +#define USB_DEVICE_ID_CYPRESS_ULTRAMOUSE 0x7417 +#define USB_DEVICE_ID_CYPRESS_BARCODE_1 0xde61 +#define USB_DEVICE_ID_CYPRESS_BARCODE_2 0xde64 +#define USB_DEVICE_ID_CYPRESS_BARCODE_3 0xbca1 +#define USB_DEVICE_ID_CYPRESS_BARCODE_4 0xed81 +#define USB_DEVICE_ID_CYPRESS_TRUETOUCH 0xc001 + +#define USB_VENDOR_ID_DEALEXTREAME 0x10c5 +#define USB_DEVICE_ID_DEALEXTREAME_RADIO_SI4701 0x819a + +#define USB_VENDOR_ID_DELORME 0x1163 +#define USB_DEVICE_ID_DELORME_EARTHMATE 0x0100 +#define USB_DEVICE_ID_DELORME_EM_LT20 0x0200 + +#define USB_VENDOR_ID_DMI 0x0c0b +#define USB_DEVICE_ID_DMI_ENC 0x5fab + +#define USB_VENDOR_ID_DRAGONRISE 0x0079 + +#define USB_VENDOR_ID_DWAV 0x0eef +#define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001 +#define USB_DEVICE_ID_DWAV_TOUCHCONTROLLER 0x0002 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480D 0x480d +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_480E 0x480e +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7207 0x7207 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_720C 0x720c +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224 0x7224 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_722A 0x722A +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_725E 0x725e +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7262 0x7262 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_726B 0x726b +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72AA 0x72aa +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72A1 0x72a1 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72FA 0x72fa +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7302 0x7302 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7349 0x7349 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_73F7 0x73f7 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_A001 0xa001 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_7224 0x7224 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72D0 0x72d0 +#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH_72C4 0x72c4 + +#define USB_VENDOR_ID_ELECOM 0x056e +#define USB_DEVICE_ID_ELECOM_BM084 0x0061 + +#define USB_VENDOR_ID_DREAM_CHEEKY 0x1d34 + +#define USB_VENDOR_ID_ELO 0x04E7 +#define USB_DEVICE_ID_ELO_TS2515 0x0022 +#define USB_DEVICE_ID_ELO_TS2700 0x0020 + +#define USB_VENDOR_ID_EMS 0x2006 +#define USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II 0x0118 + +#define USB_VENDOR_ID_FLATFROG 0x25b5 +#define USB_DEVICE_ID_MULTITOUCH_3200 0x0002 + +#define USB_VENDOR_ID_ESSENTIAL_REALITY 0x0d7f +#define USB_DEVICE_ID_ESSENTIAL_REALITY_P5 0x0100 + +#define USB_VENDOR_ID_ETT 0x0664 +#define USB_DEVICE_ID_TC5UH 0x0309 +#define USB_DEVICE_ID_TC4UM 0x0306 + +#define USB_VENDOR_ID_ETURBOTOUCH 0x22b9 +#define USB_DEVICE_ID_ETURBOTOUCH 0x0006 + +#define USB_VENDOR_ID_EZKEY 0x0518 +#define USB_DEVICE_ID_BTC_8193 0x0002 + +#define USB_VENDOR_ID_FREESCALE 0x15A2 +#define USB_DEVICE_ID_FREESCALE_MX28 0x004F + +#define USB_VENDOR_ID_FRUCTEL 0x25B6 +#define USB_DEVICE_ID_GAMETEL_MT_MODE 0x0002 + +#define USB_VENDOR_ID_GAMERON 0x0810 +#define USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR 0x0001 +#define USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR 0x0002 + +#define USB_VENDOR_ID_GENERAL_TOUCH 0x0dfc +#define USB_DEVICE_ID_GENERAL_TOUCH_WIN7_TWOFINGERS 0x0003 +#define USB_DEVICE_ID_GENERAL_TOUCH_WIN8_PWT_TENFINGERS 0x0100 + +#define USB_VENDOR_ID_GLAB 0x06c2 +#define USB_DEVICE_ID_4_PHIDGETSERVO_30 0x0038 +#define USB_DEVICE_ID_1_PHIDGETSERVO_30 0x0039 +#define USB_DEVICE_ID_0_0_4_IF_KIT 0x0040 +#define USB_DEVICE_ID_0_16_16_IF_KIT 0x0044 +#define USB_DEVICE_ID_8_8_8_IF_KIT 0x0045 +#define USB_DEVICE_ID_0_8_7_IF_KIT 0x0051 +#define USB_DEVICE_ID_0_8_8_IF_KIT 0x0053 +#define USB_DEVICE_ID_PHIDGET_MOTORCONTROL 0x0058 + +#define USB_VENDOR_ID_GOODTOUCH 0x1aad +#define USB_DEVICE_ID_GOODTOUCH_000f 0x000f + +#define USB_VENDOR_ID_GOTOP 0x08f2 +#define USB_DEVICE_ID_SUPER_Q2 0x007f +#define USB_DEVICE_ID_GOGOPEN 0x00ce +#define USB_DEVICE_ID_PENPOWER 0x00f4 + +#define USB_VENDOR_ID_GREENASIA 0x0e8f +#define USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD 0x3013 + +#define USB_VENDOR_ID_GRETAGMACBETH 0x0971 +#define USB_DEVICE_ID_GRETAGMACBETH_HUEY 0x2005 + +#define USB_VENDOR_ID_GRIFFIN 0x077d +#define USB_DEVICE_ID_POWERMATE 0x0410 +#define USB_DEVICE_ID_SOUNDKNOB 0x04AA +#define USB_DEVICE_ID_RADIOSHARK 0x627a + +#define USB_VENDOR_ID_GTCO 0x078c +#define USB_DEVICE_ID_GTCO_90 0x0090 +#define USB_DEVICE_ID_GTCO_100 0x0100 +#define USB_DEVICE_ID_GTCO_101 0x0101 +#define USB_DEVICE_ID_GTCO_103 0x0103 +#define USB_DEVICE_ID_GTCO_104 0x0104 +#define USB_DEVICE_ID_GTCO_105 0x0105 +#define USB_DEVICE_ID_GTCO_106 0x0106 +#define USB_DEVICE_ID_GTCO_107 0x0107 +#define USB_DEVICE_ID_GTCO_108 0x0108 +#define USB_DEVICE_ID_GTCO_200 0x0200 +#define USB_DEVICE_ID_GTCO_201 0x0201 +#define USB_DEVICE_ID_GTCO_202 0x0202 +#define USB_DEVICE_ID_GTCO_203 0x0203 +#define USB_DEVICE_ID_GTCO_204 0x0204 +#define USB_DEVICE_ID_GTCO_205 0x0205 +#define USB_DEVICE_ID_GTCO_206 0x0206 +#define USB_DEVICE_ID_GTCO_207 0x0207 +#define USB_DEVICE_ID_GTCO_300 0x0300 +#define USB_DEVICE_ID_GTCO_301 0x0301 +#define USB_DEVICE_ID_GTCO_302 0x0302 +#define USB_DEVICE_ID_GTCO_303 0x0303 +#define USB_DEVICE_ID_GTCO_304 0x0304 +#define USB_DEVICE_ID_GTCO_305 0x0305 +#define USB_DEVICE_ID_GTCO_306 0x0306 +#define USB_DEVICE_ID_GTCO_307 0x0307 +#define USB_DEVICE_ID_GTCO_308 0x0308 +#define USB_DEVICE_ID_GTCO_309 0x0309 +#define USB_DEVICE_ID_GTCO_400 0x0400 +#define USB_DEVICE_ID_GTCO_401 0x0401 +#define USB_DEVICE_ID_GTCO_402 0x0402 +#define USB_DEVICE_ID_GTCO_403 0x0403 +#define USB_DEVICE_ID_GTCO_404 0x0404 +#define USB_DEVICE_ID_GTCO_405 0x0405 +#define USB_DEVICE_ID_GTCO_500 0x0500 +#define USB_DEVICE_ID_GTCO_501 0x0501 +#define USB_DEVICE_ID_GTCO_502 0x0502 +#define USB_DEVICE_ID_GTCO_503 0x0503 +#define USB_DEVICE_ID_GTCO_504 0x0504 +#define USB_DEVICE_ID_GTCO_1000 0x1000 +#define USB_DEVICE_ID_GTCO_1001 0x1001 +#define USB_DEVICE_ID_GTCO_1002 0x1002 +#define USB_DEVICE_ID_GTCO_1003 0x1003 +#define USB_DEVICE_ID_GTCO_1004 0x1004 +#define USB_DEVICE_ID_GTCO_1005 0x1005 +#define USB_DEVICE_ID_GTCO_1006 0x1006 +#define USB_DEVICE_ID_GTCO_1007 0x1007 + +#define USB_VENDOR_ID_GYRATION 0x0c16 +#define USB_DEVICE_ID_GYRATION_REMOTE 0x0002 +#define USB_DEVICE_ID_GYRATION_REMOTE_2 0x0003 +#define USB_DEVICE_ID_GYRATION_REMOTE_3 0x0008 + +#define USB_VENDOR_ID_HANWANG 0x0b57 +#define USB_DEVICE_ID_HANWANG_TABLET_FIRST 0x5000 +#define USB_DEVICE_ID_HANWANG_TABLET_LAST 0x8fff + +#define USB_VENDOR_ID_HANVON 0x20b3 +#define USB_DEVICE_ID_HANVON_MULTITOUCH 0x0a18 + +#define USB_VENDOR_ID_HANVON_ALT 0x22ed +#define USB_DEVICE_ID_HANVON_ALT_MULTITOUCH 0x1010 + +#define USB_VENDOR_ID_HAPP 0x078b +#define USB_DEVICE_ID_UGCI_DRIVING 0x0010 +#define USB_DEVICE_ID_UGCI_FLYING 0x0020 +#define USB_DEVICE_ID_UGCI_FIGHTING 0x0030 + +#define USB_VENDOR_ID_IDEACOM 0x1cb6 +#define USB_DEVICE_ID_IDEACOM_IDC6650 0x6650 +#define USB_DEVICE_ID_IDEACOM_IDC6651 0x6651 + +#define USB_VENDOR_ID_ILITEK 0x222a +#define USB_DEVICE_ID_ILITEK_MULTITOUCH 0x0001 + +#define USB_VENDOR_ID_ION 0x15e4 +#define USB_DEVICE_ID_ICADE 0x0132 + +#define USB_VENDOR_ID_HOLTEK 0x1241 +#define USB_DEVICE_ID_HOLTEK_ON_LINE_GRIP 0x5015 + +#define USB_VENDOR_ID_HOLTEK_ALT 0x04d9 +#define USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD 0xa055 + +#define USB_VENDOR_ID_IMATION 0x0718 +#define USB_DEVICE_ID_DISC_STAKKA 0xd000 + +#define USB_VENDOR_ID_INTEL_8086 0x8086 +#define USB_VENDOR_ID_INTEL_8087 0x8087 +#define USB_DEVICE_ID_SENSOR_HUB_1020 0x1020 +#define USB_DEVICE_ID_SENSOR_HUB_09FA 0x09FA + +#define USB_VENDOR_ID_IRTOUCHSYSTEMS 0x6615 +#define USB_DEVICE_ID_IRTOUCH_INFRARED_USB 0x0070 + +#define USB_VENDOR_ID_JESS 0x0c45 +#define USB_DEVICE_ID_JESS_YUREX 0x1010 + +#define USB_VENDOR_ID_KBGEAR 0x084e +#define USB_DEVICE_ID_KBGEAR_JAMSTUDIO 0x1001 + +#define USB_VENDOR_ID_KENSINGTON 0x047d +#define USB_DEVICE_ID_KS_SLIMBLADE 0x2041 + +#define USB_VENDOR_ID_KWORLD 0x1b80 +#define USB_DEVICE_ID_KWORLD_RADIO_FM700 0xd700 + +#define USB_VENDOR_ID_KEYTOUCH 0x0926 +#define USB_DEVICE_ID_KEYTOUCH_IEC 0x3333 + +#define USB_VENDOR_ID_KYE 0x0458 +#define USB_DEVICE_ID_KYE_ERGO_525V 0x0087 +#define USB_DEVICE_ID_KYE_GPEN_560 0x5003 +#define USB_DEVICE_ID_KYE_EASYPEN_I405X 0x5010 +#define USB_DEVICE_ID_KYE_MOUSEPEN_I608X 0x5011 +#define USB_DEVICE_ID_KYE_EASYPEN_M610X 0x5013 + +#define USB_VENDOR_ID_LABTEC 0x1020 +#define USB_DEVICE_ID_LABTEC_WIRELESS_KEYBOARD 0x0006 + +#define USB_VENDOR_ID_LCPOWER 0x1241 +#define USB_DEVICE_ID_LCPOWER_LC1000 0xf767 + +#define USB_VENDOR_ID_LD 0x0f11 +#define USB_DEVICE_ID_LD_CASSY 0x1000 +#define USB_DEVICE_ID_LD_CASSY2 0x1001 +#define USB_DEVICE_ID_LD_POCKETCASSY 0x1010 +#define USB_DEVICE_ID_LD_POCKETCASSY2 0x1011 +#define USB_DEVICE_ID_LD_MOBILECASSY 0x1020 +#define USB_DEVICE_ID_LD_MOBILECASSY2 0x1021 +#define USB_DEVICE_ID_LD_MICROCASSYVOLTAGE 0x1031 +#define USB_DEVICE_ID_LD_MICROCASSYCURRENT 0x1032 +#define USB_DEVICE_ID_LD_MICROCASSYTIME 0x1033 +#define USB_DEVICE_ID_LD_MICROCASSYTEMPERATURE 0x1035 +#define USB_DEVICE_ID_LD_MICROCASSYPH 0x1038 +#define USB_DEVICE_ID_LD_JWM 0x1080 +#define USB_DEVICE_ID_LD_DMMP 0x1081 +#define USB_DEVICE_ID_LD_UMIP 0x1090 +#define USB_DEVICE_ID_LD_UMIC 0x10A0 +#define USB_DEVICE_ID_LD_UMIB 0x10B0 +#define USB_DEVICE_ID_LD_XRAY 0x1100 +#define USB_DEVICE_ID_LD_XRAY2 0x1101 +#define USB_DEVICE_ID_LD_XRAYCT 0x1110 +#define USB_DEVICE_ID_LD_VIDEOCOM 0x1200 +#define USB_DEVICE_ID_LD_MOTOR 0x1210 +#define USB_DEVICE_ID_LD_COM3LAB 0x2000 +#define USB_DEVICE_ID_LD_TELEPORT 0x2010 +#define USB_DEVICE_ID_LD_NETWORKANALYSER 0x2020 +#define USB_DEVICE_ID_LD_POWERCONTROL 0x2030 +#define USB_DEVICE_ID_LD_MACHINETEST 0x2040 +#define USB_DEVICE_ID_LD_MOSTANALYSER 0x2050 +#define USB_DEVICE_ID_LD_MOSTANALYSER2 0x2051 +#define USB_DEVICE_ID_LD_ABSESP 0x2060 +#define USB_DEVICE_ID_LD_AUTODATABUS 0x2070 +#define USB_DEVICE_ID_LD_MCT 0x2080 +#define USB_DEVICE_ID_LD_HYBRID 0x2090 +#define USB_DEVICE_ID_LD_HEATCONTROL 0x20A0 + +#define USB_VENDOR_ID_LENOVO 0x17ef +#define USB_DEVICE_ID_LENOVO_TPKBD 0x6009 + +#define USB_VENDOR_ID_LG 0x1fd2 +#define USB_DEVICE_ID_LG_MULTITOUCH 0x0064 + +#define USB_VENDOR_ID_LOGITECH 0x046d +#define USB_DEVICE_ID_LOGITECH_AUDIOHUB 0x0a0e +#define USB_DEVICE_ID_LOGITECH_RECEIVER 0xc101 +#define USB_DEVICE_ID_LOGITECH_HARMONY_FIRST 0xc110 +#define USB_DEVICE_ID_LOGITECH_HARMONY_LAST 0xc14f +#define USB_DEVICE_ID_LOGITECH_HARMONY_PS3 0x0306 +#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD_CORD 0xc20a +#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD 0xc211 +#define USB_DEVICE_ID_LOGITECH_EXTREME_3D 0xc215 +#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2 0xc218 +#define USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2 0xc219 +#define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D 0xc283 +#define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO 0xc286 +#define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940 0xc287 +#define USB_DEVICE_ID_LOGITECH_WHEEL 0xc294 +#define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG 0xc293 +#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL 0xc295 +#define USB_DEVICE_ID_LOGITECH_DFP_WHEEL 0xc298 +#define USB_DEVICE_ID_LOGITECH_G25_WHEEL 0xc299 +#define USB_DEVICE_ID_LOGITECH_DFGT_WHEEL 0xc29a +#define USB_DEVICE_ID_LOGITECH_G27_WHEEL 0xc29b +#define USB_DEVICE_ID_LOGITECH_WII_WHEEL 0xc29c +#define USB_DEVICE_ID_LOGITECH_ELITE_KBD 0xc30a +#define USB_DEVICE_ID_S510_RECEIVER 0xc50c +#define USB_DEVICE_ID_S510_RECEIVER_2 0xc517 +#define USB_DEVICE_ID_LOGITECH_CORDLESS_DESKTOP_LX500 0xc512 +#define USB_DEVICE_ID_MX3000_RECEIVER 0xc513 +#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER 0xc52b +#define USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2 0xc532 +#define USB_DEVICE_ID_SPACETRAVELLER 0xc623 +#define USB_DEVICE_ID_SPACENAVIGATOR 0xc626 +#define USB_DEVICE_ID_DINOVO_DESKTOP 0xc704 +#define USB_DEVICE_ID_DINOVO_EDGE 0xc714 +#define USB_DEVICE_ID_DINOVO_MINI 0xc71f +#define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2 0xca03 + +#define USB_VENDOR_ID_LUMIO 0x202e +#define USB_DEVICE_ID_CRYSTALTOUCH 0x0006 +#define USB_DEVICE_ID_CRYSTALTOUCH_DUAL 0x0007 + +#define USB_VENDOR_ID_MADCATZ 0x0738 +#define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540 + +#define USB_VENDOR_ID_MCC 0x09db +#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076 +#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a + +#define USB_VENDOR_ID_MGE 0x0463 +#define USB_DEVICE_ID_MGE_UPS 0xffff +#define USB_DEVICE_ID_MGE_UPS1 0x0001 + +#define USB_VENDOR_ID_MICROCHIP 0x04d8 +#define USB_DEVICE_ID_PICKIT1 0x0032 +#define USB_DEVICE_ID_PICKIT2 0x0033 +#define USB_DEVICE_ID_PICOLCD 0xc002 +#define USB_DEVICE_ID_PICOLCD_BOOTLOADER 0xf002 + +#define USB_VENDOR_ID_MICROSOFT 0x045e +#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b +#define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d +#define USB_DEVICE_ID_MS_NE4K 0x00db +#define USB_DEVICE_ID_MS_LK6K 0x00f9 +#define USB_DEVICE_ID_MS_PRESENTER_8K_BT 0x0701 +#define USB_DEVICE_ID_MS_PRESENTER_8K_USB 0x0713 +#define USB_DEVICE_ID_MS_DIGITAL_MEDIA_3K 0x0730 +#define USB_DEVICE_ID_MS_COMFORT_MOUSE_4500 0x076c + +#define USB_VENDOR_ID_MOJO 0x8282 +#define USB_DEVICE_ID_RETRO_ADAPTER 0x3201 + +#define USB_VENDOR_ID_MONTEREY 0x0566 +#define USB_DEVICE_ID_GENIUS_KB29E 0x3004 + +#define USB_VENDOR_ID_NATIONAL_SEMICONDUCTOR 0x0400 +#define USB_DEVICE_ID_N_S_HARMONY 0xc359 + +#define USB_VENDOR_ID_NATSU 0x08b7 +#define USB_DEVICE_ID_NATSU_GAMEPAD 0x0001 + +#define USB_VENDOR_ID_NCR 0x0404 +#define USB_DEVICE_ID_NCR_FIRST 0x0300 +#define USB_DEVICE_ID_NCR_LAST 0x03ff + +#define USB_VENDOR_ID_NEC 0x073e +#define USB_DEVICE_ID_NEC_USB_GAME_PAD 0x0301 + +#define USB_VENDOR_ID_NEXTWINDOW 0x1926 +#define USB_DEVICE_ID_NEXTWINDOW_TOUCHSCREEN 0x0003 + +#define USB_VENDOR_ID_NINTENDO 0x057e +#define USB_DEVICE_ID_NINTENDO_WIIMOTE 0x0306 + +#define USB_VENDOR_ID_NOVATEK 0x0603 +#define USB_DEVICE_ID_NOVATEK_PCT 0x0600 + +#define USB_VENDOR_ID_NTRIG 0x1b96 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN 0x0001 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1 0x0003 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2 0x0004 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_3 0x0005 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_4 0x0006 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_5 0x0007 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_6 0x0008 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_7 0x0009 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_8 0x000A +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_9 0x000B +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_10 0x000C +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_11 0x000D +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_12 0x000E +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_13 0x000F +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_14 0x0010 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_15 0x0011 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_16 0x0012 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_17 0x0013 +#define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_18 0x0014 + +#define USB_VENDOR_ID_ONTRAK 0x0a07 +#define USB_DEVICE_ID_ONTRAK_ADU100 0x0064 + +#define USB_VENDOR_ID_ORTEK 0x05a4 +#define USB_DEVICE_ID_ORTEK_PKB1700 0x1700 +#define USB_DEVICE_ID_ORTEK_WKB2000 0x2000 + +#define USB_VENDOR_ID_PANASONIC 0x04da +#define USB_DEVICE_ID_PANABOARD_UBT780 0x1044 +#define USB_DEVICE_ID_PANABOARD_UBT880 0x104d + +#define USB_VENDOR_ID_PANJIT 0x134c + +#define USB_VENDOR_ID_PANTHERLORD 0x0810 +#define USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK 0x0001 + +#define USB_VENDOR_ID_PENMOUNT 0x14e1 +#define USB_DEVICE_ID_PENMOUNT_PCI 0x3500 + +#define USB_VENDOR_ID_PETALYNX 0x18b1 +#define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 + +#define USB_VENDOR_ID_PHILIPS 0x0471 +#define USB_DEVICE_ID_PHILIPS_IEEE802154_DONGLE 0x0617 + +#define USB_VENDOR_ID_PI_ENGINEERING 0x05f3 +#define USB_DEVICE_ID_PI_ENGINEERING_VEC_USB_FOOTPEDAL 0xff + +#define USB_VENDOR_ID_PIXART 0x093a +#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN 0x8001 +#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1 0x8002 +#define USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2 0x8003 + +#define USB_VENDOR_ID_PLAYDOTCOM 0x0b43 +#define USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII 0x0003 + +#define USB_VENDOR_ID_POWERCOM 0x0d9f +#define USB_DEVICE_ID_POWERCOM_UPS 0x0002 + +#define USB_VENDOR_ID_PRODIGE 0x05af +#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062 + +#define USB_VENDOR_ID_QUANTA 0x0408 +#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000 +#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001 +#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008 + +#define USB_VENDOR_ID_ROCCAT 0x1e7d +#define USB_DEVICE_ID_ROCCAT_ARVO 0x30d4 +#define USB_DEVICE_ID_ROCCAT_ISKU 0x319c +#define USB_DEVICE_ID_ROCCAT_KONE 0x2ced +#define USB_DEVICE_ID_ROCCAT_KONEPLUS 0x2d51 +#define USB_DEVICE_ID_ROCCAT_KONEXTD 0x2e22 +#define USB_DEVICE_ID_ROCCAT_KOVAPLUS 0x2d50 +#define USB_DEVICE_ID_ROCCAT_LUA 0x2c2e +#define USB_DEVICE_ID_ROCCAT_PYRA_WIRED 0x2c24 +#define USB_DEVICE_ID_ROCCAT_PYRA_WIRELESS 0x2cf6 +#define USB_DEVICE_ID_ROCCAT_SAVU 0x2d5a + +#define USB_VENDOR_ID_SAITEK 0x06a3 +#define USB_DEVICE_ID_SAITEK_RUMBLEPAD 0xff17 +#define USB_DEVICE_ID_SAITEK_PS1000 0x0621 + +#define USB_VENDOR_ID_SAMSUNG 0x0419 +#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 +#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600 + +#define USB_VENDOR_ID_SENNHEISER 0x1395 +#define USB_DEVICE_ID_SENNHEISER_BTD500USB 0x002c + +#define USB_VENDOR_ID_SIGMA_MICRO 0x1c4f +#define USB_DEVICE_ID_SIGMA_MICRO_KEYBOARD 0x0002 + +#define USB_VENDOR_ID_SIGMATEL 0x066F +#define USB_DEVICE_ID_SIGMATEL_STMP3780 0x3780 + +#define USB_VENDOR_ID_SKYCABLE 0x1223 +#define USB_DEVICE_ID_SKYCABLE_WIRELESS_PRESENTER 0x3F07 + +#define USB_VENDOR_ID_SONY 0x054c +#define USB_DEVICE_ID_SONY_VAIO_VGX_MOUSE 0x024b +#define USB_DEVICE_ID_SONY_PS3_BDREMOTE 0x0306 +#define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 +#define USB_DEVICE_ID_SONY_NAVIGATION_CONTROLLER 0x042f + +#define USB_VENDOR_ID_SOUNDGRAPH 0x15c2 +#define USB_DEVICE_ID_SOUNDGRAPH_IMON_FIRST 0x0034 +#define USB_DEVICE_ID_SOUNDGRAPH_IMON_LAST 0x0046 + +#define USB_VENDOR_ID_STANTUM 0x1f87 +#define USB_DEVICE_ID_MTP 0x0002 + +#define USB_VENDOR_ID_STANTUM_STM 0x0483 +#define USB_DEVICE_ID_MTP_STM 0x3261 +#define USB_DEVICE_ID_SENSOR_HUB_7014 0x7014 + +#define USB_VENDOR_ID_STANTUM_SITRONIX 0x1403 +#define USB_DEVICE_ID_MTP_SITRONIX 0x5001 + +#define USB_VENDOR_ID_SUN 0x0430 +#define USB_DEVICE_ID_RARITAN_KVM_DONGLE 0xcdab + +#define USB_VENDOR_ID_SUNPLUS 0x04fc +#define USB_DEVICE_ID_SUNPLUS_WDESKTOP 0x05d8 + +#define USB_VENDOR_ID_SYMBOL 0x05e0 +#define USB_DEVICE_ID_SYMBOL_SCANNER_1 0x0800 +#define USB_DEVICE_ID_SYMBOL_SCANNER_2 0x1300 + +#define USB_VENDOR_ID_SYNAPTICS 0x06cb +#define USB_DEVICE_ID_SYNAPTICS_TP 0x0001 +#define USB_DEVICE_ID_SYNAPTICS_INT_TP 0x0002 +#define USB_DEVICE_ID_SYNAPTICS_CPAD 0x0003 +#define USB_DEVICE_ID_SYNAPTICS_TS 0x0006 +#define USB_DEVICE_ID_SYNAPTICS_STICK 0x0007 +#define USB_DEVICE_ID_SYNAPTICS_WP 0x0008 +#define USB_DEVICE_ID_SYNAPTICS_COMP_TP 0x0009 +#define USB_DEVICE_ID_SYNAPTICS_WTP 0x0010 +#define USB_DEVICE_ID_SYNAPTICS_DPAD 0x0013 + +#define USB_VENDOR_ID_THRUSTMASTER 0x044f + +#define USB_VENDOR_ID_TIVO 0x150a +#define USB_DEVICE_ID_TIVO_SLIDE_BT 0x1200 +#define USB_DEVICE_ID_TIVO_SLIDE 0x1201 + +#define USB_VENDOR_ID_TOPSEED 0x0766 +#define USB_DEVICE_ID_TOPSEED_CYBERLINK 0x0204 + +#define USB_VENDOR_ID_TOPSEED2 0x1784 +#define USB_DEVICE_ID_TOPSEED2_RF_COMBO 0x0004 +#define USB_DEVICE_ID_TOPSEED2_PERIPAD_701 0x0016 + +#define USB_VENDOR_ID_TOPMAX 0x0663 +#define USB_DEVICE_ID_TOPMAX_COBRAPAD 0x0103 + +#define USB_VENDOR_ID_TOUCH_INTL 0x1e5e +#define USB_DEVICE_ID_TOUCH_INTL_MULTI_TOUCH 0x0313 + +#define USB_VENDOR_ID_TOUCHPACK 0x1bfd +#define USB_DEVICE_ID_TOUCHPACK_RTS 0x1688 + +#define USB_VENDOR_ID_TPV 0x25aa +#define USB_DEVICE_ID_TPV_OPTICAL_TOUCHSCREEN 0x8883 + +#define USB_VENDOR_ID_TURBOX 0x062a +#define USB_DEVICE_ID_TURBOX_KEYBOARD 0x0201 +#define USB_DEVICE_ID_TURBOX_TOUCHSCREEN_MOSART 0x7100 + +#define USB_VENDOR_ID_TWINHAN 0x6253 +#define USB_DEVICE_ID_TWINHAN_IR_REMOTE 0x0100 + +#define USB_VENDOR_ID_UCLOGIC 0x5543 +#define USB_DEVICE_ID_UCLOGIC_TABLET_PF1209 0x0042 +#define USB_DEVICE_ID_UCLOGIC_TABLET_KNA5 0x6001 +#define USB_DEVICE_ID_UCLOGIC_TABLET_TWA60 0x0064 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP4030U 0x0003 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP5540U 0x0004 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP8060U 0x0005 +#define USB_DEVICE_ID_UCLOGIC_TABLET_WP1062 0x0064 +#define USB_DEVICE_ID_UCLOGIC_WIRELESS_TABLET_TWHL850 0x0522 +#define USB_DEVICE_ID_UCLOGIC_TABLET_TWHA60 0x0781 + +#define USB_VENDOR_ID_UNITEC 0x227d +#define USB_DEVICE_ID_UNITEC_USB_TOUCH_0709 0x0709 +#define USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19 0x0a19 + +#define USB_VENDOR_ID_VERNIER 0x08f7 +#define USB_DEVICE_ID_VERNIER_LABPRO 0x0001 +#define USB_DEVICE_ID_VERNIER_GOTEMP 0x0002 +#define USB_DEVICE_ID_VERNIER_SKIP 0x0003 +#define USB_DEVICE_ID_VERNIER_CYCLOPS 0x0004 +#define USB_DEVICE_ID_VERNIER_LCSPEC 0x0006 + +#define USB_VENDOR_ID_WACOM 0x056a +#define USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH 0x81 +#define USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH 0x00BD + +#define USB_VENDOR_ID_WALTOP 0x172f +#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_5_8_INCH 0x0032 +#define USB_DEVICE_ID_WALTOP_SLIM_TABLET_12_1_INCH 0x0034 +#define USB_DEVICE_ID_WALTOP_Q_PAD 0x0037 +#define USB_DEVICE_ID_WALTOP_PID_0038 0x0038 +#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_10_6_INCH 0x0501 +#define USB_DEVICE_ID_WALTOP_MEDIA_TABLET_14_1_INCH 0x0500 +#define USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET 0x0502 + +#define USB_VENDOR_ID_WISEGROUP 0x0925 +#define USB_DEVICE_ID_SMARTJOY_PLUS 0x0005 +#define USB_DEVICE_ID_1_PHIDGETSERVO_20 0x8101 +#define USB_DEVICE_ID_4_PHIDGETSERVO_20 0x8104 +#define USB_DEVICE_ID_8_8_4_IF_KIT 0x8201 +#define USB_DEVICE_ID_SUPER_JOY_BOX_3 0x8888 +#define USB_DEVICE_ID_QUAD_USB_JOYPAD 0x8800 +#define USB_DEVICE_ID_DUAL_USB_JOYPAD 0x8866 + +#define USB_VENDOR_ID_WISEGROUP_LTD 0x6666 +#define USB_VENDOR_ID_WISEGROUP_LTD2 0x6677 +#define USB_DEVICE_ID_SMARTJOY_DUAL_PLUS 0x8802 +#define USB_DEVICE_ID_SUPER_JOY_BOX_3_PRO 0x8801 +#define USB_DEVICE_ID_SUPER_DUAL_BOX_PRO 0x8802 +#define USB_DEVICE_ID_SUPER_JOY_BOX_5_PRO 0x8804 + +#define USB_VENDOR_ID_X_TENSIONS 0x1ae7 +#define USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE 0x9001 + +#define USB_VENDOR_ID_XAT 0x2505 +#define USB_DEVICE_ID_XAT_CSR 0x0220 + +#define USB_VENDOR_ID_XIROKU 0x1477 +#define USB_DEVICE_ID_XIROKU_SPX 0x1006 +#define USB_DEVICE_ID_XIROKU_MPX 0x1007 +#define USB_DEVICE_ID_XIROKU_CSR 0x100e +#define USB_DEVICE_ID_XIROKU_SPX1 0x1021 +#define USB_DEVICE_ID_XIROKU_CSR1 0x1022 +#define USB_DEVICE_ID_XIROKU_MPX1 0x1023 +#define USB_DEVICE_ID_XIROKU_SPX2 0x1024 +#define USB_DEVICE_ID_XIROKU_CSR2 0x1025 +#define USB_DEVICE_ID_XIROKU_MPX2 0x1026 + +#define USB_VENDOR_ID_YEALINK 0x6993 +#define USB_DEVICE_ID_YEALINK_P1K_P4K_B2K 0xb001 + +#define USB_VENDOR_ID_ZEROPLUS 0x0c12 + +#define USB_VENDOR_ID_ZYDACRON 0x13EC +#define USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL 0x0006 + +#define USB_VENDOR_ID_ZYTRONIC 0x14c8 +#define USB_DEVICE_ID_ZYTRONIC_ZXY100 0x0005 + +#define USB_VENDOR_ID_PRIMAX 0x0461 +#define USB_DEVICE_ID_PRIMAX_KEYBOARD 0x4e05 + +#endif diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index e451c515..3b6b1c49 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -5,6 +5,13 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) +#include + +#define HID_BUS_ANY 0xffff +#define HID_GROUP_ANY 0x0000 + +extern bool hid_ignore(struct hid_device *); + /* This backports: * * commit 4b20db3de8dab005b07c74161cb041db8c5ff3a7 -- cgit v1.2.3 From eaae33b21be142759d3cb6d31fc90a15d0f02982 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Dec 2012 18:26:45 -0800 Subject: compat: backport PCI_EXP_LNKCTL_ASPM_L0S and PCI_EXP_LNKCTL_ASPM_L1 This backports the addition of two defines added by the commit below. commit 7508320678b7819ac6aeb89580b8622a424ce586 Author: Bjorn Helgaas Date: Wed Dec 5 13:51:19 2012 -0700 PCI: Add standard PCIe Capability Link ASPM field names Add standard #defines for ASPM fields in PCI Express Link Capability and Link Control registers. Previously we used PCIE_LINK_STATE_L0S and PCIE_LINK_STATE_L1 directly, but these are defined for the Linux ASPM interfaces, e.g., pci_disable_link_state(), and only coincidentally match the actual register bits. PCIE_LINK_STATE_CLKPM, also part of that interface, does not match the register bit. Signed-off-by: Bjorn Helgaas Reviewed-by: Kenji Kaneshige Acked-by: Kenji Kaneshige Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.8.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 3b6b1c49..052de957 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -10,6 +10,9 @@ #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 +#define PCI_EXP_LNKCTL_ASPM_L0S 0x01 /* L0s Enable */ +#define PCI_EXP_LNKCTL_ASPM_L1 0x02 /* L1 Enable */ + extern bool hid_ignore(struct hid_device *); /* This backports: -- cgit v1.2.3 From baab561aec208a7b1c583dae9d51d745dd2c262d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 11 Dec 2012 18:47:44 -0800 Subject: compat: backport definition of HID_TYPE_USBNONE This is declared within the enum: enum hid_type { HID_TYPE_OTHER = 0, HID_TYPE_USBMOUSE, HID_TYPE_USBNONE }; But we just declare it as a define for 2. This backports was added with the below commit: mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 6dc1418e v3.1-rc1~309^2^2~14 commit 6dc1418e13144162e8bc4858789010d8f0e1e65c Author: Tomoki Sekiyama Date: Mon May 23 15:45:44 2011 -0700 HID: yurex: recognize GeneralKeys wireless presenter as generic HID Unfortunately, the device seems to have the same Vendor ID and Product ID as YUREX leg-shakes sensors, and the commit 6bc235a2e2 ("USB: add driver for Meywa-Denki & Kayac YUREX") added the ID to hid_ignore_list. I believe that we can distinguish YUREX and the Wireless Presenter by device type. The patch below makes the driver ignore only YUREX (bInterfaceProtocol==0), and recognize Wireless Presenter (bInterfaceProtocol is keyboard or mouse) as generic HID. (I don't have the Wireless Presenter, so not yet ested.) ** YUREX lsusb information: Bus 002 Device 007: ID 0c45:1010 Microdia Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 1.10 bDeviceClass 0 (Defined at Interface level) bDeviceSubClass 0 bDeviceProtocol 0 bMaxPacketSize0 8 idVendor 0x0c45 Microdia idProduct 0x1010 bcdDevice 0.03 iManufacturer 1 JESS iProduct 2 YUREX iSerial 3 10000269 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 34 bNumInterfaces 1 bConfigurationValue 1 iConfiguration 0 bmAttributes 0xa0 (Bus Powered) Remote Wakeup MaxPower 100mA Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 1 bInterfaceClass 3 Human Interface Device bInterfaceSubClass 1 Boot Interface Subclass bInterfaceProtocol 0 None iInterface 0 HID Device Descriptor: bLength 9 bDescriptorType 33 bcdHID 1.10 bCountryCode 0 Not supported bNumDescriptors 1 bDescriptorType 34 Report wDescriptorLength 31 Report Descriptors: ** UNAVAILABLE ** Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0008 1x 8 bytes bInterval 10 Device Status: 0x0002 (Bus Powered) Remote Wakeup Enabled Addresses https://bugzilla.kernel.org/show_bug.cgi?id=26922 Signed-off-by: Tomoki Sekiyama Cc: Greg KH Cc: "Rafael J. Wysocki" Cc: Maciej Rutecki Reported-by: Thomas B?chler Tested-by: Thomas B?chler Signed-off-by: Andrew Morton Signed-off-by: Jiri Kosina Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.1.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 3afca9a6..9d78b7d6 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -11,6 +11,7 @@ #include #include +#define HID_TYPE_USBNONE 2 /* This backports: * -- cgit v1.2.3 From e90763ed198be5ed5bc4aad504ba719a9e01004a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 07:49:18 -0800 Subject: compat: add HID_QUIRK_HIDDEV_FORCE and HID_QUIRK_NO_IGNORE We just need the definitions. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains b5e5a37e v2.6.35-rc1~454^2~5^2~14 commit b5e5a37e36cd4d355b875665312d7aaae4e5833c Author: Bastien Nocera Date: Fri Apr 16 17:19:50 2010 +0100 HID: add HID_QUIRK_HIDDEV_FORCE and HID_QUIRK_NO_IGNORE Add two quirks to make it possible for usbhid module options to override whether a device is ignored (HID_QUIRK_NO_IGNORE) and whether to connect a hiddev device (HID_QUIRK_HIDDEV_FORCE). Passing HID_QUIRK_NO_IGNORE for your device means that it will not be ignored by the HID layer, even if present in a blacklist. HID_QUIRK_HIDDEV_FORCE will force the creation of a hiddev for that device, making it accessible from user-space. Tested with an Apple IR Receiver, switching it from using appleir to using lirc's macmini driver. Signed-off-by: Bastien Nocera Signed-off-by: Jiri Kosina Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.35.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 22981a94..b06638ac 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -11,6 +11,9 @@ #include #include +#define HID_QUIRK_NO_IGNORE 0x40000000 +#define HID_QUIRK_HIDDEV_FORCE 0x00000010 + /* added on linux/kernel.h */ #define USHRT_MAX ((u16)(~0U)) #define SHRT_MAX ((s16)(USHRT_MAX>>1)) -- cgit v1.2.3 From 20ace7394d5cd5011836ccf7d30dc378ab130676 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 09:47:09 -0800 Subject: compat: add HID_QUIRK_IGNORE Just add the define. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 6f4303fb v2.6.30-rc1~219^2~9 commit 6f4303fb2ec68055e793b84887a7ae0f9ea7cc2d Author: Jiri Kosina Date: Thu Jan 29 00:15:51 2009 +0100 HID: bring back possibility to specify vid/pid ignore on module load When hid quirks were converted to specialized driver, the HID_QUIRK_IGNORE has been moved completely, as the hid_ignore_list[] has been moved into the generic code. However userspace already got used to the possibility that modprobing usbhid with 'quirks=vid:pid:0x4' makes the device ignored by usbhid driver. So keep this quirk flag in place for backwards compatibility. Signed-off-by: Jiri Kosina Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.30.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.30.h b/include/linux/compat-2.6.30.h index b4aafaec..5841b6c8 100644 --- a/include/linux/compat-2.6.30.h +++ b/include/linux/compat-2.6.30.h @@ -8,6 +8,8 @@ #include #include +#define HID_QUIRK_IGNORE 0x00000004 + #ifndef TP_PROTO #define TP_PROTO(args...) TPPROTO(args) #endif -- cgit v1.2.3 From 72758681942b4bf4b5e5b05efddd2ecce5653bb8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 11:54:49 -0800 Subject: compat: backport HID_USB_DEVICE() and HID_BLUETOOTH_DEVICE() commit 070748ed0b52399858a5967026a452bbb903a64c Author: Henrik Rydberg Date: Mon Apr 23 12:07:05 2012 +0200 HID: Create a generic device group Devices that do not have a special driver are handled by the generic driver. This patch does the same thing using device groups; Instead of forcing a particular driver, the appropriate driver is picked up by udev. As a consequence, one can now move a device from generic to specific handling by a simple rebind. By adding a new device id to the generic driver, the same thing can be done in reverse. Signed-off-by: Henrik Rydberg Acked-by: Benjamin Tissoires Signed-off-by: Jiri Kosina Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.8.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 052de957..46d90a10 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -7,6 +7,11 @@ #include +#define HID_USB_DEVICE(ven, prod) \ + .bus = BUS_USB, .vendor = (ven), .product = (prod) +#define HID_BLUETOOTH_DEVICE(ven, prod) \ + .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod) + #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 -- cgit v1.2.3 From 5d6b7867c8ab9f1d9af77ad9b6c752819e66db46 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 20:18:00 -0800 Subject: compat: backport struct hid_device_id Kernels older than 2.6.28 did not have this defined. Add it. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains e8c84f9a v2.6.28-rc1~571^2~54 commit e8c84f9a5f06912c94c38961096c994da3890a2e Author: Jiri Slaby Date: Mon May 19 15:50:01 2008 +0200 modpost: add support for hid Generate aliases for hid device modules to support autoloading. Signed-off-by: Jiri Slaby Signed-off-by: Jiri Kosina Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.28.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 8df4e461..b82a7eae 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -11,6 +11,17 @@ #include #include #include +#include + +#define HID_ANY_ID (~0) + +struct hid_device_id { + __u16 bus; + __u32 vendor; + __u32 product; + kernel_ulong_t driver_data + __attribute__((aligned(sizeof(kernel_ulong_t)))); +}; #ifndef ETH_P_PAE #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -- cgit v1.2.3 From 54783c5b8bd5798320ca948ce00fa88b3b3c8211 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 20:38:14 -0800 Subject: compat: fix compilation on hid_ignore() This fixes compilation on the addition of hid_ignore() for kernels older than 2.6.28. mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m58.798s user 3m59.967s sys 1m25.585s Signed-off-by: Luis R. Rodriguez --- compat/compat-3.8.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index c7df1743..034dd776 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -317,24 +317,37 @@ bool hid_ignore(struct hid_device *hdev) return true; break; case USB_VENDOR_ID_JESS: +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) if (hdev->product == USB_DEVICE_ID_JESS_YUREX && hdev->type == HID_TYPE_USBNONE) return true; +#else + if (hdev->product == USB_DEVICE_ID_JESS_YUREX) + return true; +#endif break; case USB_VENDOR_ID_DWAV: /* These are handled by usbtouchscreen. hdev->type is probably * HID_TYPE_USBNONE, but we say !HID_TYPE_USBMOUSE to match * usbtouchscreen. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) if ((hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER || hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) && hdev->type != HID_TYPE_USBMOUSE) return true; +#else + if (hdev->product == USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER || + hdev->product == USB_DEVICE_ID_DWAV_TOUCHCONTROLLER) + return true; +#endif break; } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)) if (hdev->type == HID_TYPE_USBMOUSE && hid_match_id(hdev, hid_mouse_ignore_list)) return true; +#endif return !!hid_match_id(hdev, hid_ignore_list); } -- cgit v1.2.3 From 1337db88b14e369de099e11d50a3038b64c5dfad Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 12 Dec 2012 11:45:05 -0800 Subject: compat: backport platform_device_register_data() Add the helper. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains d8bf254 v2.6.28-rc1~284^2~9 commit d8bf254089a6c31d7d01a4d1d2f1861662900855 Author: Dmitry Baryshkov Date: Mon Sep 22 14:41:40 2008 -0700 platform: add new device registration helper Add a helper that registers simple platform_device w/o resources but with parent and device data. This is usefull to cleanup platform code from code that registers such simple devices as leds-gpio, generic-bl, etc. Signed-off-by: Dmitry Baryshkov Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman mcgrof@drvbp1 ~/compat (git::master)$ time ckmake Trying kernel 3.6.5-030605-generic [OK] Trying kernel 3.5.7-030507-generic [OK] Trying kernel 3.4.17-030417-generic [OK] Trying kernel 3.3.8-030308-generic [OK] Trying kernel 3.2.33-030233-generic [OK] Trying kernel 3.1.10-030110-generic [OK] Trying kernel 3.0.50-030050-generic [OK] Trying kernel 2.6.39-02063904-generic [OK] Trying kernel 2.6.38-02063808-generic [OK] Trying kernel 2.6.37-02063706-generic [OK] Trying kernel 2.6.36-02063604-generic [OK] Trying kernel 2.6.35-02063513-generic [OK] Trying kernel 2.6.34-02063413-generic [OK] Trying kernel 2.6.33-02063320-generic [OK] Trying kernel 2.6.32-02063260-generic [OK] Trying kernel 2.6.31-02063113-generic [OK] Trying kernel 2.6.30-02063010-generic [OK] Trying kernel 2.6.29-02062906-generic [OK] Trying kernel 2.6.28-02062810-generic [OK] Trying kernel 2.6.27-020627-generic [OK] Trying kernel 2.6.26-020626-generic [OK] Trying kernel 2.6.25-020625-generic [OK] Trying kernel 2.6.24-020624-generic [OK] real 1m58.798s user 3m59.967s sys 1m25.585s Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.28.c | 48 +++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.28.h | 4 ++++ 2 files changed, 52 insertions(+) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 0ae8f465..6be54427 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -11,10 +11,58 @@ #include #include #include +#include #include /* 2.6.28 compat code goes here */ +/** + * platform_device_register_data + * @parent: parent device for the device we're adding + * @name: base name of the device we're adding + * @id: instance id + * @data: platform specific data for this platform device + * @size: size of platform specific data + * + * This function creates a simple platform device that requires minimal + * resource and memory management. Canned release function freeing memory + * allocated for the device allows drivers using such devices to be + * unloaded without waiting for the last reference to the device to be + * dropped. + */ +struct platform_device *platform_device_register_data( + struct device *parent, + const char *name, int id, + const void *data, size_t size) +{ + struct platform_device *pdev; + int retval; + + pdev = platform_device_alloc(name, id); + if (!pdev) { + retval = -ENOMEM; + goto error; + } + + pdev->dev.parent = parent; + + if (size) { + retval = platform_device_add_data(pdev, data, size); + if (retval) + goto error; + } + + retval = platform_device_add(pdev); + if (retval) + goto error; + + return pdev; + +error: + platform_device_put(pdev); + return ERR_PTR(retval); +} + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) /* diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index b82a7eae..9f1b6290 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -29,6 +29,10 @@ struct hid_device_id { #include #include +#include + +extern struct platform_device *platform_device_register_data(struct device *, + const char *, int, const void *, size_t); typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } compat_cpumask_t; -- cgit v1.2.3 From 7b4510d2d3de9bd8b849aed02806d261380c93e8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:20:34 -0800 Subject: compat: adjust get-compat-kernels for root usage If the user id is root then don't assume we want it under / but instead use the current directory. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index ff5f1bdb..ce405e66 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -29,8 +29,11 @@ KSRC_PREFIX= # else, use $HOME/compat-ksrc for enabling user-mode builds. if [[ "$EUID" != "0" ]]; then KSRC_PREFIX="$HOME/compat-ksrc" +else + KSRC_PREFIX="${PWD}" fi + # Create target directories if they doesn't exist mkdir -p $KSRC_PREFIX/{usr/src,lib/modules} @@ -213,7 +216,7 @@ echo -e "" if [[ ! -n $KSRC_PREFIX ]]; then echo -e "** Running as a privileged user!" - echo -e "** You are trying to force using system-wide ${BLUE}/lib/modules${NORMAL} and ${BLUE}/usr/src${NORMAL} ..." + echo -e "** You are trying to force using ${BLUE}${KSRC_PREFIX}/lib/modules${NORMAL} and ${BLUE}${KSRC_PREFIX}/usr/src${NORMAL} ..." echo -e "** This is a terrible idea. Consider running as a regular user." echo -e "" read -p "Do you still want to continue (y/N)? " -- cgit v1.2.3 From 374300c797605413565f2f5cf40a6dd9a12101bc Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:22:35 -0800 Subject: compat: adjust get-compat-kernels for root users Prefix the download / target directory with compat-ksrc/ if root is used. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index ce405e66..0e012330 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -30,7 +30,7 @@ KSRC_PREFIX= if [[ "$EUID" != "0" ]]; then KSRC_PREFIX="$HOME/compat-ksrc" else - KSRC_PREFIX="${PWD}" + KSRC_PREFIX="${PWD}/compat-ksrc" fi -- cgit v1.2.3 From 3ea353961751f739998465405571dbe8ec024cb8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:26:14 -0800 Subject: compat: add v3.7 to get-compat-kernels Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 0e012330..28034d8d 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -61,6 +61,7 @@ KERNELS="$KERNELS ${KPATH}/v3.3.8-quantal/linux-headers-3.3.8-030308_3.3.8-03030 KERNELS="$KERNELS ${KPATH}/v3.4.17-quantal/linux-headers-3.4.17-030417_3.4.17-030417.201210311354_all.deb" KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-030507.201210130556_all.deb" KERNELS="$KERNELS ${KPATH}/v3.6.5-raring/linux-headers-3.6.5-030605_3.6.5-030605.201211011211_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.7-raring/linux-headers-3.7.0-030700_3.7.0-030700.201212102335_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From faa905dae480f012b9718006667c51f6368072ba Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:32:21 -0800 Subject: compat: add support for forcing get-compat-kernels Useful for cronjobs. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 28034d8d..5d97e31c 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -23,6 +23,7 @@ UNDERLINE="\033[02m" KERNELS="" KPATH="http://kernel.ubuntu.com/~kernel-ppa/mainline/" +FORCE="0" KSRC_PREFIX= # Check whether we're running as root or not # If we're root stuff things into /usr/src and /lib/modules @@ -185,7 +186,7 @@ function rebuild_header_binary_deps() { } function usage() { - echo -e "Usage: $0 [ -r ] " + echo -e "Usage: $0 [ -r ] [ -f ] " echo -e "-r Rebuilds binaries required in kernel headers. Use" echo -e " this option if you've already ran this script and" echo -e " just need to fix the libc versions against which" @@ -193,9 +194,11 @@ function usage() { echo -e " This was added since kernels >= 3.4 require" echo -e " a glibc >= 2.14 for memcpy(), and not all Linux" echo -e " distributions have such versions of glibc." + echo -e "" + echo -e "-f Force running, do not ask" } -if [[ $# -gt 2 ]]; then +if [[ $# -gt 3 ]]; then usage exit 1 fi @@ -205,6 +208,11 @@ if [[ $1 == "-r" ]]; then exit fi +if [[ $1 == "-f" ]]; then + FORCE="1" + shift +fi + # Check for the availability of 'ar' before continuing which ar 2>&1 > /dev/null if [[ $? -ne 0 ]]; then @@ -240,10 +248,12 @@ echo -e "" echo -e "${BLUE}http://kernel.ubuntu.com/~kernel-ppa/mainline/${NORMAL}" echo -e "" -read -p "Do you still want to continue (y/N)? " -if [[ "${REPLY}" != "y" ]]; then - echo -e "Bailing out !" - exit 1 +if [[ "$FORCE" != "1" ]]; then + read -p "Do you still want to continue (y/N)? " + if [[ "${REPLY}" != "y" ]]; then + echo -e "Bailing out !" + exit 1 + fi fi get_ubuntu_kernels -- cgit v1.2.3 From 0f11f22d84ab51ac95b1665c3c083c7a470f5461 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:54:01 -0800 Subject: compat: fix get-compat-kernels for rebuilding kernel headers We need to rebuild headers for kernels >= 3.4, and while at it account for 4.0 and x.y kernels here x > 3. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 5d97e31c..85ef00d8 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -169,7 +169,7 @@ function rebuild_header_binary_deps() { exit 1 fi - for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | tail -3); do + for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | grep -E "/3.[4-9]|/[4-9]"); do echo $kernel count=0 -- cgit v1.2.3 From 744a6ddc41ee2e40f38b0230ee4bd1d9683b8154 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 14 Dec 2012 16:59:59 -0800 Subject: compat: add 3.2 and 3.3 kernels to rebuild headers The 3.2 and 3.3 kernels also require rebuilding kernel headers for glibc dependencies. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 85ef00d8..b8cbb5e9 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -169,7 +169,7 @@ function rebuild_header_binary_deps() { exit 1 fi - for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | grep -E "/3.[4-9]|/[4-9]"); do + for kernel in $(ls -d ${KSRC_PREFIX}/lib/modules/*generic | grep -E "/3.[2-9]|/[4-9]"); do echo $kernel count=0 -- cgit v1.2.3 From a3fad85cce070c0f8a296d4fdb35926e67ea7b6d Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 18 Dec 2012 20:06:39 -0800 Subject: compat: rewrite ckmake in Python This rewrites ckmake in Python. I suspected that we can still improve compilation down by making ckmake multithreaded. I was right, and in order to make this multithreaded I picked python and ncurses to display results. This shaves down 6 minutes for compilation of compat-drivers on 24 kernels from 25 minutes down to 19 minutes. This can likely be improved further. Before: real 25m28.705s user 506m26.003s sys 69m45.990s After: real 19m4.757s user 486m26.236s sys 70m5.579s Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 582 ++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 321 insertions(+), 261 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 5fd3e7f3..97227763 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -1,267 +1,327 @@ -#!/bin/bash -# -# Copyright (C) 2012, Luis R. Rodriguez -# Copyright (C) 2012, Hauke Mehrtens +#!/usr/bin/env python + +# ncurses Linux kernel cross kernel compilation utility + +# Copyright (C) 2012 Luis R. Rodriguez # # 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. -# -# You can use this to compile a module accross all installed kernels -# found. This relies on distribution specific kernels, but can handle -# your own custom list of target kernels. Log is setnt to LOG variable. - - -#export KCFLAGS="-Wno-unused-but-set-variable" -KERNEL_DIR="/lib/modules" -KLIBS="" -LOG="ckmake.log" -LOG_TMP="ckmake-tmp.log" -REPORT="ckmake-report.log" -TIME="0" -DEBUG="0" -NOCOLOR="0" -ARGS="" -QUIET="" -RET_FILE="ret-tmp.txt" - -# First and last kernels to use -FIRST="" -LAST="" -RANGE="" - -RET="" -NUM_CPUS=$(echo $(($(cat /proc/cpuinfo | grep processor | tail -1 | awk '{print $3}')+1))) - -# If $HOME/compat-ksrc is found use that, otherwise use system-wide -# sources in /usr/src. -KSRC_PREFIX= -if [[ -d "$HOME/compat-ksrc" ]]; then - KSRC_PREFIX="$HOME/compat-ksrc" -fi - -# Colorify output if NOCOLOR != 1 or -n is not given -function prettify() -{ - if [[ $NOCOLOR == "1" ]]; then - echo -n "$2" - else - ANSI_CODE= - NORMAL="\033[00m" - case $1 in - "green") - ANSI_CODE="\033[01;32m" - ;; - "yellow") - ANSI_CODE="\033[01;33m" - ;; - "blue") - ANSI_CODE="\033[34m" - ;; - "red") - ANSI_CODE="\033[31m" - ;; - "purple") - ANSI_CODE="\033[35m" - ;; - "cyan") - ANSI_CODE="\033[36m" - ;; - "underline") - ANSI_CODE="\033[02m" - ;; - esac - - echo -e -n "${ANSI_CODE}$2${NORMAL}" - fi -} -function tee_color_split() -{ - while read; do - echo -e $REPLY | perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g' >> $1 - echo -e $REPLY - done -} - -function log_try_kernel() -{ - printf "Trying kernel %40s\t" "$(prettify blue $1)" -} - -function usage() -{ - echo -e "Usage: $0 [-t] " - echo -e "-t will run: 'time ckmake; time ckmake' account for" - echo -e " benchmark how long it takes to compile without ccache" - echo -e " and a run after cache kicks in" - echo -e "-n Do not use colors in the output" - echo -e "-q will ask ckmake to run make with -s to only output errors" - echo - echo -e " is the arguments you want to pass to the" - echo -e "child make call that ckmake will use. For example if you have" - echo -e "a target 'linux' on your Makefile you can run 'cmake linux'" - echo -e "" - echo -e " are the kernels you want to test" - echo -e "compile against. This consists of a range. The third extraversion" - echo -e "number is ignored" -} - -for i in $@ ; do - case $1 in - "-h") - usage - exit 1 - ;; - "--help") - usage - exit 1 - ;; - "-t") - TIME="1" - shift - ;; - "-n") - NOCOLOR="1" - shift - ;; - "-s") - QUIET="-s" - shift - ;; - "-d") - DEBUG="1" - shift - ;; - *) - echo $i | grep "\.\." 2>&1 > /dev/null - if [[ $? -eq 0 ]]; then - FIRST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $1}') - LAST=$(echo $i | sed 's|\.\.|-|' | awk -F"-" '{print $2}') - RANGE="${FIRST}..${LAST}" - echo -e "Going to use kernel ranges: $(prettify blue $FIRST)..$(prettify blue $LAST)" - shift - fi - - ARGS="${ARGS} $1" - shift - esac -done - -function run_ckmake() -{ - for i in $KLIBS; do - KERNEL=$(basename $i) - DIR=${i}/build/ - echo -e "--------------------------------------------" >> $LOG - - if [[ ! -d $DIR ]]; then +import locale +import curses +import time +import os +import re +import random +import tempfile +import subprocess +import sys +import signal + +from Queue import * +from threading import Thread, Lock +from shutil import copytree, ignore_patterns, rmtree, copyfileobj + +releases_processed = [] +releases_baking = [] +processed_lock = Lock() +baking_lock = Lock() +my_cwd = os.getcwd() +ckmake_return = 0 + +tmp_path = my_cwd + "/.tmp.ckmake" +ckmake_log = my_cwd + "/ckmake.log" +ckmake_report = my_cwd + "/ckmake-report.log" + +home = os.getenv("HOME") +ksrc = home + "/" + "compat-ksrc" +modules = ksrc + "/lib/modules" + +def clean(): + if os.path.exists(tmp_path): + rmtree(tmp_path) + +def get_processed_rel(i): + "Because... list.pop(i) didn't work to keep order..." + processed_lock.acquire() + for rel in releases_processed: + if (rel['idx'] == i): + processed_lock.release() + return rel + processed_lock.release() + + baking_lock.acquire() + for rel in releases_baking: + if (rel['idx'] == i): + releases_baking.remove(rel) + baking_lock.release() + return rel + baking_lock.release() + +def get_status_name(status): + if (status == 0): + return 'OK' + if (status == 2): + return 'OK' + elif (status == 130): + return 'TERM' + elif (status == 1234): + return 'INIT' + elif (status == -2): + return 'TERM' + else: + return 'FAIL' + +def get_stat_pos(status): + if (status == 0): + return 34 + if (status == 2): + return 34 + elif (status == 130): + return 33 + elif (status == 1234): + return 33 + elif (status == -2): + return 33 + else: + return 33 + +def get_status_color(status): + if (status == 0): + return curses.color_pair(1) + if (status == 2): + return curses.color_pair(1) + elif (status == 130): + return curses.color_pair(2) + elif (status == 1234): + return curses.color_pair(2) + elif (status == -2): + return curses.color_pair(2) + else: + return curses.color_pair(3) + +def print_report(): + os.system("clear") + sys.stdout.write("\n\n\n") + sys.stdout.write("== ckmake-report.log ==\n\n") + report = open(ckmake_report, 'r+') + copyfileobj(report, sys.stdout) + report.close() + +def process_logs(): + os.system('clear') + log = open(ckmake_log, 'w+') + report = open(ckmake_report, 'w+') + for i in range(0, len(releases_processed)): + rel = get_processed_rel(i) + rel_log = open(rel['log'], 'r+') + log.write(rel_log.read()) + status = get_status_name(rel['status']) + rel_report = "%-4s%-20s[ %s ]\n" % \ + ( rel['idx']+1, rel['version'], status) + report.write(rel_report) + if (rel['status'] != 0 and + rel['status'] != 2): + ckmake_return = -1 + report.close() + log.close() + print_report() + +def process_kernel(num, kset): + while True: + rel = kset.queue.get() + work_dir = tmp_path + '/' + rel['version'] + copytree(my_cwd, \ + work_dir, \ + ignore=ignore_patterns('\.git*', '.tmp*', ".git")) + build = '%s/build/' % rel['full_path'] + jobs = ' -j%d ' % kset.build_jobs + make_args = 'KLIB=%(build)s KLIB_BUILD=%(build)s' % \ + { "build": build } + log_file = work_dir + '/' + 'ckmake.n.log' + rel['log'] = log_file + # XXX: figure out how to properly address logging + # without this nasty ass hack. + log = ' > %(log)s 2>&1' % { "log": log_file } + cmd = 'make ' + jobs + make_args + log + + kset.baking(rel) + + p = subprocess.Popen([cmd], + cwd = work_dir, + stdout=None, + stderr=None, + shell=True) + p.wait() + + kset.update_status(rel, p.returncode) + kset.queue.task_done() + kset.completed(rel) + +def cpu_info_build_jobs(): + if not os.path.exists('/proc/cpuinfo'): + return 1 + f = open('/proc/cpuinfo', 'r') + max_cpus = 1 + for line in f: + m = re.match(r"(?Pprocessor\s*:)\s*" \ + "(?P\d+)", + line) + if not m: continue - fi - - NOCOLOR="1" log_try_kernel $KERNEL >> $LOG - log_try_kernel $KERNEL - - #ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j${NUM_CPUS} -Wunused-but-set-variable $ARGS &>> $LOG - ionice -c 3 nice -n 20 make $QUIET KLIB=$DIR KLIB_BUILD=$DIR -j${NUM_CPUS} $ARGS &>> $LOG - CUR_RET=$? - - if [[ $RET = "" ]]; then - RET=$CUR_RET - fi - - if [[ $CUR_RET -eq 0 ]]; then - echo -e "$(prettify green [OK])" | tee_color_split $LOG - else - echo -e "$(prettify red [FAILED])" | tee_color_split $LOG - RET=$CUR_RET - fi - - nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG - done - # Bash doesn't do what we expect with the variables... - # and using return $RET here won't work here either given - # that we end up piping the result anyway. - echo $RET > $RET_FILE -} - -# This mimic's the kernel's own algorithm: -# -# KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -function kernel_version_orig { - echo "$@" | awk -F. '{ printf("%d\n", lshift($1,16) + lshift($2, 8) + $3); }' -} - -function kernel_version_26 { - kernel_version_orig $@ -} - -# Ignores the last extraversion number -function kernel_version_30 { - echo "$@" | awk -F. '{ printf("%d\n", lshift($1,16) + lshift($2, 8) ); }' -} - -# If we're using 3.0 kernels we do not require an extraversion, -# although one could be supplied. For purposes of this script -# though the 2.6.29..3.1 ranges are acceptable. If we forced usage -# of kernel_version_orig() for 3.0 it means we'd have to require a user -# to be very specific and specific 2.6.29..3.1.0 or whatever. Lets -# instead be flexible. -function kernel_version { - if [[ $(kernel_version_orig $@ ) -lt $(kernel_version_orig "3.0") ]] ; then - echo $(kernel_version_26 $@) - else - echo $(kernel_version_30 $@) - fi -} - -for i in $(find $KSRC_PREFIX/lib/modules/ -type d -name \*generic\* | sort -n -r | grep -v -E '\-[[:alnum:]]{1,2}\-'); do - KERNEL=$(echo ${i} | awk -F"/" '{print $NF}' | awk -F"-" '{print $1}') - - if [[ ! -z $FIRST && ! -z $LAST ]]; then - if [[ $(kernel_version $KERNEL ) -lt $(kernel_version $FIRST) ]] ; then - continue; - fi - - if [[ $(kernel_version $KERNEL ) -gt $(kernel_version $LAST) ]] ; then - continue; - fi - - if [[ ! -z $DEBUG ]]; then - echo -e "$(prettify cyan $FIRST) $(kernel_version $FIRST) <= $(prettify green $KERNEL) $(kernel_version $KERNEL) <= $(prettify cyan $LAST) $(kernel_version $LAST)" - fi - fi - - KLIBS="$KLIBS $i" -done - -for i in $LOG $LOG_TMP $REPORT; do - echo > $i -done - -DIR="$(echo $KLIBS | awk '{print $1}')/build" -nice make clean KLIB=$DIR KLIB_BUILD=$DIR 2>&1 >> $LOG - -if [[ $TIME != "1" ]]; then - run_ckmake | tee_color_split $REPORT - - cat $LOG $REPORT > $LOG_TMP - mv $LOG_TMP $LOG - rm -f $LOG_TMP - - RET=$(cat $RET_FILE) - exit $RET -fi - -time $0 $QUIET ${RANGE} $ARGS | tee_color_split $REPORT -time $0 $QUIET ${RANGE} $ARGS | egrep "real|user|sys" | tee_color_split $REPORT - -cat $LOG $REPORT > $LOG_TMP -mv $LOG_TMP $LOG - -rm -f $LOG_TMP - -RET=$(cat $RET_FILE) -rm -f $RET_FILE - -exit $RET + proc_specs = m.groupdict() + if (proc_specs['NUM'] > max_cpus): + max_cpus = proc_specs['NUM'] + return int(max_cpus) + 1 + +def kill_curses(): + curses.endwin() + sys.stdout = os.fdopen(0, 'w', 0) + +def sig_handler(signal, frame): + kill_curses() + process_logs() + clean() + sys.exit(-2) + +class kernel_set(): + def __init__(self, stdscr): + self.queue = Queue() + self.releases = [] + self.stdscr = stdscr + self.lock = Lock() + signal.signal(signal.SIGINT, sig_handler) + self.build_jobs = cpu_info_build_jobs() + if (curses.has_colors()): + curses.init_pair(1, + curses.COLOR_GREEN, + curses.COLOR_BLACK) + curses.init_pair(2, + curses.COLOR_CYAN, + curses.COLOR_BLACK) + curses.init_pair(3, + curses.COLOR_RED, + curses.COLOR_BLACK) + curses.init_pair(4, + curses.COLOR_BLUE, + curses.COLOR_BLACK) + def baking(self, rel): + baking_lock.acquire() + releases_baking.append(rel) + baking_lock.release() + def completed(self, rel): + processed_lock.acquire() + releases_processed.insert(rel['idx'], rel) + processed_lock.release() + def set_locale(self): + locale.setlocale(locale.LC_ALL, '') + code = locale.getpreferredencoding() + def refresh(self): + self.lock.acquire() + self.stdscr.refresh() + self.lock.release() + def parse_releases(self): + for dirname, dirnames, filenames in os.walk(modules): + dirnames.sort() + for subdirname in dirnames: + m = re.match(r"v*(?P\w+.)" \ + "(?P\w+.*)" \ + "(?P\w*)" \ + "(?P[.-]\w*)" \ + "(?P[-]\w*).*", \ + subdirname) + if not m: + continue + + specifics = m.groupdict() + + ver = specifics['VERSION'] + \ + specifics['PATCHLEVEL'] + \ + specifics['SUBLEVEL'] + + for rel in self.releases: + if (rel['version'] == ver): + continue + + rel = dict(idx=len(self.releases), + name=subdirname, + full_path=dirname + '/' + + subdirname, + version=ver, + processed=False, + log='', + status=1234) + self.releases.insert(rel['idx'], rel) + self.refresh() + def setup_screen(self): + for i in range(0, len(self.releases)): + rel = self.releases[i] + self.lock.acquire() + self.stdscr.addstr(rel['idx'], 0, + "%-4d" % (rel['idx']+1)) + if (curses.has_colors()): + self.stdscr.addstr(rel['idx'], 5, + "%-20s" % (rel['version']), + curses.color_pair(4)) + else: + self.stdscr.addstr(rel['idx'], 0, + "%-20s" % (rel['version'])) + self.stdscr.addstr(rel['idx'], 30, "[ ]") + self.stdscr.refresh() + self.lock.release() + def create_threads(self): + for rel in self.releases: + th = Thread(target=process_kernel, args=(0, self)) + th.setDaemon(True) + th.start() + def kick_threads(self): + for rel in self.releases: + self.queue.put(rel) + def wait_threads(self): + self.queue.join() + def update_status(self, rel, status): + self.lock.acquire() + stat_name = get_status_name(status) + stat_pos = get_stat_pos(status) + if (curses.has_colors()): + stat_color = get_status_color(status) + self.stdscr.addstr(rel['idx'], stat_pos, stat_name, + get_status_color(status)) + else: + self.stdscr.addstr(rel['idx'], stat_pos, stat_name) + rel['processed'] = True + rel['status'] = status + self.stdscr.refresh() + self.lock.release() + +def main(stdscr): + kset = kernel_set(stdscr) + + kset.set_locale() + kset.parse_releases() + kset.setup_screen() + kset.create_threads() + kset.kick_threads() + kset.wait_threads() + kset.refresh() + +if __name__ == "__main__": + if not os.path.exists(modules): + print "%s does not exist" % (modules) + sys.exit(1) + if not os.path.exists(my_cwd + '/Makefile'): + print "%s does not exist" % (my_cwd + '/Makefile') + sys.exit(1) + if os.path.exists(ckmake_log): + os.remove(ckmake_log) + if os.path.exists(ckmake_report): + os.remove(ckmake_report) + if os.path.exists(tmp_path): + rmtree(tmp_path) + os.makedirs(tmp_path) + curses.wrapper(main) + kill_curses() + process_logs() + clean() + sys.exit(ckmake_return) -- cgit v1.2.3 From 976e8703b3f0f94c94e9eecf3b64c90f1406d462 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 19 Dec 2012 16:36:38 -0800 Subject: compat: add ionice to ckmake again This adds back the ionice settings on the make call. The copying of content on the thread is not yet reniced and although Python has utilities to modify niceness and ionice there are privileged requirements on the levels we want and I'm not too sure yet how to resolve this in a reasonable way. This for example fails: p = psutil.Process(os.getpid()) delta = -20 - os.nice(0) p.set_nice(delta) p.set_ionice(psutil.IOPRIO_CLASS_RT) This improves perfomance by about 1 minute. real 17m53.079s user 446m12.733s sys 66m13.372s Since ckmake is multithreaded now though it meant that we had to copy the content of the code that we want to compile for each kernel on a new directory. This work is not reprioritized as it is nice so the best thing I can think of is we renice the ckmake process our ourselves and therefore children would properly inherit the priority. ionice -c 3 nice -n 20 ckmake Can we do better without networking the solution ? Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/ckmake b/bin/ckmake index 97227763..34bfb09f 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -144,7 +144,8 @@ def process_kernel(num, kset): # XXX: figure out how to properly address logging # without this nasty ass hack. log = ' > %(log)s 2>&1' % { "log": log_file } - cmd = 'make ' + jobs + make_args + log + nice = 'ionice -c 3 nice -n 20 ' + cmd = nice + 'make ' + jobs + make_args + log kset.baking(rel) -- cgit v1.2.3 From 46faf02b9a0e7e0e020143311aa037aebde53178 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 19 Dec 2012 18:17:56 -0800 Subject: compat: move HID_USB_DEVICE and HID_BLUETOOTH_DEVICE These were actually introduced in 2.6.28.h and as such we were getting a lot of redefinition warnings which can cause delays in compilation. Lets clear this up ;) Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.28.h | 7 +++++++ include/linux/compat-3.8.h | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 9f1b6290..97f20662 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -12,9 +12,16 @@ #include #include #include +#include #define HID_ANY_ID (~0) +#define HID_USB_DEVICE(ven, prod) \ + .bus = BUS_USB, .vendor = (ven), .product = (prod) +#define HID_BLUETOOTH_DEVICE(ven, prod) \ + .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod) + + struct hid_device_id { __u16 bus; __u32 vendor; diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 46d90a10..052de957 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -7,11 +7,6 @@ #include -#define HID_USB_DEVICE(ven, prod) \ - .bus = BUS_USB, .vendor = (ven), .product = (prod) -#define HID_BLUETOOTH_DEVICE(ven, prod) \ - .bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod) - #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 -- cgit v1.2.3 From 1b2adee659acf1d3717fa692d0ce9990f8f87c79 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 27 Dec 2012 18:19:40 +0100 Subject: compat: fix compiler warning in nla_get_s64() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warning: compat/include/linux/compat-3.7.h: In function ā€˜nla_get_s64ā€™: compat/include/linux/compat-3.7.h:191:2: warning: passing argument 2 of ā€˜nla_memcpyā€™ discards ā€˜constā€™ qualifier from pointer target type [enabled by default] In file included from include/net/genetlink.h:5:0, from compat/include/linux/compat-2.6.32.h:12, from compat/include/linux/compat-2.6.29.h:13, from compat/include/linux/compat-2.6.h:50, from :0: Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index bac76a3a..6b1d2cfa 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -184,7 +184,11 @@ static inline s8 nla_get_s8(const struct nlattr *nla) * nla_get_s64 - return payload of s64 attribute * @nla: s64 netlink attribute */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) static inline s64 nla_get_s64(const struct nlattr *nla) +#else +static inline s64 nla_get_s64(struct nlattr *nla) +#endif { s64 tmp; -- cgit v1.2.3 From 681f75854faf507d8cf128cf4cb03c9f991c40b0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 27 Dec 2012 18:19:41 +0100 Subject: compat: export platform_device_register_data() platform_device_register_data has to be exported for kernel version < 2.6.33. Some of these kernel have this method but do not export it and only kernel version < 2.6.28 does not have this function. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.28.c | 48 ------------------------------------------------ compat/compat-2.6.33.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 48 deletions(-) diff --git a/compat/compat-2.6.28.c b/compat/compat-2.6.28.c index 6be54427..0ae8f465 100644 --- a/compat/compat-2.6.28.c +++ b/compat/compat-2.6.28.c @@ -11,58 +11,10 @@ #include #include #include -#include #include /* 2.6.28 compat code goes here */ -/** - * platform_device_register_data - * @parent: parent device for the device we're adding - * @name: base name of the device we're adding - * @id: instance id - * @data: platform specific data for this platform device - * @size: size of platform specific data - * - * This function creates a simple platform device that requires minimal - * resource and memory management. Canned release function freeing memory - * allocated for the device allows drivers using such devices to be - * unloaded without waiting for the last reference to the device to be - * dropped. - */ -struct platform_device *platform_device_register_data( - struct device *parent, - const char *name, int id, - const void *data, size_t size) -{ - struct platform_device *pdev; - int retval; - - pdev = platform_device_alloc(name, id); - if (!pdev) { - retval = -ENOMEM; - goto error; - } - - pdev->dev.parent = parent; - - if (size) { - retval = platform_device_add_data(pdev, data, size); - if (retval) - goto error; - } - - retval = platform_device_add(pdev); - if (retval) - goto error; - - return pdev; - -error: - platform_device_put(pdev); - return ERR_PTR(retval); -} - #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) /* diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 6e68db4b..6d1c4d81 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef CONFIG_USB_SUSPEND /** @@ -172,3 +173,50 @@ EXPORT_SYMBOL_GPL(pcmcia_loop_tuple); #endif /* CONFIG_PCCARD */ +/** + * platform_device_register_data + * @parent: parent device for the device we're adding + * @name: base name of the device we're adding + * @id: instance id + * @data: platform specific data for this platform device + * @size: size of platform specific data + * + * This function creates a simple platform device that requires minimal + * resource and memory management. Canned release function freeing memory + * allocated for the device allows drivers using such devices to be + * unloaded without waiting for the last reference to the device to be + * dropped. + */ +struct platform_device *platform_device_register_data( + struct device *parent, + const char *name, int id, + const void *data, size_t size) +{ + struct platform_device *pdev; + int retval; + + pdev = platform_device_alloc(name, id); + if (!pdev) { + retval = -ENOMEM; + goto error; + } + + pdev->dev.parent = parent; + + if (size) { + retval = platform_device_add_data(pdev, data, size); + if (retval) + goto error; + } + + retval = platform_device_add(pdev); + if (retval) + goto error; + + return pdev; + +error: + platform_device_put(pdev); + return ERR_PTR(retval); +} +EXPORT_SYMBOL_GPL(platform_device_register_data); -- cgit v1.2.3 From c420819a63605ffc975e9b1704c2ed7f2dcefbf9 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 9 Jan 2013 17:34:19 +0100 Subject: compat: fix warning of missing struct netdev_queue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a warning on kernel version <= 2.6.26: include/linux/compat-3.3.h:44:49: warning: ā€˜struct netdev_queueā€™ declared inside parameter list [enabled by default] Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index a8a1d7e8..5d07c1ae 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -22,28 +22,34 @@ * inlines if it was defined */ #ifndef CONFIG_BQL +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue, unsigned int bytes) { } +#endif static inline void netdev_sent_queue(struct net_device *dev, unsigned int bytes) { } +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue, unsigned pkts, unsigned bytes) { } +#endif static inline void netdev_completed_queue(struct net_device *dev, unsigned pkts, unsigned bytes) { } +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)) static inline void netdev_tx_reset_queue(struct netdev_queue *q) { } +#endif static inline void netdev_reset_queue(struct net_device *dev_queue) { -- cgit v1.2.3 From e7cbb3e7160d752fdea3782c3c54c3d08d068e3f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 9 Jan 2013 17:34:20 +0100 Subject: compat: add missing return value to netif_set_real_num_tx_queues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warning: compat/compat-2.6.35.o compat/compat-2.6.35.c: In function ā€˜netif_set_real_num_tx_queuesā€™: compat/compat-2.6.35.c:45:1: warning: control reaches end of non-void function [-Wreturn-type] Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index d33db464..0fc0db2a 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -42,12 +42,14 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) dev->real_num_tx_queues = txq; qdisc_reset_all_tx_gt(dev, txq); } + return 0; } #else int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) { dev->egress_subqueue_count = txq; /* XXX: consider qdisc reset for older kernels */ + return 0; } #endif EXPORT_SYMBOL_GPL(netif_set_real_num_tx_queues); -- cgit v1.2.3 From 5084ad273822ce99c28087f950ffe0e4494044bb Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 9 Jan 2013 17:34:21 +0100 Subject: compat: add simple_write_to_buffer This was copied from fs/libfs.c Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.35.h | 3 +++ 2 files changed, 37 insertions(+) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 0fc0db2a..422487c0 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -89,3 +89,37 @@ loff_t noop_llseek(struct file *file, loff_t offset, int origin) } EXPORT_SYMBOL_GPL(noop_llseek); +/** + * simple_write_to_buffer - copy data from user space to the buffer + * @to: the buffer to write to + * @available: the size of the buffer + * @ppos: the current position in the buffer + * @from: the user space buffer to read from + * @count: the maximum number of bytes to read + * + * The simple_write_to_buffer() function reads up to @count bytes from the user + * space address starting at @from into the buffer @to at offset @ppos. + * + * On success, the number of bytes written is returned and the offset @ppos is + * advanced by this number, or negative value is returned on error. + **/ +ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, + const void __user *from, size_t count) +{ + loff_t pos = *ppos; + size_t res; + + if (pos < 0) + return -EINVAL; + if (pos >= available || !count) + return 0; + if (count > available - pos) + count = available - pos; + res = copy_from_user(to + pos, from, count); + if (res == count) + return -EFAULT; + count -= res; + *ppos = pos + count; + return count; +} +EXPORT_SYMBOL(simple_write_to_buffer); diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index b06638ac..82b4dea4 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -88,6 +88,9 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) return eps[usb_pipeendpoint(pipe)]; } +extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, + const void __user *from, size_t count); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */ #endif /* LINUX_26_35_COMPAT_H */ -- cgit v1.2.3 From 08ff277255893b83e1d20f92a9f1875913b5302b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 9 Jan 2013 17:34:22 +0100 Subject: compat: add ETHTOOL_FWVERS_LEN In older kernel version this was hard coded to 32 This was added in this commit: commit 141518c95870228da4e050fbe31a8f0c9df82c72 Author: Matt Carlson Date: Thu Dec 3 08:36:22 2009 +0000 tg3: Add some VPD preprocessor constants Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 5d07c1ae..84988bba 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -267,6 +267,8 @@ static inline u32 ethtool_rxfh_indir_default(u32 index, u32 n_rx_rings) return index % n_rx_rings; } +#define ETHTOOL_FWVERS_LEN 32 + #if !((LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,9) && LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) || (LINUX_VERSION_CODE >= KERNEL_VERSION(3,0,23) && LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0))) #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,37)) /* mask qdisc_cb_private_validate as RHEL6 backports this */ -- cgit v1.2.3 From 59a1d456ef3af7c2adbc77a60a3fc2a587b13594 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 9 Jan 2013 17:34:23 +0100 Subject: compat: fix warning in usb_autopm_get_interface_no_{resume,suspend} MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warning on kernel version <= 2.6.31. /compat/compat-2.6.33.c: In function ā€˜usb_autopm_get_interface_no_resumeā€™: /compat/compat-2.6.33.c:32:2: warning: passing argument 1 of ā€˜atomic_incā€™ from incompatible pointer type [enabled by default] /arch/x86/include/asm/atomic_64.h:85:20: note: expected ā€˜struct atomic_t *ā€™ but argument is of type ā€˜int *ā€™ /compat/compat-2.6.33.c: In function ā€˜usb_autopm_put_interface_no_suspendā€™: /compat/compat-2.6.33.c:51:2: warning: passing argument 1 of ā€˜atomic_decā€™ from incompatible pointer type [enabled by default] /arch/x86/include/asm/atomic_64.h:98:20: note: expected ā€˜struct atomic_t *ā€™ but argument is of type ā€˜int *ā€™ Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.33.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/compat/compat-2.6.33.c b/compat/compat-2.6.33.c index 6d1c4d81..f584b859 100644 --- a/compat/compat-2.6.33.c +++ b/compat/compat-2.6.33.c @@ -29,7 +29,11 @@ void usb_autopm_get_interface_no_resume(struct usb_interface *intf) struct usb_device *udev = interface_to_usbdev(intf); usb_mark_last_busy(udev); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) atomic_inc(&intf->pm_usage_cnt); +#else + intf->pm_usage_cnt++; +#endif pm_runtime_get_noresume(&intf->dev); } EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume); @@ -48,7 +52,11 @@ void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) struct usb_device *udev = interface_to_usbdev(intf); usb_mark_last_busy(udev); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) atomic_dec(&intf->pm_usage_cnt); +#else + intf->pm_usage_cnt--; +#endif pm_runtime_put_noidle(&intf->dev); } EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend); -- cgit v1.2.3 From fdf5ff3cb91df352d3b50e637bdfffba00d72f77 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 21 Jan 2013 13:31:01 -0800 Subject: compat: backport netdev_set_default_ethtool_ops() Stanislaw found that due to commit 2c60db03 by Eric Dumazet the wireless core was not assigning driver specific ethtool_ops. This was fixed by Stanislaw's commit d07d7507 which added netdev_set_default_ethtool_ops(). Since Eric's commit 2c60db03 is on v3.7-rc1 Stanislaw's fix is required down to v3.7 as well. The d07d7507 commit is currently present on v3.8-rc4 and is on its way to what we think may be v3.7.5. Because of this kernels older than v3.7.5 will require the full implementation while older kernels than v3.7.0 will require just assigning the ops passed only if netdev has no ops already set just as we used to have it implemented on cfg80211. mcgrof@frijol ~/linux-stable (git::linux-3.8.y)$ git describe --contains 2c60db v3.7-rc1~145^2~142 mcgrof@frijol ~/linux-stable (git::linux-3.8.y)$ git describe --contains d07d75 v3.8-rc4~29^2~4 ckmake results: 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.50 [ OK ] 18 3.1.10 [ OK ] 19 3.2.33 [ OK ] 20 3.3.8 [ OK ] 21 3.4.17 [ OK ] 22 3.5.7 [ OK ] 23 3.6.5 [ OK ] 24 3.7.0 [ OK ] real 0m34.791s user 11m38.572s sys 3m56.927s Signed-off-by: Luis R. Rodriguez --- compat/compat-3.8.c | 22 ++++++++++++++++++++++ include/linux/compat-3.8.h | 6 ++++++ 2 files changed, 28 insertions(+) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index 034dd776..18672585 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -16,6 +16,28 @@ #include #include #include "hid-ids.h" +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) +void netdev_set_default_ethtool_ops(struct net_device *dev, + const struct ethtool_ops *ops) +{ + if (!dev->ethtool_ops) + dev->ethtool_ops = ops; +} +#else /* kernel is between 3.7.0 and 3.7.4 */; +void netdev_set_default_ethtool_ops(struct net_device *dev, + const struct ethtool_ops *ops) +{ + if (dev->ethtool_ops == &default_ethtool_ops) + dev->ethtool_ops = ops; +} +#endif + +EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5) */ /* a list of devices that shouldn't be handled by HID core at all */ static const struct hid_device_id hid_ignore_list[] = { diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 052de957..942b4cbd 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -6,6 +6,12 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) #include +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) +extern void netdev_set_default_ethtool_ops(struct net_device *dev, + const struct ethtool_ops *ops); +#endif #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 -- cgit v1.2.3 From 5461c0248925836d7d10393ed0296aa82cb46e32 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Mon, 21 Jan 2013 16:00:49 -0800 Subject: compat: remove trailing erroneous semicolon from compat-3.8.c Signed-off-by: Luis R. Rodriguez --- compat/compat-3.8.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index 18672585..36f3c50b 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -27,7 +27,7 @@ void netdev_set_default_ethtool_ops(struct net_device *dev, if (!dev->ethtool_ops) dev->ethtool_ops = ops; } -#else /* kernel is between 3.7.0 and 3.7.4 */; +#else /* kernel is between 3.7.0 and 3.7.4 */ void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops) { -- cgit v1.2.3 From a04996415774e7bfe7bd95ef0013b13fd12eb6b2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 23 Jan 2013 13:22:44 -0800 Subject: compat: fix compile errors when assembly is built into modules On powerpc, modules can be compiled and linked with an assembly file, adding missing symbols that the compiler references when using -Os. == ckmake-report.log == 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.50 [ OK ] 18 3.1.10 [ OK ] 19 3.2.33 [ OK ] 20 3.3.8 [ OK ] 21 3.4.17 [ OK ] 22 3.5.7 [ OK ] 23 3.6.5 [ OK ] 24 3.7.0 [ OK ] real 0m33.803s user 11m24.519s sys 3m39.690s Signed-off-by: Felix Fietkau Signed-off-by: Luis R. Rodriguez Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 00a5edaa..34c49e6e 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -1,6 +1,8 @@ #ifndef LINUX_26_COMPAT_H #define LINUX_26_COMPAT_H +#ifndef __ASSEMBLY__ + #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) #include @@ -68,4 +70,6 @@ void compat_dependency_symbol(void); #include #include +#endif /* __ASSEMBLY__ */ + #endif /* LINUX_26_COMPAT_H */ -- cgit v1.2.3 From 670c4a3d46797a92fd15d201e5d9859393c7b2b6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 23 Jan 2013 23:54:45 +0100 Subject: compat: do not access default_ethtool_ops &default_ethtool_ops is not exported in kernel 3.7.4 and earlier and it should be be accessed from compat. Signed-off-by: Hauke Mehrtens --- compat/compat-3.8.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index 36f3c50b..be777675 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -19,22 +19,12 @@ #include #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)) void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops) { if (!dev->ethtool_ops) dev->ethtool_ops = ops; } -#else /* kernel is between 3.7.0 and 3.7.4 */ -void netdev_set_default_ethtool_ops(struct net_device *dev, - const struct ethtool_ops *ops) -{ - if (dev->ethtool_ops == &default_ethtool_ops) - dev->ethtool_ops = ops; -} -#endif EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5) */ -- cgit v1.2.3 From 6129acf32be7c13b3d0bd396f1c9610657494b3b Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 24 Jan 2013 00:41:41 +0100 Subject: compat: update kernel versions in bin/get-compat-kernels Signed-off-by: Hauke Mehrtens --- bin/get-compat-kernels | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index b8cbb5e9..2a81934d 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -49,20 +49,20 @@ KERNELS="$KERNELS ${KPATH}/v2.6.30.10/linux-headers-2.6.30-02063010_2.6.30-02063 KERNELS="$KERNELS ${KPATH}/v2.6.31.13-karmic/linux-headers-2.6.31-02063113_2.6.31-02063113_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.32.60-lucid/linux-headers-2.6.32-02063260_2.6.32-02063260.201210082135_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.33.20-maverick/linux-headers-2.6.33-02063320_2.6.33-02063320.201111071735_all.deb" -KERNELS="$KERNELS ${KPATH}/v2.6.34.13-maverick/linux-headers-2.6.34-02063413_2.6.34-02063413.201208201835_all.deb" +KERNELS="$KERNELS ${KPATH}/v2.6.34.14-maverick/linux-headers-2.6.34-02063414_2.6.34-02063414.201301162135_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.35.13-original-maverick/linux-headers-2.6.35-02063513_2.6.35-02063513.201107261012_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36-02063604.201102180911_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.50-oneiric/linux-headers-3.0.50-030050_3.0.50-030050.201210311335_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.60-oneiric/linux-headers-3.0.60-030060_3.0.60-030060.201301211535_all.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.2.33-precise/linux-headers-3.2.33-030233_3.2.33-030233.201210310701_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.37-precise/linux-headers-3.2.37-030237_3.2.37-030237.201301152335_all.deb" KERNELS="$KERNELS ${KPATH}/v3.3.8-quantal/linux-headers-3.3.8-030308_3.3.8-030308.201206041356_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.17-quantal/linux-headers-3.4.17-030417_3.4.17-030417.201210311354_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.27-quantal/linux-headers-3.4.27-030427_3.4.27-030427.201301211631_all.deb" KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-030507.201210130556_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.6.5-raring/linux-headers-3.6.5-030605_3.6.5-030605.201211011211_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.7-raring/linux-headers-3.7.0-030700_3.7.0-030700.201212102335_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.6.11-raring/linux-headers-3.6.11-030611_3.6.11-030611.201212171335_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.7.4-raring/linux-headers-3.7.4-030704_3.7.4-030704.201301211706_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 9f0c7145e86d00246363c25d0f063994e17dd995 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 24 Jan 2013 21:37:34 +0100 Subject: compat: ckmake: make return code 2 is error If make returns 2 it should be treat as an error and not as ok. The documentation says 2 is returned if make encountered an error: https://www.gnu.org/software/make/manual/html_node/Running.html Signed-off-by: Hauke Mehrtens --- bin/ckmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 34bfb09f..c821b0a9 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -62,8 +62,6 @@ def get_processed_rel(i): def get_status_name(status): if (status == 0): return 'OK' - if (status == 2): - return 'OK' elif (status == 130): return 'TERM' elif (status == 1234): @@ -76,8 +74,6 @@ def get_status_name(status): def get_stat_pos(status): if (status == 0): return 34 - if (status == 2): - return 34 elif (status == 130): return 33 elif (status == 1234): @@ -90,8 +86,6 @@ def get_stat_pos(status): def get_status_color(status): if (status == 0): return curses.color_pair(1) - if (status == 2): - return curses.color_pair(1) elif (status == 130): return curses.color_pair(2) elif (status == 1234): -- cgit v1.2.3 From b24d81b3794854cb7bbcbcf25fac697de263971a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 24 Jan 2013 22:15:21 +0100 Subject: compat: ckmake: remove lots of warning spam for the log Set the environment variable KCFLAGS = "-Wno-unused-but-set-variable" to remove lots of spam from the log. Signed-off-by: Hauke Mehrtens --- bin/ckmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/ckmake b/bin/ckmake index c821b0a9..f5f46b01 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -141,9 +141,13 @@ def process_kernel(num, kset): nice = 'ionice -c 3 nice -n 20 ' cmd = nice + 'make ' + jobs + make_args + log + my_env = os.environ.copy() + my_env["KCFLAGS"] = "-Wno-unused-but-set-variable" + kset.baking(rel) p = subprocess.Popen([cmd], + env = my_env, cwd = work_dir, stdout=None, stderr=None, -- cgit v1.2.3 From 63f5334d3cf14334a948e60154d2854f38100b4a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Fri, 25 Jan 2013 00:44:09 +0100 Subject: compat: ckmake: do not start all build at the same time When all builds are started at the same time this causes problems like, because all threads want to access the same file. In the compat-drivers build this resulted in this error for some threads: ./scripts/gen-compat-autoconf.sh: /usr/bin/env: bad interpreter: Text file busy Signed-off-by: Hauke Mehrtens --- bin/ckmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bin/ckmake b/bin/ckmake index f5f46b01..3d30bee8 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -22,6 +22,7 @@ import signal from Queue import * from threading import Thread, Lock from shutil import copytree, ignore_patterns, rmtree, copyfileobj +from time import sleep releases_processed = [] releases_baking = [] @@ -277,6 +278,7 @@ class kernel_set(): def kick_threads(self): for rel in self.releases: self.queue.put(rel) + sleep(1) def wait_threads(self): self.queue.join() def update_status(self, rel, status): -- cgit v1.2.3 From 5c165fc37dcff3d04251dea04eace34a2650b696 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 24 Jan 2013 11:44:56 +0100 Subject: compat: backport nla_put_be{16,32,64}() I intend to use these in nl80211. Signed-off-by: Johannes Berg Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.5.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 9cffead2..28a12090 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -8,6 +8,32 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) +#include + +/* + * This backports: + * commit 569a8fc38367dfafd87454f27ac646c8e6b54bca + * Author: David S. Miller + * Date: Thu Mar 29 23:18:53 2012 -0400 + * + * netlink: Add nla_put_be{16,32,64}() helpers. + */ + +static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) +{ + return nla_put(skb, attrtype, sizeof(__be16), &value); +} + +static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) +{ + return nla_put(skb, attrtype, sizeof(__be32), &value); +} + +static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) +{ + return nla_put(skb, attrtype, sizeof(__be64), &value); +} + /* * This backports: * -- cgit v1.2.3 From 3e1afb65a6fa6d964c1bbc9b2f4fc89c31d42d1a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 3 Feb 2013 14:01:39 +0100 Subject: compat: add efi_enabled() Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.8.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 942b4cbd..3af253b9 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -7,6 +7,7 @@ #include #include +#include #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) extern void netdev_set_default_ethtool_ops(struct net_device *dev, @@ -49,6 +50,60 @@ static inline int __must_check kref_get_unless_zero(struct kref *kref) { return atomic_add_unless(&kref->refcount, 1, 0); } + +/* This backports: + * + * commit 83e68189745ad931c2afd45d8ee3303929233e7f + * Author: Matt Fleming + * Date: Wed Nov 14 09:42:35 2012 +0000 + * + * efi: Make 'efi_enabled' a function to query EFI facilities + * + */ +/* + * We play games with efi_enabled so that the compiler will, if + * possible, remove EFI-related code altogether. + */ +#define EFI_BOOT 0 /* Were we booted from EFI? */ +#define EFI_SYSTEM_TABLES 1 /* Can we use EFI system tables? */ +#define EFI_CONFIG_TABLES 2 /* Can we use EFI config tables? */ +#define EFI_RUNTIME_SERVICES 3 /* Can we use runtime services? */ +#define EFI_MEMMAP 4 /* Can we use EFI memory map? */ +#define EFI_64BIT 5 /* Is the firmware 64-bit? */ + +#ifdef CONFIG_EFI +# ifdef CONFIG_X86 +static inline int compat_efi_enabled(int facility) +{ + switch (facility) { + case EFI_BOOT: + return efi_enabled; +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) + case EFI_64BIT: + return efi_64bit; +#endif + default: + printk(KERN_ERR "can not translate efi_enabled() to old values completly\n"); + return efi_enabled; + } +} +# else +static inline int compat_efi_enabled(int facility) +{ + return 1; +} +# endif +#else +static inline int compat_efi_enabled(int facility) +{ + return 0; +} +#endif +#ifdef efi_enabled +#undef efi_enabled +#endif +#define efi_enabled(facility) compat_efi_enabled(facility) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ #endif /* LINUX_3_8_COMPAT_H */ -- cgit v1.2.3 From 364ab9517a19d1da97d7acdc39d3019f468fdfc6 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 3 Feb 2013 15:08:46 +0100 Subject: compat: adapt signature change of tty_flip_buffer_push() and tty_insert_flip_string() The method signature of tty_flip_buffer_push() and tty_insert_flip_string() was changed in these commits and this converts it to the old behavior. commit 2e124b4a390ca85325fae75764bef92f0547fa25 Author: Jiri Slaby Date: Thu Jan 3 15:53:06 2013 +0100 TTY: switch tty_flip_buffer_push commit 05c7cd39907184328f48d3e7899f9cdd653ad336 Author: Jiri Slaby Date: Thu Jan 3 15:53:04 2013 +0100 TTY: switch tty_insert_flip_string Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.7.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 6b1d2cfa..03c5ce4d 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #define VM_DONTDUMP VM_NODUMP @@ -197,6 +198,9 @@ static inline s64 nla_get_s64(struct nlattr *nla) return tmp; } +#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty) +#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size) + #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ #define netlink_notify_portid(__notify) (__notify->portid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) -- cgit v1.2.3 From 63c2fe6247fb28462521e5232fe29d3aa7b6d94d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 3 Feb 2013 17:20:56 +0100 Subject: compat: backport BUILD_BUG_ON from recent kernel This version of BUILD_BUG_ON does not have the following error on an old kernel version (2.6.32 - 2.6.37): drivers/net/wireless/iwlwifi/mvm/quota.c:145:24: error: bit-field '' width not an integer constant Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 0aa5d9b7..8dfeed63 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -139,6 +139,41 @@ static inline int is_unicast_ether_addr(const u8 *addr) return !is_multicast_ether_addr(addr); } +/* Backport of: + * + * commit 7ef88ad561457c0346355dfd1f53e503ddfde719 + * Author: Rusty Russell + * Date: Mon Jan 24 14:45:10 2011 -0600 + * + * BUILD_BUG_ON: make it handle more cases + */ +#undef BUILD_BUG_ON +/** + * BUILD_BUG_ON - break compile if a condition is true. + * @condition: the condition which the compiler should know is false. + * + * If you have some code which relies on certain constants being equal, or + * other compile-time-evaluated condition, you should use BUILD_BUG_ON to + * detect if someone changes it. + * + * The implementation uses gcc's reluctance to create a negative array, but + * gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments + * to inline functions). So as a fallback we use the optimizer; if it can't + * prove the condition is false, it will cause a link error on the undefined + * "__build_bug_on_failed". This error message can be harder to track down + * though, hence the two different methods. + */ +#ifndef __OPTIMIZE__ +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#else +extern int __build_bug_on_failed; +#define BUILD_BUG_ON(condition) \ + do { \ + ((void)sizeof(char[1 - 2*!!(condition)])); \ + if (condition) __build_bug_on_failed = 1; \ + } while(0) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 726d9b2ca3f75cba9f1d03e519c2b2e8bf6523a7 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 3 Feb 2013 18:25:07 +0100 Subject: compat: netdev_set_default_ethtool_ops() is not in kernel 3.7.5 netdev_set_default_ethtool_ops() should be added to compat for every 3.7.X series kernel as it is also not in 3.7.5. Signed-off-by: Hauke Mehrtens --- compat/compat-3.8.c | 3 --- include/linux/compat-3.8.h | 2 -- 2 files changed, 5 deletions(-) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index be777675..b3d399c0 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -18,16 +18,13 @@ #include "hid-ids.h" #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops) { if (!dev->ethtool_ops) dev->ethtool_ops = ops; } - EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5) */ /* a list of devices that shouldn't be handled by HID core at all */ static const struct hid_device_id hid_ignore_list[] = { diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 3af253b9..b55a46d9 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -9,10 +9,8 @@ #include #include -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,5)) extern void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops); -#endif #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 -- cgit v1.2.3 From af65e2eaa98b958fa4efa8f097590f90141ae731 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 10 Feb 2013 19:45:10 +0100 Subject: compat: backport idr_alloc() usage This backports a patch series send by Tejun Heo: https://lkml.org/lkml/2013/2/2/159 --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.9.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 include/linux/compat-3.9.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 34c49e6e..68e95d58 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -69,6 +69,7 @@ void compat_dependency_symbol(void); #include #include #include +#include #endif /* __ASSEMBLY__ */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h new file mode 100644 index 00000000..b6cd4151 --- /dev/null +++ b/include/linux/compat-3.9.h @@ -0,0 +1,52 @@ +#ifndef LINUX_3_9_COMPAT_H +#define LINUX_3_9_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) + +#include + + +/** + * backport of idr idr_alloc() usage + * + * This backports a patch series send by Tejun Heo: + * https://lkml.org/lkml/2013/2/2/159 + */ +static inline void compat_idr_destroy(struct idr *idp) +{ + idr_remove_all(idp); + idr_destroy(idp); +} +#define idr_destroy(idp) compat_idr_destroy(idp) + +static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end, + gfp_t gfp_mask) +{ + int id, ret; + + do { + if (!idr_pre_get(idr, gfp_mask)) + return -ENOMEM; + ret = idr_get_new_above(idr, ptr, start, &id); + if (!ret && id > end) { + idr_remove(idr, id); + ret = -ENOSPC; + } + } while (ret == -EAGAIN); + + return ret ? ret : id; +} + +static inline void idr_preload(gfp_t gfp_mask) +{ +} + +static inline void idr_preload_end(void) +{ +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ + +#endif /* LINUX_3_9_COMPAT_H */ -- cgit v1.2.3 From dbc390647a841061954f67ea226221fc7f4b3836 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 10 Feb 2013 20:10:10 +0100 Subject: compat: backport drop of node parameter from iterators This patch backports the following commit in mainline linux kernel: commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9 Author: Sasha Levin Date: Thu Feb 7 12:32:18 2013 +1100 hlist: drop the node parameter from iterators Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.37.h | 12 ++++++++ include/linux/compat-3.9.h | 69 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index d1e7db95..c1d45af1 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -166,6 +166,18 @@ static inline bool skb_has_frag_list(const struct sk_buff *skb) return skb_shinfo(skb)->frag_list != NULL; } +/** + * backport: + * + * commit 67bdbffd696f29a0b68aa8daa285783a06651583 + * Author: Arnd Bergmann + * Date: Thu Feb 25 16:55:13 2010 +0100 + * + * rculist: avoid __rcu annotations + */ +#define hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first))) +#define hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next))) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */ #endif /* LINUX_26_37_COMPAT_H */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index b6cd4151..f472cf88 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -6,6 +6,14 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) #include +#include +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) +#include +#endif +#include + +/* include this before changing hlist_for_each_* to use the old versions. */ +#include /** @@ -47,6 +55,67 @@ static inline void idr_preload_end(void) { } + +/** + * backport: + * + * commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9 + * Author: Sasha Levin + * Date: Thu Feb 7 12:32:18 2013 +1100 + * + * hlist: drop the node parameter from iterators + */ + +#define hlist_entry_safe(ptr, type, member) \ + (ptr) ? hlist_entry(ptr, type, member) : NULL + +#undef hlist_for_each_entry +/** + * hlist_for_each_entry - iterate over list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the hlist_node within the struct. + */ +#define hlist_for_each_entry(pos, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \ + pos; \ + pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member)) + +#undef hlist_for_each_entry_safe +/** + * hlist_for_each_entry_safe - iterate over list of given type safe against removal of list entry + * @pos: the type * to use as a loop cursor. + * @n: another &struct hlist_node to use as temporary storage + * @head: the head for your list. + * @member: the name of the hlist_node within the struct. + */ +#define hlist_for_each_entry_safe(pos, n, head, member) \ + for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \ + pos && ({ n = pos->member.next; 1; }); \ + pos = hlist_entry_safe(n, typeof(*pos), member)) + +#undef hlist_for_each_entry_rcu +/** + * hlist_for_each_entry_rcu - iterate over rcu list of given type + * @pos: the type * to use as a loop cursor. + * @head: the head for your list. + * @member: the name of the hlist_node within the struct. + * + * This list-traversal primitive may safely run concurrently with + * the _rcu list-mutation primitives such as hlist_add_head_rcu() + * as long as the traversal is guarded by rcu_read_lock(). + */ +#define hlist_for_each_entry_rcu(pos, head, member) \ + for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\ + typeof(*(pos)), member); \ + pos; \ + pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \ + &(pos)->member)), typeof(*(pos)), member)) + +#undef sk_for_each +#define sk_for_each(__sk, list) \ + hlist_for_each_entry(__sk, list, sk_node) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ #endif /* LINUX_3_9_COMPAT_H */ -- cgit v1.2.3 From 28c1dde0df2c9e01e8d57a774687734ed21bd208 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 10 Feb 2013 21:50:15 +0100 Subject: compat: check if efi_enabled() was already backported efi_enabled() gets backported to older kernel versions and if this is the case compat should not try to do the same. Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.8.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index b55a46d9..c913188a 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -58,6 +58,8 @@ static inline int __must_check kref_get_unless_zero(struct kref *kref) * efi: Make 'efi_enabled' a function to query EFI facilities * */ +/* check first if this was already backported */ +#ifndef EFI_BOOT /* * We play games with efi_enabled so that the compiler will, if * possible, remove EFI-related code altogether. @@ -101,6 +103,7 @@ static inline int compat_efi_enabled(int facility) #undef efi_enabled #endif #define efi_enabled(facility) compat_efi_enabled(facility) +#endif /* EFI_BOOT */ #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ -- cgit v1.2.3 From 3dfdf5da39de78ebad0af2e71056d3f181e0f671 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 10 Feb 2013 20:51:22 +0100 Subject: compat: add kernel 3.8-rc7 and update others This adds 3.8-rc7 to the get.compat-kernels fetch script and updates some kernel versions to the last minor version. Signed-off-by: Hauke Mehrtens --- bin/get-compat-kernels | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index 2a81934d..e6171d20 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -55,14 +55,15 @@ KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36- KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.60-oneiric/linux-headers-3.0.60-030060_3.0.60-030060.201301211535_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.62-oneiric/linux-headers-3.0.62-030062_3.0.62-030062.201302032235_all.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.2.37-precise/linux-headers-3.2.37-030237_3.2.37-030237.201301152335_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.2.38-precise/linux-headers-3.2.38-030238_3.2.38-030238.201302060135_all.deb" KERNELS="$KERNELS ${KPATH}/v3.3.8-quantal/linux-headers-3.3.8-030308_3.3.8-030308.201206041356_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.27-quantal/linux-headers-3.4.27-030427_3.4.27-030427.201301211631_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.29-quantal/linux-headers-3.4.29-030429_3.4.29-030429.201302032331_all.deb" KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-030507.201210130556_all.deb" KERNELS="$KERNELS ${KPATH}/v3.6.11-raring/linux-headers-3.6.11-030611_3.6.11-030611.201212171335_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.7.4-raring/linux-headers-3.7.4-030704_3.7.4-030704.201301211706_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.7.6-raring/linux-headers-3.7.6-030706_3.7.6-030706.201302040006_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.8-rc7-raring/linux-headers-3.8.0-030800rc7_3.8.0-030800rc7.201302081635_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 1de03156f08011821f59d28e34d1beb2ba89d45a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 10 Feb 2013 22:49:06 +0100 Subject: compat: move tty_flip_buffer_push() and tty_insert_flip_string() These backports are also needed for kernel 3.7 and 3.8. Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.7.h | 4 ---- include/linux/compat-3.9.h | 5 +++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 03c5ce4d..6b1d2cfa 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -13,7 +13,6 @@ #include #include #include -#include #include #define VM_DONTDUMP VM_NODUMP @@ -198,9 +197,6 @@ static inline s64 nla_get_s64(struct nlattr *nla) return tmp; } -#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty) -#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size) - #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ #define netlink_notify_portid(__notify) (__notify->portid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index f472cf88..ff1b3862 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -11,6 +11,8 @@ #include #endif #include +#include +#include /* include this before changing hlist_for_each_* to use the old versions. */ #include @@ -116,6 +118,9 @@ static inline void idr_preload_end(void) #define sk_for_each(__sk, list) \ hlist_for_each_entry(__sk, list, sk_node) +#define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty) +#define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size) + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ #endif /* LINUX_3_9_COMPAT_H */ -- cgit v1.2.3 From 6fe5a43f62df7c37fb5c1a0b5b34308b98a541f5 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Feb 2013 19:23:00 +0100 Subject: compat: add PCI_EXP_LNKCAP_SLS_2_5GB and PCI_EXP_LNKCAP_SLS_5_0GB This is a backport of: commit 130f1b8f35f14d27c43da755f3c9226318c17f57 Author: Bjorn Helgaas Date: Wed Dec 26 10:39:23 2012 -0700 PCI: Add PCIe Link Capability link speed and width names Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.8.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index c913188a..545e9f04 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -105,6 +105,17 @@ static inline int compat_efi_enabled(int facility) #define efi_enabled(facility) compat_efi_enabled(facility) #endif /* EFI_BOOT */ +/* This backports: + * + * commit 130f1b8f35f14d27c43da755f3c9226318c17f57 + * Author: Bjorn Helgaas + * Date: Wed Dec 26 10:39:23 2012 -0700 + * + * PCI: Add PCIe Link Capability link speed and width names + */ +#define PCI_EXP_LNKCAP_SLS_2_5GB 0x1 /* LNKCAP2 SLS Vector bit 0 (2.5GT/s) */ +#define PCI_EXP_LNKCAP_SLS_5_0GB 0x2 /* LNKCAP2 SLS Vector bit 1 (5.0GT/s) */ + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)) */ #endif /* LINUX_3_8_COMPAT_H */ -- cgit v1.2.3 From 99e5b9b95e259f75e53ab7b01815d0042d33b58a Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Feb 2013 19:23:13 +0100 Subject: compat: add missing platform devid constants They are both set to none and will result in no id being added to the device. This is a backport of: commit 689ae231afbac8979f96100b372a5a73458baaa9 Author: Jean Delvare Date: Fri Jul 27 22:14:59 2012 +0200 platform: Add support for automatic device IDs Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.7.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index 6b1d2cfa..dd05e00c 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -197,6 +197,9 @@ static inline s64 nla_get_s64(struct nlattr *nla) return tmp; } +#define PLATFORM_DEVID_NONE (-1) +#define PLATFORM_DEVID_AUTO (-1) + #else /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,7,0)) */ #define netlink_notify_portid(__notify) (__notify->portid) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_portid) -- cgit v1.2.3 From 00116d84656a88e5b69638e8cc97317e570b9921 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Feb 2013 20:33:51 +0100 Subject: compat: add empty struct watchdog_device This is needed in some header file but so driver accesses this struct. Signed-off-by: Hauke Mehrtens --- include/linux/compat-3.1.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 9d78b7d6..2b5eb8b7 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -105,6 +105,10 @@ void ida_simple_remove(struct ida *ida, unsigned int id); unsigned int cpufreq_quick_get_max(unsigned int cpu); #endif + +struct watchdog_device { +}; + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)) */ #endif /* LINUX_3_1_COMPAT_H */ -- cgit v1.2.3 From db98d16c88021922cd5720e01c36aaa34e9fa92f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Feb 2013 20:50:02 +0100 Subject: compat: backport of lock_map_acquire_read() This is a backport of: commit e159489baa717dbae70f9903770a6a4990865887 Author: Tejun Heo Date: Sun Jan 9 23:32:15 2011 +0100 workqueue: relax lockdep annotation on flush_work() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.38.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index 8dfeed63..e936c427 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -174,6 +174,24 @@ extern int __build_bug_on_failed; } while(0) #endif +/* Backport of: + * + * commit e159489baa717dbae70f9903770a6a4990865887 + * Author: Tejun Heo + * Date: Sun Jan 9 23:32:15 2011 +0100 + * + * workqueue: relax lockdep annotation on flush_work() + */ +#ifdef CONFIG_DEBUG_LOCK_ALLOC +# ifdef CONFIG_PROVE_LOCKING +# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 2, NULL, _THIS_IP_) +# else +# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 1, NULL, _THIS_IP_) +# endif +#else +# define lock_map_acquire_read(l) do { } while (0) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)) */ #endif /* LINUX_26_38_COMPAT_H */ -- cgit v1.2.3 From 6649081917c808bed07b6f9bc3e302fb37688a54 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Wed, 13 Feb 2013 20:51:00 +0100 Subject: compat: backport of lock_map_acquire() and lock_map_release() This is a backport of: commit 3295f0ef9ff048a4619ede597ad9ec9cab725654 Author: Ingo Molnar Date: Mon Aug 11 10:30:30 2008 +0200 lockdep: rename map_[acquire|release]() => lock_map_[acquire|release]() Signed-off-by: Hauke Mehrtens --- include/linux/compat-2.6.27.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index ece825de..2eae9f2f 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -287,6 +287,26 @@ static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep) #define netif_wake_subqueue netif_start_subqueue +/* Backport of: + * + * commit 3295f0ef9ff048a4619ede597ad9ec9cab725654 + * Author: Ingo Molnar + * Date: Mon Aug 11 10:30:30 2008 +0200 + * + * lockdep: rename map_[acquire|release]() => lock_map_[acquire|release]() + */ +#ifdef CONFIG_DEBUG_LOCK_ALLOC +# ifdef CONFIG_PROVE_LOCKING +# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_) +# else +# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_) +# endif +# define lock_map_release(l) lock_release(l, 1, _THIS_IP_) +#else +# define lock_map_acquire(l) do { } while (0) +# define lock_map_release(l) do { } while (0) +#endif + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)) */ #endif /* LINUX_26_27_COMPAT_H */ -- cgit v1.2.3 From 4971ae5e2075a284ff36a68cab7c3f407a852801 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Mon, 18 Feb 2013 22:37:36 +0100 Subject: compat: deactivate netdev_set_default_ethtool_ops() for some 3.7 kernels netdev_set_default_ethtool_ops() was backported in 3.7.8 and compat should not ship it on any more recent versions any more. Signed-off-by: Hauke Mehrtens --- compat/compat-3.8.c | 2 ++ include/linux/compat-3.8.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/compat/compat-3.8.c b/compat/compat-3.8.c index b3d399c0..81343234 100644 --- a/compat/compat-3.8.c +++ b/compat/compat-3.8.c @@ -18,6 +18,7 @@ #include "hid-ids.h" #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8)) void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops) { @@ -25,6 +26,7 @@ void netdev_set_default_ethtool_ops(struct net_device *dev, dev->ethtool_ops = ops; } EXPORT_SYMBOL_GPL(netdev_set_default_ethtool_ops); +#endif /* a list of devices that shouldn't be handled by HID core at all */ static const struct hid_device_id hid_ignore_list[] = { diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 545e9f04..4aeffdba 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -9,8 +9,10 @@ #include #include +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8)) extern void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops); +#endif #define HID_BUS_ANY 0xffff #define HID_GROUP_ANY 0x0000 -- cgit v1.2.3 From fb57da514ae16fc362c2366fce777eb44aa180f0 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Tue, 19 Feb 2013 23:26:31 +0100 Subject: compat: update kernel versions in bin/get-compat-kernels Signed-off-by: Hauke Mehrtens --- bin/get-compat-kernels | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index e6171d20..f34a03e8 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -55,15 +55,15 @@ KERNELS="$KERNELS ${KPATH}/v2.6.36.4-natty/linux-headers-2.6.36-02063604_2.6.36- KERNELS="$KERNELS ${KPATH}/v2.6.37.6-natty/linux-headers-2.6.37-02063706_2.6.37-02063706.201103281005_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.38.8-natty/linux-headers-2.6.38-02063808_2.6.38-02063808.201106040910_all.deb" KERNELS="$KERNELS ${KPATH}/v2.6.39.4-oneiric/linux-headers-2.6.39-02063904_2.6.39-02063904.201108040905_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.0.62-oneiric/linux-headers-3.0.62-030062_3.0.62-030062.201302032235_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.0.65-oneiric/linux-headers-3.0.65-030065_3.0.65-030065.201302171435_all.deb" KERNELS="$KERNELS ${KPATH}/v3.1.10-precise/linux-headers-3.1.10-030110_3.1.10-030110.201201181135_all.deb" KERNELS="$KERNELS ${KPATH}/v3.2.38-precise/linux-headers-3.2.38-030238_3.2.38-030238.201302060135_all.deb" KERNELS="$KERNELS ${KPATH}/v3.3.8-quantal/linux-headers-3.3.8-030308_3.3.8-030308.201206041356_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.4.29-quantal/linux-headers-3.4.29-030429_3.4.29-030429.201302032331_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.4.32-quantal/linux-headers-3.4.32-030432_3.4.32-030432.201302171531_all.deb" KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-030507.201210130556_all.deb" KERNELS="$KERNELS ${KPATH}/v3.6.11-raring/linux-headers-3.6.11-030611_3.6.11-030611.201212171335_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.7.6-raring/linux-headers-3.7.6-030706_3.7.6-030706.201302040006_all.deb" -KERNELS="$KERNELS ${KPATH}/v3.8-rc7-raring/linux-headers-3.8.0-030800rc7_3.8.0-030800rc7.201302081635_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.7.9-raring/linux-headers-3.7.9-030709_3.7.9-030709.201302171607_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.8-raring/linux-headers-3.8.0-030800_3.8.0-030800.201302181935_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From fffc4284806fbbc64e18231034702ee03b6e7135 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Feb 2013 00:54:58 +0100 Subject: compat: add file_inode() This adds a backport for file_inode(). Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.9.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index ff1b3862..26e6f57c 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -121,6 +121,20 @@ static inline void idr_preload_end(void) #define tty_flip_buffer_push(port) tty_flip_buffer_push((port)->tty) #define tty_insert_flip_string(port, chars, size) tty_insert_flip_string((port)->tty, chars, size) +/** + * backport of: + * + * commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54 + * Author: Al Viro + * Date: Wed Jan 23 17:07:38 2013 -0500 + * + * new helper: file_inode(file) + */ +static inline struct inode *file_inode(struct file *f) +{ + return f->f_path.dentry->d_inode; +} + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) */ #endif /* LINUX_3_9_COMPAT_H */ -- cgit v1.2.3 From e3cda5fc4f2dffad8667a00cfc48e6cba5308a2b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 7 Mar 2013 12:58:29 -0800 Subject: compat: add 3.9-rc1 vanilla kernel to list of kernels to test This adds the vanilla 3.9-rc1 kernel to the list set list of test kernels we'll test. Signed-off-by: Luis R. Rodriguez --- bin/get-compat-kernels | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/get-compat-kernels b/bin/get-compat-kernels index f34a03e8..269dfd26 100755 --- a/bin/get-compat-kernels +++ b/bin/get-compat-kernels @@ -64,6 +64,7 @@ KERNELS="$KERNELS ${KPATH}/v3.5.7-quantal/linux-headers-3.5.7-030507_3.5.7-03050 KERNELS="$KERNELS ${KPATH}/v3.6.11-raring/linux-headers-3.6.11-030611_3.6.11-030611.201212171335_all.deb" KERNELS="$KERNELS ${KPATH}/v3.7.9-raring/linux-headers-3.7.9-030709_3.7.9-030709.201302171607_all.deb" KERNELS="$KERNELS ${KPATH}/v3.8-raring/linux-headers-3.8.0-030800_3.8.0-030800.201302181935_all.deb" +KERNELS="$KERNELS ${KPATH}/v3.9-rc1-raring/linux-headers-3.9.0-030900rc1_3.9.0-030900rc1.201303060659_all.deb" # Number of kernels NUM_KERNELS=$(echo $KERNELS | wc -w) -- cgit v1.2.3 From 3b2942c570950e2549bd810b59128553eefb5fb2 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 13 Mar 2013 02:51:15 -0700 Subject: compat: backport rename of random32 to prandom mcgrof@frijol ~/linux-next (git::master)$ git describe \ --contains 496f2f93b1cc286f5a4f4f9acdc1e5314978683f v3.8-rc1~74^2~22 commit 496f2f93b1cc286f5a4f4f9acdc1e5314978683f Author: Akinobu Mita Date: Mon Dec 17 16:04:23 2012 -0800 random32: rename random32 to prandom This renames all random32 functions to have 'prandom_' prefix as follows: void prandom_seed(u32 seed); /* rename from srandom32() */ u32 prandom_u32(void); /* rename from random32() */ void prandom_seed_state(struct rnd_state *state, u64 seed); /* rename from prandom32_seed() */ u32 prandom_u32_state(struct rnd_state *state); /* rename from prandom32() */ The purpose of this renaming is to prevent some kernel developers from assuming that prandom32() and random32() might imply that only prandom32() was the one using a pseudo-random number generator by prandom32's "p", and the result may be a very embarassing security exposure. This concern was expressed by Theodore Ts'o. And furthermore, I'm going to introduce new functions for getting the requested number of pseudo-random bytes. If I continue to use both prandom32 and random32 prefixes for these functions, the confusion is getting worse. As a result of this renaming, "prandom_" is the common prefix for pseudo-random number library. Currently, srandom32() and random32() are preserved because it is difficult to rename too many users at once. Signed-off-by: Akinobu Mita Cc: "Theodore Ts'o" Cc: Robert Love Cc: Michel Lespinasse Cc: Valdis Kletnieks Cc: David Laight Cc: Adrian Hunter Cc: Artem Bityutskiy Cc: David Woodhouse Cc: Eilon Greenstein Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.8.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 4aeffdba..184d1d09 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -8,6 +8,12 @@ #include #include #include +#include + +/* backports 496f2f9 */ +#define prandom_seed(_seed) srandom32(_seed) +#define prandom_u32() random32() +#define prandom_u32_state(_state) prandom32(_state) #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8)) extern void netdev_set_default_ethtool_ops(struct net_device *dev, -- cgit v1.2.3 From 2d7033d00850c7db34930cff9986c4e4486d2b08 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Mar 2013 11:58:10 -0700 Subject: compat: fix compilation on 2.6.24 based on next-20130312 drivers/net/wireless/iwlwifi/mvm/mac80211.c ends up including include/net/inet_hashtables.h which in 2.6.24 has a routine called __inet_lookup_established() that uses the sk_for_each(1, 2, 3). The patch below by Hauke backported the change that went into the kernel that made sk_for_each(1, 3) use two arguments. It turns out that upstream we realized that the second argument was useless. The header however uses it though so the trick didn't work for 2.6.24 if code used it there. We fix it using a nasty hack by ensuring that when the header file is included we redefine that routine to something else, then we udef it, and then define our new version that only uses the 2 argument form of sk_for_each(). This is a nasty way to solve it but not sure if there is anything cleaner. commit dbc390647a841061954f67ea226221fc7f4b3836 Author: Hauke Mehrtens Date: Sun Feb 10 20:10:10 2013 +0100 compat: backport drop of node parameter from iterators This patch backports the following commit in mainline linux kernel: commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9 Author: Sasha Levin Date: Thu Feb 7 12:32:18 2013 +1100 hlist: drop the node parameter from iterators Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 46 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 563b65f7..5ca6783e 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -20,6 +20,52 @@ #include #include #include +#define __inet_lookup_established __inet_lookup_established_old +#include +#undef __inet_lookup_established +#include +/* + * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so we need + * not check it for lookups anymore, thanks Alexey. -DaveM + * + * Local BH must be disabled here. + */ +static inline struct sock * + __inet_lookup_established(struct inet_hashinfo *hashinfo, + const __be32 saddr, const __be16 sport, + const __be32 daddr, const u16 hnum, + const int dif) +{ + INET_ADDR_COOKIE(acookie, saddr, daddr) + const __portpair ports = INET_COMBINED_PORTS(sport, hnum); + struct sock *sk; + /* Optimize here for direct hit, only listening connections can + * have wildcards anyways. + */ + unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport); + struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); + rwlock_t *lock = inet_ehash_lockp(hashinfo, hash); + + prefetch(head->chain.first); + read_lock(lock); + sk_for_each(sk, &head->chain) { + if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) + goto hit; /* You sunk my battleship! */ + } + + /* Must check for a TIME_WAIT'er before going to listener hash. */ + sk_for_each(sk, &head->twchain) { + if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) + goto hit; + } + sk = NULL; +out: + read_unlock(lock); + return sk; +hit: + sock_hold(sk); + goto out; +} /* Backports b718989da7 */ int __must_check pci_enable_device_mem(struct pci_dev *dev); -- cgit v1.2.3 From 096a27e708de767ea7b7f8ee98a74bcaacc30083 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Mar 2013 15:08:01 -0700 Subject: compat: backport print_hex_dump_debug() This backports print_hex_dump_debug() from commit 7a555613, which itself required a definition from commit 07613b0b. mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 7a555613 v3.9-rc1~128^2~135 mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains 07613b0b v3.2-rc1~184^2~6 commit 7a555613eb77c69eb6e48b61bc5f72dd42fa1780 Author: Vladimir Kondratiev Date: Wed Dec 5 16:48:27 2012 -0500 dynamic_debug: dynamic hex dump Introduce print_hex_dump_debug() that can be dynamically controlled, similar to pr_debug. Also, make print_hex_dump_bytes() dynamically controlled Implement only 'p' flag (_DPRINTK_FLAGS_PRINT) to keep it simple since hex dump prints multiple lines and long prefix would impact readability. To provide line/file etc. information, use pr_debug or similar before/after print_hex_dump_debug() Signed-off-by: Vladimir Kondratiev Signed-off-by: Jason Baron Signed-off-by: Greg Kroah-Hartman commit 07613b0b5ef8570033aa806d1731dce599862223 Author: Jason Baron Date: Tue Oct 4 14:13:15 2011 -0700 dynamic_debug: consolidate repetitive struct _ddebug descriptor definitions Replace the repetitive struct _ddebug descriptor definitions with a new DECLARE_DYNAMIC_DEBUG_META_DATA(name, fmt) macro. [akpm@linux-foundation.org: s/DECLARE/DEFINE/] Signed-off-by: Jason Baron Cc: Arnd Bergmann Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 16 ++++++++++++++++ include/linux/compat-3.9.h | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index cde86b56..d2302068 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -7,6 +7,22 @@ #include #include +#include + +/* backports 07613b0b */ +#if defined(CONFIG_DYNAMIC_DEBUG) +#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ + static struct _ddebug __used __aligned(8) \ + __attribute__((section("__verbose"))) name = { \ + .modname = KBUILD_MODNAME, \ + .function = __func__, \ + .filename = __FILE__, \ + .format = (fmt), \ + .lineno = __LINE__, \ + .flags = _DPRINTK_FLAGS_DEFAULT, \ + .enabled = false, \ + } +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ /* backports b4625dab */ #define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index 26e6f57c..89b94a45 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -13,10 +13,34 @@ #include #include #include +#include /* include this before changing hlist_for_each_* to use the old versions. */ #include +/* backports 7a555613 */ +#if defined(CONFIG_DYNAMIC_DEBUG) +#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ +do { \ + DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, \ + __builtin_constant_p(prefix_str) ? prefix_str : "hexdump");\ + if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \ + print_hex_dump(KERN_DEBUG, prefix_str, \ + prefix_type, rowsize, groupsize, \ + buf, len, ascii); \ +} while (0) +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#else +#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) \ + print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \ + groupsize, buf, len, ascii) +#endif /* defined(CONFIG_DYNAMIC_DEBUG) */ + /** * backport of idr idr_alloc() usage -- cgit v1.2.3 From b118a9c59d399420005c97a8a1c9cec1514109f1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 14 Mar 2013 19:05:47 -0700 Subject: compat: fix ckmake to skip same base kernels The ckmake script was allowing testing of compilation of kernels even if the base kernels were the same. This fixes it to skip them, trimming down test kernel compilation down and not caring what old kernels you keep on your system. This also now prints the RC release correctly. The get_rel_spec() routine is based on the rel-html get_rel_spec() routine and rel-html is AGPL but since I wrote it I relicense a modified version of that routine here to GPLv2. Signed-off-by: Luis R. Rodriguez --- bin/ckmake | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 82 insertions(+), 17 deletions(-) diff --git a/bin/ckmake b/bin/ckmake index 3d30bee8..cd9741ae 100755 --- a/bin/ckmake +++ b/bin/ckmake @@ -185,6 +185,62 @@ def sig_handler(signal, frame): clean() sys.exit(-2) +def get_rel_spec(rel): + if ("rc" in rel): + m = re.match(r"v*(?P\d+)\.+" \ + "(?P\d+)[.]+" \ + "(?P\d+)[-]+" \ + "\d+rc(?P\d+)\-*", + rel) + else: + m = re.match(r"v*(?P\d+)\.+" \ + "(?P\d+)[.]+" \ + "(?P\d+)[-]+" \ + "(?P\d+)\-*", + rel) + if (not m): + return m + rel_specs = m.groupdict() + return rel_specs + +def krel_same_base(new_rel, rel): + if (int(new_rel['ver']) != int(rel['ver'])): + return False + if (int(new_rel['pat']) != int(rel['pat'])): + return False + if (int(new_rel['ver']) == 3): + return True + if (int(new_rel['ver']) != 2): + return False + if (int(new_rel['sub']) == int(rel['sub'])): + return True + return False + +def krel_base_update(new_rel, rel): + if (not krel_same_base(new_rel, rel)): + return False + if (int(new_rel['sub']) > int(rel['sub'])): + return True + if (int(new_rel['sub']) < int(rel['sub'])): + return False + + # Too lazy to deal with 2.x kernels, + if (not new_rel['is_rc']): + return False + + if (int(new_rel['ext']) <= int(rel['ext'])): + return False + return True + +def krel_base_smaller(new_rel, rel): + if (not krel_same_base(new_rel, rel)): + return False + if (int(new_rel['sub']) > int(rel['sub'])): + return False + if (int(new_rel['sub']) < int(rel['sub'])): + return True + return False + class kernel_set(): def __init__(self, stdscr): self.queue = Queue() @@ -221,38 +277,47 @@ class kernel_set(): self.lock.acquire() self.stdscr.refresh() self.lock.release() + def evaluate_new_rel(self, new_rel): + for rel in self.releases: + if (krel_base_update(new_rel, rel)): + new_rel['idx'] = rel['idx'] + self.releases.remove(rel) + break + if (krel_base_smaller(new_rel, rel)): + return + self.releases.insert(new_rel['idx'], new_rel) def parse_releases(self): for dirname, dirnames, filenames in os.walk(modules): dirnames.sort() for subdirname in dirnames: - m = re.match(r"v*(?P\w+.)" \ - "(?P\w+.*)" \ - "(?P\w*)" \ - "(?P[.-]\w*)" \ - "(?P[-]\w*).*", \ - subdirname) - if not m: + specifics = get_rel_spec(subdirname) + if (not specifics): continue + rc = False - specifics = m.groupdict() - - ver = specifics['VERSION'] + \ - specifics['PATCHLEVEL'] + \ - specifics['SUBLEVEL'] + ver = specifics['VERSION'] + '.' + \ + specifics['PATCHLEVEL'] - for rel in self.releases: - if (rel['version'] == ver): - continue + if ("rc" in subdirname): + rc = True + ver = ver + '-rc' + specifics['EXTRAVERSION'] + else: + ver = ver + '.' + specifics['SUBLEVEL'] rel = dict(idx=len(self.releases), name=subdirname, full_path=dirname + '/' + - subdirname, + subdirname, version=ver, + is_rc = rc, + ver=specifics['VERSION'], + pat=specifics['PATCHLEVEL'], + sub=specifics['SUBLEVEL'], + ext=specifics['EXTRAVERSION'], processed=False, log='', status=1234) - self.releases.insert(rel['idx'], rel) + self.evaluate_new_rel(rel) self.refresh() def setup_screen(self): for i in range(0, len(self.releases)): -- cgit v1.2.3 From 4ed7e742fa97375c05b4a13926f9968f5c251611 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: use EXPORT_SYMBOL_GPL() This was the intent all along, however some symbols have slipped. The goal is always clear: if you are using any of this code at run time this is making your code derivative works of the Linux kernel and therefore GPLv2. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.34.c | 4 ++-- compat/compat-2.6.35.c | 2 +- compat/compat-3.1.c | 6 +++--- compat/compat-3.4.c | 2 +- compat/compat-3.5.c | 4 ++-- compat/compat-3.7.c | 12 ++++++------ compat/user_namespace.c | 12 ++++++------ 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/compat/compat-2.6.34.c b/compat/compat-2.6.34.c index 80a61079..72060076 100644 --- a/compat/compat-2.6.34.c +++ b/compat/compat-2.6.34.c @@ -61,7 +61,7 @@ struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos) return seq_hlist_start(head, pos - 1); } -EXPORT_SYMBOL(seq_hlist_start_head); +EXPORT_SYMBOL_GPL(seq_hlist_start_head); /** * seq_hlist_next - move to the next position of the hlist @@ -82,4 +82,4 @@ struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, else return node->next; } -EXPORT_SYMBOL(seq_hlist_next); +EXPORT_SYMBOL_GPL(seq_hlist_next); diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 422487c0..646afa20 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -122,4 +122,4 @@ ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, *ppos = pos + count; return count; } -EXPORT_SYMBOL(simple_write_to_buffer); +EXPORT_SYMBOL_GPL(simple_write_to_buffer); diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index 354a8a3a..bfaf8eae 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -31,7 +31,7 @@ unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) return ret_freq; } -EXPORT_SYMBOL(compat_cpufreq_quick_get_max); +EXPORT_SYMBOL_GPL(compat_cpufreq_quick_get_max); #endif static DEFINE_SPINLOCK(compat_simple_ida_lock); @@ -86,7 +86,7 @@ again: return ret; } -EXPORT_SYMBOL(compat_ida_simple_get); +EXPORT_SYMBOL_GPL(compat_ida_simple_get); /** * ida_simple_remove - remove an allocated id. @@ -102,6 +102,6 @@ void compat_ida_simple_remove(struct ida *ida, unsigned int id) ida_remove(ida, id); spin_unlock_irqrestore(&compat_simple_ida_lock, flags); } -EXPORT_SYMBOL(compat_ida_simple_remove); +EXPORT_SYMBOL_GPL(compat_ida_simple_remove); /* source lib/idr.c */ diff --git a/compat/compat-3.4.c b/compat/compat-3.4.c index a771260e..f8512e45 100644 --- a/compat/compat-3.4.c +++ b/compat/compat-3.4.c @@ -479,7 +479,7 @@ const struct i2c_algorithm i2c_bit_algo = { .master_xfer = bit_xfer, .functionality = bit_func, }; -EXPORT_SYMBOL(i2c_bit_algo); +EXPORT_SYMBOL_GPL(i2c_bit_algo); #endif int simple_open(struct inode *inode, struct file *file) diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c index a6b174d5..01509fa1 100644 --- a/compat/compat-3.5.c +++ b/compat/compat-3.5.c @@ -25,6 +25,6 @@ int overflowuid = DEFAULT_OVERFLOWUID; int overflowgid = DEFAULT_OVERFLOWGID; -EXPORT_SYMBOL(overflowuid); -EXPORT_SYMBOL(overflowgid); +EXPORT_SYMBOL_GPL(overflowuid); +EXPORT_SYMBOL_GPL(overflowgid); #endif diff --git a/compat/compat-3.7.c b/compat/compat-3.7.c index f591f163..226d136a 100644 --- a/compat/compat-3.7.c +++ b/compat/compat-3.7.c @@ -161,7 +161,7 @@ int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val) return 0; } -EXPORT_SYMBOL(pcie_capability_read_word); +EXPORT_SYMBOL_GPL(pcie_capability_read_word); int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) { @@ -190,7 +190,7 @@ int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val) return 0; } -EXPORT_SYMBOL(pcie_capability_read_dword); +EXPORT_SYMBOL_GPL(pcie_capability_read_dword); int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) { @@ -202,7 +202,7 @@ int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val) return pci_write_config_word(dev, pci_pcie_cap(dev) + pos, val); } -EXPORT_SYMBOL(pcie_capability_write_word); +EXPORT_SYMBOL_GPL(pcie_capability_write_word); int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) { @@ -214,7 +214,7 @@ int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val) return pci_write_config_dword(dev, pci_pcie_cap(dev) + pos, val); } -EXPORT_SYMBOL(pcie_capability_write_dword); +EXPORT_SYMBOL_GPL(pcie_capability_write_dword); int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, u16 clear, u16 set) @@ -231,7 +231,7 @@ int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, return ret; } -EXPORT_SYMBOL(pcie_capability_clear_and_set_word); +EXPORT_SYMBOL_GPL(pcie_capability_clear_and_set_word); int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, u32 clear, u32 set) @@ -248,4 +248,4 @@ int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, return ret; } -EXPORT_SYMBOL(pcie_capability_clear_and_set_dword); +EXPORT_SYMBOL_GPL(pcie_capability_clear_and_set_dword); diff --git a/compat/user_namespace.c b/compat/user_namespace.c index a7cebd56..0dcc4bcf 100644 --- a/compat/user_namespace.c +++ b/compat/user_namespace.c @@ -20,14 +20,14 @@ kuid_t make_kuid(struct user_namespace *ns, uid_t uid) /* Map the uid to a global kernel uid */ return KUIDT_INIT(uid); } -EXPORT_SYMBOL(make_kuid); +EXPORT_SYMBOL_GPL(make_kuid); uid_t from_kuid(struct user_namespace *targ, kuid_t kuid) { /* Map the uid from a global kernel uid */ return __kuid_val(kuid); } -EXPORT_SYMBOL(from_kuid); +EXPORT_SYMBOL_GPL(from_kuid); uid_t from_kuid_munged(struct user_namespace *targ, kuid_t kuid) { @@ -38,21 +38,21 @@ uid_t from_kuid_munged(struct user_namespace *targ, kuid_t kuid) uid = overflowuid; return uid; } -EXPORT_SYMBOL(from_kuid_munged); +EXPORT_SYMBOL_GPL(from_kuid_munged); kgid_t make_kgid(struct user_namespace *ns, gid_t gid) { /* Map the gid to a global kernel gid */ return KGIDT_INIT(gid); } -EXPORT_SYMBOL(make_kgid); +EXPORT_SYMBOL_GPL(make_kgid); gid_t from_kgid(struct user_namespace *targ, kgid_t kgid) { /* Map the gid from a global kernel gid */ return __kgid_val(kgid); } -EXPORT_SYMBOL(from_kgid); +EXPORT_SYMBOL_GPL(from_kgid); gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid) { @@ -63,6 +63,6 @@ gid_t from_kgid_munged(struct user_namespace *targ, kgid_t kgid) gid = overflowgid; return gid; } -EXPORT_SYMBOL(from_kgid_munged); +EXPORT_SYMBOL_GPL(from_kgid_munged); #endif /* CONFIG_USER_NS */ -- cgit v1.2.3 From 8ae967309876a9297dedfdf64dfcca406639686f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: add LINUX_BACKPORT() for prefixing symbols Ben Hutchings notes that "compat" is already taken as a prefix for symbols and while this is only slightly true in practice its best we avoid any future issues. Others in the past have noted issues with symbols exported by backporting effort to conflict with other symbols that might be preferred by the running kernel. In the worst case scenerio we'd have the same subsystems with two eras with two sets of drivers using a subystem from an era each. This patch doesn't address that but tries to address the namespace conflict by compat itself. The best alternative I was hoping for was to use core module symbol namespaces but after reviewing that effort introduced in 2007 by Andi Kleen [0] I see in the end Rusty Russell nack'd these patches [1] so we're left with dealing with symbol renaming. Define LINUX_BACKPORT() to be used to allow us to rename symbols with a backport_ prefix. The the cleanest, but its a start. [0] http://thread.gmane.org/gmane.linux.network/78674 [1] http://article.gmane.org/gmane.linux.kernel/606885 Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 68e95d58..d1d24d03 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -3,6 +3,8 @@ #ifndef __ASSEMBLY__ +#define LINUX_BACKPORT(__sym) backport_ ##__sym + #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) #include -- cgit v1.2.3 From 8ef6a05c18884901d84a94b84725f5b05ebf16c0 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.23 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.23.c | 2 ++ include/linux/compat-2.6.23.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/compat/compat-2.6.23.c b/compat/compat-2.6.23.c index bc49e982..1a76957d 100644 --- a/compat/compat-2.6.23.c +++ b/compat/compat-2.6.23.c @@ -11,6 +11,7 @@ #include /* On net/core/dev.c as of 2.6.24 */ +#define __dev_addr_delete LINUX_BACKPORT(__dev_addr_delete) int __dev_addr_delete(struct dev_addr_list **list, int *count, void *addr, int alen, int glbl) { @@ -40,6 +41,7 @@ EXPORT_SYMBOL_GPL(__dev_addr_delete); /* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but * might as well add it */ +#define __dev_addr_add LINUX_BACKPORT(__dev_addr_add) int __dev_addr_add(struct dev_addr_list **list, int *count, void *addr, int alen, int glbl) { diff --git a/include/linux/compat-2.6.23.h b/include/linux/compat-2.6.23.h index fbfb470d..37cbc22a 100644 --- a/include/linux/compat-2.6.23.h +++ b/include/linux/compat-2.6.23.h @@ -75,6 +75,8 @@ static inline void tcf_destroy_chain_compat(struct tcf_proto **fl) #define __dev_set_promiscuity dev_set_promiscuity /* Our own 2.6.22 port on compat.c */ +#define dev_mc_unsync LINUX_BACKPORT(dev_mc_unsync) +#define dev_mc_sync LINUX_BACKPORT(dev_mc_sync) extern void dev_mc_unsync(struct net_device *to, struct net_device *from); extern int dev_mc_sync(struct net_device *to, struct net_device *from); @@ -113,6 +115,7 @@ struct genl_multicast_group /* Added as of 2.6.23 */ +#define pci_try_set_mwi LINUX_BACKPORT(pci_try_set_mwi) int pci_try_set_mwi(struct pci_dev *dev); /* Added as of 2.6.23 */ -- cgit v1.2.3 From fdf730192c1a876645da763c5d1970d8a649994f Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.24 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.24.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.24.h b/include/linux/compat-2.6.24.h index 456dcb6c..5448604c 100644 --- a/include/linux/compat-2.6.24.h +++ b/include/linux/compat-2.6.24.h @@ -45,6 +45,7 @@ struct net { #ifdef CONFIG_NET /* Init's network namespace */ +#define init_net LINUX_BACKPORT(init_net) extern struct net init_net; #define INIT_NET_NS(net_ns) .net_ns = &init_net, #else @@ -162,12 +163,16 @@ struct ssb_device_id { #define dev_get_by_index(a, b) dev_get_by_index(b) #define __dev_get_by_index(a, b) __dev_get_by_index(b) +#define eth_header LINUX_BACKPORT(eth_header) extern int eth_header(struct sk_buff *skb, struct net_device *dev, unsigned short type, void *daddr, void *saddr, unsigned len); +#define eth_rebuild_header LINUX_BACKPORT(eth_rebuild_header) extern int eth_rebuild_header(struct sk_buff *skb); +#define eth_header_cache_update LINUX_BACKPORT(eth_header_cache_update) extern void eth_header_cache_update(struct hh_cache *hh, struct net_device *dev, unsigned char * haddr); +#define eth_header_cache LINUX_BACKPORT(eth_header_cache) extern int eth_header_cache(struct neighbour *neigh, struct hh_cache *hh); -- cgit v1.2.3 From b407a05f13c1008dad583df1f945107c7595b600 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.25 There is one change needed here to get compilation working on v2.6.24, strict_strtoull is now being redefined and because of a change that went into v2.6.38.4 kstrtoul() was added there and the old strict_strtoul was made a define from it. To help aid the older kernels such as 2.6.24 that need the old strict_strtoul we simply check if strict_strtoull is defined, then we know you're on >= 2.6.38.4 and don't need kstrtoul() and friends. If strict_strtoull ever needs to be backported for older kernels we'll have to revisit this check. It is worth documenting here why this change went into v2.6.38.4 and not the orignal v2.6.38 release, so the commit is provided. commit 280a1c38c907ab1e2617bdcef66de6bc70897253 Author: Alexey Dobriyan kstrto*: converting strings to integers done (hopefully) right commit 33ee3b2e2eb9b4b6c64dcf9ed66e2ac3124e748c upstream. 1. simple_strto*() do not contain overflow checks and crufty, libc way to indicate failure. 2. strict_strto*() also do not have overflow checks but the name and comments pretend they do. 3. Both families have only "long long" and "long" variants, but users want strtou8() 4. Both "simple" and "strict" prefixes are wrong: Simple doesn't exactly say what's so simple, strict should not exist because conversion should be strict by default. The solution is to use "k" prefix and add convertors for more types. Enter kstrtoull() kstrtoll() kstrtoul() kstrtol() kstrtouint() kstrtoint() kstrtou64() kstrtos64() kstrtou32() kstrtos32() kstrtou16() kstrtos16() kstrtou8() kstrtos8() Include runtime testsuite (somewhat incomplete) as well. strict_strto*() become deprecated, stubbed to kstrto*() and eventually will be removed altogether. Use kstrto*() in code today! Note: on some archs _kstrtoul() and _kstrtol() are left in tree, even if they'll be unused at runtime. This is temporarily solution, because I don't want to hardcode list of archs where these functions aren't needed. Current solution with sizeof() and __alignof__ at least always works. Signed-off-by: Alexey Dobriyan Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman Tested with ckmake: 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.25.h | 5 +++++ include/linux/compat-2.6.39.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 5ca6783e..5d4fe38a 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -68,6 +68,7 @@ hit: } /* Backports b718989da7 */ +#define pci_enable_device_mem LINUX_BACKPORT(pci_enable_device_mem) int __must_check pci_enable_device_mem(struct pci_dev *dev); /* @@ -221,7 +222,9 @@ int compat_pm_qos_power_deinit(void); #define dev_crit(dev, format, arg...) \ dev_printk(KERN_CRIT , dev , format , ## arg) +#define __dev_addr_sync LINUX_BACKPORT(__dev_addr_sync) extern int __dev_addr_sync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); +#define __dev_addr_unsync LINUX_BACKPORT(__dev_addr_unsync) extern void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, struct dev_addr_list **from, int *from_count); #define seq_file_net &init_net; @@ -301,7 +304,9 @@ static inline void led_classdev_unregister_suspended(struct led_classdev *lcd) * The following things are out of ./include/linux/kernel.h * The new iwlwifi driver is using them. */ +#define strict_strtoul LINUX_BACKPORT(strict_strtoul) extern int strict_strtoul(const char *, unsigned int, unsigned long *); +#define strict_strtol LINUX_BACKPORT(strict_strtol) extern int strict_strtol(const char *, unsigned int, long *); #else diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 8ff08ba3..33db2201 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -113,7 +113,7 @@ static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc) * version included in compat-drivers. We use strict_strtol to check if * kstrto* is already available. */ -#ifndef strict_strtol +#ifndef strict_strtoull /* Internal, do not use. */ int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res); int __must_check _kstrtol(const char *s, unsigned int base, long *res); -- cgit v1.2.3 From 55986fdaa8021dc2dec9c15938476a49915d1b07 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.26 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.26.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.26.h b/include/linux/compat-2.6.26.h index 177792a3..b8d9dc64 100644 --- a/include/linux/compat-2.6.26.h +++ b/include/linux/compat-2.6.26.h @@ -45,6 +45,7 @@ #define SHORT_MAX ((s16)(USHORT_MAX>>1)) #define SHORT_MIN (-SHORT_MAX - 1) +#define dev_set_name LINUX_BACKPORT(dev_set_name) extern int dev_set_name(struct device *dev, const char *name, ...) __attribute__((format(printf, 2, 3))); -- cgit v1.2.3 From 6d8929d29ea5baa16e9b146adc0b27b67eb4cab9 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.27 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.27.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/compat-2.6.27.h b/include/linux/compat-2.6.27.h index 2eae9f2f..b71a3b57 100644 --- a/include/linux/compat-2.6.27.h +++ b/include/linux/compat-2.6.27.h @@ -87,6 +87,7 @@ static inline bool qdisc_all_tx_empty(const struct net_device *dev) return skb_queue_empty(&dev->qdisc->q); } +#define pci_pme_capable LINUX_BACKPORT(pci_pme_capable) bool pci_pme_capable(struct pci_dev *dev, pci_power_t state); /* @@ -207,7 +208,9 @@ static inline void list_splice_tail_init(struct list_head *list, } #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) +#define mmc_align_data_size LINUX_BACKPORT(mmc_align_data_size) extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int); +#define sdio_align_size LINUX_BACKPORT(sdio_align_size) extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz); #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ @@ -251,6 +254,8 @@ static inline void dma_sync_single_range_for_device(struct device *dev, #endif /* arm */ +#define debugfs_remove_recursive LINUX_BACKPORT(debugfs_remove_recursive) + #if defined(CONFIG_DEBUG_FS) void debugfs_remove_recursive(struct dentry *dentry); #else -- cgit v1.2.3 From 81a23ee1ac9aa536804a5e326fa048ad96a619a8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.28 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.28.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/compat-2.6.28.h b/include/linux/compat-2.6.28.h index 97f20662..3b5f3ea7 100644 --- a/include/linux/compat-2.6.28.h +++ b/include/linux/compat-2.6.28.h @@ -38,6 +38,7 @@ struct hid_device_id { #include #include +#define platform_device_register_data LINUX_BACKPORT(platform_device_register_data) extern struct platform_device *platform_device_register_data(struct device *, const char *, int, const void *, size_t); @@ -83,6 +84,7 @@ typedef u32 phys_addr_t; /* From : include/pcmcia/ds.h */ /* loop CIS entries for valid configuration */ +#define pcmcia_loop_config LINUX_BACKPORT(pcmcia_loop_config) int pcmcia_loop_config(struct pcmcia_device *p_dev, int (*conf_check) (struct pcmcia_device *p_dev, cistpl_cftable_entry_t *cfg, @@ -98,19 +100,24 @@ int pcmcia_loop_config(struct pcmcia_device *p_dev, #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) #if 0 +#define usb_poison_urb LINUX_BACKPORT(usb_poison_urb) extern void usb_poison_urb(struct urb *urb); #endif +#define usb_unpoison_urb LINUX_BACKPORT(usb_unpoison_urb) extern void usb_unpoison_urb(struct urb *urb); #if 0 +#define usb_poison_anchored_urbs LINUX_BACKPORT(usb_poison_anchored_urbs) extern void usb_poison_anchored_urbs(struct usb_anchor *anchor); #endif +#define usb_anchor_empty LINUX_BACKPORT(usb_anchor_empty) extern int usb_anchor_empty(struct usb_anchor *anchor); #endif /* CONFIG_USB */ #endif +#define pci_ioremap_bar LINUX_BACKPORT(pci_ioremap_bar) void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar); /** @@ -266,11 +273,7 @@ static inline void skb_queue_splice_tail(const struct sk_buff_head *list, #endif -/* openSuse includes round_jiffies_up in it's kernel 2.6.27. - * This is needed to prevent conflicts with the openSuse definition. - */ -#define round_jiffies_up backport_round_jiffies_up - +#define round_jiffies_up LINUX_BACKPORT(round_jiffies_up) unsigned long round_jiffies_up(unsigned long j); extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, @@ -279,9 +282,11 @@ extern void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *pag #define wake_up_interruptible_poll(x, m) \ __wake_up(x, TASK_INTERRUPTIBLE, 1, (void *) (m)) +#define n_tty_ioctl_helper LINUX_BACKPORT(n_tty_ioctl_helper) extern int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, unsigned int cmd, unsigned long arg); +#define pci_wake_from_d3 LINUX_BACKPORT(pci_wake_from_d3) int pci_wake_from_d3(struct pci_dev *dev, bool enable); #define alloc_workqueue(name, flags, max_active) __create_workqueue(name, flags, max_active) -- cgit v1.2.3 From 1bf31bcc0409c1d2d536309fc8d5233d026635ae Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.29 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.29.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/compat-2.6.29.h b/include/linux/compat-2.6.29.h index 9ebc5d5d..c8cf8987 100644 --- a/include/linux/compat-2.6.29.h +++ b/include/linux/compat-2.6.29.h @@ -245,6 +245,7 @@ static inline int ndo_do_ioctl(struct net_device *dev, } +#define netdev_attach_ops LINUX_BACKPORT(netdev_attach_ops) void netdev_attach_ops(struct net_device *dev, const struct net_device_ops *ops); @@ -287,6 +288,7 @@ static inline struct net_device_stats *dev_get_stats(struct net_device *dev) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) +#define usb_unpoison_anchored_urbs LINUX_BACKPORT(usb_unpoison_anchored_urbs) extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); #endif /* CONFIG_USB */ #endif @@ -298,8 +300,11 @@ extern void usb_unpoison_anchored_urbs(struct usb_anchor *anchor); } \ ) +#define eth_mac_addr LINUX_BACKPORT(eth_mac_addr) extern int eth_mac_addr(struct net_device *dev, void *p); +#define eth_change_mtu LINUX_BACKPORT(eth_change_mtu) extern int eth_change_mtu(struct net_device *dev, int new_mtu); +#define eth_validate_addr LINUX_BACKPORT(eth_validate_addr) extern int eth_validate_addr(struct net_device *dev); #ifdef CONFIG_NET_NS @@ -327,6 +332,7 @@ static inline struct net *read_pnet(struct net * const *pnet) #endif +#define init_dummy_netdev LINUX_BACKPORT(init_dummy_netdev) extern int init_dummy_netdev(struct net_device *dev); #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)) */ -- cgit v1.2.3 From 8d30ddb1b93459c954372b487977bd11c5f070b3 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.31 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.31.h | 65 +++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 42 deletions(-) diff --git a/include/linux/compat-2.6.31.h b/include/linux/compat-2.6.31.h index ce90f0a6..096c1318 100644 --- a/include/linux/compat-2.6.31.h +++ b/include/linux/compat-2.6.31.h @@ -25,25 +25,19 @@ #define ADVERTISED_10000baseKR_Full (1 << 19) #define ADVERTISED_10000baseR_FEC (1 << 20) -/* - * These macros allow us to backport rfkill without any - * changes on cfg80211 through compat.diff. Note that this - * file will be included by rfkill_backport.h so we must - * not conflict with things there. - */ -#define rfkill_get_led_trigger_name backport_rfkill_get_led_trigger_name -#define rfkill_set_led_trigger_name backport_rfkill_set_led_trigger_name -#define rfkill_set_hw_state backport_rfkill_set_hw_state -#define rfkill_set_sw_state backport_rfkill_set_sw_state -#define rfkill_init_sw_state backport_rfkill_init_sw_state -#define rfkill_set_states backport_rfkill_set_states -#define rfkill_pause_polling backport_rfkill_pause_polling -#define rfkill_resume_polling backport_rfkill_resume_polling -#define rfkill_blocked backport_rfkill_blocked -#define rfkill_alloc backport_rfkill_alloc -#define rfkill_register backport_rfkill_register -#define rfkill_unregister backport_rfkill_unregister -#define rfkill_destroy backport_rfkill_destroy +#define rfkill_get_led_trigger_name LINUX_BACKPORT(rfkill_get_led_trigger_name) +#define rfkill_set_led_trigger_name LINUX_BACKPORT(rfkill_set_led_trigger_name) +#define rfkill_set_hw_state LINUX_BACKPORT(rfkill_set_hw_state) +#define rfkill_set_sw_state LINUX_BACKPORT(rfkill_set_sw_state) +#define rfkill_init_sw_state LINUX_BACKPORT(rfkill_init_sw_state) +#define rfkill_set_states LINUX_BACKPORT(rfkill_set_states) +#define rfkill_pause_polling LINUX_BACKPORT(rfkill_pause_polling) +#define rfkill_resume_polling LINUX_BACKPORT(rfkill_resume_polling) +#define rfkill_blocked LINUX_BACKPORT(rfkill_blocked) +#define rfkill_alloc LINUX_BACKPORT(rfkill_alloc) +#define rfkill_register LINUX_BACKPORT(rfkill_register) +#define rfkill_unregister LINUX_BACKPORT(rfkill_unregister) +#define rfkill_destroy LINUX_BACKPORT(rfkill_destroy) #ifndef ERFKILL #if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC) @@ -63,29 +57,14 @@ #endif #endif -/* - * These changes allow us to backport and forward port - * the driver/net/mdio module. What we do is simply - * rename the exported symbols to other symbols and - * rely on the fact that compat-drivers will take care - * of renaming that module. This allows in-place drivers - * to use the old module and have the newer supplied - * drivers through compat-drivers to use the new bacported - * module. - * - * XXX: maybe we should have a COMPAT_EXPORT_SYMBOL() that - * takes care of renaming the symbols with a compat_ prefix? - * There are other ideas of using a separate namespace for - * modules supplied by compat -- someone already did the work - * but never sent the patches ;) who are you out there ? - */ -#define mdio45_probe compat_mdio45_probe -#define mdio_set_flag compat_mdio_set_flag -#define mdio45_links_ok compat_mdio45_links_ok -#define mdio45_nway_restart compat_mdio45_nway_restart -#define mdio45_ethtool_gset_npage compat_mdio45_ethtool_gset_npage -#define mdio45_ethtool_spauseparam_an compat_mdio45_ethtool_spauseparam_an -#define mdio_mii_ioctl compat_mdio_mii_ioctl +#define mdio45_probe LINUX_BACKPORT(mdio45_probe) +#define mdio_set_flag LINUX_BACKPORT(mdio_set_flag) +#define mdio45_links_ok LINUX_BACKPORT(mdio45_links_ok) +#define mdio45_nway_restart LINUX_BACKPORT(mdio45_nway_restart) + +#define mdio45_ethtool_gset_npage LINUX_BACKPORT(mdio45_ethtool_gset_npage) +#define mdio45_ethtool_spauseparam_an LINUX_BACKPORT(mdio45_ethtool_spauseparam_an) +#define mdio_mii_ioctl LINUX_BACKPORT(mdio_mii_ioctl) #ifndef NETDEV_PRE_UP #define NETDEV_PRE_UP 0x000D @@ -245,7 +224,9 @@ typedef struct { long long counter; } atomic64_t; +#define atomic64_read LINUX_BACKPORT(atomic64_read) extern long long atomic64_read(const atomic64_t *v); +#define atomic64_add_return LINUX_BACKPORT(atomic64_add_return) extern long long atomic64_add_return(long long a, atomic64_t *v); #define atomic64_inc_return(v) atomic64_add_return(1LL, (v)) -- cgit v1.2.3 From de419f5e97db3da355d2122f39d6b5095f178f52 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.32 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.32.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.32.h b/include/linux/compat-2.6.32.h index f8320cf0..d5b5df87 100644 --- a/include/linux/compat-2.6.32.h +++ b/include/linux/compat-2.6.32.h @@ -190,6 +190,7 @@ struct tm { int tm_yday; }; +#define time_to_tm LINUX_BACKPORT(time_to_tm) void time_to_tm(time_t totalsecs, int offset, struct tm *result); #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)) */ -- cgit v1.2.3 From 7d8d0200aabe024266db2b2f2d9cddcad67619e4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.33 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.33.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/include/linux/compat-2.6.33.h b/include/linux/compat-2.6.33.h index 307834ad..c0be190e 100644 --- a/include/linux/compat-2.6.33.h +++ b/include/linux/compat-2.6.33.h @@ -16,6 +16,8 @@ #include #include +#define usb_autopm_get_interface_no_resume LINUX_BACKPORT(usb_autopm_get_interface_no_resume) +#define usb_autopm_put_interface_no_suspend LINUX_BACKPORT(usb_autopm_put_interface_no_suspend) #ifdef CONFIG_USB_SUSPEND extern void usb_autopm_get_interface_no_resume(struct usb_interface *intf); extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); @@ -31,29 +33,27 @@ static inline void usb_autopm_put_interface_no_suspend(struct usb_interface *int #endif /* CONFIG_USB_SUSPEND */ #if defined(CONFIG_COMPAT_FIRMWARE_CLASS) -#if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) -#define release_firmware compat_release_firmware -#define request_firmware compat_request_firmware -#define request_firmware_nowait compat_request_firmware_nowait -#endif +#define request_firmware_nowait LINUX_BACKPORT(request_firmware_nowait) +#define request_firmware LINUX_BACKPORT(request_firmware) +#define release_firmware LINUX_BACKPORT(release_firmware) #if defined(CONFIG_FW_LOADER) || defined(CONFIG_FW_LOADER_MODULE) -int compat_request_firmware(const struct firmware **fw, const char *name, +int request_firmware(const struct firmware **fw, const char *name, struct device *device); -int compat_request_firmware_nowait( +int request_firmware_nowait( struct module *module, int uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)); -void compat_release_firmware(const struct firmware *fw); +void release_firmware(const struct firmware *fw); #else -static inline int compat_request_firmware(const struct firmware **fw, +static inline int request_firmware(const struct firmware **fw, const char *name, struct device *device) { return -EINVAL; } -static inline int compat_request_firmware_nowait( +static inline int request_firmware_nowait( struct module *module, int uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)) @@ -61,7 +61,7 @@ static inline int compat_request_firmware_nowait( return -EINVAL; } -static inline void compat_release_firmware(const struct firmware *fw) +static inline void release_firmware(const struct firmware *fw) { } #endif @@ -106,6 +106,7 @@ static inline struct sk_buff *netdev_alloc_skb_ip_align(struct net_device *dev, #define pcmcia_map_mem_page(a, b, c) pcmcia_map_mem_page(b, c) /* loop over CIS entries */ +#define pcmcia_loop_tuple LINUX_BACKPORT(pcmcia_loop_tuple) int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, int (*loop_tuple) (struct pcmcia_device *p_dev, tuple_t *tuple, @@ -115,6 +116,7 @@ int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, #endif /* CONFIG_PCMCIA */ /* loop over CIS entries */ +#define pccard_loop_tuple LINUX_BACKPORT(pccard_loop_tuple) int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, cisdata_t code, cisparse_t *parse, void *priv_data, int (*loop_tuple) (tuple_t *tuple, -- cgit v1.2.3 From 4f4d783558148a9fe4ee4a43dab45daa2607a062 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.34 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.34.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index eb228652..c206633a 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -326,9 +326,11 @@ static inline int lockdep_rtnl_is_held(void) } #endif /* #ifdef CONFIG_PROVE_LOCKING */ +#define seq_hlist_start_head LINUX_BACKPORT(seq_hlist_start_head) extern struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos); +#define seq_hlist_next LINUX_BACKPORT(seq_hlist_next) extern struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, loff_t *ppos); -- cgit v1.2.3 From e3f450331f5a94ebc43c831ba4c858ec28316fe7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.35 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.35.c | 4 ++-- include/linux/compat-2.6.35.h | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/compat/compat-2.6.35.c b/compat/compat-2.6.35.c index 646afa20..20fee853 100644 --- a/compat/compat-2.6.35.c +++ b/compat/compat-2.6.35.c @@ -61,7 +61,7 @@ EXPORT_SYMBOL_GPL(netif_set_real_num_tx_queues); * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad * input. */ -int compat_hex_to_bin(char ch) +int hex_to_bin(char ch) { if ((ch >= '0') && (ch <= '9')) return ch - '0'; @@ -70,7 +70,7 @@ int compat_hex_to_bin(char ch) return ch - 'a' + 10; return -1; } -EXPORT_SYMBOL_GPL(compat_hex_to_bin); +EXPORT_SYMBOL_GPL(hex_to_bin); /** * noop_llseek - No Operation Performed llseek implementation diff --git a/include/linux/compat-2.6.35.h b/include/linux/compat-2.6.35.h index 82b4dea4..99968bf2 100644 --- a/include/linux/compat-2.6.35.h +++ b/include/linux/compat-2.6.35.h @@ -45,6 +45,7 @@ static inline void qdisc_reset_all_tx_gt(struct net_device *dev, unsigned int i) } #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ +#define netif_set_real_num_tx_queues LINUX_BACKPORT(netif_set_real_num_tx_queues) extern int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq); @@ -68,11 +69,10 @@ static inline wait_queue_head_t *sk_sleep(struct sock *sk) #define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret) -/* mask hex_to_bin as RHEL6 backports this */ -#define hex_to_bin(a) compat_hex_to_bin(a) - +#define hex_to_bin LINUX_BACKPORT(hex_to_bin) int hex_to_bin(char ch); +#define noop_llseek LINUX_BACKPORT(noop_llseek) extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); #define pm_qos_request(_qos) pm_qos_requirement(_qos) @@ -88,6 +88,7 @@ usb_pipe_endpoint(struct usb_device *dev, unsigned int pipe) return eps[usb_pipeendpoint(pipe)]; } +#define simple_write_to_buffer LINUX_BACKPORT(simple_write_to_buffer) extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, const void __user *from, size_t count); -- cgit v1.2.3 From 5136b468cb633dcc7f174b99229313448da27965 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.36 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 32 ++++++++++++++++---------------- include/linux/compat-2.6.36.h | 43 +++++++++++++++++++++++-------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 72ada4a4..2c65b430 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -34,7 +34,7 @@ static void __usb_unanchor_urb(struct urb *urb, struct usb_anchor *anchor) * This routine should not be called by a driver after its disconnect * method has returned. */ -void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor) +void usb_unlink_anchored_urbs(struct usb_anchor *anchor) { struct urb *victim; @@ -43,7 +43,7 @@ void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor) usb_put_urb(victim); } } -EXPORT_SYMBOL_GPL(compat_usb_unlink_anchored_urbs); +EXPORT_SYMBOL_GPL(usb_unlink_anchored_urbs); /** * usb_get_from_anchor - get an anchor's oldest urb @@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(compat_usb_unlink_anchored_urbs); * this will take the oldest urb from an anchor, * unanchor and return it */ -struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor) +struct urb *usb_get_from_anchor(struct usb_anchor *anchor) { struct urb *victim; unsigned long flags; @@ -70,7 +70,7 @@ struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor) return victim; } -EXPORT_SYMBOL_GPL(compat_usb_get_from_anchor); +EXPORT_SYMBOL_GPL(usb_get_from_anchor); /** * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs @@ -78,7 +78,7 @@ EXPORT_SYMBOL_GPL(compat_usb_get_from_anchor); * * use this to get rid of all an anchor's urbs */ -void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) +void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) { struct urb *victim; unsigned long flags; @@ -91,7 +91,7 @@ void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor) } spin_unlock_irqrestore(&anchor->lock, flags); } -EXPORT_SYMBOL_GPL(compat_usb_scuttle_anchored_urbs); +EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); #endif /* CONFIG_COMPAT_USB_URB_THREAD_FIX */ @@ -102,13 +102,13 @@ EXPORT_SYMBOL_GPL(system_wq); EXPORT_SYMBOL_GPL(system_long_wq); EXPORT_SYMBOL_GPL(system_nrt_wq); -int compat_schedule_work(struct work_struct *work) +int schedule_work(struct work_struct *work) { return queue_work(system_wq, work); } -EXPORT_SYMBOL_GPL(compat_schedule_work); +EXPORT_SYMBOL_GPL(schedule_work); -int compat_schedule_work_on(int cpu, struct work_struct *work) +int schedule_work_on(int cpu, struct work_struct *work) { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) return queue_work_on(cpu, system_wq, work); @@ -116,25 +116,25 @@ int compat_schedule_work_on(int cpu, struct work_struct *work) return queue_work(system_wq, work); #endif } -EXPORT_SYMBOL_GPL(compat_schedule_work_on); +EXPORT_SYMBOL_GPL(schedule_work_on); -int compat_schedule_delayed_work(struct delayed_work *dwork, +int schedule_delayed_work(struct delayed_work *dwork, unsigned long delay) { return queue_delayed_work(system_wq, dwork, delay); } -EXPORT_SYMBOL_GPL(compat_schedule_delayed_work); +EXPORT_SYMBOL_GPL(schedule_delayed_work); -int compat_schedule_delayed_work_on(int cpu, +int schedule_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay) { return queue_delayed_work_on(cpu, system_wq, dwork, delay); } -EXPORT_SYMBOL_GPL(compat_schedule_delayed_work_on); +EXPORT_SYMBOL_GPL(schedule_delayed_work_on); #undef flush_scheduled_work -void compat_flush_scheduled_work(void) +void flush_scheduled_work(void) { /* * It is debatable which one we should prioritize first, lets @@ -144,7 +144,7 @@ void compat_flush_scheduled_work(void) flush_workqueue(system_wq); flush_scheduled_work(); } -EXPORT_SYMBOL_GPL(compat_flush_scheduled_work); +EXPORT_SYMBOL_GPL(flush_scheduled_work); /** * work_busy - test whether a work is currently pending or running diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index cd5e37ca..b4d3761f 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -25,13 +25,13 @@ struct va_format { #define device_rename(dev, new_name) device_rename(dev, (char *)new_name) #ifdef CONFIG_COMPAT_USB_URB_THREAD_FIX -#define usb_scuttle_anchored_urbs(anchor) compat_usb_scuttle_anchored_urbs(anchor) -#define usb_get_from_anchor(anchor) compat_usb_get_from_anchor(anchor) -#define usb_unlink_anchored_urbs(anchor) compat_usb_unlink_anchored_urbs(anchor) +#define usb_scuttle_anchored_urbs LINUX_BACKPORT(usb_scuttle_anchored_urbs) +#define usb_get_from_anchor LINUX_BACKPORT(usb_get_from_anchor) +#define usb_unlink_anchored_urbs LINUX_BACKPORT(usb_unlink_anchored_urbs) -extern void compat_usb_unlink_anchored_urbs(struct usb_anchor *anchor); -extern struct urb *compat_usb_get_from_anchor(struct usb_anchor *anchor); -extern void compat_usb_scuttle_anchored_urbs(struct usb_anchor *anchor); +extern void usb_unlink_anchored_urbs(struct usb_anchor *anchor); +extern struct urb *usb_get_from_anchor(struct usb_anchor *anchor); +extern void usb_scuttle_anchored_urbs(struct usb_anchor *anchor); #endif /** @@ -154,21 +154,29 @@ static inline void skb_tx_timestamp(struct sk_buff *skb) * item is never executed in parallel by multiple CPUs. Queue * flushing might take relatively long. */ +#define system_wq LINUX_BACKPORT(system_wq) extern struct workqueue_struct *system_wq; +#define system_long_wq LINUX_BACKPORT(system_long_wq) extern struct workqueue_struct *system_long_wq; +#define system_nrt_wq LINUX_BACKPORT(system_nrt_wq) extern struct workqueue_struct *system_nrt_wq; void compat_system_workqueue_create(void); void compat_system_workqueue_destroy(void); -int compat_schedule_work(struct work_struct *work); -int compat_schedule_work_on(int cpu, struct work_struct *work); -int compat_schedule_delayed_work(struct delayed_work *dwork, - unsigned long delay); -int compat_schedule_delayed_work_on(int cpu, - struct delayed_work *dwork, - unsigned long delay); -void compat_flush_scheduled_work(void); +#define schedule_work LINUX_BACKPORT(schedule_work) +int schedule_work(struct work_struct *work); +#define schedule_work_on LINUX_BACKPORT(schedule_work_on) +int schedule_work_on(int cpu, struct work_struct *work); +#define compat_schedule_delayed_work LINUX_BACKPORT(compat_schedule_delayed_work) +int schedule_delayed_work(struct delayed_work *dwork, + unsigned long delay); +#define compat_schedule_delayed_work_on LINUX_BACKPORT(compat_schedule_delayed_work_on) +int schedule_delayed_work_on(int cpu, + struct delayed_work *dwork, + unsigned long delay); +#define flush_scheduled_work LINUX_BACKPORT(flush_scheduled_work) +void flush_scheduled_work(void); enum { /* bit mask for work_busy() return values */ @@ -176,14 +184,9 @@ enum { WORK_BUSY_RUNNING = 1 << 1, }; +#define work_busy LINUX_BACKPORT(work_busy) extern unsigned int work_busy(struct work_struct *work); -#define schedule_work(work) compat_schedule_work(work) -#define schedule_work_on(cpu, work) compat_schedule_work_on(cpu, work) -#define schedule_delayed_work(dwork, delay) compat_schedule_delayed_work(dwork, delay) -#define schedule_delayed_work_on(cpu, dwork, delay) compat_schedule_delayed_work_on(cpu, dwork, delay) -#define flush_scheduled_work(a) compat_flush_scheduled_work(a) - #define br_port_exists(dev) (dev->br_port) #else -- cgit v1.2.3 From d43833ac3f1cc01fe71a22e03fcdc13f3ee5e88b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:13 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.37 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.37.c | 4 ++-- include/linux/compat-2.6.37.h | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/compat/compat-2.6.37.c b/compat/compat-2.6.37.c index 24b267a5..9f722a62 100644 --- a/compat/compat-2.6.37.c +++ b/compat/compat-2.6.37.c @@ -345,7 +345,7 @@ EXPORT_SYMBOL_GPL(compat_led_classdev_unregister); * For tight control over page level allocator and protection flags * use __vmalloc() instead. */ -void *compat_vzalloc(unsigned long size) +void *vzalloc(unsigned long size) { void *buf; buf = vmalloc(size); @@ -353,6 +353,6 @@ void *compat_vzalloc(unsigned long size) memset(buf, 0, size); return buf; } -EXPORT_SYMBOL_GPL(compat_vzalloc); +EXPORT_SYMBOL_GPL(vzalloc); #endif diff --git a/include/linux/compat-2.6.37.h b/include/linux/compat-2.6.37.h index c1d45af1..317ae6fe 100644 --- a/include/linux/compat-2.6.37.h +++ b/include/linux/compat-2.6.37.h @@ -41,6 +41,7 @@ static inline int proto_ports_offset(int proto) #define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */ +#define net_ns_type_operations LINUX_BACKPORT(net_ns_type_operations) extern struct kobj_ns_type_operations net_ns_type_operations; /* mask skb_checksum_none_assert as RHEL6 backports this */ @@ -144,9 +145,7 @@ extern void compat_led_brightness_set(struct led_classdev *led_cdev, #define netdev_refcnt_read(a) atomic_read(&a->refcnt) -/* mask vzalloc as RHEL6 backports this */ -#define vzalloc(a) compat_vzalloc(a) - +#define vzalloc LINUX_BACKPORT(vzalloc) extern void *vzalloc(unsigned long size); #define rtnl_dereference(p) \ -- cgit v1.2.3 From 927d442f25437b45e858c920a1abfff18787d5c4 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.38 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.38.c | 8 ++++---- include/linux/compat-2.6.38.h | 9 +++------ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/compat/compat-2.6.38.c b/compat/compat-2.6.38.c index b5461949..0074ac62 100644 --- a/compat/compat-2.6.38.c +++ b/compat/compat-2.6.38.c @@ -22,14 +22,14 @@ * * Initialize the EWMA parameters for a given struct ewma @avg. */ -void compat_ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight) +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(compat_ewma_init); +EXPORT_SYMBOL_GPL(ewma_init); /** * ewma_add() - Exponentially weighted moving average (EWMA) @@ -38,7 +38,7 @@ EXPORT_SYMBOL_GPL(compat_ewma_init); * * Add a sample to the average. */ -struct ewma *compat_ewma_add(struct ewma *avg, unsigned long val) +struct ewma *ewma_add(struct ewma *avg, unsigned long val) { avg->internal = avg->internal ? (((avg->internal * (avg->weight - 1)) + @@ -46,5 +46,5 @@ struct ewma *compat_ewma_add(struct ewma *avg, unsigned long val) (val * avg->factor); return avg; } -EXPORT_SYMBOL_GPL(compat_ewma_add); +EXPORT_SYMBOL_GPL(ewma_add); diff --git a/include/linux/compat-2.6.38.h b/include/linux/compat-2.6.38.h index e936c427..58ec64e5 100644 --- a/include/linux/compat-2.6.38.h +++ b/include/linux/compat-2.6.38.h @@ -66,17 +66,14 @@ struct ewma { unsigned long weight; }; -/* mask ewma_init as RHEL6 backports this */ -#define ewma_init(a,b,c) compat_ewma_init(a,b,c) - +#define ewma_init LINUX_BACKPORT(ewma_init) extern void ewma_init(struct ewma *avg, unsigned long factor, unsigned long weight); -/* mask ewma_add as RHEL6 backports this */ -#define ewma_add(a,b) compat_ewma_add(a,b) - +#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 -- cgit v1.2.3 From 34dfd309979f5518ea995f6aefc2b317ea6588cc Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v2.6.39 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.39.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-2.6.39.h b/include/linux/compat-2.6.39.h index 33db2201..e9a2eba8 100644 --- a/include/linux/compat-2.6.39.h +++ b/include/linux/compat-2.6.39.h @@ -24,6 +24,7 @@ static inline int __must_check PTR_RET(const void *ptr) #define tiocmset(tty, set, clear) tiocmset(tty, NULL, set, clear) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) +#define tty_set_termios LINUX_BACKPORT(tty_set_termios) extern int tty_set_termios(struct tty_struct *tty, struct ktermios *kt); #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ -- cgit v1.2.3 From 2a13ab5a026000755cc9a38b4daf3ebbb89a1dc5 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.0 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.0.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/compat-3.0.h b/include/linux/compat-3.0.h index ba25846a..7fcd763a 100644 --- a/include/linux/compat-3.0.h +++ b/include/linux/compat-3.0.h @@ -23,10 +23,12 @@ * * First part is in compat-3.0.c. */ +#define shmem_read_mapping_page_gfp LINUX_BACKPORT(shmem_read_mapping_page_gfp) extern struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, pgoff_t index, gfp_t gfp); +#define shmem_read_mapping_page LINUX_BACKPORT(shmem_read_mapping_page) static inline struct page *shmem_read_mapping_page( struct address_space *mapping, pgoff_t index) { @@ -77,6 +79,7 @@ struct bcma_device_id { #define BCMA_ANY_CLASS 0xFF #endif /* BCMA_CORE */ +#define mac_pton LINUX_BACKPORT(mac_pton) int mac_pton(const char *s, u8 *mac); int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res); -- cgit v1.2.3 From 53eb8fe4ad02f30b244e030dcb5bf5374e9c5a5a Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.1 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-3.1.c | 12 ++++++------ include/linux/compat-3.1.h | 12 +++--------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/compat/compat-3.1.c b/compat/compat-3.1.c index bfaf8eae..cb5d596a 100644 --- a/compat/compat-3.1.c +++ b/compat/compat-3.1.c @@ -19,7 +19,7 @@ * cpufreq: expose a cpufreq_quick_get_max routine */ #ifdef CONFIG_CPU_FREQ -unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) +unsigned int cpufreq_quick_get_max(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); unsigned int ret_freq = 0; @@ -31,7 +31,7 @@ unsigned int compat_cpufreq_quick_get_max(unsigned int cpu) return ret_freq; } -EXPORT_SYMBOL_GPL(compat_cpufreq_quick_get_max); +EXPORT_SYMBOL_GPL(cpufreq_quick_get_max); #endif static DEFINE_SPINLOCK(compat_simple_ida_lock); @@ -48,7 +48,7 @@ static DEFINE_SPINLOCK(compat_simple_ida_lock); * * Use ida_simple_remove() to get rid of an id. */ -int compat_ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, +int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, gfp_t gfp_mask) { int ret, id; @@ -86,14 +86,14 @@ again: return ret; } -EXPORT_SYMBOL_GPL(compat_ida_simple_get); +EXPORT_SYMBOL_GPL(ida_simple_get); /** * ida_simple_remove - remove an allocated id. * @ida: the (initialized) ida. * @id: the id returned by ida_simple_get. */ -void compat_ida_simple_remove(struct ida *ida, unsigned int id) +void ida_simple_remove(struct ida *ida, unsigned int id) { unsigned long flags; @@ -102,6 +102,6 @@ void compat_ida_simple_remove(struct ida *ida, unsigned int id) ida_remove(ida, id); spin_unlock_irqrestore(&compat_simple_ida_lock, flags); } -EXPORT_SYMBOL_GPL(compat_ida_simple_remove); +EXPORT_SYMBOL_GPL(ida_simple_remove); /* source lib/idr.c */ diff --git a/include/linux/compat-3.1.h b/include/linux/compat-3.1.h index 2b5eb8b7..3e8be336 100644 --- a/include/linux/compat-3.1.h +++ b/include/linux/compat-3.1.h @@ -88,21 +88,15 @@ static inline void security_sk_clone(const struct sock *sk, struct sock *newsk) #include #endif -/* mask ida_simple_get as RHEL6 backports this */ -#define ida_simple_get(a,b,c,d) compat_ida_simple_get(a,b,c,d) - +#define ida_simple_get LINUX_BACKPORT(ida_simple_get) int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end, gfp_t gfp_mask); -/* mask ida_simple_remove as RHEL6 backports this */ -#define ida_simple_remove(a,b) compat_ida_simple_remove(a,b) - +#define ida_simple_remove LINUX_BACKPORT(ida_simple_remove) void ida_simple_remove(struct ida *ida, unsigned int id); #ifdef CONFIG_CPU_FREQ -/* mask cpufreq_quick_get_max as RHEL6 backports this */ -#define cpufreq_quick_get_max(a) compat_cpufreq_quick_get_max(a) - +#define cpufreq_quick_get_max LINUX_BACKPORT(cpufreq_quick_get_max) unsigned int cpufreq_quick_get_max(unsigned int cpu); #endif -- cgit v1.2.3 From cded673b374bee309ac0519e4ad798b07c56b38b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.2 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.2.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-3.2.h b/include/linux/compat-3.2.h index d2302068..982b9898 100644 --- a/include/linux/compat-3.2.h +++ b/include/linux/compat-3.2.h @@ -102,6 +102,7 @@ static inline void *dma_zalloc_coherent(struct device *dev, size_t size, return ret; } +#define __netdev_printk LINUX_BACKPORT(__netdev_printk) extern int __netdev_printk(const char *level, const struct net_device *dev, struct va_format *vaf); -- cgit v1.2.3 From 678823327c6594eed8963a8299ed323fba4f5ef8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.3 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.3.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-3.3.h b/include/linux/compat-3.3.h index 84988bba..ee4b7ce2 100644 --- a/include/linux/compat-3.3.h +++ b/include/linux/compat-3.3.h @@ -287,6 +287,7 @@ static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) #endif #endif +#define __pskb_copy LINUX_BACKPORT(__pskb_copy) extern struct sk_buff *__pskb_copy(struct sk_buff *skb, int headroom, gfp_t gfp_mask); -- cgit v1.2.3 From d04ec393343ea3b076ea48c8a521632bd2a54863 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.4 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index fbd92a2a..94d3bf71 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -51,9 +51,11 @@ static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) #include #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34)) +#define i2c_bit_algo LINUX_BACKPORT(i2c_bit_algo) extern const struct i2c_algorithm i2c_bit_algo; #endif +#define simple_open LINUX_BACKPORT(simple_open) extern int simple_open(struct inode *inode, struct file *file); #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)) -- cgit v1.2.3 From 5c4395bd4d50c703bd4366c04708e01a5526e55e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.7 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.7.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/compat-3.7.h b/include/linux/compat-3.7.h index dd05e00c..96662e37 100644 --- a/include/linux/compat-3.7.h +++ b/include/linux/compat-3.7.h @@ -45,6 +45,7 @@ static inline struct user_namespace *seq_user_ns(struct seq_file *seq) #define genl_info_snd_portid(__genl_info) (__genl_info->snd_pid) #define NETLINK_CB_PORTID(__skb) NETLINK_CB(cb->skb).pid +#define mod_delayed_work LINUX_BACKPORT(mod_delayed_work) bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, unsigned long delay); @@ -55,12 +56,18 @@ bool mod_delayed_work(struct workqueue_struct *wq, struct delayed_work *dwork, #define tty_port_register_device(port, driver, index, device) \ tty_register_device(driver, index, device) +#define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word) int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val); +#define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword) int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val); +#define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word) int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val); +#define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword) int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val); +#define pcie_capability_clear_and_set_word LINUX_BACKPORT(pcie_capability_clear_and_set_word) int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos, u16 clear, u16 set); +#define pcie_capability_clear_and_set_dword LINUX_BACKPORT(pcie_capability_clear_and_set_dword) int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos, u32 clear, u32 set); -- cgit v1.2.3 From 42872b88bf5e42d4330efbda51ec647f79a6dde1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for v3.8 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.8.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/compat-3.8.h b/include/linux/compat-3.8.h index 184d1d09..55fdc165 100644 --- a/include/linux/compat-3.8.h +++ b/include/linux/compat-3.8.h @@ -16,6 +16,7 @@ #define prandom_u32_state(_state) prandom32(_state) #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8)) +#define netdev_set_default_ethtool_ops LINUX_BACKPORT(netdev_set_default_ethtool_ops) extern void netdev_set_default_ethtool_ops(struct net_device *dev, const struct ethtool_ops *ops); #endif @@ -26,6 +27,7 @@ extern void netdev_set_default_ethtool_ops(struct net_device *dev, #define PCI_EXP_LNKCTL_ASPM_L0S 0x01 /* L0s Enable */ #define PCI_EXP_LNKCTL_ASPM_L1 0x02 /* L1 Enable */ +#define hid_ignore LINUX_BACKPORT(hid_ignore) extern bool hid_ignore(struct hid_device *); /* This backports: -- cgit v1.2.3 From 13398fa523edd9d54c33a406e9c3d40b0be8cbb0 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for cordic 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/cordic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/cordic.h b/include/linux/cordic.h index f932093e..2de0aa32 100644 --- a/include/linux/cordic.h +++ b/include/linux/cordic.h @@ -43,6 +43,7 @@ struct cordic_iq { * for -180 degrees to +180 degrees. Passed values outside this range are * converted before doing the actual calculation. */ +#define cordic_calc_iq LINUX_BACKPORT(cordic_calc_iq) struct cordic_iq cordic_calc_iq(s32 theta); #endif /* __CORDIC_H_ */ -- cgit v1.2.3 From 72b310630fd84e109feeb5be47c4b2245937069b Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for crc8 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/crc8.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/crc8.h b/include/linux/crc8.h index 13c8dabb..f0a92ef1 100644 --- a/include/linux/crc8.h +++ b/include/linux/crc8.h @@ -52,6 +52,7 @@ * * - lsb first: poly = 10101011(1) = 0xAB */ +#define crc8_populate_lsb LINUX_BACKPORT(crc8_populate_lsb) void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); /** @@ -70,6 +71,7 @@ void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); * * - msb first: poly = (1)11010101 = 0xD5 */ +#define crc8_populate_msb LINUX_BACKPORT(crc8_populate_msb) void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); /** @@ -96,6 +98,7 @@ void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial); * Williams, Ross N., rossross.net * (see URL http://www.ross.net/crc/download/crc_v3.txt). */ +#define crc8 LINUX_BACKPORT(crc8) u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc); #endif /* __CRC8_H_ */ -- cgit v1.2.3 From c41ca82d3da191f1b7d37f023d47583323a189e8 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for kfifo 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/kfifo.h | 146 ++++++++++++++++++++++++++++---------------------- 1 file changed, 83 insertions(+), 63 deletions(-) diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index e30bb546..398b00d0 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h @@ -187,6 +187,89 @@ __kfifo_int_must_check_helper(int val) return val; } +#define __kfifo_alloc LINUX_BACKPORT(__kfifo_alloc) +extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, + size_t esize, gfp_t gfp_mask); +#define __kfifo_free LINUX_BACKPORT(__kfifo_free) +extern void __kfifo_free(struct __kfifo *fifo); + +#define __kfifo_init LINUX_BACKPORT(__kfifo_init) +extern int __kfifo_init(struct __kfifo *fifo, void *buffer, + unsigned int size, size_t esize); + +#define __kfifo_in LINUX_BACKPORT(__kfifo_in) +extern unsigned int __kfifo_in(struct __kfifo *fifo, + const void *buf, unsigned int len); + +#define __kfifo_out LINUX_BACKPORT(__kfifo_out) +extern unsigned int __kfifo_out(struct __kfifo *fifo, + void *buf, unsigned int len); + +#define __kfifo_from_user LINUX_BACKPORT(__kfifo_from_user) +extern int __kfifo_from_user(struct __kfifo *fifo, + const void __user *from, unsigned long len, unsigned int *copied); + +#define __kfifo_to_user LINUX_BACKPORT(__kfifo_to_user) +extern int __kfifo_to_user(struct __kfifo *fifo, + void __user *to, unsigned long len, unsigned int *copied); + +#define __kfifo_dma_in_prepare LINUX_BACKPORT(__kfifo_dma_in_prepare) +extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len); + +#define __kfifo_dma_out_prepare LINUX_BACKPORT(__kfifo_dma_out_prepare) +extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len); + +#define __kfifo_out_peek LINUX_BACKPORT(__kfifo_out_peek) +extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, + void *buf, unsigned int len); + +#define __kfifo_in_r LINUX_BACKPORT(__kfifo_in_r) +extern unsigned int __kfifo_in_r(struct __kfifo *fifo, + const void *buf, unsigned int len, size_t recsize); + +#define __kfifo_out_r LINUX_BACKPORT(__kfifo_out_r) +extern unsigned int __kfifo_out_r(struct __kfifo *fifo, + void *buf, unsigned int len, size_t recsize); + +#define __kfifo_from_user_r LINUX_BACKPORT(__kfifo_from_user_r) +extern int __kfifo_from_user_r(struct __kfifo *fifo, + const void __user *from, unsigned long len, unsigned int *copied, + size_t recsize); + +#define __kfifo_to_user_r LINUX_BACKPORT(__kfifo_to_user_r) +extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, + unsigned long len, unsigned int *copied, size_t recsize); + +#define __kfifo_dma_in_prepare_r LINUX_BACKPORT(__kfifo_dma_in_prepare_r) +extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); + +#define __kfifo_dma_in_finish_r LINUX_BACKPORT(__kfifo_dma_in_finish_r) +extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo, + unsigned int len, size_t recsize); + +#define __kfifo_dma_out_prepare_r LINUX_BACKPORT(__kfifo_dma_out_prepare_r) +extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, + struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); + +#define __kfifo_dma_out_finish_r LINUX_BACKPORT(__kfifo_dma_out_finish_r) +extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize); + +#define __kfifo_len_r LINUX_BACKPORT(__kfifo_len_r) +extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize); + +#define __kfifo_skip_r LINUX_BACKPORT(__kfifo_skip_r) +extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize); + +#define __kfifo_out_peek_r LINUX_BACKPORT(__kfifo_out_peek_r) +extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, + void *buf, unsigned int len, size_t recsize); + +#define __kfifo_max_r LINUX_BACKPORT(__kfifo_max_r) +extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize); + /** * kfifo_initialized - Check if the fifo is initialized * @fifo: address of the fifo to check @@ -790,68 +873,5 @@ __kfifo_uint_must_check_helper( \ __kfifo_out_peek(__kfifo, __buf, __n); \ }) \ ) - -extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, - size_t esize, gfp_t gfp_mask); - -extern void __kfifo_free(struct __kfifo *fifo); - -extern int __kfifo_init(struct __kfifo *fifo, void *buffer, - unsigned int size, size_t esize); - -extern unsigned int __kfifo_in(struct __kfifo *fifo, - const void *buf, unsigned int len); - -extern unsigned int __kfifo_out(struct __kfifo *fifo, - void *buf, unsigned int len); - -extern int __kfifo_from_user(struct __kfifo *fifo, - const void __user *from, unsigned long len, unsigned int *copied); - -extern int __kfifo_to_user(struct __kfifo *fifo, - void __user *to, unsigned long len, unsigned int *copied); - -extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len); - -extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len); - -extern unsigned int __kfifo_out_peek(struct __kfifo *fifo, - void *buf, unsigned int len); - -extern unsigned int __kfifo_in_r(struct __kfifo *fifo, - const void *buf, unsigned int len, size_t recsize); - -extern unsigned int __kfifo_out_r(struct __kfifo *fifo, - void *buf, unsigned int len, size_t recsize); - -extern int __kfifo_from_user_r(struct __kfifo *fifo, - const void __user *from, unsigned long len, unsigned int *copied, - size_t recsize); - -extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, - unsigned long len, unsigned int *copied, size_t recsize); - -extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); - -extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo, - unsigned int len, size_t recsize); - -extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len, size_t recsize); - -extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize); - -extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize); - -extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize); - -extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, - void *buf, unsigned int len, size_t recsize); - -extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize); - #endif #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) */ -- cgit v1.2.3 From eb0960f53e06c3c3fb6a55e1e643b1b3646a90c2 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for pm_qos_params 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/pm_qos_params.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/linux/pm_qos_params.h b/include/linux/pm_qos_params.h index d0e3ad86..4c8c89ef 100644 --- a/include/linux/pm_qos_params.h +++ b/include/linux/pm_qos_params.h @@ -23,13 +23,19 @@ #define PM_QOS_NUM_CLASSES 5 #define PM_QOS_DEFAULT_VALUE -1 +#define pm_qos_add_requirement LINUX_BACKPORT(pm_qos_add_requirement) int pm_qos_add_requirement(int qos, char *name, s32 value); +#define pm_qos_update_requirement LINUX_BACKPORT(pm_qos_update_requirement) int pm_qos_update_requirement(int qos, char *name, s32 new_value); +#define pm_qos_remove_requirement LINUX_BACKPORT(pm_qos_remove_requirement) void pm_qos_remove_requirement(int qos, char *name); +#define pm_qos_requirement LINUX_BACKPORT(pm_qos_requirement) int pm_qos_requirement(int qos); +#define pm_qos_add_notifier LINUX_BACKPORT(pm_qos_add_notifier) int pm_qos_add_notifier(int qos, struct notifier_block *notifier); +#define pm_qos_remove_notifier LINUX_BACKPORT(pm_qos_remove_notifier) int pm_qos_remove_notifier(int qos, struct notifier_block *notifier); #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,25)) */ -- cgit v1.2.3 From d8e70cc2918dc779c494c6995a691edff66880d5 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: embrace LINUX_BACKPORT() for uidgid 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- include/linux/uidgid.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h index d9e4224e..ae1ed808 100644 --- a/include/linux/uidgid.h +++ b/include/linux/uidgid.h @@ -133,19 +133,27 @@ static inline bool gid_valid(kgid_t gid) #ifdef CONFIG_USER_NS +#define make_kuid LINUX_BACKPORT(make_kuid) extern kuid_t make_kuid(struct user_namespace *from, uid_t uid); +#define make_kgid LINUX_BACKPORT(make_kgid) extern kgid_t make_kgid(struct user_namespace *from, gid_t gid); +#define from_kuid LINUX_BACKPORT(from_kuid) extern uid_t from_kuid(struct user_namespace *to, kuid_t uid); +#define from_kgid LINUX_BACKPORT(from_kgid) extern gid_t from_kgid(struct user_namespace *to, kgid_t gid); +#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged) extern uid_t from_kuid_munged(struct user_namespace *to, kuid_t uid); +#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged) extern gid_t from_kgid_munged(struct user_namespace *to, kgid_t gid); +#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping) static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) { return from_kuid(ns, uid) != (uid_t) -1; } +#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping) static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) { return from_kgid(ns, gid) != (gid_t) -1; @@ -153,26 +161,31 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) #else +#define make_kuid LINUX_BACKPORT(make_kuid) static inline kuid_t make_kuid(struct user_namespace *from, uid_t uid) { return KUIDT_INIT(uid); } +#define make_kgid LINUX_BACKPORT(make_kgid) static inline kgid_t make_kgid(struct user_namespace *from, gid_t gid) { return KGIDT_INIT(gid); } +#define from_kuid LINUX_BACKPORT(from_kuid) static inline uid_t from_kuid(struct user_namespace *to, kuid_t kuid) { return __kuid_val(kuid); } +#define from_kgid LINUX_BACKPORT(from_kgid) static inline gid_t from_kgid(struct user_namespace *to, kgid_t kgid) { return __kgid_val(kgid); } +#define from_kuid_munged LINUX_BACKPORT(from_kuid_munged) static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid) { uid_t uid = from_kuid(to, kuid); @@ -181,6 +194,7 @@ static inline uid_t from_kuid_munged(struct user_namespace *to, kuid_t kuid) return uid; } +#define from_kgid_munged LINUX_BACKPORT(from_kgid_munged) static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid) { gid_t gid = from_kgid(to, kgid); @@ -189,11 +203,13 @@ static inline gid_t from_kgid_munged(struct user_namespace *to, kgid_t kgid) return gid; } +#define kuid_has_mapping LINUX_BACKPORT(kuid_has_mapping) static inline bool kuid_has_mapping(struct user_namespace *ns, kuid_t uid) { return true; } +#define kgid_has_mapping LINUX_BACKPORT(kgid_has_mapping) static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid) { return true; -- cgit v1.2.3 From a05e783cb8853210628bd1f2bd82d17dd004c9d1 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 19 Mar 2013 17:57:14 -0700 Subject: compat: use backport_ prefix for main compat module calls 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.34.c | 8 ++++---- compat/compat-2.6.34.h | 4 ++-- compat/main.c | 25 +++++++++++++------------ compat/pm_qos_params.c | 4 ++-- include/linux/compat-2.6.25.h | 10 +++++----- include/linux/compat-2.6.34.h | 6 ------ include/linux/compat-2.6.36.h | 8 ++++---- include/linux/compat-2.6.h | 8 ++++---- 8 files changed, 34 insertions(+), 39 deletions(-) diff --git a/compat/compat-2.6.34.c b/compat/compat-2.6.34.c index 72060076..4b23c817 100644 --- a/compat/compat-2.6.34.c +++ b/compat/compat-2.6.34.c @@ -12,16 +12,16 @@ #include "compat-2.6.34.h" -static mmc_pm_flag_t compat_mmc_pm_flags; +static mmc_pm_flag_t backport_mmc_pm_flags; -void init_compat_mmc_pm_flags(void) +void backport_init_mmc_pm_flags(void) { - compat_mmc_pm_flags = 0; + backport_mmc_pm_flags = 0; } mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func) { - return compat_mmc_pm_flags; + return backport_mmc_pm_flags; } int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) diff --git a/compat/compat-2.6.34.h b/compat/compat-2.6.34.h index 173fe522..b36b441a 100644 --- a/compat/compat-2.6.34.h +++ b/compat/compat-2.6.34.h @@ -7,11 +7,11 @@ #include -void init_compat_mmc_pm_flags(void); +void backport_init_mmc_pm_flags(void); #else /* Kernels >= 2.6.34 */ -static inline void init_compat_mmc_pm_flags(void) +static inline void backport_init_mmc_pm_flags(void) { } diff --git a/compat/main.c b/compat/main.c index 972c142d..4e72ca55 100644 --- a/compat/main.c +++ b/compat/main.c @@ -1,7 +1,8 @@ #include +#include "compat-2.6.34.h" MODULE_AUTHOR("Luis R. Rodriguez"); -MODULE_DESCRIPTION("Kernel compatibility module"); +MODULE_DESCRIPTION("Kernel backport module"); MODULE_LICENSE("GPL"); #ifndef COMPAT_BASE @@ -41,17 +42,17 @@ module_param(compat_version, charp, 0400); MODULE_PARM_DESC(compat_version, "Version of the kernel compat backport work"); -void compat_dependency_symbol(void) +void backport_dependency_symbol(void) { } -EXPORT_SYMBOL_GPL(compat_dependency_symbol); +EXPORT_SYMBOL_GPL(backport_dependency_symbol); -static int __init compat_init(void) +static int __init backport_init(void) { - compat_pm_qos_power_init(); - compat_system_workqueue_create(); - init_compat_mmc_pm_flags(); + backport_pm_qos_power_init(); + backport_system_workqueue_create(); + backport_init_mmc_pm_flags(); printk(KERN_INFO COMPAT_PROJECT " backport release: " @@ -65,14 +66,14 @@ static int __init compat_init(void) return 0; } -module_init(compat_init); +module_init(backport_init); -static void __exit compat_exit(void) +static void __exit backport_exit(void) { - compat_pm_qos_power_deinit(); - compat_system_workqueue_destroy(); + backport_pm_qos_power_deinit(); + backport_system_workqueue_destroy(); return; } -module_exit(compat_exit); +module_exit(backport_exit); diff --git a/compat/pm_qos_params.c b/compat/pm_qos_params.c index 833d98c5..42785ce1 100644 --- a/compat/pm_qos_params.c +++ b/compat/pm_qos_params.c @@ -414,7 +414,7 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf, /* * This initializes pm-qos for older kernels. */ -int compat_pm_qos_power_init(void) +int backport_pm_qos_power_init(void) { int ret = 0; @@ -442,7 +442,7 @@ int compat_pm_qos_power_init(void) return ret; } -int compat_pm_qos_power_deinit(void) +int backport_pm_qos_power_deinit(void) { int ret = 0; diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index 5d4fe38a..a08e0b26 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -193,11 +193,11 @@ typedef u32 phys_addr_t; * This pm-qos implementation is copied verbatim from the kernel * written by mark gross mgross@linux.intel.com. You don't have * to do anythinig to use pm-qos except use the same exported - * routines as used in newer kernels. The compat_pm_qos_power_init() + * routines as used in newer kernels. The backport_pm_qos_power_init() * defned below is used by the compat module to initialize pm-qos. */ -int compat_pm_qos_power_init(void); -int compat_pm_qos_power_deinit(void); +int backport_pm_qos_power_init(void); +int backport_pm_qos_power_deinit(void); /* * 2.6.25 adds PM_EVENT_HIBERNATE as well here but @@ -314,12 +314,12 @@ extern int strict_strtol(const char *, unsigned int, long *); * Kernels >= 2.6.25 have pm-qos and its initialized as part of * the bootup process */ -static inline int compat_pm_qos_power_init(void) +static inline int backport_pm_qos_power_init(void) { return 0; } -static inline int compat_pm_qos_power_deinit(void) +static inline int backport_pm_qos_power_deinit(void) { return 0; } diff --git a/include/linux/compat-2.6.34.h b/include/linux/compat-2.6.34.h index c206633a..09d59229 100644 --- a/include/linux/compat-2.6.34.h +++ b/include/linux/compat-2.6.34.h @@ -25,8 +25,6 @@ typedef unsigned int mmc_pm_flag_t; extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func); extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); -void init_compat_mmc_pm_flags(void); - #define netdev_mc_count(dev) ((dev)->mc_count) #define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0) @@ -341,10 +339,6 @@ static inline struct sock *sk_entry(const struct hlist_node *node) #else /* Kernels >= 2.6.34 */ -static inline void init_compat_mmc_pm_flags(void) -{ -} - #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ diff --git a/include/linux/compat-2.6.36.h b/include/linux/compat-2.6.36.h index b4d3761f..d90b84f6 100644 --- a/include/linux/compat-2.6.36.h +++ b/include/linux/compat-2.6.36.h @@ -161,8 +161,8 @@ extern struct workqueue_struct *system_long_wq; #define system_nrt_wq LINUX_BACKPORT(system_nrt_wq) extern struct workqueue_struct *system_nrt_wq; -void compat_system_workqueue_create(void); -void compat_system_workqueue_destroy(void); +void backport_system_workqueue_create(void); +void backport_system_workqueue_destroy(void); #define schedule_work LINUX_BACKPORT(schedule_work) int schedule_work(struct work_struct *work); @@ -191,11 +191,11 @@ extern unsigned int work_busy(struct work_struct *work); #else -static inline void compat_system_workqueue_create(void) +static inline void backport_system_workqueue_create(void) { } -static inline void compat_system_workqueue_destroy(void) +static inline void backport_system_workqueue_destroy(void) { } diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index d1d24d03..5d759193 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -28,16 +28,16 @@ * To the call to the initfn we added the symbol dependency on compat * to make sure that compat.ko gets loaded for any compat modules. */ -void compat_dependency_symbol(void); +void backport_dependency_symbol(void); #undef module_init #define module_init(initfn) \ - static int __init __init_compat(void) \ + static int __init __init_backport(void) \ { \ - compat_dependency_symbol(); \ + backport_dependency_symbol(); \ return initfn(); \ } \ - int init_module(void) __attribute__((alias("__init_compat"))); + int init_module(void) __attribute__((alias("__init_backport"))); /* * Each compat file represents compatibility code for new kernel -- cgit v1.2.3 From b6dc7a859bd7e0fa99fabefdd36dffa3884b2247 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 21 Mar 2013 21:16:42 +0000 Subject: compat: backport sg page iterator a321e91b This backports commit a321e91b which adds the scatterlist simple page iterator. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains a321e91b v3.9-rc1~46^2~149 commit a321e91b6d73ed011ffceed384c40d2785cf723b Author: Imre Deak Date: Wed Feb 27 17:02:56 2013 -0800 lib/scatterlist: add simple page iterator Add an iterator to walk through a scatter list a page at a time starting at a specific page offset. As opposed to the mapping iterator this is meant to be small, performing well even in simple loops like collecting all pages on the scatterlist into an array or setting up an iommu table based on the pages' DMA address. Signed-off-by: Imre Deak Cc: Maxim Levitsky Cc: Tejun Heo Cc: Daniel Vetter Tested-by: Stephen Warren Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.9.c | 54 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.9.h | 44 ++++++++++++++++++++++++++++++++++++ scripts/gen-compat-config.sh | 2 +- 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 compat/compat-3.9.c diff --git a/compat/Makefile b/compat/Makefile index 3b9bfdeb..5abdc35a 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -51,6 +51,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_5) += \ user_namespace.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_KERNEL_3_8) += compat-3.8.o +compat-$(CONFIG_COMPAT_KERNEL_3_9) += compat-3.9.o compat-$(CONFIG_COMPAT_CORDIC) += cordic.o compat-$(CONFIG_COMPAT_CRC8) += crc8.o diff --git a/compat/compat-3.9.c b/compat/compat-3.9.c new file mode 100644 index 00000000..7134caa9 --- /dev/null +++ b/compat/compat-3.9.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2013 Luis R. Rodriguez + * + * Compatibility file for Linux wireless for kernels 3.9. + * + * 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. + */ + +#include +#include + +#ifndef __sg_page_iter_next + +void __sg_page_iter_start(struct sg_page_iter *piter, + struct scatterlist *sglist, unsigned int nents, + unsigned long pgoffset) +{ + piter->__pg_advance = 0; + piter->__nents = nents; + + piter->page = NULL; + piter->sg = sglist; + piter->sg_pgoffset = pgoffset; +} +EXPORT_SYMBOL_GPL(__sg_page_iter_start); + +static int sg_page_count(struct scatterlist *sg) +{ + return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT; +} + +bool __sg_page_iter_next(struct sg_page_iter *piter) +{ + if (!piter->__nents || !piter->sg) + return false; + + piter->sg_pgoffset += piter->__pg_advance; + piter->__pg_advance = 1; + + while (piter->sg_pgoffset >= sg_page_count(piter->sg)) { + piter->sg_pgoffset -= sg_page_count(piter->sg); + piter->sg = sg_next(piter->sg); + if (!--piter->__nents || !piter->sg) + return false; + } + piter->page = nth_page(sg_page(piter->sg), piter->sg_pgoffset); + + return true; +} +EXPORT_SYMBOL_GPL(__sg_page_iter_next); + +#endif /* __sg_page_iter_next */ diff --git a/include/linux/compat-3.9.h b/include/linux/compat-3.9.h index 89b94a45..240a328d 100644 --- a/include/linux/compat-3.9.h +++ b/include/linux/compat-3.9.h @@ -14,10 +14,54 @@ #include #include #include +#include /* include this before changing hlist_for_each_* to use the old versions. */ #include +/* Lets expect distributions might backport this */ + +#ifndef for_each_sg_page +/* + * sg page iterator + * + * Iterates over sg entries page-by-page. On each successful iteration, + * @piter->page points to the current page, @piter->sg to the sg holding this + * page and @piter->sg_pgoffset to the page's page offset within the sg. The + * iteration will stop either when a maximum number of sg entries was reached + * or a terminating sg (sg_last(sg) == true) was reached. + */ +struct sg_page_iter { + struct page *page; /* current page */ + struct scatterlist *sg; /* sg holding the page */ + unsigned int sg_pgoffset; /* page offset within the sg */ + + /* these are internal states, keep away */ + unsigned int __nents; /* remaining sg entries */ + int __pg_advance; /* nr pages to advance at the + * next step */ +}; + +#define __sg_page_iter_next LINUX_BACKPORT(__sg_page_iter_next) +bool __sg_page_iter_next(struct sg_page_iter *piter); +#define __sg_page_iter_start LINUX_BACKPORT(__sg_page_iter_start) +void __sg_page_iter_start(struct sg_page_iter *piter, + struct scatterlist *sglist, unsigned int nents, + unsigned long pgoffset); + +/** + * for_each_sg_page - iterate over the pages of the given sg list + * @sglist: sglist to iterate over + * @piter: page iterator to hold current page, sg, sg_pgoffset + * @nents: maximum number of sg entries to iterate over + * @pgoffset: starting page offset + */ +#define for_each_sg_page(sglist, piter, nents, pgoffset) \ + for (__sg_page_iter_start((piter), (sglist), (nents), (pgoffset)); \ + __sg_page_iter_next(piter);) + +#endif /* for_each_sg_page assumption */ + /* backports 7a555613 */ #if defined(CONFIG_DYNAMIC_DEBUG) #define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \ diff --git a/scripts/gen-compat-config.sh b/scripts/gen-compat-config.sh index 00511c51..8dd6f4c4 100755 --- a/scripts/gen-compat-config.sh +++ b/scripts/gen-compat-config.sh @@ -17,7 +17,7 @@ fi KERNEL_VERSION=$(${MAKE} -C ${KLIB_BUILD} kernelversion | sed -n 's/^\([0-9]\)\..*/\1/p') # 3.0 kernel stuff -COMPAT_LATEST_VERSION="8" +COMPAT_LATEST_VERSION="9" KERNEL_SUBLEVEL="-1" # Note that this script will export all variables explicitly, -- cgit v1.2.3 From d281c6eb26438b005b0faf20cba2276e2e5d8c24 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 21 Mar 2013 23:17:59 +0000 Subject: compat: fix backport_ prefix change on compat module The commit a05e783c addressed the main compat module routine name changes but failed to fix two calls. Fix this. Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 2c65b430..3479af49 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -170,7 +170,7 @@ unsigned int work_busy(struct work_struct *work) } EXPORT_SYMBOL_GPL(work_busy); -void compat_system_workqueue_create() +void backport_system_workqueue_create(void) { system_wq = alloc_workqueue("events", 0, 0); system_long_wq = alloc_workqueue("events_long", 0, 0); @@ -178,7 +178,7 @@ void compat_system_workqueue_create() BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq); } -void compat_system_workqueue_destroy() +void backport_system_workqueue_destroy(void) { destroy_workqueue(system_wq); destroy_workqueue(system_long_wq); -- cgit v1.2.3 From cc35b309c5f605aa489098897d8bd57ae2f0abe7 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 21 Mar 2013 23:29:23 +0000 Subject: compat: backport sg_alloc_table_from_pages() from efc42bc9 This backports sg_alloc_table_from_pages() added via commit efc42bc9 mcgrof@frijol ~/linux-next (git::master)$ git describe --contains efc42bc9 v3.6-rc1~57^2~11 commit efc42bc98058a36d761b16a114823db1a902ed05 Author: Tomasz Stanislawski Date: Mon Jun 18 09:25:01 2012 +0200 scatterlist: add sg_alloc_table_from_pages function This patch adds a new constructor for an sg table. The table is constructed from an array of struct pages. All contiguous chunks of the pages are merged into a single sg nodes. A user may provide an offset and a size of a buffer if the buffer is not page-aligned. The function is dedicated for DMABUF exporters which often perform conversion from an page array to a scatterlist. Moreover the scatterlist should be squashed in order to save memory and to speed-up the process of DMA mapping using dma_map_sg. The code is based on the patch 'v4l: vb2-dma-contig: add support for scatterlist in userptr mode' and hints from Laurent Pinchart. Signed-off-by: Tomasz Stanislawski Signed-off-by: Kyungmin Park Acked-by: Daniel Vetter Acked-by: Laurent Pinchart Signed-off-by: Marek Szyprowski CC: Andrew Morton Signed-off-by: Luis R. Rodriguez --- compat/Makefile | 1 + compat/compat-3.6.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-3.6.h | 9 ++++++ 3 files changed, 86 insertions(+) create mode 100644 compat/compat-3.6.c diff --git a/compat/Makefile b/compat/Makefile index 5abdc35a..469025e5 100644 --- a/compat/Makefile +++ b/compat/Makefile @@ -49,6 +49,7 @@ compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o compat-$(CONFIG_COMPAT_KERNEL_3_5) += \ compat-3.5.o \ user_namespace.o +compat-$(CONFIG_COMPAT_KERNEL_3_6) += compat-3.6.o compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o compat-$(CONFIG_COMPAT_KERNEL_3_8) += compat-3.8.o compat-$(CONFIG_COMPAT_KERNEL_3_9) += compat-3.9.o diff --git a/compat/compat-3.6.c b/compat/compat-3.6.c new file mode 100644 index 00000000..113e3a86 --- /dev/null +++ b/compat/compat-3.6.c @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2013 Luis R. Rodriguez + * + * Backport compatibility file for Linux for kernels 3.6. + * + * 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. + */ + +#include +#include + +/** + * sg_alloc_table_from_pages - Allocate and initialize an sg table from + * an array of pages + * @sgt: The sg table header to use + * @pages: Pointer to an array of page pointers + * @n_pages: Number of pages in the pages array + * @offset: Offset from start of the first page to the start of a buffer + * @size: Number of valid bytes in the buffer (after offset) + * @gfp_mask: GFP allocation mask + * + * Description: + * Allocate and initialize an sg table from a list of pages. Contiguous + * ranges of the pages are squashed into a single scatterlist node. A user + * may provide an offset at a start and a size of valid data in a buffer + * specified by the page array. The returned sg table is released by + * sg_free_table. + * + * Returns: + * 0 on success, negative error on failure + */ +int sg_alloc_table_from_pages(struct sg_table *sgt, + struct page **pages, unsigned int n_pages, + unsigned long offset, unsigned long size, + gfp_t gfp_mask) +{ + unsigned int chunks; + unsigned int i; + unsigned int cur_page; + int ret; + struct scatterlist *s; + + /* compute number of contiguous chunks */ + chunks = 1; + for (i = 1; i < n_pages; ++i) + if (page_to_pfn(pages[i]) != page_to_pfn(pages[i - 1]) + 1) + ++chunks; + + ret = sg_alloc_table(sgt, chunks, gfp_mask); + if (unlikely(ret)) + return ret; + + /* merging chunks and putting them into the scatterlist */ + cur_page = 0; + for_each_sg(sgt->sgl, s, sgt->orig_nents, i) { + unsigned long chunk_size; + unsigned int j; + + /* look for the end of the current chunk */ + for (j = cur_page + 1; j < n_pages; ++j) + if (page_to_pfn(pages[j]) != + page_to_pfn(pages[j - 1]) + 1) + break; + + chunk_size = ((j - cur_page) << PAGE_SHIFT) - offset; + sg_set_page(s, pages[cur_page], min(size, chunk_size), offset); + size -= chunk_size; + offset = 0; + cur_page = j; + } + + return 0; +} +EXPORT_SYMBOL_GPL(sg_alloc_table_from_pages); diff --git a/include/linux/compat-3.6.h b/include/linux/compat-3.6.h index 97b59933..d9c964ed 100644 --- a/include/linux/compat-3.6.h +++ b/include/linux/compat-3.6.h @@ -5,6 +5,15 @@ #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)) +#include + +/* backports efc42bc9 */ +#define sg_alloc_table_from_pages LINUX_BACKPORT(sg_alloc_table_from_pages) +int sg_alloc_table_from_pages(struct sg_table *sgt, + struct page **pages, unsigned int n_pages, + unsigned long offset, unsigned long size, + gfp_t gfp_mask); + /** * Backports * -- cgit v1.2.3 From bfd429ddd3bf54d7d6cd5d9ec64fca174e3c53eb Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Fri, 22 Mar 2013 19:33:38 +0000 Subject: compat: backport lib/scatterlist.c from 0db9299f Backport the lib/scatterlist.c addition, this required just removing the kmemleak stuff as that is not available on older kernels. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 0db9299f v2.6.25-rc1~1173^2~2 commit 0db9299f48ebd4a860d6ad4e1d36ac50671d48e7 Author: Jens Axboe Date: Fri Nov 30 09:16:50 2007 +0100 SG: Move functions to lib/scatterlist.c and add sg chaining allocator helpers Manually doing chained sg lists is not trivial, so add some helpers to make sure that drivers get it right. Signed-off-by: Jens Axboe 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.25.c | 191 ++++++++++++++++++++++++++++++++++++++++++ include/linux/compat-2.6.25.h | 33 ++++++++ 2 files changed, 224 insertions(+) diff --git a/compat/compat-2.6.25.c b/compat/compat-2.6.25.c index 15500249..20cc3dbd 100644 --- a/compat/compat-2.6.25.c +++ b/compat/compat-2.6.25.c @@ -11,6 +11,197 @@ #include #include +/* + * The default behaviour of sg_alloc_table() is to use these kmalloc/kfree + * helpers. + */ +static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask) +{ + if (nents == SG_MAX_SINGLE_ALLOC) { + return (struct scatterlist *) __get_free_page(gfp_mask); + } else + return kmalloc(nents * sizeof(struct scatterlist), gfp_mask); +} + +static void sg_kfree(struct scatterlist *sg, unsigned int nents) +{ + if (nents == SG_MAX_SINGLE_ALLOC) + free_page((unsigned long) sg); + else + kfree(sg); +} + + +/** + * __sg_free_table - Free a previously mapped sg table + * @table: The sg table header to use + * @max_ents: The maximum number of entries per single scatterlist + * @free_fn: Free function + * + * Description: + * Free an sg table previously allocated and setup with + * __sg_alloc_table(). The @max_ents value must be identical to + * that previously used with __sg_alloc_table(). + * + **/ +void __sg_free_table(struct sg_table *table, unsigned int max_ents, + sg_free_fn *free_fn) +{ + struct scatterlist *sgl, *next; + + if (unlikely(!table->sgl)) + return; + + sgl = table->sgl; + while (table->orig_nents) { + unsigned int alloc_size = table->orig_nents; + unsigned int sg_size; + + /* + * If we have more than max_ents segments left, + * then assign 'next' to the sg table after the current one. + * sg_size is then one less than alloc size, since the last + * element is the chain pointer. + */ + if (alloc_size > max_ents) { + next = sg_chain_ptr(&sgl[max_ents - 1]); + alloc_size = max_ents; + sg_size = alloc_size - 1; + } else { + sg_size = alloc_size; + next = NULL; + } + + table->orig_nents -= sg_size; + free_fn(sgl, alloc_size); + sgl = next; + } + + table->sgl = NULL; +} +EXPORT_SYMBOL(__sg_free_table); + +/** + * sg_free_table - Free a previously allocated sg table + * @table: The mapped sg table header + * + **/ +void sg_free_table(struct sg_table *table) +{ + __sg_free_table(table, SG_MAX_SINGLE_ALLOC, sg_kfree); +} +EXPORT_SYMBOL(sg_free_table); + +/** + * __sg_alloc_table - Allocate and initialize an sg table with given allocator + * @table: The sg table header to use + * @nents: Number of entries in sg list + * @max_ents: The maximum number of entries the allocator returns per call + * @gfp_mask: GFP allocation mask + * @alloc_fn: Allocator to use + * + * Description: + * This function returns a @table @nents long. The allocator is + * defined to return scatterlist chunks of maximum size @max_ents. + * Thus if @nents is bigger than @max_ents, the scatterlists will be + * chained in units of @max_ents. + * + * Notes: + * If this function returns non-0 (eg failure), the caller must call + * __sg_free_table() to cleanup any leftover allocations. + * + **/ +int __sg_alloc_table(struct sg_table *table, unsigned int nents, + unsigned int max_ents, gfp_t gfp_mask, + sg_alloc_fn *alloc_fn) +{ + struct scatterlist *sg, *prv; + unsigned int left; + +#ifndef ARCH_HAS_SG_CHAIN + if (WARN_ON_ONCE(nents > max_ents)) + return -EINVAL; +#endif + + memset(table, 0, sizeof(*table)); + + left = nents; + prv = NULL; + do { + unsigned int sg_size, alloc_size = left; + + if (alloc_size > max_ents) { + alloc_size = max_ents; + sg_size = alloc_size - 1; + } else + sg_size = alloc_size; + + left -= sg_size; + + sg = alloc_fn(alloc_size, gfp_mask); + if (unlikely(!sg)) { + /* + * Adjust entry count to reflect that the last + * entry of the previous table won't be used for + * linkage. Without this, sg_kfree() may get + * confused. + */ + if (prv) + table->nents = ++table->orig_nents; + + return -ENOMEM; + } + + sg_init_table(sg, alloc_size); + table->nents = table->orig_nents += sg_size; + + /* + * If this is the first mapping, assign the sg table header. + * If this is not the first mapping, chain previous part. + */ + if (prv) + sg_chain(prv, max_ents, sg); + else + table->sgl = sg; + + /* + * If no more entries after this one, mark the end + */ + if (!left) + sg_mark_end(&sg[sg_size - 1]); + + prv = sg; + } while (left); + + return 0; +} +EXPORT_SYMBOL(__sg_alloc_table); + +/** + * sg_alloc_table - Allocate and initialize an sg table + * @table: The sg table header to use + * @nents: Number of entries in sg list + * @gfp_mask: GFP allocation mask + * + * Description: + * Allocate and initialize an sg table. If @nents@ is larger than + * SG_MAX_SINGLE_ALLOC a chained sg table will be setup. + * + **/ +int sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask) +{ + int ret; + + ret = __sg_alloc_table(table, nents, SG_MAX_SINGLE_ALLOC, + gfp_mask, sg_kmalloc); + if (unlikely(ret)) + __sg_free_table(table, SG_MAX_SINGLE_ALLOC, sg_kfree); + + return ret; +} +EXPORT_SYMBOL(sg_alloc_table); + + /* * To backport b718989d correctly pcibios_enable_device() * is required but we don't have access to it on modules diff --git a/include/linux/compat-2.6.25.h b/include/linux/compat-2.6.25.h index a08e0b26..dd986f5c 100644 --- a/include/linux/compat-2.6.25.h +++ b/include/linux/compat-2.6.25.h @@ -20,10 +20,43 @@ #include #include #include +#include #define __inet_lookup_established __inet_lookup_established_old #include #undef __inet_lookup_established #include + +struct sg_table { + struct scatterlist *sgl; /* the list */ + unsigned int nents; /* number of mapped entries */ + unsigned int orig_nents; /* original size of list */ +}; + +#define sg_alloc_fn LINUX_BACKPORT(sg_alloc_fn) +typedef struct scatterlist *(sg_alloc_fn)(unsigned int, gfp_t); + +#define sg_free_fn LINUX_BACKPORT(sg_free_fn) +typedef void (sg_free_fn)(struct scatterlist *, unsigned int); + +#define __sg_free_table LINUX_BACKPORT(__sg_free_table) +void __sg_free_table(struct sg_table *table, unsigned int max_ents, + sg_free_fn *free_fn); +#define sg_free_table LINUX_BACKPORT(sg_free_table) +void sg_free_table(struct sg_table *); +#define __sg_alloc_table LINUX_BACKPORT(__sg_alloc_table) +int __sg_alloc_table(struct sg_table *table, unsigned int nents, + unsigned int max_ents, gfp_t gfp_mask, + sg_alloc_fn *alloc_fn); +#define sg_alloc_table LINUX_BACKPORT(sg_alloc_table) +int sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask); + +/* + * Maximum number of entries that will be allocated in one piece, if + * a list larger than this is required then chaining will be utilized. + */ +#define SG_MAX_SINGLE_ALLOC (PAGE_SIZE / sizeof(struct scatterlist)) + + /* * Sockets in TCP_CLOSE state are _always_ taken out of the hash, so we need * not check it for lookups anymore, thanks Alexey. -DaveM -- cgit v1.2.3 From 8095d14fa270ccc361fbf7e9333beaa37553d699 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Tue, 26 Mar 2013 15:12:58 -0700 Subject: compat: fix cordic backport header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mcgrof@frijol ~/linux-next (git::master)$ git describe --contains \ 10f8113ecb76eea72f96c7cfb72d7fed7c282565 v3.1-rc1~24^2~10^2^2~515 The cordic backport added the cordic library and the cordic header. It correctly only compiled cordic for kernels < 3.1 but the header however was left intact. This is non-issue until cordic itself gets updated with some new features or changes but also an issue was created when we switched the backort namespace. The issue is that the header declares backport_cordic_calc_iq() exists while it actually is not compiled on newer kernels. Fix this by doing the kernel revision check on the backported header, otherwise use #include_next to get the next header, the proper kernel header. This does not have to be added to the older releases given that the header is the same for older kernels, and we are not exporting the symbol twice given that the proper check was already in place for cordic.c. == ckmake-report.log == 1 2.6.24 [ OK ] 2 2.6.25 [ OK ] 3 2.6.26 [ OK ] 4 2.6.27 [ OK ] 5 2.6.28 [ OK ] 6 2.6.29 [ OK ] 7 2.6.30 [ OK ] 8 2.6.31 [ OK ] 9 2.6.32 [ OK ] 10 2.6.33 [ OK ] 11 2.6.34 [ OK ] 12 2.6.35 [ OK ] 13 2.6.36 [ OK ] 14 2.6.37 [ OK ] 15 2.6.38 [ OK ] 16 2.6.39 [ OK ] 17 3.0.65 [ OK ] 18 3.1.10 [ OK ] 19 3.2.38 [ OK ] 20 3.3.8 [ OK ] 21 3.4.32 [ OK ] 22 3.5.7 [ OK ] 23 3.6.11 [ OK ] 24 3.7.9 [ OK ] 25 3.8.0 [ OK ] 26 3.9-rc1 [ OK ] real 0m32.956s user 12m14.398s sys 2m12.304s Reported-by: CamaleĆ³n Signed-off-by: Luis R. Rodriguez --- include/linux/cordic.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/cordic.h b/include/linux/cordic.h index 2de0aa32..7f27b007 100644 --- a/include/linux/cordic.h +++ b/include/linux/cordic.h @@ -1,3 +1,12 @@ +#ifndef _BACKPORT_LINUX_CORDIC_H +#define _BACKPORT_LINUX_CORDIC_H 1 + +#include + +#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) +#include_next +#else + /* * Copyright (c) 2011 Broadcom Corporation * @@ -47,3 +56,5 @@ struct cordic_iq { struct cordic_iq cordic_calc_iq(s32 theta); #endif /* __CORDIC_H_ */ +#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) */ +#endif /* _BACKPORT_LINUX_CORDIC_H */ -- cgit v1.2.3 From 6ae26aae48ab0ba6c06805cba5d3b5acb1455f08 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 27 Mar 2013 19:20:32 -0700 Subject: compat: declare kmalloc_array() through LINUX_BACKPORT() This fixes compilation with Debian 3.2 kernels that cherry picked the commit that added that call (a8203725). commit a8203725dfded5c1f79dca3368a4a273e24b59bb Author: Xi Wang Date: Mon Mar 5 15:14:41 2012 -0800 slab: introduce kmalloc_array() Introduce a kmalloc_array() wrapper that performs integer overflow checking without zeroing the memory. Suggested-by: Andrew Morton Suggested-by: Jens Axboe Signed-off-by: Xi Wang Cc: Dan Carpenter Acked-by: David Rientjes Signed-off-by: Andrew Morton Signed-off-by: Pekka Enberg Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 94d3bf71..2cd64a1c 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -40,6 +40,7 @@ extern void compat_wake_up_locked(wait_queue_head_t *q, unsigned int mode, int n /* SIZE_MAX is backported in compat-3.5.h so include it */ #include +#define kmalloc_array LINUX_BACKPORT(kmalloc_array) static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags) { if (size != 0 && n > SIZE_MAX / size) -- cgit v1.2.3 From de70a4b8e4e8a92b744ecc17e66617ce4bc46230 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 27 Mar 2013 19:23:27 -0700 Subject: compat: declare eth_hw_addr_random() under LINUX_BACKPORT() Debian kernels cherry picked the commit that added this, so LINUX_BACKPORT() comes to the rescue. Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.4.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/compat-3.4.h b/include/linux/compat-3.4.h index 2cd64a1c..3866330b 100644 --- a/include/linux/compat-3.4.h +++ b/include/linux/compat-3.4.h @@ -75,6 +75,7 @@ extern int simple_open(struct inode *inode, struct file *file); #endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) +#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random) static inline void eth_hw_addr_random(struct net_device *dev) { #error eth_hw_addr_random() needs to be implemented for < 2.6.12 @@ -82,6 +83,7 @@ static inline void eth_hw_addr_random(struct net_device *dev) #else /* kernels >= 2.6.12 */ #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) +#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random) static inline void eth_hw_addr_random(struct net_device *dev) { get_random_bytes(dev->dev_addr, ETH_ALEN); @@ -98,12 +100,14 @@ static inline void eth_hw_addr_random(struct net_device *dev) #define NET_ADDR_RANDOM 1 /* address is generated randomly */ #define NET_ADDR_STOLEN 2 /* address is stolen from other device */ +#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random) static inline void eth_hw_addr_random(struct net_device *dev) { random_ether_addr(dev->dev_addr); } #else /* 2.6.36 and on */ +#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random) static inline void eth_hw_addr_random(struct net_device *dev) { dev_hw_addr_random(dev, dev->dev_addr); -- cgit v1.2.3 From 9bf65ad978d3619b7bab6dab361dd84cbabf5594 Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Wed, 27 Mar 2013 19:16:56 -0700 Subject: compat: backport ktime_get_monotonic_offset() The commit a80b83b7 exported ktime_get_monotonic_offset() but note that this was already in place on the header files declared as extern, it was just never exported. To work around the double possible declaration issue with older kernels fortunately the LINUX_BACKPORT() macro comes to the rescue by encofring our version to be declared and used in backport code. Note that this was added due to commit c61eef72 added as of v3.8 for DRM drivers that need access to timestamps that do no do not jump, unfortunately for older kernels we can't port that since it requires access to a static variable on the kernel, so just use the timestamps that jump. mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains a80b83b7 v3.5-rc6~10^2~15^2~30 mcgrof@frijol ~/linux-stable (git::master)$ git describe --contains c61eef72 v3.8-rc1~42^2~170 commit a80b83b7b8456e9b475346c2e01d7e210883208c Author: John Stultz Date: Fri Feb 3 00:19:07 2012 -0800 Input: add infrastructure for selecting clockid for event time stamps As noted by Arve and others, since wall time can jump backwards, it is difficult to use for input because one cannot determine if one event occurred before another or for how long a key was pressed. However, the timestamp field is part of the kernel ABI, and cannot be changed without possibly breaking existing users. This patch adds a new IOCTL that allows a clockid to be set in the evdev_client struct that will specify which time base to use for event timestamps (ie: CLOCK_MONOTONIC instead of CLOCK_REALTIME). For now we only support CLOCK_MONOTONIC and CLOCK_REALTIME, but in the future we could support other clockids if appropriate. The default remains CLOCK_REALTIME, so we don't change the ABI. Signed-off-by: John Stultz Reviewed-by: Daniel Kurtz Signed-off-by: Dmitry Torokhov commit c61eef726a78ae77b6ce223d01ea2130f465fe5c Author: Imre Deak Date: Tue Oct 23 18:53:26 2012 +0000 drm: add support for monotonic vblank timestamps Jumps in the vblank and page flip event timestamps cause trouble for clients, so we should avoid them. The timestamp we get currently with gettimeofday can jump, so use instead monotonic timestamps. For backward compatibility use a module flag to revert back to using gettimeofday timestamps. Add also a DRM_CAP_TIMESTAMP_MONOTONIC flag that is simply a read only version of the module flag, so that clients can query this without depending on sysfs. Signed-off-by: Imre Deak Signed-off-by: Dave Airlie Signed-off-by: Luis R. Rodriguez --- compat/compat-3.5.c | 17 ++++++++++++++++- include/linux/compat-3.5.h | 3 +++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/compat/compat-3.5.c b/compat/compat-3.5.c index 01509fa1..d7f1c275 100644 --- a/compat/compat-3.5.c +++ b/compat/compat-3.5.c @@ -1,5 +1,5 @@ /* - * Copyright 2012 Luis R. Rodriguez + * Copyright 2012-2013 Luis R. Rodriguez * * 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 @@ -10,6 +10,7 @@ #include #include +#include /* * Commit 7a4e7408c5cadb240e068a662251754a562355e3 @@ -28,3 +29,17 @@ int overflowgid = DEFAULT_OVERFLOWGID; EXPORT_SYMBOL_GPL(overflowuid); EXPORT_SYMBOL_GPL(overflowgid); #endif + +/* + * We can't access the timekeeper static variable + * on older kernels so we're shit out of luck and + * have to rely on time that might jump. Upgrade + * if you want timestamps that don't jump, this + * important for DRM vblank and page flip event + * timestamps. + */ +ktime_t ktime_get_monotonic_offset(void) +{ + return ktime_get(); +} +EXPORT_SYMBOL_GPL(ktime_get_monotonic_offset); diff --git a/include/linux/compat-3.5.h b/include/linux/compat-3.5.h index 28a12090..57b06b04 100644 --- a/include/linux/compat-3.5.h +++ b/include/linux/compat-3.5.h @@ -294,6 +294,9 @@ do { \ #define net_dbg_ratelimited(fmt, ...) \ net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__) +#define ktime_get_monotonic_offset LINUX_BACKPORT(ktime_get_monotonic_offset) +extern ktime_t ktime_get_monotonic_offset(void); + #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */ #endif /* LINUX_3_5_COMPAT_H */ -- cgit v1.2.3 From 008ae09623893ab6618328fa4e8af93637e2433c Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 Mar 2013 01:42:42 -0700 Subject: compat: backport sg_page_iter_page() and sg_page_iter_dma_address() This should be going into the next kernel release, assuming this will be called 3.10 we stuff into the 3.10 header. Although this commit does modify the struct sg_page_iter data structure that was just done to remove something no longer needed due to the change. This should not impact older kernels so just keep the original implementation. mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 2db76d7c next-20130328~64^2~6 commit 2db76d7c3c6db93058f983c8240f7c7c25e87ee6 Author: Imre Deak Date: Tue Mar 26 15:14:18 2013 +0200 lib/scatterlist: sg_page_iter: support sg lists w/o backing pages The i915 driver uses sg lists for memory without backing 'struct page' pages, similarly to other IO memory regions, setting only the DMA address for these. It does this, so that it can program the HW MMU tables in a uniform way both for sg lists with and without backing pages. Without a valid page pointer we can't call nth_page to get the current page in __sg_page_iter_next, so add a helper that relevant users can call separately. Also add a helper to get the DMA address of the current page (idea from Daniel). Convert all places in i915, to use the new API. Signed-off-by: Imre Deak Reviewed-by: Damien Lespiau Signed-off-by: Daniel Vetter Signed-off-by: Luis R. Rodriguez --- include/linux/compat-2.6.h | 1 + include/linux/compat-3.10.h | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 include/linux/compat-3.10.h diff --git a/include/linux/compat-2.6.h b/include/linux/compat-2.6.h index 5d759193..1e9effb7 100644 --- a/include/linux/compat-2.6.h +++ b/include/linux/compat-2.6.h @@ -72,6 +72,7 @@ void backport_dependency_symbol(void); #include #include #include +#include #endif /* __ASSEMBLY__ */ diff --git a/include/linux/compat-3.10.h b/include/linux/compat-3.10.h new file mode 100644 index 00000000..69ddc115 --- /dev/null +++ b/include/linux/compat-3.10.h @@ -0,0 +1,34 @@ +#ifndef LINUX_3_10_COMPAT_H +#define LINUX_3_10_COMPAT_H + +#include + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) + +#include +#include + +#define sg_page_iter_page LINUX_BACKPORT(sg_page_iter_page) +/** + * sg_page_iter_page - get the current page held by the page iterator + * @piter: page iterator holding the page + */ +static inline struct page *sg_page_iter_page(struct sg_page_iter *piter) +{ + return nth_page(sg_page(piter->sg), piter->sg_pgoffset); +} + +#define sg_page_iter_dma_address LINUX_BACKPORT(sg_page_iter_dma_address) +/** + * sg_page_iter_dma_address - get the dma address of the current page held by + * the page iterator. + * @piter: page iterator holding the page + */ +static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter) +{ + return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT); +} + +#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) */ + +#endif /* LINUX_3_10_COMPAT_H */ -- cgit v1.2.3 From b3933dd6a3f3032e7f0dfdc51c37565df626d02e Mon Sep 17 00:00:00 2001 From: "Luis R. Rodriguez" Date: Thu, 28 Mar 2013 02:53:23 -0700 Subject: compat: backport fb_info->skip_vt_switch using a static inline Commit 3cf2667 as of next-20130301 extended the struct fb_info with a skip_vt_switch to allow drivers to skip the VT switch at suspend/resume time. For older kernels we can skip this as all this switch does is call pm_vt_switch_required() with true or false depending on this new flag and later pm_vt_switch_unregister() would not have been made. compat-drivers was backporting this using #ifdef's but by integrating a static inline we'd reduce the number of lines to backport to just 1 line replacement. This would be something like: - info->skip_vt_switch = true; + fb_enable_skip_vt_switch(info); For kernels >= 3.10 we'd set the attribute as we do upstream, for older kernels this would be a no-op. If this static inline would have been added upstream it would have meant this collateral evolution would require just adding a no-op static inline to backport, and no changes as the above example hunk for every driver that requires the change. If this static inline ends up upstream *now* it means we do *not* require the type of hunk above for every driver that requires the change. All the code would be left intact ! This is a linux-next 'data structure element collateral evolution'. Cc: cocci@systeme.lip6.fr Cc: backports@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Julia Lawall Cc: Rodrigo Vivi Cc: Daniel Vetter Cc: Jesse Barnes Cc: Rafael J. Wysocki Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.10.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/include/linux/compat-3.10.h b/include/linux/compat-3.10.h index 69ddc115..9abfc4bb 100644 --- a/include/linux/compat-3.10.h +++ b/include/linux/compat-3.10.h @@ -7,6 +7,7 @@ #include #include +#include #define sg_page_iter_page LINUX_BACKPORT(sg_page_iter_page) /** @@ -29,6 +30,46 @@ static inline dma_addr_t sg_page_iter_dma_address(struct sg_page_iter *piter) return sg_dma_address(piter->sg) + (piter->sg_pgoffset << PAGE_SHIFT); } +/* + * This is a linux-next data structure element collateral evolution, + * we use a wrapper to avoid #ifdef hell to backport it. This allows + * us to use a simple fb_info_skip_vt_switch() replacement for when + * the new data structure element is used. If coccinelle SmPL grammar + * could be used to express the transformation for us on compat-drivers + * it means we'd need to express it only once. If the structure element + * collateral evolution were to be used *at development* time and we'd + * have a way to express the inverse through SmPL we'd be able to + * backport this collateral evolution automatically for any new driver + * that used it. We'd use coccinelle to look for it and do the + * transformations for us based on the original commit (maybe SmPL + * would be listed on the commit log. + * + * We may need the LINUX_BACKPORT() call that adds the backport_ + * prefix for older kernels than 3.10 if distros decide to + * add this same static inline themselves (although unlikely). + */ +#define fb_enable_skip_vt_switch LINUX_BACKPORT(fb_enable_skip_vt_switch) +static inline void fb_enable_skip_vt_switch(struct fb_info *info) +{ +} + +#else /* kernel is >= 3.10 */ +/* + * We'd delete this upstream ever got this, we use our + * backport_ prefix with LINUX_BACKPORT() so that if this + * does get upstream we would not have to add another ifdef + * here for the kernels in between v3.10.. up to the point + * the routine would have gotten added, we'd just delete this + * #else condition completely. If we didn't have this and + * say 3.12 added the static inline upstream, we'd have a + * clash on the backport for 3.12 as the routine would + * already be defined *but* we'd need it for 3.11. + */ +#define fb_enable_skip_vt_switch LINUX_BACKPORT(fb_enable_skip_vt_switch) +static inline void fb_enable_skip_vt_switch(struct fb_info *info) +{ + info->skip_vt_switch = true; +} #endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) */ #endif /* LINUX_3_10_COMPAT_H */ -- cgit v1.2.3 From 117e80b649819db203743fb8774a6f1e9c9f93c4 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Mar 2013 20:18:23 +0100 Subject: compat: add module_pcmcia_driver This is a backport of: commit 6ed7ffddcf61f668114edb676417e5fb33773b59 Author: H Hartley Sweeten Date: Wed Mar 6 11:24:44 2013 -0700 pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- include/linux/compat-3.10.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/include/linux/compat-3.10.h b/include/linux/compat-3.10.h index 9abfc4bb..f972203b 100644 --- a/include/linux/compat-3.10.h +++ b/include/linux/compat-3.10.h @@ -53,6 +53,28 @@ static inline void fb_enable_skip_vt_switch(struct fb_info *info) { } +/** + * backport of: + * + * commit 6ed7ffddcf61f668114edb676417e5fb33773b59 + * Author: H Hartley Sweeten + * Date: Wed Mar 6 11:24:44 2013 -0700 + * + * pcmcia/ds.h: introduce helper for pcmcia_driver module boilerplate + */ + +/** + * module_pcmcia_driver() - Helper macro for registering a pcmcia driver + * @__pcmcia_driver: pcmcia_driver struct + * + * Helper macro for pcmcia drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only use + * this macro once, and calling it replaces module_init() and module_exit(). + */ +#define module_pcmcia_driver(__pcmcia_driver) \ + module_driver(__pcmcia_driver, pcmcia_register_driver, \ + pcmcia_unregister_driver) + #else /* kernel is >= 3.10 */ /* * We'd delete this upstream ever got this, we use our -- cgit v1.2.3 From a74dd7cedf14ba4bea52101567a59d58666f1a0f Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Mar 2013 20:18:24 +0100 Subject: compat: fix export of __sg_page_iter* Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-3.9.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/compat-3.9.c b/compat/compat-3.9.c index 7134caa9..1f248421 100644 --- a/compat/compat-3.9.c +++ b/compat/compat-3.9.c @@ -11,7 +11,7 @@ #include #include -#ifndef __sg_page_iter_next +#ifdef __sg_page_iter_next void __sg_page_iter_start(struct sg_page_iter *piter, struct scatterlist *sglist, unsigned int nents, -- cgit v1.2.3 From 78295c893c64c3124725e9b9dcb9a05a13e4c244 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Mar 2013 20:18:25 +0100 Subject: compat: do not undef flush_scheduled_work This caused flush_scheduled_work instead of backport_flush_scheduled_work being exported. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat-2.6.36.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compat/compat-2.6.36.c b/compat/compat-2.6.36.c index 3479af49..9295895b 100644 --- a/compat/compat-2.6.36.c +++ b/compat/compat-2.6.36.c @@ -133,7 +133,6 @@ int schedule_delayed_work_on(int cpu, } EXPORT_SYMBOL_GPL(schedule_delayed_work_on); -#undef flush_scheduled_work void flush_scheduled_work(void) { /* -- cgit v1.2.3 From fec77e2667fe9326486ce6df9d27a8fce77a048d Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Mar 2013 20:18:26 +0100 Subject: compat: firmware class, remove the compat prefix This depended on some define changing firmware_* to compat_firmware_* and this should now be used to generate backport_firmware_*. This makes it export the expected symbols with the backport prefix. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/compat_firmware_class.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/compat/compat_firmware_class.c b/compat/compat_firmware_class.c index 69b442b7..9ea5080e 100644 --- a/compat/compat_firmware_class.c +++ b/compat/compat_firmware_class.c @@ -21,7 +21,7 @@ #include #include -#define compat_firmware_to_dev(obj) container_of(obj, struct device, kobj) +#define backport_firmware_to_dev(obj) container_of(obj, struct device, kobj) MODULE_AUTHOR("Manuel Estrada Sainz"); MODULE_DESCRIPTION("Multi purpose firmware loading support"); @@ -324,7 +324,7 @@ static ssize_t firmware_data_read(struct kobject *kobj, char *buffer, loff_t offset, size_t count) #endif { - struct device *dev = compat_firmware_to_dev(kobj); + struct device *dev = backport_firmware_to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t ret_count; @@ -423,7 +423,7 @@ static ssize_t firmware_data_write(struct kobject *kobj, char *buffer, loff_t offset, size_t count) #endif { - struct device *dev = compat_firmware_to_dev(kobj); + struct device *dev = backport_firmware_to_dev(kobj); struct firmware_priv *fw_priv = to_firmware_priv(dev); struct firmware *fw; ssize_t retval; @@ -635,7 +635,7 @@ out: * firmware image for this or any other device. **/ int -compat_request_firmware(const struct firmware **firmware_p, const char *name, +request_firmware(const struct firmware **firmware_p, const char *name, struct device *device) { int uevent = 1; @@ -646,7 +646,7 @@ compat_request_firmware(const struct firmware **firmware_p, const char *name, * release_firmware: - release the resource associated with a firmware image * @fw: firmware resource to release **/ -void compat_release_firmware(const struct firmware *fw) +void release_firmware(const struct firmware *fw) { if (fw) { if (!fw_is_builtin_firmware(fw)) @@ -705,7 +705,7 @@ static int request_firmware_work_func(void *arg) * in atomic contexts. **/ int -compat_request_firmware_nowait( +request_firmware_nowait( struct module *module, int uevent, const char *name, struct device *device, gfp_t gfp, void *context, void (*cont)(const struct firmware *fw, void *context)) -- cgit v1.2.3 From 8ecb0c8fc0b982baafc3e9ec339fe60321879936 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 28 Mar 2013 20:18:27 +0100 Subject: compat: build kstrtox for kernel < 2.6.25 strict_strtol with one l is defined in compat-2.6.25.h code now and this deactivates this check, use strict_strtoll instead. Signed-off-by: Hauke Mehrtens Signed-off-by: Luis R. Rodriguez --- compat/kstrtox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat/kstrtox.c b/compat/kstrtox.c index 266ffbc9..fdbc56eb 100644 --- a/compat/kstrtox.c +++ b/compat/kstrtox.c @@ -17,7 +17,7 @@ * version included in compat-drivers. We use strict_strtol to check if * kstrto* is already available. */ -#ifndef strict_strtol +#ifndef strict_strtoll #include #include -- cgit v1.2.3