Commit 750a2fe3 authored by Mauro Ribeiro's avatar Mauro Ribeiro

Copied backport

Change-Id: I49343478df6315092fc7a144df6ca836a4f7a9a7
parent 3010926f
config BACKPORT_INTEGRATE
bool
def_bool y
config BACKPORT_DIR
string
default "%%BACKPORT_DIR%%"
config BACKPORT_VERSION
string
default "%%BACKPORTS_VERSION%%"
config BACKPORT_KERNEL_VERSION
string
default "%%BACKPORTED_KERNEL_VERSION%%"
config BACKPORT_KERNEL_NAME
string
default "%%BACKPORTED_KERNEL_NAME%%"
menuconfig BACKPORT_LINUX
bool "Backport %%BACKPORTED_KERNEL_NAME%% %%BACKPORTED_KERNEL_VERSION%% (backports %%BACKPORTS_VERSION%%)"
default n
---help---
Enabling this will let give you the opportunity to use features and
drivers backported from %%BACKPORTED_KERNEL_NAME%% %%BACKPORTED_KERNEL_VERSION%%
on the kernel your are using. This is experimental and you should
say no unless you'd like to help test things or want to help debug
this should we run into any issues.
if BACKPORT_LINUX
source "$BACKPORT_DIR/Kconfig.versions"
source "$BACKPORT_DIR/Kconfig.sources"
endif # BACKPORT_LINUX
# this has the configuration for the backport code
source "$BACKPORT_DIR/compat/Kconfig"
# these are copied from the kernel
source "$BACKPORT_DIR/net/wireless/Kconfig"
source "$BACKPORT_DIR/net/mac80211/Kconfig"
source "$BACKPORT_DIR/net/bluetooth/Kconfig"
source "$BACKPORT_DIR/drivers/net/wireless/Kconfig"
source "$BACKPORT_DIR/drivers/net/ethernet/Kconfig"
source "$BACKPORT_DIR/drivers/net/usb/Kconfig"
source "$BACKPORT_DIR/drivers/ssb/Kconfig"
source "$BACKPORT_DIR/drivers/bcma/Kconfig"
source "$BACKPORT_DIR/net/nfc/Kconfig"
source "$BACKPORT_DIR/drivers/media/Kconfig"
source "$BACKPORT_DIR/net/6lowpan/Kconfig"
source "$BACKPORT_DIR/net/ieee802154/Kconfig"
source "$BACKPORT_DIR/net/mac802154/Kconfig"
source "$BACKPORT_DIR/drivers/net/ieee802154/Kconfig"
source "$BACKPORT_DIR/drivers/usb/class/Kconfig"
ifeq ($(CONFIG_BACKPORT_INTEGRATE),)
# Since 2.6.21, try-run is available, but cc-disable-warning
# was only added later, so we add it here ourselves:
backport-cc-disable-warning = $(call try-run,\
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -x c /dev/null -o "$$TMP",-Wno-$(strip $(1)))
NOSTDINC_FLAGS := \
-I$(M)/backport-include/ \
-I$(M)/backport-include/uapi \
-I$(M)/include/ \
-I$(M)/include/uapi \
-include $(M)/backport-include/backport/backport.h \
$(call backport-cc-disable-warning, unused-but-set-variable) \
-DCPTCFG_VERSION=\"$(BACKPORTS_VERSION)\" \
-DCPTCFG_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \
-DCPTCFG_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \
$(BACKPORTS_GIT_TRACKER_DEF) \
$(CFLAGS)
export backport_srctree = $(M)
else
export BACKPORT_DIR = backports/
export backport_srctree = $(BACKPORT_DIR)
NOSTDINC_FLAGS := \
-I$(BACKPORT_DIR)/backport-include/ \
-I$(BACKPORT_DIR)/backport-include/uapi \
-I$(BACKPORT_DIR)/include/ \
-I$(BACKPORT_DIR)/include/uapi \
-include $(BACKPORT_DIR)/backport-include/backport/backport.h \
$(CFLAGS)
endif
obj-y += compat/
obj-$(CPTCFG_CFG80211) += net/wireless/
obj-$(CPTCFG_MAC80211) += net/mac80211/
obj-$(CPTCFG_WLAN) += drivers/net/wireless/
obj-$(CPTCFG_BT) += net/bluetooth/
obj-$(CPTCFG_BT) += drivers/bluetooth/
obj-$(CPTCFG_SSB) += drivers/ssb/
obj-$(CPTCFG_BCMA) += drivers/bcma/
obj-$(CPTCFG_ETHERNET) += drivers/net/ethernet/
obj-$(CPTCFG_USB_NET_RNDIS_WLAN) += drivers/net/usb/
obj-$(CPTCFG_NFC) += net/nfc/
obj-$(CPTCFG_NFC) += drivers/nfc/
obj-$(CPTCFG_MEDIA_SUPPORT) += drivers/media/
obj-$(CPTCFG_6LOWPAN) += net/6lowpan/
obj-$(CPTCFG_IEEE802154) += net/ieee802154/
obj-$(CPTCFG_BT) += net/ieee802154/
obj-$(CPTCFG_MAC802154) += net/mac802154/
obj-$(CPTCFG_IEEE802154) += drivers/net/ieee802154/
obj-$(CPTCFG_USB_WDM) += drivers/usb/class/
obj-$(CPTCFG_USB_USBNET) += drivers/net/usb/
#ifndef __BACKPORT_ASM_GENERIC_BARRIER_H
#define __BACKPORT_ASM_GENERIC_BARRIER_H
#include_next <asm-generic/barrier.h>
#ifndef dma_rmb
#define dma_rmb() rmb()
#endif
#endif /* __BACKPORT_ASM_GENERIC_BARRIER_H */
#ifndef __BACKPORT_ASM_GENERIC_BUG_H
#define __BACKPORT_ASM_GENERIC_BUG_H
#include_next <asm-generic/bug.h>
#ifndef __WARN
#define __WARN(foo) dump_stack()
#endif
#ifndef WARN_ONCE
#define WARN_ONCE(condition, format...) ({ \
static int __warned; \
int __ret_warn_once = !!(condition); \
\
if (unlikely(__ret_warn_once)) \
if (WARN(!__warned, format)) \
__warned = 1; \
unlikely(__ret_warn_once); \
})
#endif
#ifndef __WARN_printf
/*
* To port this properly we'd have to port warn_slowpath_null(),
* which I'm lazy to do so just do a regular print for now. If you
* want to port this read kernel/panic.c
*/
#define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0)
#endif
#ifndef WARN
#define WARN(condition, format...) ({ \
int __ret_warn_on = !!(condition); \
if (unlikely(__ret_warn_on)) \
__WARN_printf(format); \
unlikely(__ret_warn_on); \
})
#endif
#endif /* __BACKPORT_ASM_GENERIC_BUG_H */
#ifndef __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H
#define __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H
#include_next <asm-generic/pci-dma-compat.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,17,0)
#define pci_zalloc_consistent LINUX_BACKPORT(pci_zalloc_consistent)
static inline void *pci_zalloc_consistent(struct pci_dev *hwdev, size_t size,
dma_addr_t *dma_handle)
{
void *ret = pci_alloc_consistent(hwdev, size, dma_handle);
if (ret)
memset(ret, 0, size);
return ret;
}
#endif
#endif /* __BACKPORT_ASM_GENERIC_PCI_DMA_COMPAT_H */
#ifndef __BACKPORT_ASM_ATOMIC_H
#define __BACKPORT_ASM_ATOMIC_H
#include_next <asm/atomic.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
/*
* In many versions, several architectures do not seem to include an
* atomic64_t implementation, and do not include the software emulation from
* asm-generic/atomic64_t.
* Detect and handle this here.
*/
#if (!defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !(defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64)))
#include <asm-generic/atomic64.h>
#endif
#endif
#ifndef smp_mb__after_atomic
#define smp_mb__after_atomic smp_mb__after_clear_bit
#endif
#endif /* __BACKPORT_ASM_ATOMIC_H */
#ifndef __BACKPORT_ASM_GENERIC_BARRIER_H
#define __BACKPORT_ASM_GENERIC_BARRIER_H
#include_next <asm/barrier.h>
#ifndef dma_rmb
#define dma_rmb() rmb()
#endif
#endif /* __BACKPORT_ASM_GENERIC_BARRIER_H */
#ifndef __BACKPORT_ASM_DMA_MAPPING_H
#define __BACKPORT_ASM_DMA_MAPPING_H
#include_next <asm/dma-mapping.h>
#include <linux/version.h>
#if defined(CPTCFG_BPAUTO_BUILD_DMA_SHARED_HELPERS)
#define dma_common_get_sgtable LINUX_BACKPORT(dma_common_get_sgtable)
int
dma_common_get_sgtable(struct device *dev, struct sg_table *sgt,
void *cpu_addr, dma_addr_t dma_addr, size_t size);
#endif /* defined(CPTCFG_BPAUTO_BUILD_DMA_SHARED_HELPERS) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
#define dma_get_sgtable_attrs LINUX_BACKPORT(dma_get_sgtable_attrs)
struct dma_attrs;
static inline int
dma_get_sgtable_attrs(struct device *dev, struct sg_table *sgt, void *cpu_addr,
dma_addr_t dma_addr, size_t size, struct dma_attrs *attrs)
{
return dma_common_get_sgtable(dev, sgt, cpu_addr, dma_addr, size);
}
#define dma_get_sgtable(d, t, v, h, s) dma_get_sgtable_attrs(d, t, v, h, s, NULL)
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0) */
#endif /* __BACKPORT_ASM_DMA_MAPPING_H */
#ifndef __BACKPORT_ASM_ERRNO_H
#define __BACKPORT_ASM_ERRNO_H
#include_next <asm/errno.h>
#ifndef ERFKILL
#if !defined(CONFIG_ALPHA) && !defined(CONFIG_MIPS) && !defined(CONFIG_PARISC) && !defined(CONFIG_SPARC)
#define ERFKILL 132 /* Operation not possible due to RF-kill */
#endif
#ifdef CONFIG_ALPHA
#define ERFKILL 138 /* Operation not possible due to RF-kill */
#endif
#ifdef CONFIG_MIPS
#define ERFKILL 167 /* Operation not possible due to RF-kill */
#endif
#ifdef CONFIG_PARISC
#define ERFKILL 256 /* Operation not possible due to RF-kill */
#endif
#ifdef CONFIG_SPARC
#define ERFKILL 134 /* Operation not possible due to RF-kill */
#endif
#endif
#endif /* __BACKPORT_ASM_ERRNO_H */
#ifndef __BACKPORT_ASM_IOCTLS_H
#define __BACKPORT_ASM_IOCTLS_H
#include_next <asm/ioctls.h>
#ifndef TIOCPKT_IOCTL
#define TIOCPKT_IOCTL 64
#endif
#endif /* __BACKPORT_ASM_IOCTLS_H */
#ifndef __BACKPORT_H
#define __BACKPORT_H
#include <generated/autoconf.h>
#ifndef CONFIG_BACKPORT_INTEGRATE
#include <backport/autoconf.h>
#endif
#include <linux/kconfig.h>
#ifndef __ASSEMBLY__
#define LINUX_BACKPORT(__sym) backport_ ##__sym
#ifndef CONFIG_BACKPORT_INTEGRATE
#include <backport/checks.h>
#endif
#endif
#endif /* __BACKPORT_H */
#ifndef __BACKPORT_CHECKS
#define __BACKPORT_CHECKS
#if defined(CONFIG_MAC80211) && defined(CPTCFG_MAC80211)
#error "You must not have mac80211 built into your kernel if you want to enable it"
#endif
#if defined(CONFIG_CFG80211) && defined(CPTCFG_CFG80211)
#error "You must not have cfg80211 built into your kernel if you want to enable it"
#endif
#endif /* __BACKPORT_CHECKS */
#ifndef __BACKPORT_LED_DISABLED_SUPPORT
#define __BACKPORT_LED_DISABLED_SUPPORT
/*
* LED support is strange, with the NEW_LEDS, LEDS_CLASS and LEDS_TRIGGERS
* Kconfig symbols ... If any of them are not defined, we build our
* "compatibility" code that really just makes it all non-working but
* allows compilation.
*/
#ifdef CPTCFG_BPAUTO_BUILD_LEDS
#include <linux/list.h>
#include <linux/spinlock.h>
#include <linux/rwsem.h>
#include <linux/workqueue.h>
#define led_classdev LINUX_BACKPORT(led_classdev)
#define led_trigger LINUX_BACKPORT(led_trigger)
struct led_classdev {
const char *name;
int brightness;
int max_brightness;
int flags;
/* Lower 16 bits reflect status */
#ifndef LED_SUSPENDED
#define LED_SUSPENDED (1 << 0)
/* Upper 16 bits reflect control information */
#define LED_CORE_SUSPENDRESUME (1 << 16)
#define LED_BLINK_ONESHOT (1 << 17)
#define LED_BLINK_ONESHOT_STOP (1 << 18)
#define LED_BLINK_INVERT (1 << 19)
#endif
/* Set LED brightness level */
/* Must not sleep, use a workqueue if needed */
void (*brightness_set)(struct led_classdev *led_cdev,
enum led_brightness brightness);
/* Get LED brightness level */
enum led_brightness (*brightness_get)(struct led_classdev *led_cdev);
/*
* Activate hardware accelerated blink, delays are in milliseconds
* and if both are zero then a sensible default should be chosen.
* The call should adjust the timings in that case and if it can't
* match the values specified exactly.
* Deactivate blinking again when the brightness is set to a fixed
* value via the brightness_set() callback.
*/
int (*blink_set)(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off);
struct device *dev;
struct list_head node; /* LED Device list */
const char *default_trigger; /* Trigger to use */
unsigned long blink_delay_on, blink_delay_off;
struct timer_list blink_timer;
int blink_brightness;
struct work_struct set_brightness_work;
int delayed_set_value;
/* Protects the trigger data below */
struct rw_semaphore trigger_lock;
struct led_trigger *trigger;
struct list_head trig_list;
void *trigger_data;
/* true if activated - deactivate routine uses it to do cleanup */
bool activated;
};
struct led_trigger {
const char *name;
void (*activate)(struct led_classdev *led_cdev);
void (*deactivate)(struct led_classdev *led_cdev);
rwlock_t leddev_list_lock;
struct list_head led_cdevs;
struct list_head next_trig;
};
#undef led_classdev_register
#define led_classdev_register LINUX_BACKPORT(led_classdev_register)
#undef led_classdev_unregister
#define led_classdev_unregister LINUX_BACKPORT(led_classdev_unregister)
#undef led_blink_set
#define led_blink_set LINUX_BACKPORT(led_blink_set)
#undef led_set_brightness
#define led_set_brightness LINUX_BACKPORT(led_set_brightness)
#undef led_classdev_suspend
#define led_classdev_suspend LINUX_BACKPORT(led_classdev_suspend)
#undef led_classdev_resume
#define led_classdev_resume LINUX_BACKPORT(led_classdev_resume)
#undef led_trigger_register
#define led_trigger_register LINUX_BACKPORT(led_trigger_register)
#undef led_trigger_unregister
#define led_trigger_unregister LINUX_BACKPORT(led_trigger_unregister)
#undef led_trigger_register_simple
#define led_trigger_register_simple LINUX_BACKPORT(led_trigger_register_simple)
#undef led_trigger_unregister_simple
#define led_trigger_unregister_simple LINUX_BACKPORT(led_trigger_unregister_simple)
#undef led_trigger_event
#define led_trigger_event LINUX_BACKPORT(led_trigger_event)
#undef DEFINE_LED_TRIGGER
#define DEFINE_LED_TRIGGER(x) static struct led_trigger *x;
static inline int led_classdev_register(struct device *parent,
struct led_classdev *led_cdev)
{
return 0;
}
static inline void led_classdev_unregister(struct led_classdev *led_cdev)
{
}
static inline void led_trigger_register_simple(const char *name,
struct led_trigger **trigger)
{
}
static inline void led_trigger_unregister_simple(struct led_trigger *trigger)
{
}
static inline void led_blink_set(struct led_classdev *led_cdev,
unsigned long *delay_on,
unsigned long *delay_off)
{
}
static inline void led_set_brightness(struct led_classdev *led_cdev,
enum led_brightness brightness)
{
}
static inline void led_classdev_suspend(struct led_classdev *led_cdev)
{
}
static inline void led_classdev_resume(struct led_classdev *led_cdev)
{
}
static inline int led_trigger_register(struct led_trigger *trigger)
{
INIT_LIST_HEAD(&trigger->led_cdevs);
INIT_LIST_HEAD(&trigger->next_trig);
rwlock_init(&trigger->leddev_list_lock);
return 0;
}
static inline void led_trigger_unregister(struct led_trigger *trigger)
{
}
static inline void led_trigger_event(struct led_trigger *trigger,
enum led_brightness event)
{
}
static inline void led_trigger_blink(struct led_trigger *trigger,
unsigned long *delay_on,
unsigned long *delay_off)
{
}
static inline void led_trigger_blink_oneshot(struct led_trigger *trigger,
unsigned long *delay_on,
unsigned long *delay_off,
int invert)
{
}
#endif
#endif /* __BACKPORT_LED_DISABLED_SUPPORT */
/*
* These tricks are taken from
* http://efesx.com/2010/07/17/variadic-macro-to-count-number-of-arguments/
* and
* http://efesx.com/2010/08/31/overloading-macros/
*/
#define VA_NUM_ARGS(...) VA_NUM_ARGS_IMPL(__VA_ARGS__, 5,4,3,2,1)
#define VA_NUM_ARGS_IMPL(_1,_2,_3,_4,_5,N,...) N
#define macro_dispatcher(func, ...) \
macro_dispatcher_(func, VA_NUM_ARGS(__VA_ARGS__))
#define macro_dispatcher_(func, nargs) \
macro_dispatcher__(func, nargs)
#define macro_dispatcher__(func, nargs) \
func ## nargs
#ifndef __BACKPORT_GENERATED_UTS_RELEASE_H
#define __BACKPORT_GENERATED_UTS_RELEASE_H
#include_next <generated/utsrelease.h>
/*
* We only want the UTS_UBUNTU_RELEASE_ABI var when we are on a normal
* Ubuntu distribution kernel and not when we are on a Ubuntu mainline
* kernel. Some of the Ubuntu mainline kernel do have an invalid octal
* number in this field like 031418 and we do not want to evaluate this
* at all on the Ubuntu mainline kernels. All Ubuntu distribution
* kernel have CONFIG_VERSION_SIGNATURE set so this way we can detect
* the which type of kernel we are on.
*/
#ifndef UTS_UBUNTU_RELEASE_ABI
#define UTS_UBUNTU_RELEASE_ABI 0
#elif !defined(CONFIG_VERSION_SIGNATURE)
#undef UTS_UBUNTU_RELEASE_ABI
#define UTS_UBUNTU_RELEASE_ABI 0
#endif
#endif /* __BACKPORT_GENERATED_UTS_RELEASE_H */
#ifndef __BACKPORT_LINUX_ACPI_H
#define __BACKPORT_LINUX_ACPI_H
#include_next <linux/acpi.h>
#include <linux/version.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
/*
* Backports
*
* commit 95f8a082b9b1ead0c2859f2a7b1ac91ff63d8765
* Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* Date: Wed Nov 21 00:21:50 2012 +0100
*
* ACPI / driver core: Introduce struct acpi_dev_node and related macros
*
* To avoid adding an ACPI handle pointer to struct device on
* architectures that don't use ACPI, or generally when CONFIG_ACPI is
* not set, in which cases that pointer is useless, define struct
* acpi_dev_node that will contain the handle pointer if CONFIG_ACPI is
* set and will be empty otherwise and use it to represent the ACPI
* device node field in struct device.
*
* In addition to that define macros for reading and setting the ACPI
* handle of a device that don't generate code when CONFIG_ACPI is
* unset. Modify the ACPI subsystem to use those macros instead of
* referring to the given device's ACPI handle directly.
*
* Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
* Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
* Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
*/
#ifdef CONFIG_ACPI
#define ACPI_HANDLE(dev) DEVICE_ACPI_HANDLE(dev)
#else
#define ACPI_HANDLE(dev) (NULL)
#endif /* CONFIG_ACPI */
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0) */
#endif /* __BACKPORT_LINUX_ACPI_H */
#ifndef __BACKPORT_BITOPS_H
#define __BACKPORT_BITOPS_H
#include_next <linux/bitops.h>
#include <linux/version.h>
#include <generated/utsrelease.h>
#ifndef GENMASK
/*
* Create a contiguous bitmask starting at bit position @l and ending at
* position @h. For example
* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
*/
#define GENMASK(h, l) (((U32_C(1) << ((h) - (l) + 1)) - 1) << (l))
#define GENMASK_ULL(h, l) (((U64_C(1) << ((h) - (l) + 1)) - 1) << (l))
#endif
#endif /* __BACKPORT_BITOPS_H */
#ifndef __BACKPORT_LINUX_CLK_H
#define __BACKPORT_LINUX_CLK_H
#include_next <linux/clk.h>
#include <linux/version.h>
/*
* commit 93abe8e4 - we only backport the non CONFIG_COMMON_CLK
* case as the CONFIG_COMMON_CLK case requires arch support. By
* using the backport_ namespace for older kernels we force usage
* of these helpers and that's required given that 3.5 added some
* of these helpers expecting a few exported symbols for the non
* CONFIG_COMMON_CLK case. The 3.5 kernel is not supported as
* per kernel.org so we don't send a fix upstream for that.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
#ifndef CONFIG_COMMON_CLK
/*
* Whoopsie!
*
* clk_enable() and clk_disable() have been left without
* a nop export symbols when !CONFIG_COMMON_CLK since its
* introduction on v2.6.16, but fixed until 3.6.
*/
#if 0
#define clk_enable LINUX_BACKPORT(clk_enable)
static inline int clk_enable(struct clk *clk)
{
return 0;
}
#define clk_disable LINUX_BACKPORT(clk_disable)
static inline void clk_disable(struct clk *clk) {}
#endif
#define clk_get LINUX_BACKPORT(clk_get)
static inline struct clk *clk_get(struct device *dev, const char *id)
{
return NULL;
}
#define devm_clk_get LINUX_BACKPORT(devm_clk_get)
static inline struct clk *devm_clk_get(struct device *dev, const char *id)
{
return NULL;
}
#define clk_put LINUX_BACKPORT(clk_put)
static inline void clk_put(struct clk *clk) {}
#define devm_clk_put LINUX_BACKPORT(devm_clk_put)
static inline void devm_clk_put(struct device *dev, struct clk *clk) {}
#define clk_get_rate LINUX_BACKPORT(clk_get_rate)
static inline unsigned long clk_get_rate(struct clk *clk)