diff options
Diffstat (limited to 'backport/compat')
-rw-r--r-- | backport/compat/Kconfig | 51 | ||||
-rw-r--r-- | backport/compat/Makefile | 17 | ||||
-rw-r--r-- | backport/compat/compat-2.6.26.c | 64 | ||||
-rw-r--r-- | backport/compat/compat-2.6.27.c | 241 | ||||
-rw-r--r-- | backport/compat/compat-2.6.28.c | 472 | ||||
-rw-r--r-- | backport/compat/compat-2.6.29.c | 169 | ||||
-rw-r--r-- | backport/compat/compat-2.6.32.c | 217 | ||||
-rw-r--r-- | backport/compat/compat-2.6.33.c | 233 | ||||
-rw-r--r-- | backport/compat/compat-2.6.34.c | 88 | ||||
-rw-r--r-- | backport/compat/compat-2.6.34.h | 20 | ||||
-rw-r--r-- | backport/compat/compat-2.6.35.c | 117 | ||||
-rw-r--r-- | backport/compat/compat-2.6.36.c | 120 | ||||
-rw-r--r-- | backport/compat/compat-2.6.37.c | 269 | ||||
-rw-r--r-- | backport/compat/compat-2.6.39.c | 117 | ||||
-rw-r--r-- | backport/compat/compat_atomic.c | 43 | ||||
-rw-r--r-- | backport/compat/compat_firmware_class.c | 759 | ||||
-rw-r--r-- | backport/compat/kfifo.c | 607 | ||||
-rw-r--r-- | backport/compat/kstrtox.c | 237 | ||||
-rw-r--r-- | backport/compat/main.c | 4 |
19 files changed, 2 insertions, 3843 deletions
diff --git a/backport/compat/Kconfig b/backport/compat/Kconfig index 1cec8ada..5af74337 100644 --- a/backport/compat/Kconfig +++ b/backport/compat/Kconfig @@ -47,48 +47,12 @@ # # # C) similarly, a kconfig symbol for an option, e.g. -# BACKPORT_OPTION_BT_SOCK_CREATE_NEEDS_KERN (see below) +# BACKPORT_OPTION_SOME_FIX (no examples provided) check git log # # # Variations are obviously possible. # -config BACKPORT_BUILD_FW_LOADER - tristate - # RHEL6, starting from 6.0, backports the FW loader already - depends on !BACKPORT_RHEL_KERNEL_6_0 - depends on !FW_LOADER || BACKPORT_KERNEL_2_6_33 - default m if BACKPORT_FW_LOADER - default m if BACKPORT_USERSEL_BUILD_ALL - -config BACKPORT_FW_LOADER - bool - -config BACKPORT_USERSEL_NET_SCH_CODEL - tristate "Controlled Delay AQM (CODEL)" - depends on m - depends on !BACKPORT_KERNEL_2_6_25 - default m if NET_SCH_CODEL=n - default m if BACKPORT_USERSEL_BUILD_ALL - #module-name sch_codel - #c-file net/sched/sch_codel.c - -config BACKPORT_USERSEL_NET_SCH_FQ_CODEL - tristate "Fair Queue Controlled Delay AQM (FQ_CODEL)" - depends on m - depends on !BACKPORT_KERNEL_2_6_25 - default m if NET_SCH_FQ_CODEL=n - default m if BACKPORT_USERSEL_BUILD_ALL - #module-name sch_fq_codel - #c-file net/sched/sch_fq_codel.c - #c-file net/core/flow_dissector.c - -config BACKPORT_BUILD_KFIFO - def_bool y - # RHEL6, starting from 6.1, backports kfifo already - depends on !BACKPORT_RHEL_KERNEL_6_1 - depends on BACKPORT_KERNEL_2_6_36 - config BACKPORT_BUILD_CORDIC tristate depends on !CORDIC @@ -100,15 +64,6 @@ config BACKPORT_BUILD_CORDIC config BACKPORT_CORDIC bool -config BACKPORT_BUILD_GENERIC_ATOMIC64 - bool - default y if !64BIT && !GENERIC_ATOMIC64 - -config BACKPORT_OPTION_BT_SOCK_CREATE_NEEDS_KERN - bool - # in RHEL6 (starting from 6.0), the function needs the argument - default y if !BACKPORT_KERNEL_2_6_33 || BACKPORT_RHEL_KERNEL_6_0 - config BACKPORT_BUILD_AVERAGE bool depends on !AVERAGE @@ -120,10 +75,6 @@ config BACKPORT_BUILD_AVERAGE config BACKPORT_AVERAGE bool -config BACKPORT_OPTION_USB_URB_THREAD_FIX - bool - default y if BACKPORT_KERNEL_2_6_36 - config BACKPORT_MII bool diff --git a/backport/compat/Makefile b/backport/compat/Makefile index 3c46a1ba..353a71dc 100644 --- a/backport/compat/Makefile +++ b/backport/compat/Makefile @@ -2,20 +2,7 @@ ccflags-y += -I$(src) obj-m += compat.o compat-y += main.o -obj-$(CPTCFG_BACKPORT_BUILD_FW_LOADER) += compat_firmware_class.o - -# Compat kernel compatibility code -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_26) += compat-2.6.26.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_27) += compat-2.6.27.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_28) += compat-2.6.28.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_29) += compat-2.6.29.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_32) += compat-2.6.32.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_33) += compat-2.6.33.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_34) += compat-2.6.34.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_35) += compat-2.6.35.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_36) += compat-2.6.36.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_37) += compat-2.6.37.o -compat-$(CPTCFG_BACKPORT_KERNEL_2_6_39) += compat-2.6.39.o kstrtox.o +# Kernel backport compatibility code compat-$(CPTCFG_BACKPORT_KERNEL_3_0) += compat-3.0.o compat-$(CPTCFG_BACKPORT_KERNEL_3_1) += compat-3.1.o compat-$(CPTCFG_BACKPORT_KERNEL_3_2) += backport-3.2.o @@ -33,6 +20,4 @@ compat-$(CPTCFG_BACKPORT_KERNEL_3_14) += backport-3.14.o compat-$(CPTCFG_BACKPORT_KERNEL_3_15) += backport-3.15.o compat-$(CPTCFG_BACKPORT_BUILD_CRYPTO_CCM) += crypto-ccm.o -compat-$(CPTCFG_BACKPORT_BUILD_KFIFO) += kfifo.o -compat-$(CPTCFG_BACKPORT_BUILD_GENERIC_ATOMIC64) += compat_atomic.o compat-$(CPTCFG_BACKPORT_BUILD_DMA_SHARED_HELPERS) += dma-shared-helpers.o diff --git a/backport/compat/compat-2.6.26.c b/backport/compat/compat-2.6.26.c deleted file mode 100644 index 9ff1f767..00000000 --- a/backport/compat/compat-2.6.26.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2007-2010 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. - * - * Backport functionality introduced in Linux 2.6.26. - * - * Copyright holders from ported work: - * - * Copyright (c) 2002-2003 Patrick Mochel <mochel@osdl.org> - * Copyright (c) 2006-2007 Greg Kroah-Hartman <greg@kroah.com> - * Copyright (c) 2006-2007 Novell Inc. - */ -#include <linux/device.h> -#include <net/sock.h> -#include <net/compat.h> - -/** - * kobject_set_name_vargs - Set the name of an kobject - * @kobj: struct kobject to set the name of - * @fmt: format string used to build the name - * @vargs: vargs to format the string. - */ -static -int kobject_set_name_vargs(struct kobject *kobj, const char *fmt, - va_list vargs) -{ - const char *old_name = kobj->name; - char *s; - - if (kobj->name && !fmt) - return 0; - - kobj->name = kvasprintf(GFP_KERNEL, fmt, vargs); - if (!kobj->name) - return -ENOMEM; - - /* ewww... some of these buggers have '/' in the name ... */ - while ((s = strchr(kobj->name, '/'))) - s[0] = '!'; - - kfree(old_name); - return 0; -} - -/** - * dev_set_name - set a device name - * @dev: device - * @fmt: format string for the device's name - */ -int dev_set_name(struct device *dev, const char *fmt, ...) -{ - va_list vargs; - int err; - - va_start(vargs, fmt); - err = kobject_set_name_vargs(&dev->kobj, fmt, vargs); - va_end(vargs); - return err; -} -EXPORT_SYMBOL_GPL(dev_set_name); - diff --git a/backport/compat/compat-2.6.27.c b/backport/compat/compat-2.6.27.c deleted file mode 100644 index 7235c878..00000000 --- a/backport/compat/compat-2.6.27.c +++ /dev/null @@ -1,241 +0,0 @@ -/* - * 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. - * - * Backport functionality introduced in Linux 2.6.27 - */ -#include <linux/debugfs.h> -#include <linux/compat.h> -#include <linux/pci.h> -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) -#include <linux/mmc/sdio.h> -#include <linux/mmc/sdio_func.h> -#include <linux/mmc/card.h> -#include <linux/mmc/host.h> -#endif - -/* rfkill notification chain */ -#define RFKILL_STATE_CHANGED 0x0001 /* state of a normal rfkill - switch has changed */ - -/* - * e5899e1b7d73e67de758a32174a859cc2586c0b9 made pci_pme_capable() external, - * it was defined internally, some drivers want access to this information. - * - * Unfortunately the old kernels do not have ->pm_cap or ->pme_support so - * we have to call the PCI routines directly. - */ - -#ifdef CONFIG_PCI -/** - * pci_pme_capable - check the capability of PCI device to generate PME# - * @dev: PCI device to handle. - * @state: PCI state from which device will issue PME#. - * - * This is the backport code for older kernels for compat-drivers, we read stuff - * from the initialization stuff from pci_pm_init(). - */ -bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) -{ - int pm; - u16 pmc = 0; - u16 pme_support; /* as from the pci dev */ - /* find PCI PM capability in list */ - pm = pci_find_capability(dev, PCI_CAP_ID_PM); - if (!pm) - return false; - - if ((pmc & PCI_PM_CAP_VER_MASK) > 3) { - dev_err(&dev->dev, "unsupported PM cap regs version (%u)\n", - pmc & PCI_PM_CAP_VER_MASK); - return false; - } - - pmc &= PCI_PM_CAP_PME_MASK; - - if (!pmc) - return false; - - pme_support = pmc >> PCI_PM_CAP_PME_SHIFT; - - /* Check device's ability to generate PME# */ - - return !!(pme_support & (1 << state)); -} -EXPORT_SYMBOL_GPL(pci_pme_capable); -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) -/** - * mmc_align_data_size - pads a transfer size to a more optimal value - * @card: the MMC card associated with the data transfer - * @sz: original transfer size - * - * Pads the original data size with a number of extra bytes in - * order to avoid controller bugs and/or performance hits - * (e.g. some controllers revert to PIO for certain sizes). - * - * Returns the improved size, which might be unmodified. - * - * Note that this function is only relevant when issuing a - * single scatter gather entry. - */ -unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) -{ - /* - * FIXME: We don't have a system for the controller to tell - * the core about its problems yet, so for now we just 32-bit - * align the size. - */ - sz = ((sz + 3) / 4) * 4; - - return sz; -} -EXPORT_SYMBOL_GPL(mmc_align_data_size); - -/* - * Calculate the maximum byte mode transfer size - */ -static inline unsigned int sdio_max_byte_size(struct sdio_func *func) -{ - unsigned int mval = (unsigned int) min(func->card->host->max_seg_size, - func->card->host->max_blk_size); - mval = min(mval, func->max_blksize); - return min(mval, 512u); /* maximum size for byte mode */ -} - -/** - * sdio_align_size - pads a transfer size to a more optimal value - * @func: SDIO function - * @sz: original transfer size - * - * Pads the original data size with a number of extra bytes in - * order to avoid controller bugs and/or performance hits - * (e.g. some controllers revert to PIO for certain sizes). - * - * If possible, it will also adjust the size so that it can be - * handled in just a single request. - * - * Returns the improved size, which might be unmodified. - */ -unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz) -{ - unsigned int orig_sz; - unsigned int blk_sz, byte_sz; - unsigned chunk_sz; - - orig_sz = sz; - - /* - * Do a first check with the controller, in case it - * wants to increase the size up to a point where it - * might need more than one block. - */ - sz = mmc_align_data_size(func->card, sz); - - /* - * If we can still do this with just a byte transfer, then - * we're done. - */ - if (sz <= sdio_max_byte_size(func)) - return sz; - - if (func->card->cccr.multi_block) { - /* - * Check if the transfer is already block aligned - */ - if ((sz % func->cur_blksize) == 0) - return sz; - - /* - * Realign it so that it can be done with one request, - * and recheck if the controller still likes it. - */ - blk_sz = ((sz + func->cur_blksize - 1) / - func->cur_blksize) * func->cur_blksize; - blk_sz = mmc_align_data_size(func->card, blk_sz); - - /* - * This value is only good if it is still just - * one request. - */ - if ((blk_sz % func->cur_blksize) == 0) - return blk_sz; - - /* - * We failed to do one request, but at least try to - * pad the remainder properly. - */ - byte_sz = mmc_align_data_size(func->card, - sz % func->cur_blksize); - if (byte_sz <= sdio_max_byte_size(func)) { - blk_sz = sz / func->cur_blksize; - return blk_sz * func->cur_blksize + byte_sz; - } - } else { - /* - * We need multiple requests, so first check that the - * controller can handle the chunk size; - */ - chunk_sz = mmc_align_data_size(func->card, - sdio_max_byte_size(func)); - if (chunk_sz == sdio_max_byte_size(func)) { - /* - * Fix up the size of the remainder (if any) - */ - byte_sz = orig_sz % chunk_sz; - if (byte_sz) { - byte_sz = mmc_align_data_size(func->card, - byte_sz); - } - - return (orig_sz / chunk_sz) * chunk_sz + byte_sz; - } - } - - /* - * The controller is simply incapable of transferring the size - * we want in decent manner, so just return the original size. - */ - return orig_sz; -} -EXPORT_SYMBOL_GPL(sdio_align_size); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24) */ - -#ifdef CONFIG_DEBUG_FS -/* - * Backport of debugfs_remove_recursive() without using the internals globals - * which are used by the kernel's version with: - * simple_release_fs(&debugfs_mount, &debugfs_mount_count); - */ -void debugfs_remove_recursive(struct dentry *dentry) -{ - struct dentry *last = NULL; - - /* Sanity checks */ - if (!dentry || !dentry->d_parent || !dentry->d_parent->d_inode) - return; - - while (dentry != last) { - struct dentry *child = dentry; - - /* Find a child without children */ - while (!list_empty(&child->d_subdirs)) - child = list_entry(child->d_subdirs.next, - struct dentry, - d_u.d_child); - - /* Bail out if we already tried to remove that entry */ - if (child == last) - return; - - last = child; - debugfs_remove(child); - } -} -EXPORT_SYMBOL_GPL(debugfs_remove_recursive); -#endif /* CONFIG_DEBUG_FS */ - diff --git a/backport/compat/compat-2.6.28.c b/backport/compat/compat-2.6.28.c deleted file mode 100644 index 1a4b01da..00000000 --- a/backport/compat/compat-2.6.28.c +++ /dev/null @@ -1,472 +0,0 @@ -/* - * 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. - * - * Backport functionality introduced in Linux 2.6.28. - */ - -#include <linux/compat.h> -#include <linux/usb.h> -#include <linux/tty.h> -#include <linux/skbuff.h> -#include <linux/pci.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/cistpl.h> -#include <pcmcia/cs_types.h> -#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 - -#ifdef CONFIG_PCI -void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) -{ - /* - * Make sure the BAR is actually a memory resource, not an IO resource - */ - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { - WARN_ON(1); - return NULL; - } - return ioremap_nocache(pci_resource_start(pdev, bar), - pci_resource_len(pdev, bar)); -} -EXPORT_SYMBOL_GPL(pci_ioremap_bar); -#endif - -static unsigned long round_jiffies_common(unsigned long j, int cpu, - bool force_up) -{ - int rem; - unsigned long original = j; - - /* - * We don't want all cpus firing their timers at once hitting the - * same lock or cachelines, so we skew each extra cpu with an extra - * 3 jiffies. This 3 jiffies came originally from the mm/ code which - * already did this. - * The skew is done by adding 3*cpunr, then round, then subtract this - * extra offset again. - */ - j += cpu * 3; - - rem = j % HZ; - - /* - * If the target jiffie is just after a whole second (which can happen - * due to delays of the timer irq, long irq off times etc etc) then - * we should round down to the whole second, not up. Use 1/4th second - * as cutoff for this rounding as an extreme upper bound for this. - * But never round down if @force_up is set. - */ - if (rem < HZ/4 && !force_up) /* round down */ - j = j - rem; - else /* round up */ - j = j - rem + HZ; - - /* now that we have rounded, subtract the extra skew again */ - j -= cpu * 3; - - if (j <= jiffies) /* rounding ate our timeout entirely; */ - return original; - return j; -} - -/** - * round_jiffies_up - function to round jiffies up to a full second - * @j: the time in (absolute) jiffies that should be rounded - * - * This is the same as round_jiffies() except that it will never - * round down. This is useful for timeouts for which the exact time - * of firing does not matter too much, as long as they don't fire too - * early. - */ -unsigned long round_jiffies_up(unsigned long j) -{ - return round_jiffies_common(j, raw_smp_processor_id(), true); -} -EXPORT_SYMBOL_GPL(round_jiffies_up); - -void v2_6_28_skb_add_rx_frag(struct sk_buff *skb, int i, struct page *page, int off, - int size) -{ - skb_fill_page_desc(skb, i, page, off, size); - skb->len += size; - skb->data_len += size; - skb->truesize += size; -} -EXPORT_SYMBOL_GPL(v2_6_28_skb_add_rx_frag); - -#ifdef CONFIG_TTY -void tty_write_unlock(struct tty_struct *tty) -{ - mutex_unlock(&tty->atomic_write_lock); - wake_up_interruptible_poll(&tty->write_wait, POLLOUT); -} - -int tty_write_lock(struct tty_struct *tty, int ndelay) -{ - if (!mutex_trylock(&tty->atomic_write_lock)) { - if (ndelay) - return -EAGAIN; - if (mutex_lock_interruptible(&tty->atomic_write_lock)) - return -ERESTARTSYS; - } - return 0; -} - -/** - * send_prio_char - send priority character - * - * Send a high priority character to the tty even if stopped - * - * Locking: none for xchar method, write ordering for write method. - */ - -static int send_prio_char(struct tty_struct *tty, char ch) -{ - int was_stopped = tty->stopped; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - if (tty->ops->send_xchar) { - tty->ops->send_xchar(tty, ch); -#else - if (tty->driver->send_xchar) { - tty->driver->send_xchar(tty, ch); -#endif - return 0; - } - - if (tty_write_lock(tty, 0) < 0) - return -ERESTARTSYS; - - if (was_stopped) - start_tty(tty); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - tty->ops->write(tty, &ch, 1); -#else - tty->driver->write(tty, &ch, 1); -#endif - if (was_stopped) - stop_tty(tty); - tty_write_unlock(tty); - return 0; -} - -int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file, - unsigned int cmd, unsigned long arg) -{ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - unsigned long flags; -#endif - int retval; - - switch (cmd) { - case TCXONC: - retval = tty_check_change(tty); - if (retval) - return retval; - switch (arg) { - case TCOOFF: - if (!tty->flow_stopped) { - tty->flow_stopped = 1; - stop_tty(tty); - } - break; - case TCOON: - if (tty->flow_stopped) { - tty->flow_stopped = 0; - start_tty(tty); - } - break; - case TCIOFF: - if (STOP_CHAR(tty) != __DISABLED_CHAR) - return send_prio_char(tty, STOP_CHAR(tty)); - break; - case TCION: - if (START_CHAR(tty) != __DISABLED_CHAR) - return send_prio_char(tty, START_CHAR(tty)); - break; - default: - return -EINVAL; - } - return 0; - case TCFLSH: - return tty_perform_flush(tty, arg); - case TIOCPKT: - { - int pktmode; - - if (tty->driver->type != TTY_DRIVER_TYPE_PTY || - tty->driver->subtype != PTY_TYPE_MASTER) - return -ENOTTY; - if (get_user(pktmode, (int __user *) arg)) - return -EFAULT; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - spin_lock_irqsave(&tty->ctrl_lock, flags); -#endif - if (pktmode) { - if (!tty->packet) { - tty->packet = 1; - tty->link->ctrl_status = 0; - } - } else - tty->packet = 0; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - spin_unlock_irqrestore(&tty->ctrl_lock, flags); -#endif - return 0; - } - default: - /* Try the mode commands */ - return tty_mode_ioctl(tty, file, cmd, arg); - } -} -EXPORT_SYMBOL_GPL(n_tty_ioctl_helper); -#endif /* CONFIG_TTY */ - -#ifdef CONFIG_PCI -/** - * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold - * @dev: PCI device to prepare - * @enable: True to enable wake-up event generation; false to disable - * - * Many drivers want the device to wake up the system from D3_hot or D3_cold - * and this function allows them to set that up cleanly - pci_enable_wake() - * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI - * ordering constraints. - * - * This function only returns error code if the device is not capable of - * generating PME# from both D3_hot and D3_cold, and the platform is unable to - * enable wake-up power for it. - */ -int pci_wake_from_d3(struct pci_dev *dev, bool enable) -{ - return pci_pme_capable(dev, PCI_D3cold) ? - pci_enable_wake(dev, PCI_D3cold, enable) : - pci_enable_wake(dev, PCI_D3hot, enable); -} -EXPORT_SYMBOL_GPL(pci_wake_from_d3); -#endif - diff --git a/backport/compat/compat-2.6.29.c b/backport/compat/compat-2.6.29.c deleted file mode 100644 index 65b45f8d..00000000 --- a/backport/compat/compat-2.6.29.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright 2007-2010 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. - * - * Backport functionality introduced in Linux 2.6.29. - */ - -#include <linux/compat.h> -#include <linux/usb.h> -#include <linux/etherdevice.h> - -/* - * If you don't see your net_device_ops implemented on - * netdev_attach_ops() then you are shit out of luck and - * you must do the nasty ifdef magic, unless you figure - * out a way to squeze your hacks into this routine :) - */ -void netdev_attach_ops(struct net_device *dev, - const struct net_device_ops *ops) -{ - if (!ops) - return; - - dev->open = ops->ndo_open; - dev->init = ops->ndo_init; - dev->stop = ops->ndo_stop; - dev->hard_start_xmit = ops->ndo_start_xmit; - dev->change_rx_flags = ops->ndo_change_rx_flags; - dev->set_multicast_list = ops->ndo_set_multicast_list; - dev->validate_addr = ops->ndo_validate_addr; - dev->do_ioctl = ops->ndo_do_ioctl; - dev->set_config = ops->ndo_set_config; - dev->change_mtu = ops->ndo_change_mtu; - dev->set_mac_address = ops->ndo_set_mac_address; - dev->tx_timeout = ops->ndo_tx_timeout; - if (ops->ndo_get_stats) - dev->get_stats = ops->ndo_get_stats; - dev->vlan_rx_register = ops->ndo_vlan_rx_register; - dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid; - dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid; -#ifdef CONFIG_NET_POLL_CONTROLLER - dev->poll_controller = ops->ndo_poll_controller; -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) - dev->select_queue = ops->ndo_select_queue; -#endif -} -EXPORT_SYMBOL_GPL(netdev_attach_ops); - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23)) -#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE) -/** - * usb_unpoison_anchored_urbs - let an anchor be used successfully again - * @anchor: anchor the requests are bound to - * - * Reverses the effect of usb_poison_anchored_urbs - * the anchor can be used normally after it returns - */ -void usb_unpoison_anchored_urbs(struct usb_anchor *anchor) -{ - unsigned long flags; - struct urb *lazarus; - - spin_lock_irqsave(&anchor->lock, flags); - list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) { - usb_unpoison_urb(lazarus); - } - //anchor->poisoned = 0; /* XXX: cannot backport */ - spin_unlock_irqrestore(&anchor->lock, flags); -} -EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs); -#endif /* CONFIG_USB */ -#endif - -/** - * eth_mac_addr - set new Ethernet hardware address - * @dev: network device - * @p: socket address - * Change hardware address of device. - * - * This doesn't change hardware matching, so needs to be overridden - * for most real devices. - */ -int eth_mac_addr(struct net_device *dev, void *p) -{ - struct sockaddr *addr = p; - - if (netif_running(dev)) - return -EBUSY; - if (!is_valid_ether_addr(addr->sa_data)) - return -EADDRNOTAVAIL; - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); - return 0; -} -EXPORT_SYMBOL_GPL(eth_mac_addr); - -/** - * eth_change_mtu - set new MTU size - * @dev: network device - * @new_mtu: new Maximum Transfer Unit - * - * Allow changing MTU size. Needs to be overridden for devices - * supporting jumbo frames. - */ -int eth_change_mtu(struct net_device *dev, int new_mtu) -{ - if (new_mtu < 68 || new_mtu > ETH_DATA_LEN) - return -EINVAL; - dev->mtu = new_mtu; - return 0; -} -EXPORT_SYMBOL_GPL(eth_change_mtu); - -int eth_validate_addr(struct net_device *dev) -{ - if (!is_valid_ether_addr(dev->dev_addr)) - return -EADDRNOTAVAIL; - - return 0; -} -EXPORT_SYMBOL_GPL(eth_validate_addr); -/* Source: net/ethernet/eth.c */ - -#define NETREG_DUMMY 5 -/** - * init_dummy_netdev - init a dummy network device for NAPI - * @dev: device to init - * - * This takes a network device structure and initialize the minimum - * amount of fields so it can be used to schedule NAPI polls without - * registering a full blown interface. This is to be used by drivers - * that need to tie several hardware interfaces to a single NAPI - * poll scheduler due to HW limitations. - */ -int init_dummy_netdev(struct net_device *dev) -{ - /* Clear everything. Note we don't initialize spinlocks - * are they aren't supposed to be taken by any of the - * NAPI code and this dummy netdev is supposed to be - * only ever used for NAPI polls - */ - memset(dev, 0, sizeof(struct net_device)); - - /* make sure we BUG if trying to hit standard - * register/unregister code path - */ - dev->reg_state = NETREG_DUMMY; - - /* initialize the ref count */ - atomic_set(&dev->refcnt, 1); - -#ifdef CONFIG_NETPOLL - /* NAPI wants this */ - INIT_LIST_HEAD(&dev->napi_list); -#endif - - /* a dummy interface is started by default */ - set_bit(__LINK_STATE_PRESENT, &dev->state); - set_bit(__LINK_STATE_START, &dev->state); - - return 0; -} -EXPORT_SYMBOL_GPL(init_dummy_netdev); -/* Source: net/core/dev.c */ - diff --git a/backport/compat/compat-2.6.32.c b/backport/compat/compat-2.6.32.c deleted file mode 100644 index 7d76b409..00000000 --- a/backport/compat/compat-2.6.32.c +++ /dev/null @@ -1,217 +0,0 @@ -/* - * 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. - * - * Backport functionality introduced in Linux 2.6.32. - */ - -#include <linux/compat.h> -#include <linux/netdevice.h> -#include <linux/time.h> - -int __dev_addr_add(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (da = *list; da != NULL; da = da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - da->da_addrlen == alen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 1; - if (old_glbl) - return 0; - } - da->da_users++; - return 0; - } - } - - da = kzalloc(sizeof(*da), GFP_ATOMIC); - if (da == NULL) - return -ENOMEM; - memcpy(da->da_addr, addr, alen); - da->da_addrlen = alen; - da->da_users = 1; - da->da_gusers = glbl ? 1 : 0; - da->next = *list; - *list = da; - (*count)++; - return 0; -} - -int __dev_addr_delete(struct dev_addr_list **list, int *count, - void *addr, int alen, int glbl) -{ - struct dev_addr_list *da; - - for (; (da = *list) != NULL; list = &da->next) { - if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 && - alen == da->da_addrlen) { - if (glbl) { - int old_glbl = da->da_gusers; - da->da_gusers = 0; - if (old_glbl == 0) - break; - } - if (--da->da_users) - return 0; - - *list = da->next; - kfree(da); - (*count)--; - return 0; - } - } - return -ENOENT; -} - -int __dev_addr_sync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - int err = 0; - - da = *from; - while (da != NULL) { - next = da->next; - if (!da->da_synced) { - err = __dev_addr_add(to, to_count, - da->da_addr, da->da_addrlen, 0); - if (err < 0) - break; - da->da_synced = 1; - da->da_users++; - } else if (da->da_users == 1) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } - return err; -} -EXPORT_SYMBOL_GPL(__dev_addr_sync); - -void __dev_addr_unsync(struct dev_addr_list **to, int *to_count, - struct dev_addr_list **from, int *from_count) -{ - struct dev_addr_list *da, *next; - - da = *from; - while (da != NULL) { - next = da->next; - if (da->da_synced) { - __dev_addr_delete(to, to_count, - da->da_addr, da->da_addrlen, 0); - da->da_synced = 0; - __dev_addr_delete(from, from_count, - da->da_addr, da->da_addrlen, 0); - } - da = next; - } -} -EXPORT_SYMBOL_GPL(__dev_addr_unsync); - -/* - * Nonzero if YEAR is a leap year (every 4 years, - * except every 100th isn't, and every 400th is). - */ -static int __isleap(long year) -{ - return (year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0); -} - -/* do a mathdiv for long type */ -static long math_div(long a, long b) -{ - return a / b - (a % b < 0); -} - -/* How many leap years between y1 and y2, y1 must less or equal to y2 */ -static long leaps_between(long y1, long y2) -{ - long leaps1 = math_div(y1 - 1, 4) - math_div(y1 - 1, 100) - + math_div(y1 - 1, 400); - long leaps2 = math_div(y2 - 1, 4) - math_div(y2 - 1, 100) - + math_div(y2 - 1, 400); - return leaps2 - leaps1; -} - -/* How many days come before each month (0-12). */ -static const unsigned short __mon_yday[2][13] = { - /* Normal years. */ - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - /* Leap years. */ - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} -}; - -#define SECS_PER_HOUR (60 * 60) -#define SECS_PER_DAY (SECS_PER_HOUR * 24) - -/** - * time_to_tm - converts the calendar time to local broken-down time - * - * @totalsecs the number of seconds elapsed since 00:00:00 on January 1, 1970, - * Coordinated Universal Time (UTC). - * @offset offset seconds adding to totalsecs. - * @result pointer to struct tm variable to receive broken-down time - */ -void time_to_tm(time_t totalsecs, int offset, struct tm *result) -{ - long days, rem, y; - const unsigned short *ip; - - days = totalsecs / SECS_PER_DAY; - rem = totalsecs % SECS_PER_DAY; - rem += offset; - while (rem < 0) { - rem += SECS_PER_DAY; - --days; - } - while (rem >= SECS_PER_DAY) { - rem -= SECS_PER_DAY; - ++days; - } - - result->tm_hour = rem / SECS_PER_HOUR; - rem %= SECS_PER_HOUR; - result->tm_min = rem / 60; - result->tm_sec = rem % 60; - - /* January 1, 1970 was a Thursday. */ - result->tm_wday = (4 + days) % 7; - if (result->tm_wday < 0) - result->tm_wday += 7; - - y = 1970; - - while (days < 0 || days >= (__isleap(y) ? 366 : 365)) { - /* Guess a corrected year, assuming 365 days per year. */ - long yg = y + math_div(days, 365); - - /* Adjust DAYS and Y to match the guessed year. */ - days -= (yg - y) * 365 + leaps_between(y, yg); - y = yg; - } - - result->tm_year = y - 1900; - - result->tm_yday = days; - - ip = __mon_yday[__isleap(y)]; - for (y = 11; days < ip[y]; y--) - continue; - days -= ip[y]; - - result->tm_mon = y; - result->tm_mday = days + 1; -} -EXPORT_SYMBOL_GPL(time_to_tm); -/* source: kernel/time/timeconv.c*/ - diff --git a/backport/compat/compat-2.6.33.c b/backport/compat/compat-2.6.33.c deleted file mode 100644 index b6115bae..00000000 --- a/backport/compat/compat-2.6.33.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Copyright 2009 Hauke Mehrtens <hauke@hauke-m.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Backport functionality introduced in Linux 2.6.33. - */ - -#include <linux/compat.h> -#include <linux/device.h> -#include <linux/usb.h> -#include <linux/pm_runtime.h> -#include <linux/platform_device.h> -#include <pcmcia/cs_types.h> -#include <pcmcia/cistpl.h> -#include <pcmcia/ds.h> - -#ifdef CONFIG_USB_SUSPEND -/** - * usb_autopm_get_interface_no_resume - increment a USB interface's PM-usage counter - * @intf: the usb_interface whose counter should be incremented - * - * This routine increments @intf's usage counter but does not carry out an - * autoresume. - * - * This routine can run in atomic context. - */ -void usb_autopm_get_interface_no_resume(struct usb_interface *intf) -{ - struct usb_device *udev = interface_to_usbdev(intf); - - usb_mark_last_busy(udev); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) - atomic_inc(&intf->pm_usage_cnt); -#else - intf->pm_usage_cnt++; -#endif - pm_runtime_get_noresume(&intf->dev); -} -EXPORT_SYMBOL_GPL(usb_autopm_get_interface_no_resume); - -/** - * usb_autopm_put_interface_no_suspend - decrement a USB interface's PM-usage counter - * @intf: the usb_interface whose counter should be decremented - * - * This routine decrements @intf's usage counter but does not carry out an - * autosuspend. - * - * This routine can run in atomic context. - */ -void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) -{ - struct usb_device *udev = interface_to_usbdev(intf); - - usb_mark_last_busy(udev); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) - atomic_dec(&intf->pm_usage_cnt); -#else - intf->pm_usage_cnt--; -#endif - pm_runtime_put_noidle(&intf->dev); -} -EXPORT_SYMBOL_GPL(usb_autopm_put_interface_no_suspend); -#endif /* CONFIG_USB_SUSPEND */ - -#if defined(CONFIG_PCCARD) || defined(CONFIG_PCCARD_MODULE) - -/** - * pccard_loop_tuple() - loop over tuples in the CIS - * @s: the struct pcmcia_socket where the card is inserted - * @function: the device function we loop for - * @code: which CIS code shall we look for? - * @parse: buffer where the tuple shall be parsed (or NULL, if no parse) - * @priv_data: private data to be passed to the loop_tuple function. - * @loop_tuple: function to call for each CIS entry of type @function. IT - * gets passed the raw tuple, the paresed tuple (if @parse is - * set) and @priv_data. - * - * pccard_loop_tuple() loops over all CIS entries of type @function, and - * calls the @loop_tuple function for each entry. If the call to @loop_tuple - * returns 0, the loop exits. Returns 0 on success or errorcode otherwise. - */ -int pccard_loop_tuple(struct pcmcia_socket *s, unsigned int function, - cisdata_t code, cisparse_t *parse, void *priv_data, - int (*loop_tuple) (tuple_t *tuple, - cisparse_t *parse, - void *priv_data)) -{ - tuple_t tuple; - cisdata_t *buf; - int ret; - - buf = kzalloc(256, GFP_KERNEL); - if (buf == NULL) { - dev_printk(KERN_WARNING, &s->dev, "no memory to read tuple\n"); - return -ENOMEM; - } - - tuple.TupleData = buf; - tuple.TupleDataMax = 255; - tuple.TupleOffset = 0; - tuple.DesiredTuple = code; - tuple.Attributes = 0; - - ret = pccard_get_first_tuple(s, function, &tuple); - while (!ret) { - if (pccard_get_tuple_data(s, &tuple)) - goto next_entry; - - if (parse) - if (pcmcia_parse_tuple(&tuple, parse)) - goto next_entry; - - ret = loop_tuple(&tuple, parse, priv_data); - if (!ret) - break; - -next_entry: - ret = pccard_get_next_tuple(s, function, &tuple); - } - - kfree(buf); - return ret; -} -EXPORT_SYMBOL_GPL(pccard_loop_tuple); -/* Source: drivers/pcmcia/cistpl.c */ - -#if defined(CONFIG_PCMCIA) || defined(CONFIG_PCMCIA_MODULE) - -struct pcmcia_loop_mem { - struct pcmcia_device *p_dev; - void *priv_data; - int (*loop_tuple) (struct pcmcia_device *p_dev, - tuple_t *tuple, - void *priv_data); -}; - -/** - * pcmcia_do_loop_tuple() - internal helper for pcmcia_loop_config() - * - * pcmcia_do_loop_tuple() is the internal callback for the call from - * pcmcia_loop_tuple() to pccard_loop_tuple(). Data is transferred - * by a struct pcmcia_cfg_mem. - */ -static int pcmcia_do_loop_tuple(tuple_t *tuple, cisparse_t *parse, void *priv) -{ - struct pcmcia_loop_mem *loop = priv; - - return loop->loop_tuple(loop->p_dev, tuple, loop->priv_data); -}; - -/** - * pcmcia_loop_tuple() - loop over tuples in the CIS - * @p_dev: the struct pcmcia_device which we need to loop for. - * @code: which CIS code shall we look for? - * @priv_data: private data to be passed to the loop_tuple function. - * @loop_tuple: function to call for each CIS entry of type @function. IT - * gets passed the raw tuple and @priv_data. - * - * pcmcia_loop_tuple() loops over all CIS entries of type @function, and - * calls the @loop_tuple function for each entry. If the call to @loop_tuple - * returns 0, the loop exits. Returns 0 on success or errorcode otherwise. - */ -int pcmcia_loop_tuple(struct pcmcia_device *p_dev, cisdata_t code, - int (*loop_tuple) (struct pcmcia_device *p_dev, - tuple_t *tuple, - void *priv_data), - void *priv_data) -{ - struct pcmcia_loop_mem loop = { - .p_dev = p_dev, - .loop_tuple = loop_tuple, - .priv_data = priv_data}; - - return pccard_loop_tuple(p_dev->socket, p_dev->func, code, NULL, - &loop, pcmcia_do_loop_tuple); -} -EXPORT_SYMBOL_GPL(pcmcia_loop_tuple); -/* Source: drivers/pcmcia/pcmcia_resource.c */ - -#endif /* CONFIG_PCMCIA */ - -#endif /* CONFIG_PCCARD */ - -/** - * platform_device_register_data - * @parent: parent device for the device we're adding - * @name: base name of the device we're adding - * @id: instance id - * @data: platform specific data for this platform device - * @size: size of platform specific data - * - * This function creates a simple platform device that requires minimal - * resource and memory management. Canned release function freeing memory - * allocated for the device allows drivers using such devices to be - * unloaded without waiting for the last reference to the device to be - * dropped. - */ -struct platform_device *platform_device_register_data( - struct device *parent, - const char *name, int id, - const void *data, size_t size) -{ - struct platform_device *pdev; - int retval; - - pdev = platform_device_alloc(name, id); - if (!pdev) { - retval = -ENOMEM; - goto error; - } - - pdev->dev.parent = parent; - - if (size) { - retval = platform_device_add_data(pdev, data, size); - if (retval) - goto error; - } - - retval = platform_device_add(pdev); - if (retval) - goto error; - - return pdev; - -error: - platform_device_put(pdev); - return ERR_PTR(retval); -} -EXPORT_SYMBOL_GPL(platform_device_register_data); diff --git a/backport/compat/compat-2.6.34.c b/backport/compat/compat-2.6.34.c deleted file mode 100644 index 4ae7f9a3..00000000 --- a/backport/compat/compat-2.6.34.c +++ /dev/null @@ -1,88 +0,0 @@ -/* - * 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. - * - * Backport functionality introduced in Linux 2.6.34. - */ - -#include <linux/mmc/sdio_func.h> -#include <linux/seq_file.h> -#include "compat-2.6.34.h" - -static mmc_pm_flag_t backport_mmc_pm_flags; - -void backport_init_mmc_pm_flags(void) -{ - backport_mmc_pm_flags = 0; -} - -mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func) -{ - return backport_mmc_pm_flags; -} -EXPORT_SYMBOL_GPL(sdio_get_host_pm_caps); - -int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) -{ - return -EINVAL; -} -EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags); - -/** - * seq_hlist_start - start an iteration of a hlist - * @head: the head of the hlist - * @pos: the start position of the sequence - * - * Called at seq_file->op->start(). - */ -static struct hlist_node * -seq_hlist_start(struct hlist_head *head, loff_t pos) -{ - struct hlist_node *node; - - hlist_for_each(node, head) - if (pos-- == 0) - return node; - return NULL; -} - -/** - * seq_hlist_start_head - start an iteration of a hlist - * @head: the head of the hlist - * @pos: the start position of the sequence - * - * Called at seq_file->op->start(). Call this function if you want to - * print a header at the top of the output. - */ -struct hlist_node *seq_hlist_start_head(struct hlist_head *head, loff_t pos) -{ - if (!pos) - return SEQ_START_TOKEN; - - return seq_hlist_start(head, pos - 1); -} -EXPORT_SYMBOL_GPL(seq_hlist_start_head); - -/** - * seq_hlist_next - move to the next position of the hlist - * @v: the current iterator - * @head: the head of the hlist - * @ppos: the current position - * - * Called at seq_file->op->next(). - */ -struct hlist_node *seq_hlist_next(void *v, struct hlist_head *head, - loff_t *ppos) -{ - struct hlist_node *node = v; - - ++*ppos; - if (v == SEQ_START_TOKEN) - return head->first; - else - return node->next; -} -EXPORT_SYMBOL_GPL(seq_hlist_next); diff --git a/backport/compat/compat-2.6.34.h b/backport/compat/compat-2.6.34.h deleted file mode 100644 index b36b441a..00000000 --- a/backport/compat/compat-2.6.34.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef LINUX_26_34_COMPAT_PRIVATE_H -#define LINUX_26_34_COMPAT_PRIVATE_H - -#include <linux/version.h> - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) - -#include <linux/mmc/sdio_func.h> - -void backport_init_mmc_pm_flags(void); - -#else /* Kernels >= 2.6.34 */ - -static inline void backport_init_mmc_pm_flags(void) -{ -} - -#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)) */ - -#endif /* LINUX_26_34_COMPAT_PRIVATE_H */ diff --git a/backport/compat/compat-2.6.35.c b/backport/compat/compat-2.6.35.c deleted file mode 100644 index e59cdc1c..00000000 --- a/backport/compat/compat-2.6.35.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2010 Kshitij Kulshreshtha <kkhere.geo@gmail.com> - * 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. - * - * Backport functionality introduced in Linux 2.6.35. - */ - -#include <linux/compat.h> -#include <linux/ctype.h> -#include <linux/netdevice.h> -#include <linux/module.h> -#include <linux/fs.h> -#include <linux/uaccess.h> -#include <net/sch_generic.h> - -/* - * Routine to help set real_num_tx_queues. To avoid skbs mapped to queues - * greater then real_num_tx_queues stale skbs on the qdisc must be flushed. - */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) -int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) -{ - unsigned int real_num = dev->real_num_tx_queues; - - if (unlikely(txq > dev->num_tx_queues)) - return -EINVAL; - else if (txq > real_num) - dev->real_num_tx_queues = txq; - else if (txq < real_num) { - dev->real_num_tx_queues = txq; - qdisc_reset_all_tx_gt(dev, txq); - } - return 0; -} -#else -int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) -{ - dev->egress_subqueue_count = txq; - /* XXX: consider qdisc reset for older kernels */ - return 0; -} -#endif -EXPORT_SYMBOL_GPL(netif_set_real_num_tx_queues); - -/** - * hex_to_bin - convert a hex digit to its real value - * @ch: ascii character represents hex digit - * - * hex_to_bin() converts one hex digit to its actual value or -1 in case of bad - * input. - */ -int hex_to_bin(char ch) -{ - if ((ch >= '0') && (ch <= '9')) - return ch - '0'; - ch = tolower(ch); - if ((ch >= 'a') && (ch <= 'f')) - return ch - 'a' + 10; - return -1; -} -EXPORT_SYMBOL_GPL(hex_to_bin); - -/** - * noop_llseek - No Operation Performed llseek implementation - * @file: file structure to seek on - * @offset: file offset to seek to - * @origin: type of seek - * - * This is an implementation of ->llseek useable for the rare special case when - * userspace expects the seek to succeed but the (device) file is actually not - * able to perform the seek. In this case you use noop_llseek() instead of - * falling back to the default implementation of ->llseek. - */ -loff_t noop_llseek(struct file *file, loff_t offset, int origin) -{ - return file->f_pos; -} -EXPORT_SYMBOL_GPL(noop_llseek); - -/** - * simple_write_to_buffer - copy data from user space to the buffer - * @to: the buffer to write to - * @available: the size of the buffer - * @ppos: the current position in the buffer - * @from: the user space buffer to read from - * @count: the maximum number of bytes to read - * - * The simple_write_to_buffer() function reads up to @count bytes from the user - * space address starting at @from into the buffer @to at offset @ppos. - * - * On success, the number of bytes written is returned and the offset @ppos is - * advanced by this number, or negative value is returned on error. - **/ -ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, - const void __user *from, size_t count) -{ - loff_t pos = *ppos; - size_t res; - - if (pos < 0) - return -EINVAL; - if (pos >= available || !count) - return 0; - if (count > available - pos) - count = available - pos; - res = copy_from_user(to + pos, from, count); - if (res == count) - return -EFAULT; - count -= res; - *ppos = pos + count; - return count; -} -EXPORT_SYMBOL_GPL(simple_write_to_buffer); diff --git a/backport/compat/compat-2.6.36.c b/backport/compat/compat-2.6.36.c deleted file mode 100644 index 2c00bc78..00000000 --- a/backport/compat/compat-2.6.36.c +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Backport functionality introduced in Linux 2.6.36. - */ - -#include <linux/compat.h> -#include <linux/usb.h> - -#ifdef CPTCFG_BACKPORT_OPTION_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_get_from_anchor - get an anchor's oldest urb - * @anchor: the anchor whose urb you want - * - * this will take the oldest urb from an anchor, - * unanchor and return it - */ -struct urb *usb_get_from_anchor(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - if (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.next, struct urb, - anchor_list); - usb_get_urb(victim); - __usb_unanchor_urb(victim, anchor); - } else { - victim = NULL; - } - spin_unlock_irqrestore(&anchor->lock, flags); - - return victim; -} -EXPORT_SYMBOL_GPL(usb_get_from_anchor); - -/** - * usb_scuttle_anchored_urbs - unanchor all an anchor's urbs - * @anchor: the anchor whose urbs you want to unanchor - * - * use this to get rid of all an anchor's urbs - */ -void usb_scuttle_anchored_urbs(struct usb_anchor *anchor) -{ - struct urb *victim; - unsigned long flags; - - spin_lock_irqsave(&anchor->lock, flags); - while (!list_empty(&anchor->urb_list)) { - victim = list_entry(anchor->urb_list.prev, struct urb, - anchor_list); - __usb_unanchor_urb(victim, anchor); - } - spin_unlock_irqrestore(&anchor->lock, flags); -} -EXPORT_SYMBOL_GPL(usb_scuttle_anchored_urbs); - -#endif /* CPTCFG_BACKPORT_OPTION_USB_URB_THREAD_FIX */ - -struct workqueue_struct *system_wq __read_mostly; -struct workqueue_struct *system_long_wq __read_mostly; -struct workqueue_struct *system_nrt_wq __read_mostly; -EXPORT_SYMBOL_GPL(system_wq); -EXPORT_SYMBOL_GPL(system_long_wq); -EXPORT_SYMBOL_GPL(system_nrt_wq); - -int schedule_work(struct work_struct *work) -{ - return queue_work(system_wq, work); -} -EXPORT_SYMBOL_GPL(schedule_work); - -int schedule_delayed_work(struct delayed_work *dwork, - unsigned long delay) -{ - return queue_delayed_work(system_wq, dwork, delay); -} -EXPORT_SYMBOL_GPL(schedule_delayed_work); - -void flush_scheduled_work(void) -{ - /* - * It is debatable which one we should prioritize first, lets - * go with the old kernel's one first for now (keventd_wq) and - * if think its reasonable later we can flip this around. - */ - flush_workqueue(system_wq); - flush_scheduled_work(); -} -EXPORT_SYMBOL_GPL(flush_scheduled_work); - -void backport_system_workqueue_create(void) -{ - system_wq = alloc_workqueue("events", 0, 0); - system_long_wq = alloc_workqueue("events_long", 0, 0); - system_nrt_wq = create_singlethread_workqueue("events_nrt"); - BUG_ON(!system_wq || !system_long_wq || !system_nrt_wq); -} - -void backport_system_workqueue_destroy(void) -{ - destroy_workqueue(system_wq); - destroy_workqueue(system_long_wq); - destroy_workqueue(system_nrt_wq); -} diff --git a/backport/compat/compat-2.6.37.c b/backport/compat/compat-2.6.37.c deleted file mode 100644 index 8d401e18..00000000 --- a/backport/compat/compat-2.6.37.c +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright 2010 Hauke Mehrtens <hauke@hauke-m.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Backport functionality introduced in Linux 2.6.37. - */ - -#include <linux/compat.h> -#include <linux/netdevice.h> -#include <net/sock.h> -#include <linux/nsproxy.h> -#include <linux/vmalloc.h> -#include <linux/leds.h> - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35) -static const void *net_current_ns(void) -{ - return current->nsproxy->net_ns; -} - -static const void *net_initial_ns(void) -{ - return &init_net; -} - -static const void *net_netlink_ns(struct sock *sk) -{ - return sock_net(sk); -} - -struct kobj_ns_type_operations net_ns_type_operations = { - .type = KOBJ_NS_TYPE_NET, - .current_ns = net_current_ns, - .netlink_ns = net_netlink_ns, - .initial_ns = net_initial_ns, -}; -EXPORT_SYMBOL_GPL(net_ns_type_operations); -#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)*/ - -#if IS_ENABLED(CONFIG_LEDS_CLASS) && !defined(CPTCFG_BACKPORT_BUILD_LEDS) - -#undef led_brightness_set -#undef led_classdev_unregister - -static DEFINE_SPINLOCK(led_lock); -static LIST_HEAD(led_timers); - -struct led_timer { - struct list_head list; - struct led_classdev *cdev; - struct timer_list blink_timer; - unsigned long blink_delay_on; - unsigned long blink_delay_off; - int blink_brightness; -}; - -static void led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - led_cdev->brightness = brightness; - led_cdev->brightness_set(led_cdev, brightness); -} - -static struct led_timer *led_get_timer(struct led_classdev *led_cdev) -{ - struct led_timer *p; - unsigned long flags; - - spin_lock_irqsave(&led_lock, flags); - list_for_each_entry(p, &led_timers, list) { - if (p->cdev == led_cdev) - goto found; - } - p = NULL; -found: - spin_unlock_irqrestore(&led_lock, flags); - return p; -} - -static void led_stop_software_blink(struct led_timer *led) -{ - del_timer_sync(&led->blink_timer); - led->blink_delay_on = 0; - led->blink_delay_off = 0; -} - -static void led_timer_function(unsigned long data) -{ - struct led_timer *led = (struct led_timer *)data; - unsigned long brightness; - unsigned long delay; - - if (!led->blink_delay_on || !led->blink_delay_off) { - led->cdev->brightness_set(led->cdev, LED_OFF); - return; - } - - brightness = led->cdev->brightness; - if (!brightness) { - /* Time to switch the LED on. */ - brightness = led->blink_brightness; - delay = led->blink_delay_on; - } else { - /* Store the current brightness value to be able - * to restore it when the delay_off period is over. - */ - led->blink_brightness = brightness; - brightness = LED_OFF; - delay = led->blink_delay_off; - } - - led_brightness_set(led->cdev, brightness); - mod_timer(&led->blink_timer, jiffies + msecs_to_jiffies(delay)); -} - -static struct led_timer *led_new_timer(struct led_classdev *led_cdev) -{ - struct led_timer *led; - unsigned long flags; - - led = kzalloc(sizeof(struct led_timer), GFP_ATOMIC); - if (!led) - return NULL; - - led->cdev = led_cdev; - init_timer(&led->blink_timer); - led->blink_timer.function = led_timer_function; - led->blink_timer.data = (unsigned long) led; - - spin_lock_irqsave(&led_lock, flags); - list_add(&led->list, &led_timers); - spin_unlock_irqrestore(&led_lock, flags); - - return led; -} - -void led_blink_set(struct led_classdev *led_cdev, - unsigned long *delay_on, - unsigned long *delay_off) -{ - struct led_timer *led; - int current_brightness; - - if (led_cdev->blink_set && - !led_cdev->blink_set(led_cdev, delay_on, delay_off)) - return; - - led = led_get_timer(led_cdev); - if (!led) { - led = led_new_timer(led_cdev); - if (!led) - return; - } - - /* blink with 1 Hz as default if nothing specified */ - if (!*delay_on && !*delay_off) - *delay_on = *delay_off = 500; - - if (led->blink_delay_on == *delay_on && - led->blink_delay_off == *delay_off) - return; - - current_brightness = led_cdev->brightness; - if (current_brightness) - led->blink_brightness = current_brightness; - if (!led->blink_brightness) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30) - led->blink_brightness = led_cdev->max_brightness; -#else - led->blink_brightness = LED_FULL; -#endif - - led_stop_software_blink(led); - led->blink_delay_on = *delay_on; - led->blink_delay_off = *delay_off; - - /* never on - don't blink */ - if (!*delay_on) - return; - - /* never off - just set to brightness */ - if (!*delay_off) { - led_brightness_set(led_cdev, led->blink_brightness); - return; - } - - mod_timer(&led->blink_timer, jiffies + 1); -} -EXPORT_SYMBOL_GPL(led_blink_set); - -void compat_led_brightness_set(struct led_classdev *led_cdev, - enum led_brightness brightness) -{ - struct led_timer *led = led_get_timer(led_cdev); - - if (led) - led_stop_software_blink(led); - - return led_cdev->brightness_set(led_cdev, brightness); -} -EXPORT_SYMBOL_GPL(compat_led_brightness_set); - -void compat_led_classdev_unregister(struct led_classdev *led_cdev) -{ - struct led_timer *led = led_get_timer(led_cdev); - unsigned long flags; - - if (led) { - del_timer_sync(&led->blink_timer); - spin_lock_irqsave(&led_lock, flags); - list_del(&led->list); - spin_unlock_irqrestore(&led_lock, flags); - kfree(led); - } - - led_classdev_unregister(led_cdev); -} -EXPORT_SYMBOL_GPL(compat_led_classdev_unregister); -#endif - -/** - * vzalloc - allocate virtually contiguous memory with zero fill - * @size: allocation size - * Allocate enough pages to cover @size from the page level - * allocator and map them into contiguous kernel virtual space. - * The memory allocated is set to zero. - * - * For tight control over page level allocator and protection flags - * use __vmalloc() instead. - */ -void *vzalloc(unsigned long size) -{ - void *buf; - buf = vmalloc(size); - if (buf) - memset(buf, 0, size); - return buf; -} -EXPORT_SYMBOL_GPL(vzalloc); - -#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4)) -#ifdef CONFIG_RPS -/** - * netif_set_real_num_rx_queues - set actual number of RX queues used - * @dev: Network device - * @rxq: Actual number of RX queues - * - * This must be called either with the rtnl_lock held or before - * registration of the net device. Returns 0 on success, or a - * negative error code. If called before registration, it always - * succeeds. - */ -int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) -{ - if (rxq < 1 || rxq > dev->num_rx_queues) - return -EINVAL; - - /* we can't update the sysfs object for older kernels */ - if (dev->reg_state == NETREG_REGISTERED) - return -EINVAL; - dev->num_rx_queues = rxq; - return 0; -} -EXPORT_SYMBOL_GPL(netif_set_real_num_rx_queues); -#endif -#endif diff --git a/backport/compat/compat-2.6.39.c b/backport/compat/compat-2.6.39.c deleted file mode 100644 index 44796da1..00000000 --- a/backport/compat/compat-2.6.39.c +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright 2011 Hauke Mehrtens <hauke@hauke-m.de> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * Backport functionality introduced in Linux 2.6.39. - */ - -#include <linux/compat.h> -#include <linux/tty.h> -#include <linux/sched.h> -#include <linux/module.h> - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) -#ifdef CONFIG_TTY -/* - * Termios Helper Methods - */ -static void unset_locked_termios(struct ktermios *termios, - struct ktermios *old, - struct ktermios *locked) -{ - int i; - -#define NOSET_MASK(x, y, z) (x = ((x) & ~(z)) | ((y) & (z))) - - if (!locked) { - printk(KERN_WARNING "Warning?!? termios_locked is NULL.\n"); - return; - } - - NOSET_MASK(termios->c_iflag, old->c_iflag, locked->c_iflag); - NOSET_MASK(termios->c_oflag, old->c_oflag, locked->c_oflag); - NOSET_MASK(termios->c_cflag, old->c_cflag, locked->c_cflag); - NOSET_MASK(termios->c_lflag, old->c_lflag, locked->c_lflag); - termios->c_line = locked->c_line ? old->c_line : termios->c_line; - for (i = 0; i < NCCS; i++) - termios->c_cc[i] = locked->c_cc[i] ? - old->c_cc[i] : termios->c_cc[i]; - /* FIXME: What should we do for i/ospeed */ -} - -/** - * tty_set_termios - update termios values - * @tty: tty to update - * @new_termios: desired new value - * - * Perform updates to the termios values set on this terminal. There - * is a bit of layering violation here with n_tty in terms of the - * internal knowledge of this function. - * - * Locking: termios_mutex - */ -int tty_set_termios(struct tty_struct *tty, struct ktermios *new_termios) -{ - struct ktermios old_termios; - struct tty_ldisc *ld; - unsigned long flags; - - /* - * Perform the actual termios internal changes under lock. - */ - - - /* FIXME: we need to decide on some locking/ordering semantics - for the set_termios notification eventually */ - mutex_lock(&tty->termios_mutex); - old_termios = *tty->termios; - *tty->termios = *new_termios; - unset_locked_termios(tty->termios, &old_termios, tty->termios_locked); - - /* See if packet mode change of state. */ - if (tty->link && tty->link->packet) { - int extproc = (old_termios.c_lflag & EXTPROC) | - (tty->termios->c_lflag & EXTPROC); - int old_flow = ((old_termios.c_iflag & IXON) && - (old_termios.c_cc[VSTOP] == '\023') && - (old_termios.c_cc[VSTART] == '\021')); - int new_flow = (I_IXON(tty) && - STOP_CHAR(tty) == '\023' && - START_CHAR(tty) == '\021'); - if ((old_flow != new_flow) || extproc) { - spin_lock_irqsave(&tty->ctrl_lock, flags); - if (old_flow != new_flow) { - tty->ctrl_status &= ~(TIOCPKT_DOSTOP | TIOCPKT_NOSTOP); - if (new_flow) - tty->ctrl_status |= TIOCPKT_DOSTOP; - else - tty->ctrl_status |= TIOCPKT_NOSTOP; - } - if (extproc) - tty->ctrl_status |= TIOCPKT_IOCTL; - spin_unlock_irqrestore(&tty->ctrl_lock, flags); - wake_up_interruptible(&tty->link->read_wait); - } - } - - if (tty->ops->set_termios) - (*tty->ops->set_termios)(tty, &old_termios); - else - tty_termios_copy_hw(tty->termios, &old_termios); - - ld = tty_ldisc_ref(tty); - if (ld != NULL) { - if (ld->ops->set_termios) - (ld->ops->set_termios)(tty, &old_termios); - tty_ldisc_deref(ld); - } - mutex_unlock(&tty->termios_mutex); - return 0; -} -EXPORT_SYMBOL_GPL(tty_set_termios); -#endif /* CONFIG_TTY */ -#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)) */ - diff --git a/backport/compat/compat_atomic.c b/backport/compat/compat_atomic.c deleted file mode 100644 index 5ced5a49..00000000 --- a/backport/compat/compat_atomic.c +++ /dev/null @@ -1,43 +0,0 @@ -#include <linux/spinlock.h> -#include <linux/module.h> - -#if !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && (defined(CONFIG_UML) || defined(CONFIG_X86))) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64)) - -static DEFINE_SPINLOCK(lock); - -long long atomic64_read(const atomic64_t *v) -{ - unsigned long flags; - long long val; - - spin_lock_irqsave(&lock, flags); - val = v->counter; - spin_unlock_irqrestore(&lock, flags); - return val; -} -EXPORT_SYMBOL_GPL(atomic64_read); - -void atomic64_set(atomic64_t *v, long long i) -{ - unsigned long flags; - - spin_lock_irqsave(&lock, flags); - v->counter = i; - spin_unlock_irqrestore(&lock, flags); -} -EXPORT_SYMBOL_GPL(atomic64_set); - -long long atomic64_add_return(long long a, atomic64_t *v) -{ - unsigned long flags; - long long val; - - spin_lock_irqsave(&lock, flags); - val = v->counter += a; - spin_unlock_irqrestore(&lock, flags); - return val; -} -EXPORT_SYMBOL_GPL(atomic64_add_return); - -#endif - diff --git a/backport/compat/compat_firmware_class.c b/backport/compat/compat_firmware_class.c deleted file mode 100644 index 9ea5080e..00000000 --- a/backport/compat/compat_firmware_class.c +++ /dev/null @@ -1,759 +0,0 @@ -/* - * firmware_class.c - Multi purpose firmware loading support - * - * Copyright (c) 2003 Manuel Estrada Sainz - * - * Please see Documentation/firmware_class/ for more information. - * - */ - -#include <linux/capability.h> -#include <linux/device.h> -#include <linux/module.h> -#include <linux/init.h> -#include <linux/timer.h> -#include <linux/vmalloc.h> -#include <linux/interrupt.h> -#include <linux/bitops.h> -#include <linux/mutex.h> -#include <linux/kthread.h> -#include <linux/highmem.h> -#include <linux/firmware.h> -#include <linux/slab.h> - -#define backport_firmware_to_dev(obj) container_of(obj, struct device, kobj) - -MODULE_AUTHOR("Manuel Estrada Sainz"); -MODULE_DESCRIPTION("Multi purpose firmware loading support"); -MODULE_LICENSE("GPL"); - -/* Builtin firmware support */ - -//#ifdef CONFIG_FW_LOADER -#if 0 - -extern struct builtin_fw __start_builtin_fw[]; -extern struct builtin_fw __end_builtin_fw[]; - -static bool fw_get_builtin_firmware(struct firmware *fw, const char *name) -{ - struct builtin_fw *b_fw; - - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) { - if (strcmp(name, b_fw->name) == 0) { - fw->size = b_fw->size; - fw->data = b_fw->data; - return true; - } - } - - return false; -} - -static bool fw_is_builtin_firmware(const struct firmware *fw) -{ - struct builtin_fw *b_fw; - - for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) - if (fw->data == b_fw->data) - return true; - - return false; -} - -#else /* Module case - no builtin firmware support */ - -static inline bool fw_get_builtin_firmware(struct firmware *fw, const char *name) -{ - return false; -} - -static inline bool fw_is_builtin_firmware(const struct firmware *fw) -{ - return false; -} -#endif - -enum { - FW_STATUS_LOADING, - FW_STATUS_DONE, - FW_STATUS_ABORT, -}; - -static int loading_timeout = 60; /* In seconds */ - -/* fw_lock could be moved to 'struct firmware_priv' but since it is just - * guarding for corner cases a global lock should be OK */ -static DEFINE_MUTEX(fw_lock); - -struct firmware_priv { - struct completion completion; - struct firmware *fw; - unsigned long status; - struct page **pages; - int nr_pages; - int page_array_size; - struct timer_list timeout; - struct device dev; - bool nowait; - char fw_id[]; -}; - -static struct firmware_priv *to_firmware_priv(struct device *dev) -{ - return container_of(dev, struct firmware_priv, dev); -} - -static void fw_load_abort(struct firmware_priv *fw_priv) -{ - set_bit(FW_STATUS_ABORT, &fw_priv->status); - wmb(); - complete(&fw_priv->completion); -} - -static ssize_t firmware_timeout_show(struct class *class, - char *buf) -{ - return sprintf(buf, "%d\n", loading_timeout); -} - -/** - * firmware_timeout_store - set number of seconds to wait for firmware - * @class: device class pointer - * @buf: buffer to scan for timeout value - * @count: number of bytes in @buf - * - * Sets the number of seconds to wait for the firmware. Once - * this expires an error will be returned to the driver and no - * firmware will be provided. - * - * Note: zero means 'wait forever'. - **/ -static ssize_t firmware_timeout_store(struct class *class, - const char *buf, size_t count) -{ - loading_timeout = simple_strtol(buf, NULL, 10); - if (loading_timeout < 0) - loading_timeout = 0; - - return count; -} - -static struct class_attribute firmware_class_attrs[] = { - __ATTR(timeout, S_IWUSR | S_IRUGO, - firmware_timeout_show, firmware_timeout_store), - __ATTR_NULL -}; - -static void fw_dev_release(struct device *dev) -{ - struct firmware_priv *fw_priv = to_firmware_priv(dev); - int i; - - for (i = 0; i < fw_priv->nr_pages; i++) - __free_page(fw_priv->pages[i]); - kfree(fw_priv->pages); - kfree(fw_priv); - - module_put(THIS_MODULE); -} - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)) -static int firmware_uevent(struct device *dev, struct kobj_uevent_env *env) -{ - struct firmware_priv *fw_priv = to_firmware_priv(dev); - - if (add_uevent_var(env, "FIRMWARE=%s", fw_priv->fw_id)) - return -ENOMEM; - if (add_uevent_var(env, "TIMEOUT=%i", loading_timeout)) - return -ENOMEM; - if (add_uevent_var(env, "ASYNC=%d", fw_priv->nowait)) - return -ENOMEM; - - return 0; -} -#else -static int firmware_uevent(struct device *dev, char **envp, - int num_envp, char *buf, int size) -{ - struct firmware_priv *fw_priv = to_firmware_priv(dev); - int error, len = 0, i = 0; - - error = add_uevent_var(envp, num_envp, &i, - buf, size, &len, - "FIRMWARE=%s", fw_priv->fw_id); - if (error) - goto exit; - - error = add_uevent_var(envp, num_envp, &i, - buf, size, &len, - "TIMEOUT=%i", loading_timeout); - if (error) - goto exit; - error = add_uevent_var(envp, num_envp, &i, - buf, size, &len, - "ASYNC=%i", fw_priv->nowait); - if (error) - goto exit; - - return 0; -exit: - envp[i] = NULL; - return error; -} -#endif - -static struct class firmware_class = { - .name = "compat_firmware", - .class_attrs = firmware_class_attrs, - .dev_uevent = firmware_uevent, - .dev_release = fw_dev_release, -}; - -static ssize_t firmware_loading_show(struct device *dev, - struct device_attribute *attr, char *buf) -{ - struct firmware_priv *fw_priv = to_firmware_priv(dev); - int loading = test_bit(FW_STATUS_LOADING, &fw_priv->status); - - return sprintf(buf, "%d\n", loading); -} - -static void firmware_free_data(const struct firmware *fw) -{ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) - int i; - vunmap(fw->data); - if (fw->pages) { - for (i = 0; i < PFN_UP(fw->size); i++) - __free_page(fw->pages[i]); - kfree(fw->pages); - } -#else - vunmap(fw->data); -#endif -} - -/* Some architectures don't have PAGE_KERNEL_RO */ -#ifndef PAGE_KERNEL_RO -#define PAGE_KERNEL_RO PAGE_KERNEL -#endif -/** - * firmware_loading_store - set value in the 'loading' control file - * @dev: device pointer - * @buf: buffer to scan for loading control value - * @count: number of bytes in @buf - * - * The relevant values are: - * - * 1: Start a load, discarding any previous partial load. - * 0: Conclude the load and hand the data to the driver code. - * -1: Conclude the load with an error and discard any written data. - **/ -static ssize_t firmware_loading_store(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - struct firmware_priv *fw_priv = to_firmware_priv(dev); - int loading = simple_strtol(buf, NULL, 10); - int i; - - switch (loading) { - case 1: - mutex_lock(&fw_lock); - if (!fw_priv->fw) { - mutex_unlock(&fw_lock); - break; - } - firmware_free_data(fw_priv->fw); - memset(fw_priv->fw, 0, sizeof(struct firmware)); - /* If the pages are not owned by 'struct firmware' */ - for (i = 0; i < fw_priv->nr_pages; i++) - __free_page(fw_priv->pages[i]); - kfree(fw_priv->pages); - fw_priv->pages = NULL; - fw_priv->page_array_size = 0; - fw_priv->nr_pages = 0; - set_bit(FW_STATUS_LOADING, &fw_priv->status); - mutex_unlock(&fw_lock); - break; - case 0: - if (test_bit(FW_STATUS_LOADING, &fw_priv->status)) { - vunmap(fw_priv->fw->data); - fw_priv->fw->data = vmap(fw_priv->pages, - fw_priv->nr_pages, - 0, PAGE_KERNEL_RO); - if (!fw_priv->fw->data) { - dev_err(dev, "%s: vmap() failed\n", __func__); - goto err; - } - /* Pages are now owned by 'struct firmware' */ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35)) - fw_priv->fw->pages = fw_priv->pages; - fw_priv->pages = NULL; -#endif - - fw_priv->page_array_size = 0; - fw_priv->nr_pages = 0; - complete(&fw_priv->completion); - clear_bit(FW_STATUS_LOADING, &fw_priv->status); - break; - } - /* fallthrough */ - default: - dev_err(dev, "%s: unexpected value (%d)\n", __func__, loading); - /* fallthrough */ - case -1: - err: - fw_load_abort(fw_priv); - break; - } - - return count; -} - -static DEVICE_ATTR(loading, 0644, firmware_loading_show, firmware_loading_store); - -#if defined(CONFIG_COMPAT_FIRMWARE_DATA_RW_NEEDS_FILP) -static ssize_t firmware_data_read(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) -#else -static ssize_t firmware_data_read(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) -#endif -{ - struct device *dev = backport_firmware_to_dev(kobj); - struct firmware_priv *fw_priv = to_firmware_priv(dev); - struct firmware *fw; - ssize_t ret_count; - - mutex_lock(&fw_lock); - fw = fw_priv->fw; - if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { - ret_count = -ENODEV; - goto out; - } - if (offset > fw->size) { - ret_count = 0; - goto out; - } - if (count > fw->size - offset) - count = fw->size - offset; - - ret_count = count; - - while (count) { - void *page_data; - int page_nr = offset >> PAGE_SHIFT; - int page_ofs = offset & (PAGE_SIZE-1); - int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count); - - page_data = kmap(fw_priv->pages[page_nr]); - - memcpy(buffer, page_data + page_ofs, page_cnt); - - kunmap(fw_priv->pages[page_nr]); - buffer += page_cnt; - offset += page_cnt; - count -= page_cnt; - } -out: - mutex_unlock(&fw_lock); - return ret_count; -} - -static int fw_realloc_buffer(struct firmware_priv *fw_priv, int min_size) -{ - int pages_needed = ALIGN(min_size, PAGE_SIZE) >> PAGE_SHIFT; - - /* If the array of pages is too small, grow it... */ - if (fw_priv->page_array_size < pages_needed) { - int new_array_size = max(pages_needed, - fw_priv->page_array_size * 2); - struct page **new_pages; - - new_pages = kmalloc(new_array_size * sizeof(void *), - GFP_KERNEL); - if (!new_pages) { - fw_load_abort(fw_priv); - return -ENOMEM; - } - memcpy(new_pages, fw_priv->pages, - fw_priv->page_array_size * sizeof(void *)); - memset(&new_pages[fw_priv->page_array_size], 0, sizeof(void *) * - (new_array_size - fw_priv->page_array_size)); - kfree(fw_priv->pages); - fw_priv->pages = new_pages; - fw_priv->page_array_size = new_array_size; - } - - while (fw_priv->nr_pages < pages_needed) { - fw_priv->pages[fw_priv->nr_pages] = - alloc_page(GFP_KERNEL | __GFP_HIGHMEM); - - if (!fw_priv->pages[fw_priv->nr_pages]) { - fw_load_abort(fw_priv); - return -ENOMEM; - } - fw_priv->nr_pages++; - } - return 0; -} - -/** - * firmware_data_write - write method for firmware - * @kobj: kobject for the device - * @bin_attr: bin_attr structure - * @buffer: buffer being written - * @offset: buffer offset for write in total data store area - * @count: buffer size - * - * Data written to the 'data' attribute will be later handed to - * the driver as a firmware image. - **/ -#if defined(CONFIG_COMPAT_FIRMWARE_DATA_RW_NEEDS_FILP) -static ssize_t firmware_data_write(struct file *filp, struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) -#else -static ssize_t firmware_data_write(struct kobject *kobj, - struct bin_attribute *bin_attr, - char *buffer, loff_t offset, size_t count) -#endif -{ - struct device *dev = backport_firmware_to_dev(kobj); - struct firmware_priv *fw_priv = to_firmware_priv(dev); - struct firmware *fw; - ssize_t retval; - - if (!capable(CAP_SYS_RAWIO)) - return -EPERM; - - mutex_lock(&fw_lock); - fw = fw_priv->fw; - if (!fw || test_bit(FW_STATUS_DONE, &fw_priv->status)) { - retval = -ENODEV; - goto out; - } - retval = fw_realloc_buffer(fw_priv, offset + count); - if (retval) - goto out; - - retval = count; - - while (count) { - void *page_data; - int page_nr = offset >> PAGE_SHIFT; - int page_ofs = offset & (PAGE_SIZE - 1); - int page_cnt = min_t(size_t, PAGE_SIZE - page_ofs, count); - - page_data = kmap(fw_priv->pages[page_nr]); - - memcpy(page_data + page_ofs, buffer, page_cnt); - - kunmap(fw_priv->pages[page_nr]); - buffer += page_cnt; - offset += page_cnt; - count -= page_cnt; - } - - fw->size = max_t(size_t, offset, fw->size); -out: - mutex_unlock(&fw_lock); - return retval; -} - -static struct bin_attribute firmware_attr_data = { - .attr = { .name = "data", .mode = 0644 }, - .size = 0, - .read = firmware_data_read, - .write = firmware_data_write, -}; - -static void firmware_class_timeout(u_long data) -{ - struct firmware_priv *fw_priv = (struct firmware_priv *) data; - - fw_load_abort(fw_priv); -} - -static struct firmware_priv * -fw_create_instance(struct firmware *firmware, const char *fw_name, - struct device *device, bool uevent, bool nowait) -{ - struct firmware_priv *fw_priv; - struct device *f_dev; - int error; - - fw_priv = kzalloc(sizeof(*fw_priv) + strlen(fw_name) + 1 , GFP_KERNEL); - if (!fw_priv) { - dev_err(device, "%s: kmalloc failed\n", __func__); - error = -ENOMEM; - goto err_out; - } - - fw_priv->fw = firmware; - fw_priv->nowait = nowait; - strcpy(fw_priv->fw_id, fw_name); - init_completion(&fw_priv->completion); - setup_timer(&fw_priv->timeout, - firmware_class_timeout, (u_long) fw_priv); - - f_dev = &fw_priv->dev; - - device_initialize(f_dev); - dev_set_name(f_dev, "%s", dev_name(device)); - f_dev->parent = device; - f_dev->class = &firmware_class; - - dev_set_uevent_suppress(f_dev, true); - - /* Need to pin this module until class device is destroyed */ - __module_get(THIS_MODULE); - - error = device_add(f_dev); - if (error) { - dev_err(device, "%s: device_register failed\n", __func__); - goto err_put_dev; - } - - error = device_create_bin_file(f_dev, &firmware_attr_data); - if (error) { - dev_err(device, "%s: sysfs_create_bin_file failed\n", __func__); - goto err_del_dev; - } - - error = device_create_file(f_dev, &dev_attr_loading); - if (error) { - dev_err(device, "%s: device_create_file failed\n", __func__); - goto err_del_bin_attr; - } - - if (uevent) - dev_set_uevent_suppress(f_dev, false); - - return fw_priv; - -err_del_bin_attr: - device_remove_bin_file(f_dev, &firmware_attr_data); -err_del_dev: - device_del(f_dev); -err_put_dev: - put_device(f_dev); -err_out: - return ERR_PTR(error); -} - -static void fw_destroy_instance(struct firmware_priv *fw_priv) -{ - struct device *f_dev = &fw_priv->dev; - - device_remove_file(f_dev, &dev_attr_loading); - device_remove_bin_file(f_dev, &firmware_attr_data); - device_unregister(f_dev); -} - -static int _request_firmware(const struct firmware **firmware_p, - const char *name, struct device *device, - bool uevent, bool nowait) -{ - struct firmware_priv *fw_priv; - struct firmware *firmware; - int retval = 0; - - if (!firmware_p) - return -EINVAL; - - *firmware_p = firmware = kzalloc(sizeof(*firmware), GFP_KERNEL); - if (!firmware) { - dev_err(device, "%s: kmalloc(struct firmware) failed\n", - __func__); - retval = -ENOMEM; - goto out; - } - - if (fw_get_builtin_firmware(firmware, name)) { - dev_dbg(device, "firmware: using built-in firmware %s\n", name); - return 0; - } - - if (uevent) - dev_dbg(device, "firmware: requesting %s\n", name); - - fw_priv = fw_create_instance(firmware, name, device, uevent, nowait); - if (IS_ERR(fw_priv)) { - retval = PTR_ERR(fw_priv); - goto out; - } - - if (uevent) { - if (loading_timeout > 0) - mod_timer(&fw_priv->timeout, - round_jiffies_up(jiffies + - loading_timeout * HZ)); - - kobject_uevent(&fw_priv->dev.kobj, KOBJ_ADD); - } - - wait_for_completion(&fw_priv->completion); - - set_bit(FW_STATUS_DONE, &fw_priv->status); - del_timer_sync(&fw_priv->timeout); - - mutex_lock(&fw_lock); - if (!fw_priv->fw->size || test_bit(FW_STATUS_ABORT, &fw_priv->status)) - retval = -ENOENT; - fw_priv->fw = NULL; - mutex_unlock(&fw_lock); - - fw_destroy_instance(fw_priv); - -out: - if (retval) { - release_firmware(firmware); - *firmware_p = NULL; - } - - return retval; -} - -/** - * request_firmware: - send firmware request and wait for it - * @firmware_p: pointer to firmware image - * @name: name of firmware file - * @device: device for which firmware is being loaded - * - * @firmware_p will be used to return a firmware image by the name - * of @name for device @device. - * - * Should be called from user context where sleeping is allowed. - * - * @name will be used as $FIRMWARE in the uevent environment and - * should be distinctive enough not to be confused with any other - * firmware image for this or any other device. - **/ -int -request_firmware(const struct firmware **firmware_p, const char *name, - struct device *device) -{ - int uevent = 1; - return _request_firmware(firmware_p, name, device, uevent, false); -} - -/** - * release_firmware: - release the resource associated with a firmware image - * @fw: firmware resource to release - **/ -void release_firmware(const struct firmware *fw) -{ - if (fw) { - if (!fw_is_builtin_firmware(fw)) - firmware_free_data(fw); - kfree(fw); - } -} - -/* Async support */ -struct firmware_work { - struct work_struct work; - struct module *module; - const char *name; - struct device *device; - void *context; - void (*cont)(const struct firmware *fw, void *context); - int uevent; -}; - -static int request_firmware_work_func(void *arg) -{ - struct firmware_work *fw_work = arg; - const struct firmware *fw; - int ret; - - if (!arg) { - WARN_ON(1); - return 0; - } - - ret = _request_firmware(&fw, fw_work->name, fw_work->device, - fw_work->uevent, true); - fw_work->cont(fw, fw_work->context); - - module_put(fw_work->module); - kfree(fw_work); - - return ret; -} - -/** - * request_firmware_nowait - asynchronous version of request_firmware - * @module: module requesting the firmware - * @uevent: sends uevent to copy the firmware image if this flag - * is non-zero else the firmware copy must be done manually. - * @name: name of firmware file - * @device: device for which firmware is being loaded - * @gfp: allocation flags - * @context: will be passed over to @cont, and - * @fw may be %NULL if firmware request fails. - * @cont: function will be called asynchronously when the firmware - * request is over. - * - * Asynchronous variant of request_firmware() for user contexts where - * it is not possible to sleep for long time. It can't be called - * in atomic contexts. - **/ -int -request_firmware_nowait( - struct module *module, int uevent, - const char *name, struct device *device, gfp_t gfp, void *context, - void (*cont)(const struct firmware *fw, void *context)) -{ - struct task_struct *task; - struct firmware_work *fw_work; - - fw_work = kzalloc(sizeof (struct firmware_work), gfp); - if (!fw_work) - return -ENOMEM; - - fw_work->module = module; - fw_work->name = name; - fw_work->device = device; - fw_work->context = context; - fw_work->cont = cont; - fw_work->uevent = uevent; - - if (!try_module_get(module)) { - kfree(fw_work); - return -EFAULT; - } - - task = kthread_run(request_firmware_work_func, fw_work, - "firmware/%s", name); - if (IS_ERR(task)) { - fw_work->cont(NULL, fw_work->context); - module_put(fw_work->module); - kfree(fw_work); - return PTR_ERR(task); - } - - return 0; -} - -static int __init firmware_class_init(void) -{ - return class_register(&firmware_class); -} - -static void __exit firmware_class_exit(void) -{ - class_unregister(&firmware_class); -} - -fs_initcall(firmware_class_init); -module_exit(firmware_class_exit); - -EXPORT_SYMBOL_GPL(release_firmware); -EXPORT_SYMBOL_GPL(request_firmware); -EXPORT_SYMBOL_GPL(request_firmware_nowait); diff --git a/backport/compat/kfifo.c b/backport/compat/kfifo.c deleted file mode 100644 index 3c2520fb..00000000 --- a/backport/compat/kfifo.c +++ /dev/null @@ -1,607 +0,0 @@ -/* - * A generic kernel FIFO implementation - * - * Copyright (C) 2009/2010 Stefani Seibold <stefani@seibold.net> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -#include <linux/kernel.h> -#include <linux/export.h> -#include <linux/slab.h> -#include <linux/err.h> -#include <linux/log2.h> -#include <linux/uaccess.h> -#include <linux/kfifo.h> - -/* - * internal helper to calculate the unused elements in a fifo - */ -static inline unsigned int kfifo_unused(struct __kfifo *fifo) -{ - return (fifo->mask + 1) - (fifo->in - fifo->out); -} - -int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, - size_t esize, gfp_t gfp_mask) -{ - /* - * round down to the next power of 2, since our 'let the indices - * wrap' technique works only in this case. - */ - size = roundup_pow_of_two(size); - - fifo->in = 0; - fifo->out = 0; - fifo->esize = esize; - - if (size < 2) { - fifo->data = NULL; - fifo->mask = 0; - return -EINVAL; - } - - fifo->data = kmalloc(size * esize, gfp_mask); - - if (!fifo->data) { - fifo->mask = 0; - return -ENOMEM; - } - fifo->mask = size - 1; - - return 0; -} -EXPORT_SYMBOL_GPL(__kfifo_alloc); - -void __kfifo_free(struct __kfifo *fifo) -{ - kfree(fifo->data); - fifo->in = 0; - fifo->out = 0; - fifo->esize = 0; - fifo->data = NULL; - fifo->mask = 0; -} -EXPORT_SYMBOL_GPL(__kfifo_free); - -int __kfifo_init(struct __kfifo *fifo, void *buffer, - unsigned int size, size_t esize) -{ - size /= esize; - - size = roundup_pow_of_two(size); - - fifo->in = 0; - fifo->out = 0; - fifo->esize = esize; - fifo->data = buffer; - - if (size < 2) { - fifo->mask = 0; - return -EINVAL; - } - fifo->mask = size - 1; - - return 0; -} -EXPORT_SYMBOL_GPL(__kfifo_init); - -static void kfifo_copy_in(struct __kfifo *fifo, const void *src, - unsigned int len, unsigned int off) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - memcpy(fifo->data + off, src, l); - memcpy(fifo->data, src + l, len - l); - /* - * make sure that the data in the fifo is up to date before - * incrementing the fifo->in index counter - */ - smp_wmb(); -} - -unsigned int __kfifo_in(struct __kfifo *fifo, - const void *buf, unsigned int len) -{ - unsigned int l; - - l = kfifo_unused(fifo); - if (len > l) - len = l; - - kfifo_copy_in(fifo, buf, len, fifo->in); - fifo->in += len; - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_in); - -static void kfifo_copy_out(struct __kfifo *fifo, void *dst, - unsigned int len, unsigned int off) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - memcpy(dst, fifo->data + off, l); - memcpy(dst + l, fifo->data, len - l); - /* - * make sure that the data is copied before - * incrementing the fifo->out index counter - */ - smp_wmb(); -} - -unsigned int __kfifo_out_peek(struct __kfifo *fifo, - void *buf, unsigned int len) -{ - unsigned int l; - - l = fifo->in - fifo->out; - if (len > l) - len = l; - - kfifo_copy_out(fifo, buf, len, fifo->out); - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_out_peek); - -unsigned int __kfifo_out(struct __kfifo *fifo, - void *buf, unsigned int len) -{ - len = __kfifo_out_peek(fifo, buf, len); - fifo->out += len; - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_out); - -static unsigned long kfifo_copy_from_user(struct __kfifo *fifo, - const void __user *from, unsigned int len, unsigned int off, - unsigned int *copied) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - unsigned long ret; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - ret = copy_from_user(fifo->data + off, from, l); - if (unlikely(ret)) - ret = DIV_ROUND_UP(ret + len - l, esize); - else { - ret = copy_from_user(fifo->data, from + l, len - l); - if (unlikely(ret)) - ret = DIV_ROUND_UP(ret, esize); - } - /* - * make sure that the data in the fifo is up to date before - * incrementing the fifo->in index counter - */ - smp_wmb(); - *copied = len - ret * esize; - /* return the number of elements which are not copied */ - return ret; -} - -int __kfifo_from_user(struct __kfifo *fifo, const void __user *from, - unsigned long len, unsigned int *copied) -{ - unsigned int l; - unsigned long ret; - unsigned int esize = fifo->esize; - int err; - - if (esize != 1) - len /= esize; - - l = kfifo_unused(fifo); - if (len > l) - len = l; - - ret = kfifo_copy_from_user(fifo, from, len, fifo->in, copied); - if (unlikely(ret)) { - len -= ret; - err = -EFAULT; - } else - err = 0; - fifo->in += len; - return err; -} -EXPORT_SYMBOL_GPL(__kfifo_from_user); - -static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to, - unsigned int len, unsigned int off, unsigned int *copied) -{ - unsigned int l; - unsigned long ret; - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - ret = copy_to_user(to, fifo->data + off, l); - if (unlikely(ret)) - ret = DIV_ROUND_UP(ret + len - l, esize); - else { - ret = copy_to_user(to + l, fifo->data, len - l); - if (unlikely(ret)) - ret = DIV_ROUND_UP(ret, esize); - } - /* - * make sure that the data is copied before - * incrementing the fifo->out index counter - */ - smp_wmb(); - *copied = len - ret * esize; - /* return the number of elements which are not copied */ - return ret; -} - -int __kfifo_to_user(struct __kfifo *fifo, void __user *to, - unsigned long len, unsigned int *copied) -{ - unsigned int l; - unsigned long ret; - unsigned int esize = fifo->esize; - int err; - - if (esize != 1) - len /= esize; - - l = fifo->in - fifo->out; - if (len > l) - len = l; - ret = kfifo_copy_to_user(fifo, to, len, fifo->out, copied); - if (unlikely(ret)) { - len -= ret; - err = -EFAULT; - } else - err = 0; - fifo->out += len; - return err; -} -EXPORT_SYMBOL_GPL(__kfifo_to_user); - -static int setup_sgl_buf(struct scatterlist *sgl, void *buf, - int nents, unsigned int len) -{ - int n; - unsigned int l; - unsigned int off; - struct page *page; - - if (!nents) - return 0; - - if (!len) - return 0; - - n = 0; - page = virt_to_page(buf); - off = offset_in_page(buf); - l = 0; - - while (len >= l + PAGE_SIZE - off) { - struct page *npage; - - l += PAGE_SIZE; - buf += PAGE_SIZE; - npage = virt_to_page(buf); - if (page_to_phys(page) != page_to_phys(npage) - l) { - sg_set_page(sgl, page, l - off, off); - sgl = sg_next(sgl); - if (++n == nents || sgl == NULL) - return n; - page = npage; - len -= l - off; - l = off = 0; - } - } - sg_set_page(sgl, page, len, off); - return n + 1; -} - -static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, - int nents, unsigned int len, unsigned int off) -{ - unsigned int size = fifo->mask + 1; - unsigned int esize = fifo->esize; - unsigned int l; - unsigned int n; - - off &= fifo->mask; - if (esize != 1) { - off *= esize; - size *= esize; - len *= esize; - } - l = min(len, size - off); - - n = setup_sgl_buf(sgl, fifo->data + off, nents, l); - n += setup_sgl_buf(sgl + n, fifo->data, nents - n, len - l); - - return n; -} - -unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len) -{ - unsigned int l; - - l = kfifo_unused(fifo); - if (len > l) - len = l; - - return setup_sgl(fifo, sgl, nents, len, fifo->in); -} -EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare); - -unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len) -{ - unsigned int l; - - l = fifo->in - fifo->out; - if (len > l) - len = l; - - return setup_sgl(fifo, sgl, nents, len, fifo->out); -} -EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare); - -unsigned int __kfifo_max_r(unsigned int len, size_t recsize) -{ - unsigned int max = (1 << (recsize << 3)) - 1; - - if (len > max) - return max; - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_max_r); - -#define __KFIFO_PEEK(data, out, mask) \ - ((data)[(out) & (mask)]) -/* - * __kfifo_peek_n internal helper function for determinate the length of - * the next record in the fifo - */ -static unsigned int __kfifo_peek_n(struct __kfifo *fifo, size_t recsize) -{ - unsigned int l; - unsigned int mask = fifo->mask; - unsigned char *data = fifo->data; - - l = __KFIFO_PEEK(data, fifo->out, mask); - - if (--recsize) - l |= __KFIFO_PEEK(data, fifo->out + 1, mask) << 8; - - return l; -} - -#define __KFIFO_POKE(data, in, mask, val) \ - ( \ - (data)[(in) & (mask)] = (unsigned char)(val) \ - ) - -/* - * __kfifo_poke_n internal helper function for storeing the length of - * the record into the fifo - */ -static void __kfifo_poke_n(struct __kfifo *fifo, unsigned int n, size_t recsize) -{ - unsigned int mask = fifo->mask; - unsigned char *data = fifo->data; - - __KFIFO_POKE(data, fifo->in, mask, n); - - if (recsize > 1) - __KFIFO_POKE(data, fifo->in + 1, mask, n >> 8); -} - -unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize) -{ - return __kfifo_peek_n(fifo, recsize); -} -EXPORT_SYMBOL_GPL(__kfifo_len_r); - -unsigned int __kfifo_in_r(struct __kfifo *fifo, const void *buf, - unsigned int len, size_t recsize) -{ - if (len + recsize > kfifo_unused(fifo)) - return 0; - - __kfifo_poke_n(fifo, len, recsize); - - kfifo_copy_in(fifo, buf, len, fifo->in + recsize); - fifo->in += len + recsize; - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_in_r); - -static unsigned int kfifo_out_copy_r(struct __kfifo *fifo, - void *buf, unsigned int len, size_t recsize, unsigned int *n) -{ - *n = __kfifo_peek_n(fifo, recsize); - - if (len > *n) - len = *n; - - kfifo_copy_out(fifo, buf, len, fifo->out + recsize); - return len; -} - -unsigned int __kfifo_out_peek_r(struct __kfifo *fifo, void *buf, - unsigned int len, size_t recsize) -{ - unsigned int n; - - if (fifo->in == fifo->out) - return 0; - - return kfifo_out_copy_r(fifo, buf, len, recsize, &n); -} -EXPORT_SYMBOL_GPL(__kfifo_out_peek_r); - -unsigned int __kfifo_out_r(struct __kfifo *fifo, void *buf, - unsigned int len, size_t recsize) -{ - unsigned int n; - - if (fifo->in == fifo->out) - return 0; - - len = kfifo_out_copy_r(fifo, buf, len, recsize, &n); - fifo->out += n + recsize; - return len; -} -EXPORT_SYMBOL_GPL(__kfifo_out_r); - -void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize) -{ - unsigned int n; - - n = __kfifo_peek_n(fifo, recsize); - fifo->out += n + recsize; -} -EXPORT_SYMBOL_GPL(__kfifo_skip_r); - -int __kfifo_from_user_r(struct __kfifo *fifo, const void __user *from, - unsigned long len, unsigned int *copied, size_t recsize) -{ - unsigned long ret; - - len = __kfifo_max_r(len, recsize); - - if (len + recsize > kfifo_unused(fifo)) { - *copied = 0; - return 0; - } - - __kfifo_poke_n(fifo, len, recsize); - - ret = kfifo_copy_from_user(fifo, from, len, fifo->in + recsize, copied); - if (unlikely(ret)) { - *copied = 0; - return -EFAULT; - } - fifo->in += len + recsize; - return 0; -} -EXPORT_SYMBOL_GPL(__kfifo_from_user_r); - -int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to, - unsigned long len, unsigned int *copied, size_t recsize) -{ - unsigned long ret; - unsigned int n; - - if (fifo->in == fifo->out) { - *copied = 0; - return 0; - } - - n = __kfifo_peek_n(fifo, recsize); - if (len > n) - len = n; - - ret = kfifo_copy_to_user(fifo, to, len, fifo->out + recsize, copied); - if (unlikely(ret)) { - *copied = 0; - return -EFAULT; - } - fifo->out += n + recsize; - return 0; -} -EXPORT_SYMBOL_GPL(__kfifo_to_user_r); - -unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) -{ - if (!nents) - BUG(); - - len = __kfifo_max_r(len, recsize); - - if (len + recsize > kfifo_unused(fifo)) - return 0; - - return setup_sgl(fifo, sgl, nents, len, fifo->in + recsize); -} -EXPORT_SYMBOL_GPL(__kfifo_dma_in_prepare_r); - -void __kfifo_dma_in_finish_r(struct __kfifo *fifo, - unsigned int len, size_t recsize) -{ - len = __kfifo_max_r(len, recsize); - __kfifo_poke_n(fifo, len, recsize); - fifo->in += len + recsize; -} -EXPORT_SYMBOL_GPL(__kfifo_dma_in_finish_r); - -unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo, - struct scatterlist *sgl, int nents, unsigned int len, size_t recsize) -{ - if (!nents) - BUG(); - - len = __kfifo_max_r(len, recsize); - - if (len + recsize > fifo->in - fifo->out) - return 0; - - return setup_sgl(fifo, sgl, nents, len, fifo->out + recsize); -} -EXPORT_SYMBOL_GPL(__kfifo_dma_out_prepare_r); - -void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize) -{ - unsigned int len; - - len = __kfifo_peek_n(fifo, recsize); - fifo->out += len + recsize; -} -EXPORT_SYMBOL_GPL(__kfifo_dma_out_finish_r); diff --git a/backport/compat/kstrtox.c b/backport/compat/kstrtox.c deleted file mode 100644 index aaaea242..00000000 --- a/backport/compat/kstrtox.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Convert integer string representation to an integer. - * If an integer doesn't fit into specified type, -E is returned. - * - * Integer starts with optional sign. - * kstrtou*() functions do not accept sign "-". - * - * Radix 0 means autodetection: leading "0x" implies radix 16, - * leading "0" implies radix 8, otherwise radix is 10. - * Autodetection hints work after optional sign, but not before. - * - * If -E is returned, result is not touched. - */ -#include <linux/kernel.h> -/* - * kstrto* was included in kernel 2.6.38.4 and causes conflicts with the - * version included in compat-drivers. We use strict_strtol to check if - * kstrto* is already available. - */ -#ifndef strict_strtoll - -#include <linux/ctype.h> -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/math64.h> -#include <linux/module.h> -#include <linux/types.h> - -#define _tolower LINUX_BACKPORT(_tolower) -static inline char _tolower(const char c) -{ - return c | 0x20; -} - -static int _kstrtoull(const char *s, unsigned int base, unsigned long long *res) -{ - unsigned long long acc; - int ok; - - if (base == 0) { - if (s[0] == '0') { - if (_tolower(s[1]) == 'x' && isxdigit(s[2])) - base = 16; - else - base = 8; - } else - base = 10; - } - if (base == 16 && s[0] == '0' && _tolower(s[1]) == 'x') - s += 2; - - acc = 0; - ok = 0; - while (*s) { - unsigned int val; - - if ('0' <= *s && *s <= '9') - val = *s - '0'; - else if ('a' <= _tolower(*s) && _tolower(*s) <= 'f') - val = _tolower(*s) - 'a' + 10; - else if (*s == '\n') { - if (*(s + 1) == '\0') - break; - else - return -EINVAL; - } else - return -EINVAL; - - if (val >= base) - return -EINVAL; - if (acc > div_u64(ULLONG_MAX - val, base)) - return -ERANGE; - acc = acc * base + val; - ok = 1; - - s++; - } - if (!ok) - return -EINVAL; - *res = acc; - return 0; -} - -int kstrtoull(const char *s, unsigned int base, unsigned long long *res) -{ - if (s[0] == '+') - s++; - return _kstrtoull(s, base, res); -} -EXPORT_SYMBOL_GPL(kstrtoull); - -int kstrtoll(const char *s, unsigned int base, long long *res) -{ - unsigned long long tmp; - int rv; - - if (s[0] == '-') { - rv = _kstrtoull(s + 1, base, &tmp); - if (rv < 0) - return rv; - if ((long long)(-tmp) >= 0) - return -ERANGE; - *res = -tmp; - } else { - rv = kstrtoull(s, base, &tmp); - if (rv < 0) - return rv; - if ((long long)tmp < 0) - return -ERANGE; - *res = tmp; - } - return 0; -} -EXPORT_SYMBOL_GPL(kstrtoll); - -/* Internal, do not use. */ -int _kstrtoul(const char *s, unsigned int base, unsigned long *res) -{ - unsigned long long tmp; - int rv; - - rv = kstrtoull(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (unsigned long long)(unsigned long)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(_kstrtoul); - -/* Internal, do not use. */ -int _kstrtol(const char *s, unsigned int base, long *res) -{ - long long tmp; - int rv; - - rv = kstrtoll(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (long long)(long)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(_kstrtol); - -int kstrtouint(const char *s, unsigned int base, unsigned int *res) -{ - unsigned long long tmp; - int rv; - - rv = kstrtoull(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (unsigned long long)(unsigned int)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtouint); - -int kstrtoint(const char *s, unsigned int base, int *res) -{ - long long tmp; - int rv; - - rv = kstrtoll(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (long long)(int)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtoint); - -int kstrtou16(const char *s, unsigned int base, u16 *res) -{ - unsigned long long tmp; - int rv; - - rv = kstrtoull(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (unsigned long long)(u16)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtou16); - -int kstrtos16(const char *s, unsigned int base, s16 *res) -{ - long long tmp; - int rv; - - rv = kstrtoll(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (long long)(s16)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtos16); - -int kstrtou8(const char *s, unsigned int base, u8 *res) -{ - unsigned long long tmp; - int rv; - - rv = kstrtoull(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (unsigned long long)(u8)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtou8); - -int kstrtos8(const char *s, unsigned int base, s8 *res) -{ - long long tmp; - int rv; - - rv = kstrtoll(s, base, &tmp); - if (rv < 0) - return rv; - if (tmp != (long long)(s8)tmp) - return -ERANGE; - *res = tmp; - return 0; -} -EXPORT_SYMBOL_GPL(kstrtos8); -#endif /* #ifndef strict_strtol */ diff --git a/backport/compat/main.c b/backport/compat/main.c index 07efc8c0..b3d7661b 100644 --- a/backport/compat/main.c +++ b/backport/compat/main.c @@ -2,7 +2,6 @@ #include <linux/init.h> #include <linux/pm_qos.h> #include <linux/workqueue.h> -#include "compat-2.6.34.h" #include "backports.h" MODULE_AUTHOR("Luis R. Rodriguez"); @@ -58,8 +57,6 @@ static int __init backport_init(void) if (ret) return ret; - backport_system_workqueue_create(); - backport_init_mmc_pm_flags(); dma_buf_init(); printk(KERN_INFO "Loading modules backported from " BACKPORTED_KERNEL_NAME @@ -79,7 +76,6 @@ subsys_initcall(backport_init); static void __exit backport_exit(void) { - backport_system_workqueue_destroy(); crypto_ccm_module_exit(); } module_exit(backport_exit); |