compat-y += main.o
# Compat kernel compatibility code
-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_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 \
- flow_dissector.o
+ compat-3.3.o
compat-$(CONFIG_COMPAT_KERNEL_3_4) += compat-3.4.o
compat-$(CONFIG_COMPAT_KERNEL_3_5) += compat-3.5.o
+compat-$(CONFIG_COMPAT_KERNEL_3_6) += compat-3.6.o
+compat-$(CONFIG_COMPAT_KERNEL_3_7) += compat-3.7.o
compat-$(CONFIG_COMPAT_CORDIC) += cordic.o
compat-$(CONFIG_COMPAT_CRC8) += crc8.o
+++ /dev/null
-/*
- * Copyright 2007 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
- *
- * 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 <net/compat.h>
-
-/* 2.6.14 compat code goes here */
-
#include <net/compat.h>
/* 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)
{
/* 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)
{
*/
#include <linux/compat.h>
-#include <linux/usb.h>
#include <linux/tty.h>
#include <asm/poll.h>
/* 2.6.28 compat code goes here */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
-/*
- * 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
-#endif /* CONFIG_USB */
-
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
-
-#include <pcmcia/ds.h>
-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_GPL(pcmcia_loop_config);
-
-#endif /* CONFIG_PCMCIA */
-
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
-
-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_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);
-#endif /* CONFIG_USB */
-#endif
-
void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
{
/*
#include <linux/compat.h>
#include <linux/autoconf.h>
+#include <linux/string.h>
+#include <linux/ctype.h>
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef BITMAP_FIRST_WORD_MASK
+#define BITMAP_FIRST_WORD_MASK(start) (~0UL << ((start) % BITS_PER_LONG))
+#endif /* BITMAP_FIRST_WORD_MASK */
-#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE)
+#ifndef CONFIG_COMPAT_IS_BITMAP
-/**
- * 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))
+void bitmap_set(unsigned long *map, int start, int nr)
{
- 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;
+ unsigned long *p = map + BIT_WORD(start);
+ const int size = start + nr;
+ int bits_to_set = BITS_PER_LONG - (start % BITS_PER_LONG);
+ unsigned long mask_to_set = BITMAP_FIRST_WORD_MASK(start);
+
+ while (nr - bits_to_set >= 0) {
+ *p |= mask_to_set;
+ nr -= bits_to_set;
+ bits_to_set = BITS_PER_LONG;
+ mask_to_set = ~0UL;
+ p++;
}
-
- 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);
+ if (nr) {
+ mask_to_set &= BITMAP_LAST_WORD_MASK(size);
+ *p |= mask_to_set;
}
-
- kfree(buf);
- return ret;
}
-EXPORT_SYMBOL_GPL(pccard_loop_tuple);
-/* Source: drivers/pcmcia/cistpl.c */
+EXPORT_SYMBOL(bitmap_set);
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
+void bitmap_clear(unsigned long *map, int start, int nr)
+{
+ unsigned long *p = map + BIT_WORD(start);
+ const int size = start + nr;
+ int bits_to_clear = BITS_PER_LONG - (start % BITS_PER_LONG);
+ unsigned long mask_to_clear = BITMAP_FIRST_WORD_MASK(start);
+
+ while (nr - bits_to_clear >= 0) {
+ *p &= ~mask_to_clear;
+ nr -= bits_to_clear;
+ bits_to_clear = BITS_PER_LONG;
+ mask_to_clear = ~0UL;
+ p++;
+ }
+ if (nr) {
+ mask_to_clear &= BITMAP_LAST_WORD_MASK(size);
+ *p &= ~mask_to_clear;
+ }
+}
+EXPORT_SYMBOL(bitmap_clear);
-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);
-};
+/*
+ * bitmap_find_next_zero_area - find a contiguous aligned zero area
+ * @map: The address to base the search on
+ * @size: The bitmap size in bits
+ * @start: The bitnumber to start searching at
+ * @nr: The number of zeroed bits we're looking for
+ * @align_mask: Alignment mask for zero area
+ *
+ * The @align_mask should be one less than a power of 2; the effect is that
+ * the bit offset of all zero areas this function finds is multiples of that
+ * power of 2. A @align_mask of 0 means no alignment is required.
+ */
+unsigned long bitmap_find_next_zero_area(unsigned long *map,
+ unsigned long size,
+ unsigned long start,
+ unsigned int nr,
+ unsigned long align_mask)
+{
+ unsigned long index, end, i;
+again:
+ index = find_next_zero_bit(map, size, start);
+
+ /* Align allocation */
+ index = __ALIGN_MASK(index, align_mask);
+
+ end = index + nr;
+ if (end > size)
+ return end;
+ i = find_next_bit(map, end, index);
+ if (i < end) {
+ start = i + 1;
+ goto again;
+ }
+ return index;
+}
+EXPORT_SYMBOL(bitmap_find_next_zero_area);
+#endif /* CONFIG_COMPAT_IS_BITMAP */
/**
- * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config()
+ * skip_spaces - Removes leading whitespace from @str.
+ * @str: The string to be stripped.
*
- * 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.
+ * Returns a pointer to the first non-whitespace character in @str.
*/
-static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv)
+char *skip_spaces(const char *str)
{
- struct pcmcia_loop_mem *loop = priv;
-
- return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data);
-};
+ while (isspace(*str))
+ ++str;
+ return (char *)str;
+}
+EXPORT_SYMBOL(skip_spaces);
/**
- * 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.
+ * strim - Removes leading and trailing whitespace from @s.
+ * @s: The string to be stripped.
*
- * 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.
+ * Note that the first trailing whitespace is replaced with a %NUL-terminator
+ * in the given string @s. Returns a pointer to the first non-whitespace
+ * character in @s.
*/
-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)
+char *strim(char *s)
{
- struct pcmcia_loop_mem loop = {
- .p_dev = p_dev,
- .loop_tuple = loop_tuple,
- .priv_data = priv_data};
+ size_t size;
+ char *end;
- return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL,
- &loop, pcmcia_do_loop_tuple);
-}
-EXPORT_SYMBOL_GPL(pcmcia_loop_tuple);
-/* Source: drivers/pcmcia/pcmcia_resource.c */
-
-#endif /* CONFIG_PCMCIA */
+ size = strlen(s);
+ if (!size)
+ return s;
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+ end = s + size - 1;
+ while (end >= s && isspace(*end))
+ end--;
+ *(end + 1) = '\0';
-#endif /* CONFIG_PCCARD */
+ return skip_spaces(s);
+}
+EXPORT_SYMBOL(strim);
*/
#include <linux/mmc/sdio_func.h>
+#include <linux/pci.h>
+#include <linux/export.h>
#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)
{
return -EINVAL;
}
+
+int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt)
+{
+ int i;
+
+ for (i = off; i < len; ) {
+ u8 val = buf[i];
+
+ if (val & PCI_VPD_LRDT) {
+ /* Don't return success of the tag isn't complete */
+ if (i + PCI_VPD_LRDT_TAG_SIZE > len)
+ break;
+
+ if (val == rdt)
+ return i;
+
+ i += PCI_VPD_LRDT_TAG_SIZE +
+ pci_vpd_lrdt_size(&buf[i]);
+ } else {
+ u8 tag = val & ~PCI_VPD_SRDT_LEN_MASK;
+
+ if (tag == rdt)
+ return i;
+
+ if (tag == PCI_VPD_SRDT_END)
+ break;
+
+ i += PCI_VPD_SRDT_TAG_SIZE +
+ pci_vpd_srdt_size(&buf[i]);
+ }
+ }
+
+ return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(pci_vpd_find_tag);
+
+int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
+ unsigned int len, const char *kw)
+{
+ int i;
+
+ for (i = off; i + PCI_VPD_INFO_FLD_HDR_SIZE <= off + len;) {
+ if (buf[i + 0] == kw[0] &&
+ buf[i + 1] == kw[1])
+ return i;
+
+ i += PCI_VPD_INFO_FLD_HDR_SIZE +
+ pci_vpd_info_field_size(&buf[i]);
+ }
+
+ return -ENOENT;
+}
+EXPORT_SYMBOL_GPL(pci_vpd_find_info_keyword);
#include <linux/mmc/sdio_func.h>
-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)
{
}
* 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';
return ch - 'a' + 10;
return -1;
}
-EXPORT_SYMBOL_GPL(compat_hex_to_bin);
+EXPORT_SYMBOL_GPL(hex_to_bin);
-#ifndef CONFIG_COMPAT_RHEL_6_4
/**
* noop_llseek - No Operation Performed llseek implementation
* @file: file structure to seek on
return file->f_pos;
}
EXPORT_SYMBOL_GPL(noop_llseek);
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
*/
#include <linux/compat.h>
-#include <linux/usb.h>
-
-#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 */
struct workqueue_struct *system_wq __read_mostly;
struct workqueue_struct *system_long_wq __read_mostly;
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);
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);
-void compat_flush_scheduled_work(void)
+void flush_scheduled_work(void)
{
/*
* It is debatable which one we should prioritize first, lets
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
}
EXPORT_SYMBOL_GPL(work_busy);
-void compat_system_workqueue_create()
+int backport_system_workqueue_create()
{
system_wq = alloc_workqueue("events", 0, 0);
+ if (!system_wq)
+ return -ENOMEM;
+
system_long_wq = alloc_workqueue("events_long", 0, 0);
+ if (!system_long_wq)
+ goto err1;
+
system_nrt_wq = create_singlethread_workqueue("events_nrt");
- BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq);
+ if (!system_nrt_wq)
+ goto err2;
+
+ return 0;
+
+err2:
+ destroy_workqueue(system_long_wq);
+err1:
+ destroy_workqueue(system_wq);
+ return -ENOMEM;
}
-void compat_system_workqueue_destroy()
+void backport_system_workqueue_destroy()
{
+ destroy_workqueue(system_nrt_wq);
destroy_workqueue(system_wq);
destroy_workqueue(system_long_wq);
- destroy_workqueue(system_nrt_wq);
}
#include <net/sock.h>
#include <linux/nsproxy.h>
#include <linux/vmalloc.h>
+#include <linux/sunrpc/xprt.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)
static const void *net_current_ns(void)
* 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);
memset(buf, 0, size);
return buf;
}
-EXPORT_SYMBOL_GPL(compat_vzalloc);
+EXPORT_SYMBOL_GPL(vzalloc);
+/**
+ * vzalloc_node - allocate memory on a specific node with zero fill
+ * @size: allocation size
+ * @node: numa node
+ *
+ * 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_node(unsigned long size, int node)
+{
+ return vzalloc(size);
+}
+EXPORT_SYMBOL(vzalloc_node);
+
+#endif
+
+#ifndef CONFIG_COMPAT_XPRTRDMA_NEEDED
+struct rpc_xprt *xprt_alloc(int size, int max_req)
+{
+ struct rpc_xprt *xprt;
+
+ xprt = kzalloc(size, GFP_KERNEL);
+ if (xprt == NULL)
+ goto out;
+
+ xprt->max_reqs = max_req;
+ xprt->slot = kcalloc(max_req, sizeof(struct rpc_rqst), GFP_KERNEL);
+ if (xprt->slot == NULL)
+ goto out_free;
+
+ return xprt;
+
+out_free:
+ kfree(xprt);
+out:
+ return NULL;
+}
+EXPORT_SYMBOL_GPL(xprt_alloc);
+
+void xprt_free(struct rpc_xprt *xprt)
+{
+ kfree(xprt->slot);
+ kfree(xprt);
+}
+EXPORT_SYMBOL_GPL(xprt_free);
#endif
* Compatibility file for Linux wireless for kernels 3.0.
*/
-#ifndef CONFIG_COMPAT_RHEL_6_4
-
#include <linux/compat.h>
#include <linux/if_ether.h>
}
EXPORT_SYMBOL_GPL(mac_pton);
+#ifndef CONFIG_COMPAT_IS_KSTRTOX
#define kstrto_from_user(f, g, type) \
int f(const char __user *s, size_t count, unsigned int base, type *res) \
{ \
kstrto_from_user(kstrtos16_from_user, kstrtos16, s16);
kstrto_from_user(kstrtou8_from_user, kstrtou8, u8);
kstrto_from_user(kstrtos8_from_user, kstrtos8, s8);
-
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
}
EXPORT_SYMBOL(__ethtool_get_settings);
-#if (!defined(CONFIG_COMPAT_SLES_11_2) && !defined(CONFIG_COMPAT_SLES_11_3))
-#if !defined(RHEL_MINOR) || (RHEL_MINOR < 3)
/**
* llist_add_batch - add several linked entries in batch
* @new_first: first entry in batch to be added
return entry;
}
EXPORT_SYMBOL_GPL(llist_del_first);
-
-#endif /* (!defined(CONFIG_COMPAT_SLES_11_2) && !defined(CONFIG_COMPAT_SLES_11_3)) */
-#endif
* Compatibility file for Linux wireless for kernels 3.4.
*/
-#if (!defined(CONFIG_COMPAT_RHEL_6_4) && !defined(CONFIG_COMPAT_SLES_11_3))
-
#include <linux/fs.h>
#include <linux/module.h>
return 0;
}
EXPORT_SYMBOL_GPL(simple_open);
-
-#endif /* (!defined(CONFIG_COMPAT_RHEL_6_4) && !defined(CONFIG_COMPAT_SLES_11_3)) */
*
* Compatibility file for Linux wireless for kernels 3.4.
*/
-#ifndef CONFIG_COMPAT_RHEL_6_4
+
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/export.h>
+#include <linux/types.h>
#include <linux/pkt_sched.h>
+
#define ECN_OR_COST(class) TC_PRIO_##class
+#ifndef CONFIG_COMPAT_IS_IP_TOS2PRIO
const __u8 ip_tos2prio[16] = {
TC_PRIO_BESTEFFORT,
ECN_OR_COST(BESTEFFORT),
ECN_OR_COST(INTERACTIVE_BULK)
};
EXPORT_SYMBOL(ip_tos2prio);
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
+
+int dev_uc_add_excl(struct net_device *dev, unsigned char *addr)
+{
+ struct netdev_hw_addr *ha;
+ int err;
+
+ netif_addr_lock_bh(dev);
+ netdev_for_each_uc_addr(ha, dev) {
+ if (!memcmp(ha->addr, addr, dev->addr_len) &&
+ ha->type == NETDEV_HW_ADDR_T_UNICAST) {
+ err = -EEXIST;
+ goto out;
+ }
+ }
+ netif_addr_unlock_bh(dev);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ return dev_uc_add(dev, addr);
+#else
+ return dev_unicast_add(dev, addr);
+#endif
+
+out:
+ netif_addr_unlock_bh(dev);
+ return err;
+}
+EXPORT_SYMBOL(dev_uc_add_excl);
+
+int dev_mc_add_excl(struct net_device *dev, unsigned char *addr)
+{
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ struct netdev_hw_addr *ha;
+#else
+ struct dev_addr_list *ha;
+#endif
+ int err;
+
+ netif_addr_lock_bh(dev);
+ netdev_for_each_mc_addr(ha, dev) {
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ if (!memcmp(ha->addr, addr, dev->addr_len)) {
+#else
+ if (!memcmp(ha->da_addr, addr, dev->addr_len)) {
+#endif
+ err = -EEXIST;
+ goto out;
+ }
+ }
+ netif_addr_lock_bh(dev);
+
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
+ return dev_mc_add(dev, addr);
+#else
+ return dev_mc_add(dev, addr, ETH_ALEN, true);
+#endif
+
+out:
+ netif_addr_unlock_bh(dev);
+ return err;
+}
+EXPORT_SYMBOL(dev_mc_add_excl);
--- /dev/null
+/*
+ * Copyright 2012 Mellanox Technologies Ltd.
+ *
+ * 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 <linux/cpu.h>
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+#include <linux/export.h>
+#include <linux/types.h>
+#include <linux/netdevice.h>
+
+/**
+ * netif_get_num_default_rss_queues - default number of RSS queues
+ *
+ * This routine should set an upper limit on the number of RSS queues
+ * used by default by multiqueue devices.
+ */
+int netif_get_num_default_rss_queues(void)
+{
+ return min_t(int, DEFAULT_MAX_NUM_RSS_QUEUES, num_online_cpus());
+}
+EXPORT_SYMBOL(netif_get_num_default_rss_queues);
--- /dev/null
+/*
+ * Copyright 2012 Luis R. Rodriguez <mcgrof@do-not-panic.com>
+ *
+ * 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 <linux/workqueue.h>
+#include <linux/export.h>
+#include <linux/file.h>
+
+#define mod_delayed_work LINUX_BACKPORT(mod_delayed_work)
+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);
+
+/*
+ * 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.
+ */
+#define pcie_flags_reg LINUX_BACKPORT(pcie_flags_reg)
+static inline u16 pcie_flags_reg(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;
+}
+
+#define pci_pcie_type LINUX_BACKPORT(pci_pcie_type)
+static inline int pci_pcie_type(struct pci_dev *dev)
+{
+ return (pcie_flags_reg(dev) & PCI_EXP_FLAGS_TYPE) >> 4;
+}
+
+#define pcie_cap_version LINUX_BACKPORT(pcie_cap_version)
+static inline int pcie_cap_version(struct pci_dev *dev)
+{
+ return pcie_flags_reg(dev) & PCI_EXP_FLAGS_VERS;
+}
+
+#define pcie_cap_has_devctl LINUX_BACKPORT(pcie_cap_has_devctl)
+static inline bool pcie_cap_has_devctl(const struct pci_dev *dev)
+{
+ return true;
+}
+
+#define pcie_cap_has_lnkctl LINUX_BACKPORT(pcie_cap_has_lnkctl)
+static inline bool pcie_cap_has_lnkctl(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;
+}
+
+#define pcie_cap_has_sltctl LINUX_BACKPORT(pcie_cap_has_sltctl)
+static inline bool pcie_cap_has_sltctl(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);
+}
+
+#define pcie_cap_has_rtctl LINUX_BACKPORT(pcie_cap_has_rtctl)
+static inline bool pcie_cap_has_rtctl(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;
+}
+
+#define pcie_capability_reg_implemented LINUX_BACKPORT(pcie_capability_reg_implemented)
+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.)
+ */
+#define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
+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);
+
+#define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword)
+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);
+
+#define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word)
+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);
+
+#define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword)
+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);
+
+#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)
+{
+ 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);
+
+#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)
+{
+ 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);
+
+/* Actually fget_light is defined in fs/file.c but only 3.7 exports it.
+ * Lets export it here.
+ */
+struct file *fget_light(unsigned int fd, int *fput_needed)
+{
+ struct file *file;
+ struct files_struct *files = current->files;
+
+ *fput_needed = 0;
+ if (atomic_read(&files->count) == 1) {
+ file = fcheck_files(files, fd);
+ if (file && (file->f_mode & FMODE_PATH))
+ file = NULL;
+ } else {
+ rcu_read_lock();
+ file = fcheck_files(files, fd);
+ if (file) {
+ if (!(file->f_mode & FMODE_PATH) &&
+ atomic_long_inc_not_zero(&file->f_count))
+ *fput_needed = 1;
+ else
+ /* Didn't get the reference, someone's freed */
+ file = NULL;
+ }
+ rcu_read_unlock();
+ }
+
+ return file;
+}
+EXPORT_SYMBOL(fget_light);
#include <linux/firmware.h>
#include <linux/slab.h>
-#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");
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;
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;
* 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;
* 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))
* in atomic contexts.
**/
int
-compat_request_firmware_nowait(
+backport_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))
EXPORT_SYMBOL_GPL(release_firmware);
EXPORT_SYMBOL_GPL(request_firmware);
-EXPORT_SYMBOL_GPL(request_firmware_nowait);
+EXPORT_SYMBOL_GPL(backport_request_firmware_nowait);
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
{
if (!nents)
- BUG();
+ return -EINVAL;
len = __kfifo_max_r(len, recsize);
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize)
{
if (!nents)
- BUG();
+ return -EINVAL;
len = __kfifo_max_r(len, recsize);
* If -E is returned, result is not touched.
*/
#include <linux/kernel.h>
+
+#ifndef CONFIG_COMPAT_IS_KSTRTOX
/*
* 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
+#ifndef strict_strtoll
#include <linux/ctype.h>
#include <linux/errno.h>
#include <linux/module.h>
#include <linux/types.h>
-#ifndef CONFIG_COMPAT_RHEL_6_4
-
static inline char _tolower(const char c)
{
return c | 0x20;
return 0;
}
EXPORT_SYMBOL_GPL(kstrtos8);
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
#endif /* #ifndef strict_strtol */
+#endif /* #ifndef CONFIG_COMPAT_IS_KSTRTOX */
#include <linux/module.h>
+#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
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();
+ int err;
+
+ backport_pm_qos_power_init();
+ err = backport_system_workqueue_create();
+ if (err) {
+ pr_warn("backport_system_workqueue_create() failed\n");
+ return err;
+ }
+ backport_init_mmc_pm_flags();
printk(KERN_INFO
COMPAT_PROJECT " backport release: "
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);
/*
* This initializes pm-qos for older kernels.
*/
-int compat_pm_qos_power_init(void)
+int backport_pm_qos_power_init(void)
{
int ret = 0;
return ret;
}
-int compat_pm_qos_power_deinit(void)
+int backport_pm_qos_power_deinit(void)
{
int ret = 0;
--- /dev/null
+#!/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")
+ 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/
+ ;;
+esac
+
--- /dev/null
+#!/bin/bash
+#
+# Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
+# Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de>
+# Copyright 2011 John W. Linville <linville@tuxdriver.com>
+#
+# 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 <<EOF
+#ifndef COMPAT_AUTOCONF_INCLUDED
+#define COMPAT_AUTOCONF_INCLUDED
+/*
+ * Automatically generated C config: don't edit
+ */
+EOF
+
+# Checks user is compiling against a kernel we support
+kernel_version_req $OLDEST_KERNEL_SUPPORTED
+
+# For each CONFIG_FOO=x option
+for i in $(egrep '^CONFIG_|^ifdef CONFIG_|^ifndef CONFIG_|^endif #CONFIG_|^else #CONFIG_' $COMPAT_CONFIG | sed 's/ /+/'); do
+ case $i in
+ 'ifdef+CONFIG_'* )
+ echo "#$i" | sed -e 's/+/ /' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_3_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(3,\2,0))/' -e 's/\(ifdef CONFIG_COMPAT_KERNEL_2_6_\)\([0-9]*\)/if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,\2))/' -e 's/\(ifdef CONFIG_COMPAT_RHEL_\)\([0-9]*\)_\([0-9]*\)/if (defined(RHEL_MAJOR) \&\& RHEL_MAJOR == \2 \&\& RHEL_MINOR >= \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 */"
--- /dev/null
+#!/bin/bash
+# Copyright 2012 Luis R. Rodriguez <mcgrof@frijolero.org>
+# Copyright 2012 Hauke Mehrtens <hauke@hauke-m.de>
+#
+# 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="5"
+KERNEL_SUBLEVEL="-1"
+
+# 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')
+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
+ eval 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 "export 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
+ eval 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 "export CONFIG_COMPAT_FIRMWARE_CLASS=m"
+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 / FQ 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"
+ echo "export CONFIG_COMPAT_NET_SCH_FQ_CODEL=m"
+ fi
+fi
--- /dev/null
+#!/bin/bash
+perl -pe 's|(\e)\[(\d+)(;*)(\d*)(\w)||g'
#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);
/* 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 */
#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
#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);
#include <linux/pci.h>
/* Backports b718989da7 */
+#define pci_enable_device_mem LINUX_BACKPORT(pci_enable_device_mem)
int __must_check pci_enable_device_mem(struct pci_dev *dev);
/*
* 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
#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;
* 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
* 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;
}
#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)));
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);
/*
}
#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) */
#endif /* arm */
+#define debugfs_remove_recursive LINUX_BACKPORT(debugfs_remove_recursive)
+
#if defined(CONFIG_DEBUG_FS)
void debugfs_remove_recursive(struct dentry *dentry);
#else
})
#endif /* From include/asm-generic/bug.h */
-#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE)
-
-#include <pcmcia/cs_types.h>
-#include <pcmcia/cs.h>
-#include <pcmcia/cistpl.h>
-#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);
-
-#endif /* CONFIG_PCMCIA */
-
-/* USB anchors were added as of 2.6.23 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
-
-#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
-#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 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);
/**
#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,
#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)
}
+#define netdev_attach_ops LINUX_BACKPORT(netdev_attach_ops)
void netdev_attach_ops(struct net_device *dev,
const struct net_device_ops *ops);
#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
} \
)
+#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
#endif
+#define init_dummy_netdev LINUX_BACKPORT(init_dummy_netdev)
extern int init_dummy_netdev(struct net_device *dev);
#define compat_pci_suspend(fn) \
#include <net/genetlink.h>
#include <linux/ethtool.h>
-/*
- * 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)
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))
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)) */
#include <linux/sched.h>
#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
-#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))
return -EINVAL;
}
-static inline void compat_release_firmware(const struct firmware *fw)
+static inline void release_firmware(const struct firmware *fw)
{
}
#endif
+#endif
/* mask KEY_RFKILL as RHEL6 backports this */
#if !defined(KEY_RFKILL)
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)
-
-/* 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);
-
-#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,
- int (*loop_tuple) (tuple_t *tuple,
- cisparse_t *parse,
- void *priv_data));
-
-#endif /* CONFIG_PCCARD */
-
/**
* list_for_each_entry_continue_rcu - continue iteration over list of given type
* @pos: the type * to use as a loop cursor.
#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)
+#define pci_pcie_cap LINUX_BACKPORT(pci_pcie_cap)
/**
* pci_pcie_cap - get the saved PCIe capability offset
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)
+#define pci_is_pcie LINUX_BACKPORT(pci_is_pcie)
/**
* pci_is_pcie - check if the PCI device is PCI Express capable
#define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
+#ifndef CONFIG_COMPAT_IS_BITMAP
+
+extern void bitmap_set(unsigned long *map, int i, int len);
+extern void bitmap_clear(unsigned long *map, int start, int nr);
+extern unsigned long bitmap_find_next_zero_area(unsigned long *map,
+ unsigned long size,
+ unsigned long start,
+ unsigned int nr,
+ unsigned long align_mask);
+
+#endif /* CONFIG_COMPAT_IS_BITMAP */
+
+#ifdef CONFIG_PPC
+#ifndef NUMA_NO_NODE
+#define NUMA_NO_NODE (-1)
+#endif
+#endif /* CONFIG_PPC */
+
+#define strim LINUX_BACKPORT(strim)
+extern char *strim(char *);
+
+#define skip_spaces LINUX_BACKPORT(skip_spaces)
+extern char * __must_check skip_spaces(const char *);
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)) */
#endif /* LINUX_26_33_COMPAT_H */
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_uc_count(dev) ((dev)->uc.count)
+#define netdev_uc_empty(dev) ((dev)->uc.count == 0)
+#define netdev_for_each_uc_addr(ha, dev) \
+ list_for_each_entry(ha, &dev->uc.list, list)
#define netdev_mc_count(dev) ((dev)->mc_count)
#define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0)
/* source: include/linux/netdevice.h */
+#define device_lock LINUX_BACKPORT(device_lock)
static inline void device_lock(struct device *dev)
{
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
#endif
}
+#define device_trylock LINUX_BACKPORT(device_trylock)
static inline int device_trylock(struct device *dev)
{
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
#endif
}
+#define device_unlock LINUX_BACKPORT(device_unlock)
static inline void device_unlock(struct device *dev)
{
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
#define rcu_dereference_check(p, c) rcu_dereference(p)
+#ifndef sysfs_attr_init
/**
* 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
+#endif /* sysfs_attr_init */
/**
* sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
#ifndef rcu_dereference_protected
#define rcu_dereference_protected(p, c) (p)
#endif
-#ifndef rcu_access_pointer
+
#define rcu_access_pointer(p) ACCESS_ONCE(p)
-#endif
-#ifndef rcu_dereference_raw
+
#define rcu_dereference_raw(p) rcu_dereference(p)
-#endif
#define KEY_WPS_BUTTON 0x211 /* WiFi Protected Setup key */
#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;
-}
-
#ifdef CONFIG_PROVE_LOCKING
/*
* Obviously, this is wrong. But the base kernel will have rtnl_mutex
}
#endif /* #ifdef CONFIG_PROVE_LOCKING */
-#else /* Kernels >= 2.6.34 */
+#ifndef NETIF_F_NTUPLE
+#define NETIF_F_NTUPLE (1 << 27) /* N-tuple filters supported */
+#endif
+
+
+#ifndef PCI_VPD_LRDT
+#define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */
+#define PCI_VPD_LRDT_ID(x) (x | PCI_VPD_LRDT)
+
+/* Large Resource Data Type Tag Item Names */
+#define PCI_VPD_LTIN_ID_STRING 0x02 /* Identifier String */
+#define PCI_VPD_LTIN_RO_DATA 0x10 /* Read-Only Data */
+#define PCI_VPD_LTIN_RW_DATA 0x11 /* Read-Write Data */
+
+#define PCI_VPD_LRDT_ID_STRING PCI_VPD_LRDT_ID(PCI_VPD_LTIN_ID_STRING)
+#define PCI_VPD_LRDT_RO_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RO_DATA)
+#define PCI_VPD_LRDT_RW_DATA PCI_VPD_LRDT_ID(PCI_VPD_LTIN_RW_DATA)
+#define PCI_VPD_LRDT_TAG_SIZE 3
+#define PCI_VPD_SRDT_TAG_SIZE 1
+
+#define PCI_VPD_INFO_FLD_HDR_SIZE 3
+
+/* Small Resource Data Type Tag Item Names */
+#define PCI_VPD_STIN_END 0x78 /* End */
+
+#define PCI_VPD_SRDT_END PCI_VPD_STIN_END
+
+#define PCI_VPD_SRDT_TIN_MASK 0x78
+#define PCI_VPD_SRDT_LEN_MASK 0x07
+#endif /* PCI_VPD_LRDT */
+
+/**
+ * pci_vpd_info_field_size - Extracts the information field length
+ * @lrdt: Pointer to the beginning of an information field header
+ *
+ * Returns the extracted information field length.
+ */
+#define pci_vpd_info_field_size LINUX_BACKPORT(pci_vpd_info_field_size)
+static inline u8 pci_vpd_info_field_size(const u8 *info_field)
+{
+ return info_field[2];
+}
+
+/**
+ * pci_vpd_lrdt_size - Extracts the Large Resource Data Type length
+ * @lrdt: Pointer to the beginning of the Large Resource Data Type tag
+ *
+ * Returns the extracted Large Resource Data Type length.
+ */
+#define pci_vpd_lrdt_size LINUX_BACKPORT(pci_vpd_lrdt_size)
+static inline u16 pci_vpd_lrdt_size(const u8 *lrdt)
+{
+ return (u16)lrdt[1] + ((u16)lrdt[2] << 8);
+}
-static inline void init_compat_mmc_pm_flags(void)
+/**
+ * pci_vpd_find_info_keyword - Locates an information field keyword in the VPD
+ * @buf: Pointer to buffered vpd data
+ * @off: The offset into the buffer at which to begin the search
+ * @len: The length of the buffer area, relative to off, in which to search
+ * @kw: The keyword to search for
+ *
+ * Returns the index where the information field keyword was found or
+ * -ENOENT otherwise.
+ */
+#define pci_vpd_find_info_keyword LINUX_BACKPORT(pci_vpd_find_info_keyword)
+int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
+ unsigned int len, const char *kw);
+
+/**
+ * pci_vpd_find_tag - Locates the Resource Data Type tag provided
+ * @buf: Pointer to buffered vpd data
+ * @off: The offset into the buffer at which to begin the search
+ * @len: The length of the vpd buffer
+ * @rdt: The Resource Data Type to search for
+ *
+ * Returns the index where the Resource Data Type was found or
+ * -ENOENT otherwise.
+ */
+#define pci_vpd_find_tag LINUX_BACKPORT(pci_vpd_find_tag)
+int pci_vpd_find_tag(const u8 *buf, unsigned int off, unsigned int len, u8 rdt);
+
+/**
+ * pci_vpd_srdt_size - Extracts the Small Resource Data Type length
+ * @lrdt: Pointer to the beginning of the Small Resource Data Type tag
+ *
+ * Returns the extracted Small Resource Data Type length.
+ */
+#define pci_vpd_srdt_size LINUX_BACKPORT(pci_vpd_srdt_size)
+static inline u8 pci_vpd_srdt_size(const u8 *srdt)
{
+ return (*srdt) & PCI_VPD_SRDT_LEN_MASK;
}
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */
#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
+#ifndef PCI_EXP_LNKSTA_CLS_2_5GB
+#define PCI_EXP_LNKSTA_CLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
+#endif
+
+#ifndef PCI_EXP_LNKSTA_CLS_5_0GB
+#define PCI_EXP_LNKSTA_CLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
+#endif
+
/*
* 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.
*/
-#define irq_set_affinity_hint(a, b) compat_irq_set_affinity_hint(a, b)
+#define irq_set_affinity_hint LINUX_BACKPORT(irq_set_affinity_hint)
static inline int irq_set_affinity_hint(unsigned int irq,
const struct cpumask *m)
#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)
-/* mask hex_to_bin as RHEL6.3 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)
-{
- struct usb_host_endpoint **eps;
- eps = usb_pipein(pipe) ? dev->ep_in : dev->ep_out;
- return eps[usb_pipeendpoint(pipe)];
-}
+#ifndef __ALIGN_KERNEL
+#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#endif
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)) */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
-#include <linux/usb.h>
-#include <pcmcia/cistpl.h>
-#include <pcmcia/ds.h>
#include <linux/pm_qos_params.h>
#include <linux/smp_lock.h>
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef kparam_block_sysfs_write
#define kparam_block_sysfs_write(a)
+#endif
+#ifndef kparam_unblock_sysfs_write
#define kparam_unblock_sysfs_write(a)
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
/* mask va_format as RHEL6 backports this */
#define va_format compat_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
-
-#ifndef CONFIG_COMPAT_RHEL_6_4
-/**
- * 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 /* CONFIG_COMPAT_RHEL_6_4 */
-
struct pm_qos_request_list {
u32 qos;
void *request;
return false;
}
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#define skb_tx_timestamp LINUX_BACKPORT(skb_tx_timestamp)
static inline void skb_tx_timestamp(struct sk_buff *skb)
{
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
/*
* System-wide workqueues which are always present.
* 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);
-
+int 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);
+#define schedule_work_on LINUX_BACKPORT(schedule_work_on)
+int schedule_work_on(int cpu, struct work_struct *work);
+#define schedule_delayed_work LINUX_BACKPORT(schedule_delayed_work)
+int schedule_delayed_work(struct delayed_work *dwork,
+ unsigned long delay);
+#define schedule_delayed_work_on LINUX_BACKPORT(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);
+
+#ifndef CONFIG_COMPAT_IS_WORK_BUSY
enum {
/* bit mask for work_busy() return values */
WORK_BUSY_PENDING = 1 << 0,
WORK_BUSY_RUNNING = 1 << 1,
};
+#endif
+#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
-static inline void compat_system_workqueue_create(void)
+static inline int backport_system_workqueue_create(void)
{
+ return 0;
}
-static inline void compat_system_workqueue_destroy(void)
+static inline void backport_system_workqueue_destroy(void)
{
}
*/
#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
+#ifndef __rcu
+#define __rcu
+#endif
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
#endif /* LINUX_26_36_COMPAT_H */
#include <linux/skbuff.h>
#include <linux/leds.h>
#include <linux/in.h>
+#include <linux/rcupdate.h>
+#include <linux/netdevice.h>
#include <linux/errno.h>
static inline int proto_ports_offset(int proto)
}
}
+/* supports eipoib flags, priv_flags is short till that version */
+#define CONFIG_COMPAT_IFF_EIPOIB_PIF 0x8000 /*== IFF_OVS_DATAPATH*/
+#define CONFIG_COMPAT_IFF_EIPOIB_VIF 0x4000 /*IFF_MACVLAN_PORT*/
+
+/* Definitions for tx_flags in struct skb_shared_info */
+enum {
+ /* generate hardware time stamp */
+ SKBTX_HW_TSTAMP = 1 << 0,
+
+ /* generate software time stamp */
+ SKBTX_SW_TSTAMP = 1 << 1,
+
+ /* device driver is going to provide hardware time stamp */
+ SKBTX_IN_PROGRESS = 1 << 2,
+
+ /* ensure the originating sk reference is available on driver level */
+ SKBTX_DRV_NEEDS_SK_REF = 1 << 3,
+};
+
+
#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */
#define VLAN_N_VID 4096
-#ifndef CONFIG_COMPAT_RHEL_6_4
/*
* netif_set_real_num_rx_queues - set actual number of RX queues used
* @dev: Network device
* possible. Hence adding this function to avoid changes in driver source
* code and making this function to always return success.
*/
+/* mask netif_set_real_num_rx_queues as RHEL6.4 backports this */
+#define netif_set_real_num_rx_queues(a, b) compat_netif_set_real_num_rx_queues(a, b)
static inline int netif_set_real_num_rx_queues(struct net_device *dev,
unsigned int rxq)
{
return 0;
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#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 */
#endif
}
-#ifndef CONFIG_COMPAT_RHEL_6_4
-#define pcmcia_enable_device(link) pcmcia_request_configuration(link, &link->conf)
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
#include <net/genetlink.h>
struct compat_genl_info {
#define genl_unregister_mc_group(_fam, _grp) genl_unregister_mc_group(&(_fam)->family, _grp)
+#define led_blink_set LINUX_BACKPORT(led_blink_set)
extern void led_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off);
#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)
+#define vzalloc_node LINUX_BACKPORT(vzalloc_node)
extern void *vzalloc(unsigned long size);
+extern void *vzalloc_node(unsigned long size, int node);
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef rtnl_dereference
#define rtnl_dereference(p) \
rcu_dereference_protected(p, lockdep_rtnl_is_held())
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
+
+#ifndef rcu_dereference_protected
+#define rcu_dereference_protected(p, c) \
+ rcu_dereference((p))
+#endif
+
+#ifndef rcu_dereference_bh
+#define rcu_dereference_bh(p) \
+ rcu_dereference((p))
+#endif
/**
* RCU_INIT_POINTER() - initialize an RCU protected pointer
#define RCU_INIT_POINTER(p, v) \
p = (typeof(*v) __force __rcu *)(v)
+#define skb_has_frag_list LINUX_BACKPORT(skb_has_frag_list)
static inline bool skb_has_frag_list(const struct sk_buff *skb)
{
return skb_shinfo(skb)->frag_list != NULL;
ETH_FLAG_RXVLAN = (1 << 8), /* RX VLAN offload enabled */
};
+extern void unregister_netdevice_queue(struct net_device *dev,
+ struct list_head *head);
+
+#ifndef max3
+#define max3(x, y, z) ({ \
+ typeof(x) _max1 = (x); \
+ typeof(y) _max2 = (y); \
+ typeof(z) _max3 = (z); \
+ (void) (&_max1 == &_max2); \
+ (void) (&_max1 == &_max3); \
+ _max1 > _max2 ? (_max1 > _max3 ? _max1 : _max3) : \
+ (_max2 > _max3 ? _max2 : _max3); })
+#endif
+
+#ifndef CONFIG_COMPAT_XPRTRDMA_NEEDED
+struct rpc_xprt * xprt_alloc(int size, int max_req);
+void xprt_free(struct rpc_xprt *);
+#endif /* CONFIG_COMPAT_XPRTRDMA_NEEDED */
+
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)) */
#endif /* LINUX_26_37_COMPAT_H */
#include <linux/etherdevice.h>
#include <net/sch_generic.h>
+#define __DEFERRED_WORK_INITIALIZER(n, f) { \
+ .work = __WORK_INITIALIZER((n).work, (f)), \
+ .timer = TIMER_DEFERRED_INITIALIZER(NULL, 0, 0), \
+ }
+
+#define DECLARE_DEFERRED_WORK(n, f) \
+ struct delayed_work n = __DEFERRED_WORK_INITIALIZER(n, f)
+
#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)
unsigned long weight;
};
+#define ewma_init LINUX_BACKPORT(ewma_init)
extern void ewma_init(struct ewma *avg, unsigned long factor,
unsigned long weight);
+#define ewma_add LINUX_BACKPORT(ewma_add)
extern struct ewma *ewma_add(struct ewma *avg, unsigned long val);
+#define ewma_read LINUX_BACKPORT(ewma_read)
/**
* ewma_read() - Get average value
* @avg: Average structure
}
#define pr_warn pr_warning
-
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef create_freezable_workqueue
#define create_freezable_workqueue create_freezeable_workqueue
+#endif
+/* mask skb_checksum_start_offset as RHEL6.4 backports this */
+#define skb_checksum_start_offset(a) compat_skb_checksum_start_offset(a)
static inline int skb_checksum_start_offset(const struct sk_buff *skb)
{
return skb->csum_start - skb_headroom(skb);
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
/* from include/linux/printk.h */
#define pr_emerg_once(fmt, ...) \
*
* Return true if the address is a unicast address.
*/
+#define is_unicast_ether_addr LINUX_BACKPORT(is_unicast_ether_addr)
static inline int is_unicast_ether_addr(const u8 *addr)
{
return !is_multicast_ether_addr(addr);
#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)) */
+#define netif_is_bond_slave LINUX_BACKPORT(netif_is_bond_slave)
static inline int netif_is_bond_slave(struct net_device *dev)
{
return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
}
-
-#ifndef CONFIG_COMPAT_RHEL_6_4
static inline int irq_set_irq_wake(unsigned int irq, unsigned int on)
{
return set_irq_wake(irq, on);
{
return set_irq_chip_data(irq, data);
}
+#ifndef irq_set_irq_type
static inline int irq_set_irq_type(unsigned int irq, unsigned int type)
{
return set_irq_type(irq, type);
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
+#endif
static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
{
return set_irq_msi(irq, entry);
}
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)) */
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef CONFIG_COMPAT_IS_KSTRTOX
/*
* 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
+#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);
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 /* ifndef CONFIG_COMPAT_IS_KSTRTOX */
+#ifndef CONFIG_COMPAT_IS_BITOP
static inline int test_bit_le(int nr, const void *addr)
{
return test_bit(nr ^ BITOP_LE_SWIZZLE, addr);
{
__clear_bit(nr ^ BITOP_LE_SWIZZLE, addr);
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
+
+#ifndef __ASSEMBLY__
+#define PTR_RET LINUX_BACKPORT(PTR_RET)
+static inline int __must_check PTR_RET(const void *ptr)
+{
+ if (IS_ERR(ptr))
+ return PTR_ERR(ptr);
+ else
+ return 0;
+}
+#endif
+
+#ifndef IEEE_8021QAZ_TSA_STRICT
+#define IEEE_8021QAZ_TSA_STRICT 0
+#endif
+#ifndef IEEE_8021QAZ_TSA_CB_SHAPER
+#define IEEE_8021QAZ_TSA_CB_SHAPER 1
+#endif
+#ifndef IEEE_8021QAZ_TSA_ETS
+#define IEEE_8021QAZ_TSA_ETS 2
+#endif
+#ifndef IEEE_8021QAZ_TSA_VENDOR
+#define IEEE_8021QAZ_TSA_VENDOR 255
+#endif
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)) */
#define LINUX_BACKPORT(__sym) backport_ ##__sym
#include <linux/version.h>
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0))
+#include <linux/kconfig.h>
+#include <linux/if.h>
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
#include <linux/kconfig.h>
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))
#include <generated/autoconf.h>
#else
#include <linux/autoconf.h>
#endif
+#include <linux/compat_autoconf.h>
#include <linux/init.h>
+#include <linux/uidgid.h>
/*
* The define overwriting module_init is based on the original module_init
* 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
#include <linux/compat-3.6.h>
#include <linux/compat-3.7.h>
#include <linux/compat-3.10.h>
-#include <linux/compat-3.11.h>
#include <linux/compat-3.12.h>
#endif /* LINUX_26_COMPAT_H */
#define BCMA_ANY_CLASS 0xFF
#endif /* BCMA_CORE */
+#define mac_pton LINUX_BACKPORT(mac_pton)
int mac_pton(const char *s, u8 *mac);
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef CONFIG_COMPAT_IS_KSTRTOX
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);
{
return kstrtoint_from_user(s, count, base, res);
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
#ifndef kfree_rcu
/*
#endif
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef CONFIG_COMPAT_IS_PHYS_ID_STATE
/*
* enum ethtool_phys_id_state - indicator state for physical identification
* @ETHTOOL_ID_INACTIVE: Physical ID indicator should be deactivated
ETHTOOL_ID_ON,
ETHTOOL_ID_OFF
};
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#endif
+
+#ifndef NETLINK_RDMA
+#define NETLINK_RDMA 20
+#endif
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
#include <linux/idr.h>
#include <net/dst.h>
-#ifndef CONFIG_COMPAT_SLES_11_3
+#ifndef CONFIG_COMPAT_DST_NEIGHBOUR
static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst)
{
return dst->neighbour;
{
return rcu_dereference_raw(dst->neighbour);
}
-#endif /* CONFIG_COMPAT_SLES_11_3 */
+#endif /* CONFIG_COMPAT_DST_NEIGHBOUR */
/* Backports 56f8a75c */
static inline bool ip_is_fragment(const struct iphdr *iph)
return skb;
}
-#ifndef NEED_MIN_DUMP_ALLOC_ARG
+#if ! defined(CONFIG_COMPAT_MIN_DUMP_ALLOC_ARG) && ! defined(CONFIG_COMPAT_NETLINK_3_7)
#include <linux/netlink.h>
/* remove last arg */
#define netlink_dump_start(a, b, c, d, e, f) netlink_dump_start(a, b, c, d, e)
#include <linux/version.h>
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0))
+#include <linux/random.h>
-#include <linux/if_vlan.h>
-#define __vlan_hwaccel_put_tag(a, b, c) __vlan_hwaccel_put_tag(a, c)
-
-#include <linux/netdev_features.h>
+#ifndef NETIF_F_HW_VLAN_CTAG_RX
#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX
+#endif
+
+#ifndef NETIF_F_HW_VLAN_CTAG_TX
+#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
+#endif
+
+#ifndef NETIF_F_HW_VLAN_CTAG_FILTER
+#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
+#endif
+
+#ifndef prandom_u32
+#define prandom_u32() random32()
+#endif
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) */
#endif /* LINUX_3_10_COMPAT_H */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0))
-#define PTR_ERR_OR_ZERO LINUX_BACKPORT(PTR_ERR_OR_ZERO)
-static inline int __must_check PTR_ERR_OR_ZERO(__force const void *ptr)
-{
- if (IS_ERR(ptr))
- return PTR_ERR(ptr);
- else
- return 0;
-}
-#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0) */
+#ifndef PTR_ERR_OR_ZERO
+#define PTR_ERR_OR_ZERO(p) PTR_RET(p)
+#endif
+
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)) */
#endif /* LINUX_3_12_COMPAT_H */
extern int __ethtool_get_settings(struct net_device *dev,
struct ethtool_cmd *cmd);
-#ifndef CONFIG_COMPAT_SLES_11_3
-#ifdef CONFIG_COMPAT_SKB_FRAG_NEEDED
-
/**
* skb_frag_page - retrieve the page refered to by a paged fragment
* @frag: the paged fragment
*
* Returns the &struct page associated with @frag.
*/
+#define skb_frag_page LINUX_BACKPORT(skb_frag_page)
static inline struct page *skb_frag_page(const skb_frag_t *frag)
{
return frag->page;
*
* Sets the fragment @frag to contain @page.
*/
+#define __skb_frag_set_page LINUX_BACKPORT(__skb_frag_set_page)
static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
{
frag->page = page;
*
* Sets the @f'th fragment of @skb to contain @page.
*/
+#define skb_frag_set_page LINUX_BACKPORT(skb_frag_set_page)
static inline void skb_frag_set_page(struct sk_buff *skb, int f,
struct page *page)
{
* Returns the address of the data within @frag. Checks that the page
* is mapped and returns %NULL otherwise.
*/
+#define skb_frag_address_safe LINUX_BACKPORT(skb_frag_address_safe)
static inline void *skb_frag_address_safe(const skb_frag_t *frag)
{
void *ptr = page_address(skb_frag_page(frag));
*
* Maps the page associated with @frag to @device.
*/
+#define skb_frag_dma_map LINUX_BACKPORT(skb_frag_dma_map)
static inline dma_addr_t skb_frag_dma_map(struct device *dev,
const skb_frag_t *frag,
size_t offset, size_t size,
frag->page_offset + offset, size, dir);
}
+/**
+ * __skb_frag_unref - release a reference on a paged fragment.
+ * @frag: the paged fragment
+ *
+ * Releases a reference on the paged fragment @frag.
+ */
+#define __skb_frag_unref LINUX_BACKPORT(__skb_frag_unref)
+static inline void __skb_frag_unref(skb_frag_t *frag)
+{
+ put_page(skb_frag_page(frag));
+}
+
#define ETH_P_TDLS 0x890D /* TDLS */
+#define skb_frag_size LINUX_BACKPORT(skb_frag_size)
static inline unsigned int skb_frag_size(const skb_frag_t *frag)
{
return frag->size;
}
+#define skb_frag_size_set LINUX_BACKPORT(skb_frag_size_set)
static inline void skb_frag_size_set(skb_frag_t *frag, unsigned int size)
{
frag->size = size;
}
+#define skb_frag_size_add LINUX_BACKPORT(skb_frag_size_add)
static inline void skb_frag_size_add(skb_frag_t *frag, int delta)
{
frag->size += delta;
}
+#define skb_frag_size_sub LINUX_BACKPORT(skb_frag_size_sub)
static inline void skb_frag_size_sub(skb_frag_t *frag, int delta)
{
frag->size -= delta;
}
-/**
- * __skb_frag_unref - release a reference on a paged fragment.
- * @frag: the paged fragment
- *
- * Releases a reference on the paged fragment @frag.
- */
-static inline void __skb_frag_unref(skb_frag_t *frag)
-{
- put_page(skb_frag_page(frag));
-}
-
-#endif /* CONFIG_COMPAT_SKB_FRAG_NEEDED */
-
+#define hex_byte_pack LINUX_BACKPORT(hex_byte_pack)
static inline char *hex_byte_pack(char *buf, u8 byte)
{
*buf++ = hex_asc_hi(byte);
*buf++ = hex_asc_lo(byte);
return buf;
}
-#endif /* CONFIG_COMPAT_SLES_11_3 */
/* module_platform_driver() - Helper macro for drivers that don't do
* anything special in module init/exit. This eliminates a lot of
module_driver(__platform_driver, platform_driver_register, \
platform_driver_unregister)
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#define dma_zalloc_coherent LINUX_BACKPORT(dma_zalloc_coherent)
static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
dma_addr_t *dma_handle, gfp_t flag)
{
memset(ret, 0, size);
return ret;
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#define __netdev_printk LINUX_BACKPORT(__netdev_printk)
extern int __netdev_printk(const char *level, const struct net_device *dev,
struct va_format *vaf);
extern struct sk_buff *__pskb_copy(struct sk_buff *skb,
int headroom, gfp_t gfp_mask);
-#ifndef CONFIG_COMPAT_RHEL_6_4
-static inline void skb_complete_wifi_ack(struct sk_buff *skb, bool acked)
-{
- WARN_ON(1);
-}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
#define NL80211_FEATURE_SK_TX_STATUS 0
+#ifndef CONFIG_COMPAT_NETDEV_FEATURES
typedef u32 netdev_features_t;
+#endif /* CONFIG_COMPAT_NETDEV_FEATURES */
-#ifndef CONFIG_COMPAT_SLES_11_3
+#ifndef module_driver
/* source include/linux/device.h */
/**
* module_driver() - Helper macro for drivers that don't do anything
__unregister(&(__driver)); \
} \
module_exit(__driver##_exit);
+#endif
/* source include/linux/usb.h */
/**
}
#define NETIF_F_LOOPBACK (1 << 31) /* Enable loopback */
-#endif /* CONFIG_COMPAT_SLES_11_3 */
+
+#ifndef NETIF_F_RXCSUM
+#define NETIF_F_RXCSUM (1 << 29)
+#endif
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)) */
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
-#ifndef CONFIG_COMPAT_SLES_11_3
-extern int simple_open(struct inode *inode, struct file *file);
+#ifndef VM_NODUMP
+#define VM_NODUMP 0x04000000 /* Do not include in the core dump */
+#endif
+
+#ifndef EPROBE_DEFER
+#define EPROBE_DEFER 517 /* Driver requests probe retry */
#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))
#define skb_add_rx_frag(skb, i, page, off, size, truesize) \
v2_6_28_skb_add_rx_frag(skb, i, page, off, size)
#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
#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);
#define NET_ADDR_RANDOM 1 /* address is generated randomly */
#define NET_ADDR_STOLEN 2 /* address is stolen from other device */
-#ifndef CONFIG_COMPAT_RHEL_6_4
+#ifndef CONFIG_COMPAT_ETH_HW_ADDR_RANDOM
+#ifndef CONFIG_COMPAT_DEV_HW_ADDR_RANDOM
+#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);
}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
+#else
+#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);
+}
+#endif
+#endif
-#else /* 2.6.36 and on */
-#ifndef CONFIG_COMPAT_SLES_11_3
+#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
+#ifndef CONFIG_COMPAT_ETH_HW_ADDR_RANDOM
+#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);
}
-#endif /* CONFIG_COMPAT_SLES_11_3 */
-#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
+#endif
+#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)) */
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)) */
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)) */
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0))
-/*
- * This backports:
- *
- * commit f56f821feb7b36223f309e0ec05986bb137ce418
- * Author: Daniel Vetter <daniel.vetter@ffwll.ch>
- * 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.
- *
- */
-
-#if (!defined(CONFIG_COMPAT_RHEL_6_4) && !defined(CONFIG_COMPAT_SLES_11_3))
-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;
-}
-#endif /* (!defined(CONFIG_COMPAT_RHEL_6_4) && !defined(CONFIG_COMPAT_SLES_11_3)) */
-
-/* switcheroo is available on >= 2.6.34 */
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34))
-#ifndef CONFIG_COMPAT_SLES_11_3
-#include <linux/vga_switcheroo.h>
-/*
- * This backports:
- *
- * From 26ec685ff9d9c16525d8ec4c97e52fcdb187b302 Mon Sep 17 00:00:00 2001
- * From: Takashi Iwai <tiwai@suse.de>
- * 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 /* CONFIG_COMPAT_SLES_11_3 */
-#endif
-
/*
* This backports:
*
};
};
+#ifndef CONFIG_COMPAT_IS_MAXRATE
+#ifndef IEEE_8021QAZ_MAX_TCS
+#define IEEE_8021QAZ_MAX_TCS 8
+#endif
+
+struct ieee_maxrate {
+ u64 tc_maxrate[IEEE_8021QAZ_MAX_TCS];
+};
+#endif
/* Backports tty_lock: Localise the lock */
#define tty_lock(__tty) tty_lock()
#define tty_unlock(__tty) tty_unlock()
-#ifndef CONFIG_COMPAT_RHEL_6_4
-/* Backport ether_addr_equal */
-static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
-{
- return !compare_ether_addr(addr1, addr2);
-}
-#endif /* CONFIG_COMPAT_RHEL_6_4 */
-
#define net_ratelimited_function(function, ...) \
do { \
if (net_ratelimit()) \
return NULL;
}
+#ifndef CONFIG_COMPAT_IS_IP_TOS2PRIO
extern const __u8 ip_tos2prio[16];
+#endif
+
+#define dev_uc_add_excl LINUX_BACKPORT(dev_uc_add_excl)
+extern int dev_uc_add_excl(struct net_device *dev, unsigned char *addr);
+
+#define dev_mc_add_excl LINUX_BACKPORT(dev_mc_add_excl)
+extern int dev_mc_add_excl(struct net_device *dev, unsigned char *addr);
+
+#define SK_CAN_REUSE 1
+
+#define ether_addr_equal_64bits LINUX_BACKPORT(ether_addr_equal_64bits)
+static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
+ const u8 addr2[6+2])
+{
+ return !compare_ether_addr_64bits(addr1, addr2);
+}
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)) */
* Signed-off-by: Dave Airlie <airlied@redhat.com>
*/
+#ifndef PCI_EXP_LNKCAP2
#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 */
+#endif
#include <net/genetlink.h>
#include <linux/etherdevice.h>
*
* Assign the broadcast address to the given address array.
*/
+#define eth_broadcast_addr LINUX_BACKPORT(eth_broadcast_addr)
static inline void eth_broadcast_addr(u8 *addr)
{
memset(addr, 0xff, ETH_ALEN);
#define VM_DONTDUMP VM_NODUMP
+#ifndef INIT_DEFERRABLE_WORK
+#define INIT_DEFERRABLE_WORK(_work, _func) INIT_DELAYED_WORK_DEFERRABLE(_work, _func)
+#endif
+
+#ifndef DECLARE_DEFERRABLE_WORK
+#define DECLARE_DEFERRABLE_WORK(n, f) DECLARE_DEFERRED_WORK(n, f)
+#endif
+
#ifdef CONFIG_USER_NS
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
#define MAX_IDR_MASK (MAX_IDR_BIT - 1)
/* IPoIB section */
-
+#ifndef IFLA_IPOIB_MAX
enum {
IFLA_IPOIB_UNSPEC,
IFLA_IPOIB_PKEY,
};
#define IFLA_IPOIB_MAX (__IFLA_IPOIB_MAX - 1)
+#endif
#define FMODE_PATH ((__force fmode_t)0x4000)
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0))
#include_next <linux/llist.h>
+#define llist_add_batch LINUX_BACKPORT(llist_add_batch)
extern bool llist_add_batch(struct llist_node *new_first,
struct llist_node *new_last,
struct llist_head *head);
+#define llist_del_first LINUX_BACKPORT(llist_del_first)
extern struct llist_node *llist_del_first(struct llist_head *head);
#else
* init_llist_head - initialize lock-less list head
* @head: the head for your lock-less list
*/
+#define init_llist_head LINUX_BACKPORT(init_llist_head)
static inline void init_llist_head(struct llist_head *list)
{
list->first = NULL;
* @type: the type of the struct this is embedded in.
* @member: the name of the llist_node within the struct.
*/
+#ifndef llist_entry
#define llist_entry(ptr, type, member) \
container_of(ptr, type, member)
+#endif
/**
* llist_for_each - iterate over some deleted entries of a lock-less list
* you want to traverse from the oldest to the newest, you must
* reverse the order by yourself before traversing.
*/
+#ifndef llist_for_each
#define llist_for_each(pos, node) \
for ((pos) = (node); pos; (pos) = (pos)->next)
+#endif
/**
* llist_for_each_entry - iterate over some deleted entries of lock-less list of given type
* you want to traverse from the oldest to the newest, you must
* reverse the order by yourself before traversing.
*/
+#ifndef llist_for_each_entry
#define llist_for_each_entry(pos, node, member) \
for ((pos) = llist_entry((node), typeof(*(pos)), member); \
&(pos)->member != NULL; \
(pos) = llist_entry((pos)->member.next, typeof(*(pos)), member))
+#endif
/**
* llist_empty - tests whether a lock-less list is empty
* test whether the list is empty without deleting something from the
* list.
*/
+#define llist_empty LINUX_BACKPORT(llist_empty)
static inline bool llist_empty(const struct llist_head *head)
{
return ACCESS_ONCE(head->first) == NULL;
}
+#define llist_next LINUX_BACKPORT(llist_next)
static inline struct llist_node *llist_next(struct llist_node *node)
{
return node->next;
*
* Returns true if the list was empty prior to adding this entry.
*/
+#define llist_add LINUX_BACKPORT(llist_add)
static inline bool llist_add(struct llist_node *new, struct llist_head *head)
{
struct llist_node *entry, *old_entry;
* return the pointer to the first entry. The order of entries
* deleted is from the newest to the oldest added one.
*/
+#define llist_del_all LINUX_BACKPORT(llist_del_all)
static inline struct llist_node *llist_del_all(struct llist_head *head)
{
return xchg(&head->first, NULL);
}
+#define llist_add_batch LINUX_BACKPORT(llist_add_batch)
extern bool llist_add_batch(struct llist_node *new_first,
struct llist_node *new_last,
struct llist_head *head);
+#define llist_del_first LINUX_BACKPORT(llist_del_first)
extern struct llist_node *llist_del_first(struct llist_head *head);
#endif /* (defined(CONFIG_COMPAT_SLES_11_2) || defined(CONFIG_COMPAT_SLES_11_3)) */
--- /dev/null
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
+#include_next <linux/uidgid.h>
+#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 <linux/types.h>
+#include <linux/highuid.h>
+
+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
+
+#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;
+}
+
+#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);
+ if (uid == (uid_t)-1)
+ uid = overflowuid;
+ 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);
+ if (gid == (gid_t)-1)
+ gid = overflowgid;
+ 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;
+}
+
+#endif /* CONFIG_USER_NS */
+
+#endif /* _LINUX_UIDGID_H */
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0) */