mirror of
https://github.com/AlexisTM/RT-WiFi.git
synced 2024-12-18 13:26:49 +00:00
Backport v3.13.2
This commit is contained in:
parent
f3aa04c1ff
commit
210da501c5
1102
.local-symbols
Normal file
1102
.local-symbols
Normal file
File diff suppressed because it is too large
Load Diff
356
COPYING
Normal file
356
COPYING
Normal file
@ -0,0 +1,356 @@
|
||||
|
||||
NOTE! This copyright does *not* cover user programs that use kernel
|
||||
services by normal system calls - this is merely considered normal use
|
||||
of the kernel, and does *not* fall under the heading of "derived work".
|
||||
Also note that the GPL below is copyrighted by the Free Software
|
||||
Foundation, but the instance of code that it refers to (the Linux
|
||||
kernel) is copyrighted by me and others who actually wrote it.
|
||||
|
||||
Also note that the only valid version of the GPL as far as the kernel
|
||||
is concerned is _this_ particular version of the license (ie v2, not
|
||||
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
|
||||
|
||||
Linus Torvalds
|
||||
|
||||
----------------------------------------
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
48
Kconfig
Normal file
48
Kconfig
Normal file
@ -0,0 +1,48 @@
|
||||
mainmenu "Linux Backports from $BACKPORTED_KERNEL_NAME $BACKPORTED_KERNEL_VERSION (with backports $BACKPORTS_VERSION)"
|
||||
|
||||
config BACKPORTS_VERSION
|
||||
string
|
||||
option env="BACKPORTS_VERSION"
|
||||
config BACKPORTED_KERNEL_VERSION
|
||||
string
|
||||
option env="BACKPORTED_KERNEL_VERSION"
|
||||
config BACKPORTED_KERNEL_NAME
|
||||
string
|
||||
option env="BACKPORTED_KERNEL_NAME"
|
||||
|
||||
# these will be generated
|
||||
source Kconfig.kernel
|
||||
source Kconfig.versions
|
||||
|
||||
# some hacks ...
|
||||
config WIRELESS
|
||||
def_bool y
|
||||
config NET_CORE
|
||||
def_bool y
|
||||
config EXPERT
|
||||
def_bool y
|
||||
|
||||
# this has the configuration for the backport code
|
||||
source compat/Kconfig
|
||||
|
||||
# these are copied from the kernel
|
||||
source net/wireless/Kconfig
|
||||
source net/mac80211/Kconfig
|
||||
source net/bluetooth/Kconfig
|
||||
source drivers/net/wireless/Kconfig
|
||||
source drivers/net/ethernet/Kconfig
|
||||
source drivers/net/usb/Kconfig
|
||||
|
||||
source drivers/ssb/Kconfig
|
||||
source drivers/bcma/Kconfig
|
||||
|
||||
source net/nfc/Kconfig
|
||||
|
||||
source drivers/regulator/Kconfig
|
||||
source drivers/media/Kconfig
|
||||
|
||||
source net/ieee802154/Kconfig
|
||||
source net/mac802154/Kconfig
|
||||
source drivers/net/ieee802154/Kconfig
|
||||
|
||||
source drivers/usb/class/Kconfig
|
9693
MAINTAINERS
Normal file
9693
MAINTAINERS
Normal file
File diff suppressed because it is too large
Load Diff
163
Makefile
Normal file
163
Makefile
Normal file
@ -0,0 +1,163 @@
|
||||
#
|
||||
# Makefile for the output source package
|
||||
#
|
||||
|
||||
ifeq ($(KERNELRELEASE),)
|
||||
|
||||
MAKEFLAGS += --no-print-directory
|
||||
SHELL := /bin/bash
|
||||
BACKPORT_PWD := $(shell pwd)
|
||||
|
||||
KMODDIR ?= updates
|
||||
ifneq ($(origin KLIB), undefined)
|
||||
KMODPATH_ARG := "INSTALL_MOD_PATH=$(KLIB)"
|
||||
else
|
||||
KLIB := /lib/modules/$(shell uname -r)/
|
||||
KMODPATH_ARG :=
|
||||
endif
|
||||
KLIB_BUILD ?= $(KLIB)/build/
|
||||
KERNEL_CONFIG := $(KLIB_BUILD)/.config
|
||||
KERNEL_MAKEFILE := $(KLIB_BUILD)/Makefile
|
||||
CONFIG_MD5 := $(shell md5sum $(KERNEL_CONFIG) 2>/dev/null | sed 's/\s.*//')
|
||||
|
||||
export KLIB KLIB_BUILD BACKPORT_PWD KMODDIR KMODPATH_ARG
|
||||
|
||||
# disable built-in rules for this file
|
||||
.SUFFIXES:
|
||||
|
||||
.PHONY: default
|
||||
default:
|
||||
@$(MAKE) modules
|
||||
|
||||
.PHONY: mrproper
|
||||
mrproper:
|
||||
@test -f .config && $(MAKE) clean || true
|
||||
@rm -f .config
|
||||
@rm -f .kernel_config_md5 Kconfig.versions Kconfig.kernel
|
||||
@rm -f backport-include/backport/autoconf.h
|
||||
|
||||
.DEFAULT:
|
||||
@set -e ; test -f .local-symbols || ( \
|
||||
echo "/--------------" ;\
|
||||
echo "| You shouldn't run make in the backports tree, but only in" ;\
|
||||
echo "| the generated output. This here is only the skeleton code" ;\
|
||||
echo "| copied into the output directory. To use the backport system" ;\
|
||||
echo "| from scratch, go into the top-level directory and run" ;\
|
||||
echo "| ./gentree.py /path/to/linux-next/ /tmp/output" ;\
|
||||
echo "| and then make menuconfig/... in the output directory. See" ;\
|
||||
echo "| ./gentree.py --help" ;\
|
||||
echo "| for more options." ;\
|
||||
echo "\\--" ;\
|
||||
false)
|
||||
@set -e ; test -f $(KERNEL_CONFIG) || ( \
|
||||
echo "/--------------" ;\
|
||||
echo "| Your kernel headers are incomplete/not installed." ;\
|
||||
echo "| Please install kernel headers, including a .config" ;\
|
||||
echo "| file or use the KLIB/KLIB_BUILD make variables to" ;\
|
||||
echo "| set the kernel to build against, e.g." ;\
|
||||
echo "| make KLIB=/lib/modules/3.1.7/" ;\
|
||||
echo "| to compile/install for the installed kernel 3.1.7" ;\
|
||||
echo "| (that isn't currently running.)" ;\
|
||||
echo "\\--" ;\
|
||||
false)
|
||||
@set -e ; if [ "$$(cat .kernel_config_md5 2>/dev/null)" != "$(CONFIG_MD5)" ] ;\
|
||||
then \
|
||||
echo -n "Generating local configuration database from kernel ..." ;\
|
||||
grep -v -f .local-symbols $(KERNEL_CONFIG) | grep = | ( \
|
||||
while read l ; do \
|
||||
if [ "$${l:0:7}" != "CONFIG_" ] ; then \
|
||||
continue ;\
|
||||
fi ;\
|
||||
l=$${l:7} ;\
|
||||
n=$${l%%=*} ;\
|
||||
v=$${l#*=} ;\
|
||||
if [ "$$v" = "m" ] ; then \
|
||||
echo config $$n ;\
|
||||
echo ' tristate' ;\
|
||||
elif [ "$$v" = "y" ] ; then \
|
||||
echo config $$n ;\
|
||||
echo ' bool' ;\
|
||||
else \
|
||||
continue ;\
|
||||
fi ;\
|
||||
echo " default $$v" ;\
|
||||
echo "" ;\
|
||||
done \
|
||||
) > Kconfig.kernel ;\
|
||||
kver=$$($(MAKE) --no-print-directory -C $(KLIB_BUILD) kernelversion | \
|
||||
sed 's/^\(\(3\|2\.6\)\.[0-9]\+\).*/\1/;t;d') ;\
|
||||
test "$$kver" != "" || echo "Kernel version parse failed!" ;\
|
||||
test "$$kver" != "" ;\
|
||||
kvers="$$(seq 14 39 | sed 's/^/2.6./')" ;\
|
||||
kvers="$$kvers $$(seq 0 99 | sed 's/^/3./')" ;\
|
||||
print=0 ;\
|
||||
for v in $$kvers ; do \
|
||||
if [ "$$print" = "1" ] ; then \
|
||||
echo config BACKPORT_KERNEL_$$(echo $$v | tr . _) ;\
|
||||
echo " def_bool y" ;\
|
||||
fi ;\
|
||||
if [ "$$v" = "$$kver" ] ; then print=1 ; fi ;\
|
||||
done > Kconfig.versions ;\
|
||||
# RHEL as well, sadly we need to grep for it ;\
|
||||
RHEL_MAJOR=$$(grep '^RHEL_MAJOR' $(KERNEL_MAKEFILE) | \
|
||||
sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
|
||||
RHEL_MINOR=$$(grep '^RHEL_MINOR' $(KERNEL_MAKEFILE) | \
|
||||
sed 's/.*=\s*\([0-9]*\)/\1/;t;d') ;\
|
||||
for v in $$(seq 0 $$RHEL_MINOR) ; do \
|
||||
echo config BACKPORT_RHEL_KERNEL_$${RHEL_MAJOR}_$$v ;\
|
||||
echo " def_bool y" ;\
|
||||
done >> Kconfig.versions ;\
|
||||
echo " done." ;\
|
||||
fi ;\
|
||||
echo "$(CONFIG_MD5)" > .kernel_config_md5
|
||||
@$(MAKE) -f Makefile.real "$@"
|
||||
|
||||
.PHONY: defconfig-help
|
||||
defconfig-help:
|
||||
@echo "Driver or subsystem configuration targets:"
|
||||
@set -e ;\
|
||||
bk_configs="$$(ls defconfigs/*)" ;\
|
||||
for cfg in $$bk_configs; do \
|
||||
echo " defconfig-$${cfg##defconfigs/}" ;\
|
||||
done
|
||||
@echo ""
|
||||
|
||||
.PHONY: help
|
||||
help: defconfig-help
|
||||
@echo "Cleaning targets:"
|
||||
@echo " clean - Remove most generated files but keep the config and"
|
||||
@echo " enough build support to build external modules"
|
||||
@echo " mrproper - Remove all generated files + config + various backup files"
|
||||
@echo ""
|
||||
@echo "Driver configuration help:"
|
||||
@echo " defconfig-help - List all prearranged defconfig-targets we have"
|
||||
@echo " designed for you. You can use this to find"
|
||||
@echo " driver specific configs in case all you really"
|
||||
@echo " need is to just compile one or a small group "
|
||||
@echo " of drivers."
|
||||
@echo ""
|
||||
@echo "Configuration targets:"
|
||||
@echo " menuconfig - Update current config utilising a menu based program"
|
||||
@echo " oldconfig - Update current config utilising a provided .config as base"
|
||||
@echo " oldaskconfig - ??"
|
||||
@echo " silentoldconfig - Same as oldconfig, but quietly, additionally update deps"
|
||||
@echo " allnoconfig - New config where all options are answered with no"
|
||||
@echo " allyesconfig - New config where all options are accepted with yes"
|
||||
@echo " allmodconfig - New config selecting modules when possible"
|
||||
@echo " alldefconfig - New config with all symbols set to default"
|
||||
@echo " randconfig - New config with random answer to all options"
|
||||
@echo " listnewconfig - List new options"
|
||||
@echo " olddefconfig - Same as silentoldconfig but sets new symbols to their default value"
|
||||
@echo ""
|
||||
@echo "Other generic targets:"
|
||||
@echo " all - Build all targets marked with [*]"
|
||||
@echo "* modules - Build all modules"
|
||||
@echo ""
|
||||
@echo "Architecture specific targets:"
|
||||
@echo " install - Install modules"
|
||||
@echo " uninstall - Uninstall modules"
|
||||
@echo ""
|
||||
@echo "Execute "make" or "make all" to build all targets marked with [*]"
|
||||
else
|
||||
include $(BACKPORT_PWD)/Makefile.kernel
|
||||
endif
|
10
Makefile.build
Normal file
10
Makefile.build
Normal file
@ -0,0 +1,10 @@
|
||||
-include .config
|
||||
export
|
||||
|
||||
.PHONY: modules
|
||||
modules:
|
||||
@$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_PWD) modules
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_PWD) clean
|
42
Makefile.kernel
Normal file
42
Makefile.kernel
Normal file
@ -0,0 +1,42 @@
|
||||
# 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) \
|
||||
-DBACKPORTS_VERSION=\"$(BACKPORTS_VERSION)\" \
|
||||
-DBACKPORTED_KERNEL_VERSION=\"$(BACKPORTED_KERNEL_VERSION)\" \
|
||||
-DBACKPORTED_KERNEL_NAME=\"$(BACKPORTED_KERNEL_NAME)\" \
|
||||
$(BACKPORTS_GIT_TRACKER_DEF) \
|
||||
$(CFLAGS)
|
||||
|
||||
export backport_srctree = $(M)
|
||||
|
||||
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_REGULATOR) += drivers/regulator/
|
||||
obj-$(CPTCFG_MEDIA_SUPPORT) += drivers/media/
|
||||
|
||||
obj-$(CPTCFG_IEEE802154) += 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/
|
116
Makefile.real
Normal file
116
Makefile.real
Normal file
@ -0,0 +1,116 @@
|
||||
include versions
|
||||
export BACKPORTS_VERSION BACKPORTED_KERNEL_VERSION BACKPORTED_KERNEL_NAME
|
||||
ifdef BACKPORTS_GIT_TRACKED
|
||||
export BACKPORTS_GIT_TRACKER_DEF=-DBACKPORTS_GIT_TRACKED=\"$(BACKPORTS_GIT_TRACKED)\"
|
||||
else
|
||||
export BACKPORTS_GIT_TRACKER_DEF=
|
||||
endif
|
||||
|
||||
# disable built-in rules for this file
|
||||
.SUFFIXES:
|
||||
|
||||
export CONFIG_=CPTCFG_
|
||||
|
||||
.PHONY: menuconfig
|
||||
menuconfig:
|
||||
@$(MAKE) -C kconf mconf
|
||||
@./kconf/mconf Kconfig
|
||||
|
||||
.PHONY: listnewconfig oldaskconfig oldconfig \
|
||||
silentoldconfig olddefconfig oldnoconfig \
|
||||
allnoconfig allyesconfig allmodconfig \
|
||||
alldefconfig randconfig
|
||||
listnewconfig oldaskconfig oldconfig \
|
||||
silentoldconfig olddefconfig oldnoconfig \
|
||||
allnoconfig allyesconfig allmodconfig \
|
||||
alldefconfig randconfig:
|
||||
@$(MAKE) -C kconf conf
|
||||
@./kconf/conf --$@ Kconfig
|
||||
|
||||
.PHONY: usedefconfig
|
||||
usedefconfig:
|
||||
@$(MAKE) -C kconf conf
|
||||
@./kconf/conf --defconfig=defconfig Kconfig
|
||||
|
||||
defconfig-%::
|
||||
@$(MAKE) -C kconf conf
|
||||
@./kconf/conf --defconfig=defconfigs/$(@:defconfig-%=%) Kconfig
|
||||
|
||||
.config:
|
||||
@test -f defconfig && $(MAKE) usedefconfig || ( \
|
||||
echo "/--------------" ;\
|
||||
echo "| Your backport package isn't configured, please configure it" ;\
|
||||
echo "| using one of the following options:" ;\
|
||||
echo "| To configure manually:" ;\
|
||||
echo "| make oldconfig" ;\
|
||||
echo "| make menuconfig" ;\
|
||||
echo "|" ;\
|
||||
echo "| To get defaults for certain drivers:" ;\
|
||||
(cd defconfigs ; for f in $$(ls) ; do \
|
||||
echo "| make defconfig-$$f" ;\
|
||||
done ) ;\
|
||||
echo "\--" ;\
|
||||
false )
|
||||
|
||||
backport-include/backport/autoconf.h: .config Kconfig.versions Kconfig.kernel
|
||||
@$(MAKE) oldconfig
|
||||
@echo -n "Building backport-include/backport/autoconf.h ..."
|
||||
@grep -f .local-symbols .config | ( \
|
||||
echo "#ifndef COMPAT_AUTOCONF_INCLUDED" ;\
|
||||
echo "#define COMPAT_AUTOCONF_INCLUDED" ;\
|
||||
echo "/*" ;\
|
||||
echo " * Automatically generated file, don't edit!" ;\
|
||||
echo " * Changes will be overwritten" ;\
|
||||
echo " */" ;\
|
||||
echo "" ;\
|
||||
while read l ; do \
|
||||
n=$${l%%=*} ;\
|
||||
v=$${l#*=} ;\
|
||||
case $$v in \
|
||||
y) echo "#define $$n 1" ;; \
|
||||
m) echo "#define $${n}_MODULE 1" ;; \
|
||||
\"*) echo "#define $$n $$v" ;; \
|
||||
[0-9]*) echo "#define $$n $$v" ;; \
|
||||
*) echo "#warning unknown value for $$n";;\
|
||||
esac ;\
|
||||
done ;\
|
||||
echo "#endif /* COMPAT_AUTOCONF_INCLUDED */" ;\
|
||||
) > backport-include/backport/autoconf.h
|
||||
@echo " done."
|
||||
|
||||
.PHONY: modules
|
||||
modules: backport-include/backport/autoconf.h
|
||||
@$(MAKE) -f Makefile.build modules
|
||||
|
||||
.PHONY: install
|
||||
install: modules
|
||||
@$(MAKE) -C $(KLIB_BUILD) M=$(BACKPORT_PWD) \
|
||||
INSTALL_MOD_DIR=$(KMODDIR) $(KMODPATH_ARG) \
|
||||
modules_install
|
||||
@./scripts/blacklist.sh $(KLIB)/ $(KLIB)/$(KMODDIR)
|
||||
@./scripts/compress_modules.sh $(KLIB)/$(KMODDIR)
|
||||
@./scripts/check_depmod.sh
|
||||
@./scripts/backport_firmware_install.sh
|
||||
@/sbin/depmod -a
|
||||
@./scripts/update-initramfs.sh $(KLIB)
|
||||
@echo
|
||||
@echo Your backported driver modules should be installed now.
|
||||
@echo Reboot.
|
||||
@echo
|
||||
|
||||
.PHONY: modules_install
|
||||
modules_install: install
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
@./scripts/uninstall.sh
|
||||
@/sbin/depmod -a
|
||||
@./scripts/update-initramfs.sh $(KLIB)
|
||||
@echo
|
||||
@echo Your backported driver modules should be uninstalled now.
|
||||
@echo Reboot.
|
||||
@echo
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(MAKE) -f Makefile.build clean
|
39
backport-include/asm-generic/bug.h
Normal file
39
backport-include/asm-generic/bug.h
Normal file
@ -0,0 +1,39 @@
|
||||
#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 */
|
17
backport-include/asm-generic/pci-dma-compat.h
Normal file
17
backport-include/asm-generic/pci-dma-compat.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __BACKPORT_ASM_PCI_DMA_COMPAT_H
|
||||
#define __BACKPORT_ASM_PCI_DMA_COMPAT_H
|
||||
#include_next <asm-generic/pci-dma-compat.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
#include <backport/magic.h>
|
||||
|
||||
#define pci_dma_mapping_error1(dma_addr) dma_mapping_error1(dma_addr)
|
||||
#define pci_dma_mapping_error2(pdev, dma_addr) dma_mapping_error2(pdev, dma_addr)
|
||||
#undef pci_dma_mapping_error
|
||||
#define pci_dma_mapping_error(...) \
|
||||
macro_dispatcher(pci_dma_mapping_error, __VA_ARGS__)(__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_ASM_PCI_DMA_COMPAT_H */
|
37
backport-include/asm/atomic.h
Normal file
37
backport-include/asm/atomic.h
Normal file
@ -0,0 +1,37 @@
|
||||
#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.
|
||||
*/
|
||||
#include <asm/atomic.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)) && !defined(ATOMIC64_INIT) && !defined(CONFIG_X86) && !((LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)) && defined(CONFIG_ARM) && !defined(CONFIG_GENERIC_ATOMIC64))
|
||||
#include <asm-generic/atomic64.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
|
||||
#ifndef CONFIG_64BIT
|
||||
|
||||
typedef struct {
|
||||
long long counter;
|
||||
} atomic64_t;
|
||||
|
||||
#define atomic64_read LINUX_BACKPORT(atomic64_read)
|
||||
extern long long atomic64_read(const atomic64_t *v);
|
||||
#define atomic64_add_return LINUX_BACKPORT(atomic64_add_return)
|
||||
extern long long atomic64_add_return(long long a, atomic64_t *v);
|
||||
|
||||
#define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_ASM_ATOMIC_H */
|
27
backport-include/asm/dma-mapping.h
Normal file
27
backport-include/asm/dma-mapping.h
Normal file
@ -0,0 +1,27 @@
|
||||
#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_BACKPORT_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_BACKPORT_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 */
|
23
backport-include/asm/errno.h
Normal file
23
backport-include/asm/errno.h
Normal file
@ -0,0 +1,23 @@
|
||||
#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 */
|
9
backport-include/asm/ioctls.h
Normal file
9
backport-include/asm/ioctls.h
Normal file
@ -0,0 +1,9 @@
|
||||
#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 */
|
213
backport-include/asm/unaligned.h
Normal file
213
backport-include/asm/unaligned.h
Normal file
@ -0,0 +1,213 @@
|
||||
#ifndef __BACKPORT_ASM_UNALIGNED_H
|
||||
#define __BACKPORT_ASM_UNALIGNED_H
|
||||
#include_next <asm/unaligned.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
/*
|
||||
* 2.6.26 added its own unaligned API which the
|
||||
* new drivers can use. Lets port it here by including it in older
|
||||
* kernels and also deal with the architecture handling here.
|
||||
*/
|
||||
#ifdef CONFIG_ALPHA
|
||||
|
||||
#include <linux/unaligned/be_struct.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* alpha */
|
||||
#ifdef CONFIG_ARM
|
||||
|
||||
/* arm */
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* arm */
|
||||
#ifdef CONFIG_AVR32
|
||||
|
||||
/*
|
||||
* AVR32 can handle some unaligned accesses, depending on the
|
||||
* implementation. The AVR32 AP implementation can handle unaligned
|
||||
* words, but halfwords must be halfword-aligned, and doublewords must
|
||||
* be word-aligned.
|
||||
*
|
||||
* However, swapped word loads must be word-aligned so we can't
|
||||
* optimize word loads in general.
|
||||
*/
|
||||
|
||||
#include <linux/unaligned/be_struct.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif
|
||||
#ifdef CONFIG_BLACKFIN
|
||||
|
||||
#include <linux/unaligned/le_struct.h>
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* blackfin */
|
||||
#ifdef CONFIG_CRIS
|
||||
|
||||
/*
|
||||
* CRIS can do unaligned accesses itself.
|
||||
*/
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* cris */
|
||||
#ifdef CONFIG_FRV
|
||||
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* frv */
|
||||
#ifdef CONFIG_H8300
|
||||
|
||||
#include <linux/unaligned/be_memmove.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* h8300 */
|
||||
#ifdef CONFIG_IA64
|
||||
|
||||
#include <linux/unaligned/le_struct.h>
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* ia64 */
|
||||
#ifdef CONFIG_M32R
|
||||
|
||||
#if defined(__LITTLE_ENDIAN__)
|
||||
# include <linux/unaligned/le_memmove.h>
|
||||
# include <linux/unaligned/be_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#else
|
||||
# include <linux/unaligned/be_memmove.h>
|
||||
# include <linux/unaligned/le_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#endif
|
||||
|
||||
#endif /* m32r */
|
||||
#ifdef CONFIG_M68K /* this handles both m68k and m68knommu */
|
||||
|
||||
#ifdef CONFIG_COLDFIRE
|
||||
#include <linux/unaligned/be_struct.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
#else
|
||||
|
||||
/*
|
||||
* The m68k can do unaligned accesses itself.
|
||||
*/
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
#endif
|
||||
|
||||
#endif /* m68k and m68knommu */
|
||||
#ifdef CONFIG_MIPS
|
||||
|
||||
#if defined(__MIPSEB__)
|
||||
# include <linux/unaligned/be_struct.h>
|
||||
# include <linux/unaligned/le_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
# define get_unaligned __get_unaligned_be
|
||||
# define put_unaligned __put_unaligned_be
|
||||
#elif defined(__MIPSEL__)
|
||||
# include <linux/unaligned/le_struct.h>
|
||||
# include <linux/unaligned/be_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#endif
|
||||
|
||||
#endif /* mips */
|
||||
#ifdef CONFIG_MN10300
|
||||
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* mn10300 */
|
||||
#ifdef CONFIG_PARISC
|
||||
|
||||
#include <linux/unaligned/be_struct.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* parisc */
|
||||
#ifdef CONFIG_PPC
|
||||
/*
|
||||
* The PowerPC can do unaligned accesses itself in big endian mode.
|
||||
*/
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* ppc */
|
||||
#ifdef CONFIG_S390
|
||||
|
||||
/*
|
||||
* The S390 can do unaligned accesses itself.
|
||||
*/
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* s390 */
|
||||
#ifdef CONFIG_SUPERH
|
||||
|
||||
/* SH can't handle unaligned accesses. */
|
||||
#ifdef __LITTLE_ENDIAN__
|
||||
# include <linux/unaligned/le_struct.h>
|
||||
# include <linux/unaligned/be_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#else
|
||||
# include <linux/unaligned/be_struct.h>
|
||||
# include <linux/unaligned/le_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#endif
|
||||
|
||||
#endif /* sh - SUPERH */
|
||||
#ifdef CONFIG_SPARC
|
||||
|
||||
/* sparc and sparc64 */
|
||||
#include <linux/unaligned/be_struct.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* sparc */
|
||||
#ifdef CONFIG_UML
|
||||
|
||||
#include "asm/arch/unaligned.h"
|
||||
|
||||
#endif /* um - uml */
|
||||
#ifdef CONFIG_V850
|
||||
|
||||
#include <linux/unaligned/be_byteshift.h>
|
||||
#include <linux/unaligned/le_byteshift.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* v850 */
|
||||
#ifdef CONFIG_X86
|
||||
/*
|
||||
* The x86 can do unaligned accesses itself.
|
||||
*/
|
||||
#include <linux/unaligned/access_ok.h>
|
||||
#include <linux/unaligned/generic.h>
|
||||
|
||||
#endif /* x86 */
|
||||
#ifdef CONFIG_XTENSA
|
||||
|
||||
#ifdef __XTENSA_EL__
|
||||
# include <linux/unaligned/le_memmove.h>
|
||||
# include <linux/unaligned/be_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#elif defined(__XTENSA_EB__)
|
||||
# include <linux/unaligned/be_memmove.h>
|
||||
# include <linux/unaligned/le_byteshift.h>
|
||||
# include <linux/unaligned/generic.h>
|
||||
#else
|
||||
# error processor byte order undefined!
|
||||
#endif
|
||||
|
||||
#endif /* xtensa */
|
||||
#endif /* < 2.6.26 */
|
||||
|
||||
#endif /* __BACKPORT_ASM_UNALIGNED_H */
|
11
backport-include/backport/backport.h
Normal file
11
backport-include/backport/backport.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __BACKPORT_H
|
||||
#define __BACKPORT_H
|
||||
#include <backport/autoconf.h>
|
||||
#include <linux/kconfig.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
#define LINUX_BACKPORT(__sym) backport_ ##__sym
|
||||
#include <backport/checks.h>
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_H */
|
16
backport-include/backport/checks.h
Normal file
16
backport-include/backport/checks.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __BACKPORT_CHECKS
|
||||
#define __BACKPORT_CHECKS
|
||||
|
||||
#if defined(CPTCFG_BACKPORT_KERNEL_2_6_28) && defined(CONFIG_DYNAMIC_FTRACE)
|
||||
#error "You can't build on a 2.6.27 or older kernel with dynamic ftrace, it's broken"
|
||||
#endif
|
||||
|
||||
#if defined(CPTCFG_MAC80211) && defined(CPTCFG_MAC80211)
|
||||
#error "You must not have mac80211 built into your kernel if you want to enable it"
|
||||
#endif
|
||||
|
||||
#if defined(CPTCFG_CFG80211) && defined(CPTCFG_CFG80211)
|
||||
#error "You must not have cfg80211 built into your kernel if you want to enable it"
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_CHECKS */
|
181
backport-include/backport/leds-disabled.h
Normal file
181
backport-include/backport/leds-disabled.h
Normal file
@ -0,0 +1,181 @@
|
||||
#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_BACKPORT_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 */
|
16
backport-include/backport/magic.h
Normal file
16
backport-include/backport/magic.h
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* 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
|
21
backport-include/crypto/aes.h
Normal file
21
backport-include/crypto/aes.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef _COMPAT_CRYPTO_AES_H
|
||||
#define _COMPAT_CRYPTO_AES_H
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24))
|
||||
#include_next <crypto/aes.h>
|
||||
#else
|
||||
|
||||
#define AES_MIN_KEY_SIZE 16
|
||||
#define AES_MAX_KEY_SIZE 32
|
||||
#define AES_KEYSIZE_128 16
|
||||
#define AES_KEYSIZE_192 24
|
||||
#define AES_KEYSIZE_256 32
|
||||
#define AES_BLOCK_SIZE 16
|
||||
#define AES_MAX_KEYLENGTH (15 * 16)
|
||||
#define AES_MAX_KEYLENGTH_U32 (AES_MAX_KEYLENGTH / sizeof(u32))
|
||||
|
||||
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)) */
|
||||
|
||||
#endif
|
12
backport-include/linux/atomic.h
Normal file
12
backport-include/linux/atomic.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef _COMPAT_LINUX_ATOMIC_H
|
||||
#define _COMPAT_LINUX_ATOMIC_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36))
|
||||
#include_next <linux/atomic.h>
|
||||
#else
|
||||
#include <asm/atomic.h>
|
||||
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36)) */
|
||||
|
||||
#endif /* _COMPAT_LINUX_ATOMIC_H */
|
35
backport-include/linux/bitops.h
Normal file
35
backport-include/linux/bitops.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef __BACKPORT_BITOPS_H
|
||||
#define __BACKPORT_BITOPS_H
|
||||
#include_next <linux/bitops.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30))
|
||||
static inline unsigned long __ffs64(u64 word)
|
||||
{
|
||||
#if BITS_PER_LONG == 32
|
||||
if (((u32)word) == 0UL)
|
||||
return __ffs((u32)(word >> 32)) + 32;
|
||||
#elif BITS_PER_LONG != 64
|
||||
#error BITS_PER_LONG not 32 or 64
|
||||
#endif
|
||||
return __ffs((unsigned long)word);
|
||||
}
|
||||
#endif /* < 2.6.30 */
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34))
|
||||
#define for_each_set_bit(bit, addr, size) \
|
||||
for ((bit) = find_first_bit((addr), (size)); \
|
||||
(bit) < (size); \
|
||||
(bit) = find_next_bit((addr), (size), (bit) + 1))
|
||||
#endif /* < 2.6.34 */
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38))
|
||||
#define sign_extend32 LINUX_BACKPORT(sign_extend32)
|
||||
static inline __s32 sign_extend32(__u32 value, int index)
|
||||
{
|
||||
__u8 shift = 31 - index;
|
||||
return (__s32)(value << shift) >> shift;
|
||||
}
|
||||
#endif /* < 2.6.38 */
|
||||
|
||||
#endif /* __BACKPORT_BITOPS_H */
|
45
backport-include/linux/bug.h
Normal file
45
backport-include/linux/bug.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __BACKPORT_LINUX_BUG_H
|
||||
#define __BACKPORT_LINUX_BUG_H
|
||||
#include_next <linux/bug.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
/* is defined there for older kernels */
|
||||
#include <linux/kernel.h>
|
||||
/* Backport of:
|
||||
*
|
||||
* commit 7ef88ad561457c0346355dfd1f53e503ddfde719
|
||||
* Author: Rusty Russell <rusty@rustcorp.com.au>
|
||||
* Date: Mon Jan 24 14:45:10 2011 -0600
|
||||
*
|
||||
* BUILD_BUG_ON: make it handle more cases
|
||||
*/
|
||||
#undef BUILD_BUG_ON
|
||||
/**
|
||||
* BUILD_BUG_ON - break compile if a condition is true.
|
||||
* @condition: the condition which the compiler should know is false.
|
||||
*
|
||||
* If you have some code which relies on certain constants being equal, or
|
||||
* other compile-time-evaluated condition, you should use BUILD_BUG_ON to
|
||||
* detect if someone changes it.
|
||||
*
|
||||
* The implementation uses gcc's reluctance to create a negative array, but
|
||||
* gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments
|
||||
* to inline functions). So as a fallback we use the optimizer; if it can't
|
||||
* prove the condition is false, it will cause a link error on the undefined
|
||||
* "__build_bug_on_failed". This error message can be harder to track down
|
||||
* though, hence the two different methods.
|
||||
*/
|
||||
#ifndef __OPTIMIZE__
|
||||
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
|
||||
#else
|
||||
extern int __build_bug_on_failed;
|
||||
#define BUILD_BUG_ON(condition) \
|
||||
do { \
|
||||
((void)sizeof(char[1 - 2*!!(condition)])); \
|
||||
if (condition) __build_bug_on_failed = 1; \
|
||||
} while(0)
|
||||
#endif
|
||||
#endif /* < 2.6.38 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_BUG_H */
|
16
backport-include/linux/compat.h
Normal file
16
backport-include/linux/compat.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __BACKPORT_COMPAT_H
|
||||
#define __BACKPORT_COMPAT_H
|
||||
|
||||
#include_next <linux/compat.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
|
||||
#ifdef CONFIG_X86_X32_ABI
|
||||
#define COMPAT_USE_64BIT_TIME \
|
||||
(!!(task_pt_regs(current)->orig_ax & __X32_SYSCALL_BIT))
|
||||
#else
|
||||
#define COMPAT_USE_64BIT_TIME 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_COMPAT_H */
|
17
backport-include/linux/compiler.h
Normal file
17
backport-include/linux/compiler.h
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef __BACKPORT_LINUX_COMPILER_H
|
||||
#define __BACKPORT_LINUX_COMPILER_H
|
||||
#include_next <linux/compiler.h>
|
||||
|
||||
#ifndef __rcu
|
||||
#define __rcu
|
||||
#endif
|
||||
|
||||
#ifndef __always_unused
|
||||
#ifdef __GNUC__
|
||||
#define __always_unused __attribute__((unused))
|
||||
#else
|
||||
#define __always_unused /* unimplemented */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_COMPILER_H */
|
20
backport-include/linux/completion.h
Normal file
20
backport-include/linux/completion.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef __BACKPORT_COMPLETION_H
|
||||
#define __BACKPORT_COMPLETION_H
|
||||
#include_next <linux/completion.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
|
||||
/**
|
||||
* reinit_completion - reinitialize a completion structure
|
||||
* @x: pointer to completion structure that is to be reinitialized
|
||||
*
|
||||
* This inline function should be used to reinitialize a completion structure so it can
|
||||
* be reused. This is especially important after complete_all() is used.
|
||||
*/
|
||||
static inline void reinit_completion(struct completion *x)
|
||||
{
|
||||
x->done = 0;
|
||||
}
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) */
|
||||
|
||||
#endif /* __BACKPORT_COMPLETION_H */
|
60
backport-include/linux/cordic.h
Normal file
60
backport-include/linux/cordic.h
Normal file
@ -0,0 +1,60 @@
|
||||
#ifndef _BACKPORT_LINUX_CORDIC_H
|
||||
#define _BACKPORT_LINUX_CORDIC_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0))
|
||||
#include_next <linux/cordic.h>
|
||||
#else
|
||||
|
||||
/*
|
||||
* Copyright (c) 2011 Broadcom Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef __CORDIC_H_
|
||||
#define __CORDIC_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/**
|
||||
* struct cordic_iq - i/q coordinate.
|
||||
*
|
||||
* @i: real part of coordinate (in phase).
|
||||
* @q: imaginary part of coordinate (quadrature).
|
||||
*/
|
||||
struct cordic_iq {
|
||||
s32 i;
|
||||
s32 q;
|
||||
};
|
||||
|
||||
/**
|
||||
* cordic_calc_iq() - calculates the i/q coordinate for given angle.
|
||||
*
|
||||
* @theta: angle in degrees for which i/q coordinate is to be calculated.
|
||||
* @coord: function output parameter holding the i/q coordinate.
|
||||
*
|
||||
* The function calculates the i/q coordinate for a given angle using
|
||||
* cordic algorithm. The coordinate consists of a real (i) and an
|
||||
* imaginary (q) part. The real part is essentially the cosine of the
|
||||
* angle and the imaginary part is the sine of the angle. The returned
|
||||
* values are scaled by 2^16 for precision. The range for theta is
|
||||
* for -180 degrees to +180 degrees. Passed values outside this range are
|
||||
* converted before doing the actual calculation.
|
||||
*/
|
||||
#define cordic_calc_iq LINUX_BACKPORT(cordic_calc_iq)
|
||||
struct cordic_iq cordic_calc_iq(s32 theta);
|
||||
|
||||
#endif /* __CORDIC_H_ */
|
||||
#endif /* LINUX_VERSION_CODE > KERNEL_VERSION(3,1,0)) */
|
||||
#endif /* _BACKPORT_LINUX_CORDIC_H */
|
109
backport-include/linux/crc8.h
Normal file
109
backport-include/linux/crc8.h
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 2011 Broadcom Corporation
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
#ifndef CPTCFG_BACKPORT_BUILD_CRC8_MODULE
|
||||
#include_next <linux/crc8.h>
|
||||
#else
|
||||
|
||||
#ifndef __CRC8_H_
|
||||
#define __CRC8_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* see usage of this value in crc8() description */
|
||||
#define CRC8_INIT_VALUE 0xFF
|
||||
|
||||
/*
|
||||
* Return value of crc8() indicating valid message+crc. This is true
|
||||
* if a CRC is inverted before transmission. The CRC computed over the
|
||||
* whole received bitstream is _table[x], where x is the bit pattern
|
||||
* of the modification (almost always 0xff).
|
||||
*/
|
||||
#define CRC8_GOOD_VALUE(_table) (_table[0xFF])
|
||||
|
||||
/* required table size for crc8 algorithm */
|
||||
#define CRC8_TABLE_SIZE 256
|
||||
|
||||
/* helper macro assuring right table size is used */
|
||||
#define DECLARE_CRC8_TABLE(_table) \
|
||||
static u8 _table[CRC8_TABLE_SIZE]
|
||||
|
||||
/**
|
||||
* crc8_populate_lsb - fill crc table for given polynomial in regular bit order.
|
||||
*
|
||||
* @table: table to be filled.
|
||||
* @polynomial: polynomial for which table is to be filled.
|
||||
*
|
||||
* This function fills the provided table according the polynomial provided for
|
||||
* regular bit order (lsb first). Polynomials in CRC algorithms are typically
|
||||
* represented as shown below.
|
||||
*
|
||||
* poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1
|
||||
*
|
||||
* For lsb first direction x^7 maps to the lsb. So the polynomial is as below.
|
||||
*
|
||||
* - lsb first: poly = 10101011(1) = 0xAB
|
||||
*/
|
||||
#define crc8_populate_lsb LINUX_BACKPORT(crc8_populate_lsb)
|
||||
void crc8_populate_lsb(u8 table[CRC8_TABLE_SIZE], u8 polynomial);
|
||||
|
||||
/**
|
||||
* crc8_populate_msb - fill crc table for given polynomial in reverse bit order.
|
||||
*
|
||||
* @table: table to be filled.
|
||||
* @polynomial: polynomial for which table is to be filled.
|
||||
*
|
||||
* This function fills the provided table according the polynomial provided for
|
||||
* reverse bit order (msb first). Polynomials in CRC algorithms are typically
|
||||
* represented as shown below.
|
||||
*
|
||||
* poly = x^8 + x^7 + x^6 + x^4 + x^2 + 1
|
||||
*
|
||||
* For msb first direction x^7 maps to the msb. So the polynomial is as below.
|
||||
*
|
||||
* - msb first: poly = (1)11010101 = 0xD5
|
||||
*/
|
||||
#define crc8_populate_msb LINUX_BACKPORT(crc8_populate_msb)
|
||||
void crc8_populate_msb(u8 table[CRC8_TABLE_SIZE], u8 polynomial);
|
||||
|
||||
/**
|
||||
* crc8() - calculate a crc8 over the given input data.
|
||||
*
|
||||
* @table: crc table used for calculation.
|
||||
* @pdata: pointer to data buffer.
|
||||
* @nbytes: number of bytes in data buffer.
|
||||
* @crc: previous returned crc8 value.
|
||||
*
|
||||
* The CRC8 is calculated using the polynomial given in crc8_populate_msb()
|
||||
* or crc8_populate_lsb().
|
||||
*
|
||||
* The caller provides the initial value (either %CRC8_INIT_VALUE
|
||||
* or the previous returned value) to allow for processing of
|
||||
* discontiguous blocks of data. When generating the CRC the
|
||||
* caller is responsible for complementing the final return value
|
||||
* and inserting it into the byte stream. When validating a byte
|
||||
* stream (including CRC8), a final return value of %CRC8_GOOD_VALUE
|
||||
* indicates the byte stream data can be considered valid.
|
||||
*
|
||||
* Reference:
|
||||
* "A Painless Guide to CRC Error Detection Algorithms", ver 3, Aug 1993
|
||||
* Williams, Ross N., ross<at>ross.net
|
||||
* (see URL http://www.ross.net/crc/download/crc_v3.txt).
|
||||
*/
|
||||
#define crc8 LINUX_BACKPORT(crc8)
|
||||
u8 crc8(const u8 table[CRC8_TABLE_SIZE], u8 *pdata, size_t nbytes, u8 crc);
|
||||
|
||||
#endif /* __CRC8_H_ */
|
||||
#endif /* BACKPORT_BUILD_CRC8_MODULE */
|
10
backport-include/linux/cred.h
Normal file
10
backport-include/linux/cred.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __BACKPORT_LINUX_CRED_H
|
||||
#define __BACKPORT_LINUX_CRED_H
|
||||
#include_next <linux/cred.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifndef current_user_ns
|
||||
#define current_user_ns() (current->nsproxy->user_ns)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_CRED_H */
|
29
backport-include/linux/debugfs.h
Normal file
29
backport-include/linux/debugfs.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef __BACKPORT_LINUX_DEBUGFS_H
|
||||
#define __BACKPORT_LINUX_DEBUGFS_H
|
||||
#include_next <linux/debugfs.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
#define debugfs_remove_recursive LINUX_BACKPORT(debugfs_remove_recursive)
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
void debugfs_remove_recursive(struct dentry *dentry);
|
||||
#else
|
||||
static inline void debugfs_remove_recursive(struct dentry *dentry)
|
||||
{ }
|
||||
#endif
|
||||
#endif /* < 2.6.27 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4)
|
||||
static inline struct dentry *debugfs_create_x64(const char *name, umode_t mode,
|
||||
struct dentry *parent,
|
||||
u64 *value)
|
||||
{
|
||||
return debugfs_create_u64(name, mode, parent, value);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_DEBUGFS_H */
|
10
backport-include/linux/delay.h
Normal file
10
backport-include/linux/delay.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __BACKPORT_LINUX_DELAY_H
|
||||
#define __BACKPORT_LINUX_DELAY_H
|
||||
#include_next <linux/delay.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
|
||||
#define usleep_range(_min, _max) msleep((_max) / 1000)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_DELAY_H */
|
232
backport-include/linux/device.h
Normal file
232
backport-include/linux/device.h
Normal file
@ -0,0 +1,232 @@
|
||||
#ifndef __BACKPORT_DEVICE_H
|
||||
#define __BACKPORT_DEVICE_H
|
||||
#include <linux/export.h>
|
||||
#include_next <linux/device.h>
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
/* backport
|
||||
* commit 9f3b795a626ee79574595e06d1437fe0c7d51d29
|
||||
* Author: Michał Mirosław <mirq-linux@rere.qmqm.pl>
|
||||
* Date: Fri Feb 1 20:40:17 2013 +0100
|
||||
*
|
||||
* driver-core: constify data for class_find_device()
|
||||
*/
|
||||
typedef int (backport_device_find_function_t)(struct device *, void *);
|
||||
#define class_find_device(cls, start, idx, fun) \
|
||||
class_find_device((cls), (start), (void *)(idx),\
|
||||
(backport_device_find_function_t *)(fun))
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||
static inline int
|
||||
backport_device_move(struct device *dev, struct device *new_parent,
|
||||
enum dpm_order dpm_order)
|
||||
{
|
||||
return device_move(dev, new_parent);
|
||||
}
|
||||
#define device_move LINUX_BACKPORT(device_move)
|
||||
#endif
|
||||
|
||||
#ifndef module_driver
|
||||
/**
|
||||
* module_driver() - Helper macro for drivers that don't do anything
|
||||
* special in module init/exit. This eliminates a lot of boilerplate.
|
||||
* Each module may only use this macro once, and calling it replaces
|
||||
* module_init() and module_exit().
|
||||
*
|
||||
* Use this macro to construct bus specific macros for registering
|
||||
* drivers, and do not use it on its own.
|
||||
*/
|
||||
#define module_driver(__driver, __register, __unregister) \
|
||||
static int __init __driver##_init(void) \
|
||||
{ \
|
||||
return __register(&(__driver)); \
|
||||
} \
|
||||
module_init(__driver##_init); \
|
||||
static void __exit __driver##_exit(void) \
|
||||
{ \
|
||||
__unregister(&(__driver)); \
|
||||
} \
|
||||
module_exit(__driver##_exit);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
#define devm_ioremap_resource LINUX_BACKPORT(devm_ioremap_resource)
|
||||
void __iomem *devm_ioremap_resource(struct device *dev, struct resource *res);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
|
||||
#define devres_release LINUX_BACKPORT(devres_release)
|
||||
extern int devres_release(struct device *dev, dr_release_t release,
|
||||
dr_match_t match, void *match_data);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27)
|
||||
#include <linux/ratelimit.h>
|
||||
|
||||
#define dev_level_ratelimited(dev_level, dev, fmt, ...) \
|
||||
do { \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
DEFAULT_RATELIMIT_INTERVAL, \
|
||||
DEFAULT_RATELIMIT_BURST); \
|
||||
if (__ratelimit(&_rs)) \
|
||||
dev_level(dev, fmt, ##__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define dev_emerg_ratelimited(dev, fmt, ...) \
|
||||
dev_level_ratelimited(dev_emerg, dev, fmt, ##__VA_ARGS__)
|
||||
#define dev_alert_ratelimited(dev, fmt, ...) \
|
||||
dev_level_ratelimited(dev_alert, dev, fmt, ##__VA_ARGS__)
|
||||
|
||||
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG) || defined(DEBUG)
|
||||
#define dev_dbg_ratelimited(dev, fmt, ...) \
|
||||
do { \
|
||||
static DEFINE_RATELIMIT_STATE(_rs, \
|
||||
DEFAULT_RATELIMIT_INTERVAL, \
|
||||
DEFAULT_RATELIMIT_BURST); \
|
||||
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, fmt); \
|
||||
if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT) && \
|
||||
__ratelimit(&_rs)) \
|
||||
__dynamic_pr_debug(&descriptor, pr_fmt(fmt), \
|
||||
##__VA_ARGS__); \
|
||||
} while (0)
|
||||
#else
|
||||
#define dev_dbg_ratelimited(dev, fmt, ...) \
|
||||
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#endif /* dynamic debug */
|
||||
#endif /* 2.6.27 <= version <= 3.5 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
|
||||
#define device_rename(dev, new_name) device_rename(dev, (char *)new_name)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
|
||||
/*
|
||||
* This belongs into pm_wakeup.h but that isn't included directly.
|
||||
* Note that on 2.6.36, this was defined but not exported, so we
|
||||
* need to override it.
|
||||
*/
|
||||
#define pm_wakeup_event LINUX_BACKPORT(pm_wakeup_event)
|
||||
static inline void pm_wakeup_event(struct device *dev, unsigned int msec) {}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
#define device_lock LINUX_BACKPORT(device_lock)
|
||||
static inline void device_lock(struct device *dev)
|
||||
{
|
||||
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
|
||||
mutex_lock(&dev->mutex);
|
||||
#else
|
||||
down(&dev->sem);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define device_trylock LINUX_BACKPORT(device_trylock)
|
||||
static inline int device_trylock(struct device *dev)
|
||||
{
|
||||
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
|
||||
return mutex_trylock(&dev->mutex);
|
||||
#else
|
||||
return down_trylock(&dev->sem);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define device_unlock LINUX_BACKPORT(device_unlock)
|
||||
static inline void device_unlock(struct device *dev)
|
||||
{
|
||||
#if defined(CONFIG_PREEMPT_RT) || defined(CONFIG_PREEMPT_DESKTOP)
|
||||
mutex_unlock(&dev->mutex);
|
||||
#else
|
||||
up(&dev->sem);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
static inline const char *dev_name(struct device *dev)
|
||||
{
|
||||
/* will be changed into kobject_name(&dev->kobj) in the near future */
|
||||
return dev->bus_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||
static inline void dev_set_uevent_suppress(struct device *dev, int val)
|
||||
{
|
||||
dev->uevent_suppress = val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
#define device_create(cls, parent, devt, drvdata, fmt, ...) \
|
||||
({ \
|
||||
struct device *_dev; \
|
||||
_dev = (device_create)(cls, parent, devt, fmt, __VA_ARGS__); \
|
||||
dev_set_drvdata(_dev, drvdata); \
|
||||
_dev; \
|
||||
})
|
||||
|
||||
#define dev_name(dev) dev_name((struct device *)dev)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
#define dev_set_name LINUX_BACKPORT(dev_set_name)
|
||||
extern int dev_set_name(struct device *dev, const char *name, ...)
|
||||
__attribute__((format(printf, 2, 3)));
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0)
|
||||
static inline void
|
||||
backport_device_release_driver(struct device *dev)
|
||||
{
|
||||
device_release_driver(dev);
|
||||
device_lock(dev);
|
||||
dev_set_drvdata(dev, NULL);
|
||||
device_unlock(dev);
|
||||
}
|
||||
#define device_release_driver LINUX_BACKPORT(device_release_driver)
|
||||
#endif /* LINUX_VERSION_CODE <= KERNEL_VERSION(3,6,0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
|
||||
#define DEVICE_ATTR_RO(_name) \
|
||||
struct device_attribute dev_attr_ ## _name = __ATTR_RO(_name);
|
||||
#define DEVICE_ATTR_RW(_name) \
|
||||
struct device_attribute dev_attr_ ## _name = __ATTR_RW(_name)
|
||||
#endif
|
||||
|
||||
#define ATTRIBUTE_GROUPS_BACKPORT(_name) \
|
||||
static struct BP_ATTR_GRP_STRUCT _name##_dev_attrs[ARRAY_SIZE(_name##_attrs)];\
|
||||
static void init_##_name##_attrs(void) \
|
||||
{ \
|
||||
int i; \
|
||||
for (i = 0; _name##_attrs[i]; i++) \
|
||||
_name##_dev_attrs[i] = \
|
||||
*container_of(_name##_attrs[i], \
|
||||
struct BP_ATTR_GRP_STRUCT, \
|
||||
attr); \
|
||||
}
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
|
||||
#undef ATTRIBUTE_GROUPS
|
||||
#define ATTRIBUTE_GROUPS(_name) \
|
||||
static const struct attribute_group _name##_group = { \
|
||||
.attrs = _name##_attrs, \
|
||||
}; \
|
||||
static inline void init_##_name##_attrs(void) {} \
|
||||
__ATTRIBUTE_GROUPS(_name)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
|
||||
#define dev_get_platdata LINUX_BACKPORT(dev_get_platdata)
|
||||
static inline void *dev_get_platdata(const struct device *dev)
|
||||
{
|
||||
return dev->platform_data;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_DEVICE_H */
|
6
backport-include/linux/dma-attrs.h
Normal file
6
backport-include/linux/dma-attrs.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __BACKPORT_DMA_ATTR_H
|
||||
#define __BACKPORT_DMA_ATTR_H
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
|
||||
#include_next <linux/dma-attrs.h>
|
||||
#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26) */
|
||||
#endif /* __BACKPORT_DMA_ATTR_H */
|
109
backport-include/linux/dma-mapping.h
Normal file
109
backport-include/linux/dma-mapping.h
Normal file
@ -0,0 +1,109 @@
|
||||
#ifndef __BACKPORT_LINUX_DMA_MAPPING_H
|
||||
#define __BACKPORT_LINUX_DMA_MAPPING_H
|
||||
#include_next <linux/dma-mapping.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
|
||||
#define dma_zalloc_coherent LINUX_BACKPORT(dma_zalloc_coherent)
|
||||
static inline void *dma_zalloc_coherent(struct device *dev, size_t size,
|
||||
dma_addr_t *dma_handle, gfp_t flag)
|
||||
{
|
||||
void *ret = dma_alloc_coherent(dev, size, dma_handle, flag);
|
||||
if (ret)
|
||||
memset(ret, 0, size);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
/* only include this if DEFINE_DMA_UNMAP_ADDR is not set as debian squeeze also backports this */
|
||||
#ifndef DEFINE_DMA_UNMAP_ADDR
|
||||
#ifdef CONFIG_NEED_DMA_MAP_STATE
|
||||
#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME) dma_addr_t ADDR_NAME
|
||||
#define DEFINE_DMA_UNMAP_LEN(LEN_NAME) __u32 LEN_NAME
|
||||
#define dma_unmap_addr(PTR, ADDR_NAME) ((PTR)->ADDR_NAME)
|
||||
#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) (((PTR)->ADDR_NAME) = (VAL))
|
||||
#define dma_unmap_len(PTR, LEN_NAME) ((PTR)->LEN_NAME)
|
||||
#define dma_unmap_len_set(PTR, LEN_NAME, VAL) (((PTR)->LEN_NAME) = (VAL))
|
||||
#else
|
||||
#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
|
||||
#define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
|
||||
#define dma_unmap_addr(PTR, ADDR_NAME) (0)
|
||||
#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
|
||||
#define dma_unmap_len(PTR, LEN_NAME) (0)
|
||||
#define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* mask dma_set_coherent_mask as debian squeeze also backports this */
|
||||
#define dma_set_coherent_mask LINUX_BACKPORT(dma_set_coherent_mask)
|
||||
|
||||
static inline int dma_set_coherent_mask(struct device *dev, u64 mask)
|
||||
{
|
||||
if (!dma_supported(dev, mask))
|
||||
return -EIO;
|
||||
dev->coherent_dma_mask = mask;
|
||||
return 0;
|
||||
}
|
||||
#endif /* < 2.6.34 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
#include <backport/magic.h>
|
||||
/* These really belong to asm/dma-mapping.h but it doesn't really matter */
|
||||
/* On 2.6.27 a second argument was added, on older kernels we ignore it */
|
||||
static inline int dma_mapping_error1(dma_addr_t dma_addr)
|
||||
{
|
||||
/* use an inline to grab the old definition */
|
||||
return dma_mapping_error(dma_addr);
|
||||
}
|
||||
|
||||
#define dma_mapping_error2(pdef, dma_addr) \
|
||||
dma_mapping_error1(dma_addr)
|
||||
|
||||
#undef dma_mapping_error
|
||||
#define dma_mapping_error(...) \
|
||||
macro_dispatcher(dma_mapping_error, __VA_ARGS__)(__VA_ARGS__)
|
||||
|
||||
/* This kinda belongs into asm/dma-mapping.h or so, but doesn't matter */
|
||||
#ifdef CONFIG_ARM
|
||||
|
||||
/*
|
||||
* The caller asks to handle a range between offset and offset + size,
|
||||
* but we process a larger range from 0 to offset + size due to lack of
|
||||
* offset support.
|
||||
*/
|
||||
|
||||
static inline void dma_sync_single_range_for_cpu(struct device *dev,
|
||||
dma_addr_t handle, unsigned long offset, size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
dma_sync_single_for_cpu(dev, handle, offset + size, dir);
|
||||
}
|
||||
|
||||
static inline void dma_sync_single_range_for_device(struct device *dev,
|
||||
dma_addr_t handle, unsigned long offset, size_t size,
|
||||
enum dma_data_direction dir)
|
||||
{
|
||||
dma_sync_single_for_device(dev, handle, offset + size, dir);
|
||||
}
|
||||
|
||||
#endif /* arm */
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
|
||||
/*
|
||||
* Set both the DMA mask and the coherent DMA mask to the same thing.
|
||||
* Note that we don't check the return value from dma_set_coherent_mask()
|
||||
* as the DMA API guarantees that the coherent DMA mask can be set to
|
||||
* the same or smaller than the streaming DMA mask.
|
||||
*/
|
||||
static inline int dma_set_mask_and_coherent(struct device *dev, u64 mask)
|
||||
{
|
||||
int rc = dma_set_mask(dev, mask);
|
||||
if (rc == 0)
|
||||
dma_set_coherent_mask(dev, mask);
|
||||
return rc;
|
||||
}
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_DMA_MAPPING_H */
|
38
backport-include/linux/dynamic_debug.h
Normal file
38
backport-include/linux/dynamic_debug.h
Normal file
@ -0,0 +1,38 @@
|
||||
#ifndef __BACKPORT_LINUX_DYNAMIC_DEBUG_H
|
||||
#define __BACKPORT_LINUX_DYNAMIC_DEBUG_H
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
|
||||
#include_next <linux/dynamic_debug.h>
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,2,0)
|
||||
/* backports 07613b0b */
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4))
|
||||
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
|
||||
static struct _ddebug __used __aligned(8) \
|
||||
__attribute__((section("__verbose"))) name = { \
|
||||
.modname = KBUILD_MODNAME, \
|
||||
.function = __func__, \
|
||||
.filename = __FILE__, \
|
||||
.format = (fmt), \
|
||||
.lineno = __LINE__, \
|
||||
.flags = _DPRINTK_FLAGS_DEFAULT, \
|
||||
.enabled = false, \
|
||||
}
|
||||
#else
|
||||
#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \
|
||||
static struct _ddebug __used __aligned(8) \
|
||||
__attribute__((section("__verbose"))) name = { \
|
||||
.modname = KBUILD_MODNAME, \
|
||||
.function = __func__, \
|
||||
.filename = __FILE__, \
|
||||
.format = (fmt), \
|
||||
.lineno = __LINE__, \
|
||||
.flags = _DPRINTK_FLAGS_DEFAULT, \
|
||||
}
|
||||
#endif /* RHEL_RELEASE_CODE < 6.4 */
|
||||
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
|
||||
#endif /* < 3.2 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_DYNAMIC_DEBUG_H */
|
10
backport-include/linux/eeprom_93cx6.h
Normal file
10
backport-include/linux/eeprom_93cx6.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _COMPAT_LINUX_EEPROM_93CX6_H
|
||||
#define _COMPAT_LINUX_EEPROM_93CX6_H 1
|
||||
|
||||
#include_next <linux/eeprom_93cx6.h>
|
||||
|
||||
#ifndef PCI_EEPROM_WIDTH_93C86
|
||||
#define PCI_EEPROM_WIDTH_93C86 8
|
||||
#endif /* PCI_EEPROM_WIDTH_93C86 */
|
||||
|
||||
#endif /* _COMPAT_LINUX_EEPROM_93CX6_H */
|
31
backport-include/linux/err.h
Normal file
31
backport-include/linux/err.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef __BACKPORT_LINUX_ERR_H
|
||||
#define __BACKPORT_LINUX_ERR_H
|
||||
#include_next <linux/err.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
|
||||
#define PTR_RET LINUX_BACKPORT(PTR_RET)
|
||||
static inline int __must_check PTR_RET(const void *ptr)
|
||||
{
|
||||
if (IS_ERR(ptr))
|
||||
return PTR_ERR(ptr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
|
||||
/* mask IS_ERR_OR_NULL as debian squeeze also backports this */
|
||||
#define IS_ERR_OR_NULL LINUX_BACKPORT(IS_ERR_OR_NULL)
|
||||
|
||||
static inline long __must_check IS_ERR_OR_NULL(const void *ptr)
|
||||
{
|
||||
return !ptr || IS_ERR_VALUE((unsigned long)ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
|
||||
#define PTR_ERR_OR_ZERO(p) PTR_RET(p)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_ERR_H */
|
161
backport-include/linux/etherdevice.h
Normal file
161
backport-include/linux/etherdevice.h
Normal file
@ -0,0 +1,161 @@
|
||||
#ifndef _BACKPORT_LINUX_ETHERDEVICE_H
|
||||
#define _BACKPORT_LINUX_ETHERDEVICE_H
|
||||
#include_next <linux/etherdevice.h>
|
||||
#include <linux/version.h>
|
||||
/*
|
||||
* newer kernels include this already and some
|
||||
* users rely on getting this indirectly
|
||||
*/
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
|
||||
#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random)
|
||||
static inline void eth_hw_addr_random(struct net_device *dev)
|
||||
{
|
||||
#error eth_hw_addr_random() needs to be implemented for < 2.6.12
|
||||
}
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
|
||||
#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random)
|
||||
static inline void eth_hw_addr_random(struct net_device *dev)
|
||||
{
|
||||
get_random_bytes(dev->dev_addr, ETH_ALEN);
|
||||
dev->dev_addr[0] &= 0xfe; /* clear multicast bit */
|
||||
dev->dev_addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
|
||||
}
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
|
||||
/* So this is 2.6.31..2.6.35 */
|
||||
|
||||
/* Just have the flags present, they won't really mean anything though */
|
||||
#define NET_ADDR_PERM 0 /* address is permanent (default) */
|
||||
#define NET_ADDR_RANDOM 1 /* address is generated randomly */
|
||||
#define NET_ADDR_STOLEN 2 /* address is stolen from other device */
|
||||
|
||||
#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random)
|
||||
static inline void eth_hw_addr_random(struct net_device *dev)
|
||||
{
|
||||
random_ether_addr(dev->dev_addr);
|
||||
}
|
||||
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0)
|
||||
#define eth_hw_addr_random LINUX_BACKPORT(eth_hw_addr_random)
|
||||
static inline void eth_hw_addr_random(struct net_device *dev)
|
||||
{
|
||||
dev->addr_assign_type |= NET_ADDR_RANDOM;
|
||||
random_ether_addr(dev->dev_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
|
||||
#include <linux/random.h>
|
||||
/**
|
||||
* eth_broadcast_addr - Assign broadcast address
|
||||
* @addr: Pointer to a six-byte array containing the Ethernet address
|
||||
*
|
||||
* Assign the broadcast address to the given address array.
|
||||
*/
|
||||
#define eth_broadcast_addr LINUX_BACKPORT(eth_broadcast_addr)
|
||||
static inline void eth_broadcast_addr(u8 *addr)
|
||||
{
|
||||
memset(addr, 0xff, ETH_ALEN);
|
||||
}
|
||||
|
||||
/**
|
||||
* eth_random_addr - Generate software assigned random Ethernet address
|
||||
* @addr: Pointer to a six-byte array containing the Ethernet address
|
||||
*
|
||||
* Generate a random Ethernet address (MAC) that is not multicast
|
||||
* and has the local assigned bit set.
|
||||
*/
|
||||
#define eth_random_addr LINUX_BACKPORT(eth_random_addr)
|
||||
static inline void eth_random_addr(u8 *addr)
|
||||
{
|
||||
get_random_bytes(addr, ETH_ALEN);
|
||||
addr[0] &= 0xfe; /* clear multicast bit */
|
||||
addr[0] |= 0x02; /* set local assignment bit (IEEE802) */
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 6d57e9078e880a3dd232d579f42ac437a8f1ef7b
|
||||
* Author: Duan Jiong <djduanjiong@gmail.com>
|
||||
* Date: Sat Sep 8 16:32:28 2012 +0000
|
||||
*
|
||||
* etherdevice: introduce help function eth_zero_addr()
|
||||
*/
|
||||
#define eth_zero_addr LINUX_BACKPORT(eth_zero_addr)
|
||||
static inline void eth_zero_addr(u8 *addr)
|
||||
{
|
||||
memset(addr, 0x00, ETH_ALEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0)
|
||||
#define ether_addr_equal LINUX_BACKPORT(ether_addr_equal)
|
||||
static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
|
||||
{
|
||||
return !compare_ether_addr(addr1, addr2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
#define alloc_etherdev_mqs(sizeof_priv, tx_q, rx_q) alloc_etherdev_mq(sizeof_priv, tx_q)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
/**
|
||||
* is_unicast_ether_addr - Determine if the Ethernet address is unicast
|
||||
* @addr: Pointer to a six-byte array containing the Ethernet address
|
||||
*
|
||||
* Return true if the address is a unicast address.
|
||||
*/
|
||||
#define is_unicast_ether_addr LINUX_BACKPORT(is_unicast_ether_addr)
|
||||
static inline int is_unicast_ether_addr(const u8 *addr)
|
||||
{
|
||||
return !is_multicast_ether_addr(addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
#define eth_prepare_mac_addr_change LINUX_BACKPORT(eth_prepare_mac_addr_change)
|
||||
extern int eth_prepare_mac_addr_change(struct net_device *dev, void *p);
|
||||
|
||||
#define eth_commit_mac_addr_change LINUX_BACKPORT(eth_commit_mac_addr_change)
|
||||
extern void eth_commit_mac_addr_change(struct net_device *dev, void *p);
|
||||
#endif /* < 3.9 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||
#define eth_mac_addr LINUX_BACKPORT(eth_mac_addr)
|
||||
extern int eth_mac_addr(struct net_device *dev, void *p);
|
||||
#define eth_change_mtu LINUX_BACKPORT(eth_change_mtu)
|
||||
extern int eth_change_mtu(struct net_device *dev, int new_mtu);
|
||||
#define eth_validate_addr LINUX_BACKPORT(eth_validate_addr)
|
||||
extern int eth_validate_addr(struct net_device *dev);
|
||||
#endif /* < 2.6.29 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define netdev_hw_addr dev_mc_list
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
|
||||
/**
|
||||
* eth_hw_addr_inherit - Copy dev_addr from another net_device
|
||||
* @dst: pointer to net_device to copy dev_addr to
|
||||
* @src: pointer to net_device to copy dev_addr from
|
||||
*
|
||||
* Copy the Ethernet address from one net_device to another along with
|
||||
* the address attributes (addr_assign_type).
|
||||
*/
|
||||
static inline void eth_hw_addr_inherit(struct net_device *dst,
|
||||
struct net_device *src)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
|
||||
dst->addr_assign_type = src->addr_assign_type;
|
||||
#endif
|
||||
memcpy(dst->dev_addr, src->dev_addr, ETH_ALEN);
|
||||
}
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0) */
|
||||
|
||||
#endif /* _BACKPORT_LINUX_ETHERDEVICE_H */
|
45
backport-include/linux/ethtool.h
Normal file
45
backport-include/linux/ethtool.h
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef __BACKPORT_LINUX_ETHTOOL_H
|
||||
#define __BACKPORT_LINUX_ETHTOOL_H
|
||||
#include_next <linux/ethtool.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifndef SPEED_UNKNOWN
|
||||
#define SPEED_UNKNOWN -1
|
||||
#endif /* SPEED_UNKNOWN */
|
||||
|
||||
#ifndef DUPLEX_UNKNOWN
|
||||
#define DUPLEX_UNKNOWN 0xff
|
||||
#endif /* DUPLEX_UNKNOWN */
|
||||
|
||||
#ifndef ETHTOOL_FWVERS_LEN
|
||||
#define ETHTOOL_FWVERS_LEN 32
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
|
||||
#define SUPPORTED_Backplane (1 << 16)
|
||||
#define SUPPORTED_1000baseKX_Full (1 << 17)
|
||||
#define SUPPORTED_10000baseKX4_Full (1 << 18)
|
||||
#define SUPPORTED_10000baseKR_Full (1 << 19)
|
||||
#define SUPPORTED_10000baseR_FEC (1 << 20)
|
||||
|
||||
#define ADVERTISED_Backplane (1 << 16)
|
||||
#define ADVERTISED_1000baseKX_Full (1 << 17)
|
||||
#define ADVERTISED_10000baseKX4_Full (1 << 18)
|
||||
#define ADVERTISED_10000baseKR_Full (1 << 19)
|
||||
#define ADVERTISED_10000baseR_FEC (1 << 20)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
|
||||
__u32 speed)
|
||||
{
|
||||
ep->speed = (__u16)speed;
|
||||
}
|
||||
|
||||
static inline __u32 ethtool_cmd_speed(const struct ethtool_cmd *ep)
|
||||
{
|
||||
return ep->speed;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_ETHTOOL_H */
|
19
backport-include/linux/export.h
Normal file
19
backport-include/linux/export.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _COMPAT_LINUX_EXPORT_H
|
||||
#define _COMPAT_LINUX_EXPORT_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
|
||||
#include_next <linux/export.h>
|
||||
#else
|
||||
#ifndef pr_fmt
|
||||
#define backport_undef_pr_fmt
|
||||
#endif
|
||||
#include <linux/module.h>
|
||||
#ifdef backport_undef_pr_fmt
|
||||
#undef pr_fmt
|
||||
#undef backport_undef_pr_fmt
|
||||
#endif
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
|
||||
|
||||
#endif /* _COMPAT_LINUX_EXPORT_H */
|
29
backport-include/linux/firmware.h
Normal file
29
backport-include/linux/firmware.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef __BACKPORT_LINUX_FIRMWARE_H
|
||||
#define __BACKPORT_LINUX_FIRMWARE_H
|
||||
#include_next <linux/firmware.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if defined(CPTCFG_BACKPORT_BUILD_FW_LOADER_MODULE)
|
||||
#define request_firmware_nowait LINUX_BACKPORT(request_firmware_nowait)
|
||||
#define request_firmware LINUX_BACKPORT(request_firmware)
|
||||
#define release_firmware LINUX_BACKPORT(release_firmware)
|
||||
|
||||
int request_firmware(const struct firmware **fw, const char *name,
|
||||
struct device *device);
|
||||
int request_firmware_nowait(
|
||||
struct module *module, int uevent,
|
||||
const char *name, struct device *device, gfp_t gfp, void *context,
|
||||
void (*cont)(const struct firmware *fw, void *context));
|
||||
|
||||
void release_firmware(const struct firmware *fw);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
struct builtin_fw {
|
||||
char *name;
|
||||
void *data;
|
||||
unsigned long size;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_FIRMWARE_H */
|
55
backport-include/linux/fs.h
Normal file
55
backport-include/linux/fs.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef _COMPAT_LINUX_FS_H
|
||||
#define _COMPAT_LINUX_FS_H
|
||||
#include_next <linux/fs.h>
|
||||
#include <linux/version.h>
|
||||
/*
|
||||
* some versions don't have this and thus don't
|
||||
* include it from the original fs.h
|
||||
*/
|
||||
#include <linux/uidgid.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0))
|
||||
#define simple_open LINUX_BACKPORT(simple_open)
|
||||
extern int simple_open(struct inode *inode, struct file *file);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
/**
|
||||
* backport of:
|
||||
*
|
||||
* commit 496ad9aa8ef448058e36ca7a787c61f2e63f0f54
|
||||
* Author: Al Viro <viro@zeniv.linux.org.uk>
|
||||
* Date: Wed Jan 23 17:07:38 2013 -0500
|
||||
*
|
||||
* new helper: file_inode(file)
|
||||
*/
|
||||
static inline struct inode *file_inode(struct file *f)
|
||||
{
|
||||
return f->f_path.dentry->d_inode;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define noop_llseek LINUX_BACKPORT(noop_llseek)
|
||||
extern loff_t noop_llseek(struct file *file, loff_t offset, int origin);
|
||||
|
||||
#define simple_write_to_buffer LINUX_BACKPORT(simple_write_to_buffer)
|
||||
extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
|
||||
const void __user *from, size_t count);
|
||||
#endif
|
||||
|
||||
#ifndef replace_fops
|
||||
/*
|
||||
* This one is to be used *ONLY* from ->open() instances.
|
||||
* fops must be non-NULL, pinned down *and* module dependencies
|
||||
* should be sufficient to pin the caller down as well.
|
||||
*/
|
||||
#define replace_fops(f, fops) \
|
||||
do { \
|
||||
struct file *__file = (f); \
|
||||
fops_put(__file->f_op); \
|
||||
BUG_ON(!(__file->f_op = (fops))); \
|
||||
} while(0)
|
||||
#endif /* replace_fops */
|
||||
|
||||
#endif /* _COMPAT_LINUX_FS_H */
|
18
backport-include/linux/genetlink.h
Normal file
18
backport-include/linux/genetlink.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef __BACKPORT_LINUX_GENETLINK_H
|
||||
#define __BACKPORT_LINUX_GENETLINK_H
|
||||
#include_next <linux/genetlink.h>
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit e9412c37082b5c932e83364aaed0c38c2ce33acb
|
||||
* Author: Neil Horman <nhorman@tuxdriver.com>
|
||||
* Date: Tue May 29 09:30:41 2012 +0000
|
||||
*
|
||||
* genetlink: Build a generic netlink family module alias
|
||||
*/
|
||||
#ifndef MODULE_ALIAS_GENL_FAMILY
|
||||
#define MODULE_ALIAS_GENL_FAMILY(family)\
|
||||
MODULE_ALIAS_NET_PF_PROTO_NAME(PF_NETLINK, NETLINK_GENERIC, "-family-" family)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_GENETLINK_H */
|
87
backport-include/linux/hid.h
Normal file
87
backport-include/linux/hid.h
Normal file
@ -0,0 +1,87 @@
|
||||
#ifndef __BACKPORT_HID_H
|
||||
#define __BACKPORT_HID_H
|
||||
#include_next <linux/hid.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||
#define hid_ignore LINUX_BACKPORT(hid_ignore)
|
||||
extern bool hid_ignore(struct hid_device *);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
|
||||
#define HID_TYPE_USBNONE 2
|
||||
#endif
|
||||
|
||||
#ifndef HID_QUIRK_NO_IGNORE
|
||||
#define HID_QUIRK_NO_IGNORE 0x40000000
|
||||
#endif
|
||||
|
||||
#ifndef HID_QUIRK_HIDDEV_FORCE
|
||||
#define HID_QUIRK_HIDDEV_FORCE 0x00000010
|
||||
#endif
|
||||
|
||||
#ifndef HID_QUIRK_IGNORE
|
||||
#define HID_QUIRK_IGNORE 0x00000004
|
||||
#endif
|
||||
|
||||
#ifndef HID_USB_DEVICE
|
||||
#define HID_USB_DEVICE(ven, prod) \
|
||||
.bus = BUS_USB, .vendor = (ven), .product = (prod)
|
||||
#endif
|
||||
|
||||
#ifndef HID_BLUETOOTH_DEVICE
|
||||
#define HID_BLUETOOTH_DEVICE(ven, prod) \
|
||||
.bus = BUS_BLUETOOTH, .vendor = (ven), .product = (prod)
|
||||
#endif
|
||||
|
||||
#ifndef hid_printk
|
||||
#define hid_printk(level, hid, fmt, arg...) \
|
||||
dev_printk(level, &(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_emerg
|
||||
#define hid_emerg(hid, fmt, arg...) \
|
||||
dev_emerg(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_crit
|
||||
#define hid_crit(hid, fmt, arg...) \
|
||||
dev_crit(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_alert
|
||||
#define hid_alert(hid, fmt, arg...) \
|
||||
dev_alert(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_err
|
||||
#define hid_err(hid, fmt, arg...) \
|
||||
dev_err(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_notice
|
||||
#define hid_notice(hid, fmt, arg...) \
|
||||
dev_notice(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_warn
|
||||
#define hid_warn(hid, fmt, arg...) \
|
||||
dev_warn(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_info
|
||||
#define hid_info(hid, fmt, arg...) \
|
||||
dev_info(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#ifndef hid_dbg
|
||||
#define hid_dbg(hid, fmt, arg...) \
|
||||
dev_dbg(&(hid)->dev, fmt, ##arg)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,12,0)
|
||||
#define hid_alloc_report_buf LINUX_BACKPORT(hid_alloc_report_buf)
|
||||
u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags);
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_HID_H */
|
41
backport-include/linux/i2c.h
Normal file
41
backport-include/linux/i2c.h
Normal file
@ -0,0 +1,41 @@
|
||||
#ifndef __BACKPORT_LINUX_I2C_H
|
||||
#define __BACKPORT_LINUX_I2C_H
|
||||
#include_next <linux/i2c.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0) && \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
|
||||
#include <linux/i2c.h>
|
||||
/* Unlocked flavor */
|
||||
#define __i2c_transfer LINUX_BACKPORT(__i2c_transfer)
|
||||
extern int __i2c_transfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
|
||||
int num);
|
||||
#endif
|
||||
|
||||
/* This backports
|
||||
*
|
||||
* commit 14674e70119ea01549ce593d8901a797f8a90f74
|
||||
* Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
|
||||
* Date: Wed May 30 10:55:34 2012 +0200
|
||||
*
|
||||
* i2c: Split I2C_M_NOSTART support out of I2C_FUNC_PROTOCOL_MANGLING
|
||||
*/
|
||||
#ifndef I2C_FUNC_NOSTART
|
||||
#define I2C_FUNC_NOSTART 0x00000010 /* I2C_M_NOSTART */
|
||||
#endif
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 7c92784a546d2945b6d6973a30f7134be78eb7a4
|
||||
* Author: Lars-Peter Clausen <lars@metafoo.de>
|
||||
* Date: Wed Nov 16 10:13:36 2011 +0100
|
||||
*
|
||||
* I2C: Add helper macro for i2c_driver boilerplate
|
||||
*/
|
||||
#ifndef module_i2c_driver
|
||||
#define module_i2c_driver(__i2c_driver) \
|
||||
module_driver(__i2c_driver, i2c_add_driver, \
|
||||
i2c_del_driver)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_I2C_H */
|
59
backport-include/linux/idr.h
Normal file
59
backport-include/linux/idr.h
Normal file
@ -0,0 +1,59 @@
|
||||
#ifndef __BACKPORT_IDR_H
|
||||
#define __BACKPORT_IDR_H
|
||||
/* some versions have a broken idr header */
|
||||
#include <linux/spinlock.h>
|
||||
#include_next <linux/idr.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,1,0)
|
||||
#define ida_simple_get LINUX_BACKPORT(ida_simple_get)
|
||||
int ida_simple_get(struct ida *ida, unsigned int start, unsigned int end,
|
||||
gfp_t gfp_mask);
|
||||
|
||||
#define ida_simple_remove LINUX_BACKPORT(ida_simple_remove)
|
||||
void ida_simple_remove(struct ida *ida, unsigned int id);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
#include <linux/errno.h>
|
||||
/**
|
||||
* backport of idr idr_alloc() usage
|
||||
*
|
||||
* This backports a patch series send by Tejun Heo:
|
||||
* https://lkml.org/lkml/2013/2/2/159
|
||||
*/
|
||||
static inline void compat_idr_destroy(struct idr *idp)
|
||||
{
|
||||
idr_remove_all(idp);
|
||||
idr_destroy(idp);
|
||||
}
|
||||
#define idr_destroy(idp) compat_idr_destroy(idp)
|
||||
|
||||
static inline int idr_alloc(struct idr *idr, void *ptr, int start, int end,
|
||||
gfp_t gfp_mask)
|
||||
{
|
||||
int id, ret;
|
||||
|
||||
do {
|
||||
if (!idr_pre_get(idr, gfp_mask))
|
||||
return -ENOMEM;
|
||||
ret = idr_get_new_above(idr, ptr, start, &id);
|
||||
if (!ret && id > end) {
|
||||
idr_remove(idr, id);
|
||||
ret = -ENOSPC;
|
||||
}
|
||||
} while (ret == -EAGAIN);
|
||||
|
||||
return ret ? ret : id;
|
||||
}
|
||||
|
||||
static inline void idr_preload(gfp_t gfp_mask)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void idr_preload_end(void)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_IDR_H */
|
36
backport-include/linux/if.h
Normal file
36
backport-include/linux/if.h
Normal file
@ -0,0 +1,36 @@
|
||||
#ifndef _BACKPORT_LINUX_IF_H
|
||||
#define _BACKPORT_LINUX_IF_H
|
||||
#include_next <linux/if.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/* mask IFF_DONT_BRIDGE as RHEL6 backports this */
|
||||
#if !defined(IFF_DONT_BRIDGE)
|
||||
#define IFF_DONT_BRIDGE 0x800 /* disallow bridging this ether dev */
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36))
|
||||
#define br_port_exists(dev) (dev->br_port)
|
||||
#else
|
||||
/*
|
||||
* This is not part of The 2.6.37 kernel yet but we
|
||||
* we use it to optimize the backport code we
|
||||
* need to implement. Instead of using ifdefs
|
||||
* to check what version of the check we use
|
||||
* we just replace all checks on current code
|
||||
* with this. I'll submit this upstream too, that
|
||||
* way all we'd have to do is to implement this
|
||||
* for older kernels, then we would not have to
|
||||
* edit the upstrema code for backport efforts.
|
||||
*/
|
||||
#define br_port_exists(dev) (dev->priv_flags & IFF_BRIDGE_PORT)
|
||||
#endif
|
||||
|
||||
#ifndef IFF_TX_SKB_SHARING
|
||||
#define IFF_TX_SKB_SHARING 0x10000
|
||||
#endif
|
||||
|
||||
#ifndef IFF_LIVE_ADDR_CHANGE
|
||||
#define IFF_LIVE_ADDR_CHANGE 0x100000
|
||||
#endif
|
||||
|
||||
#endif /* _BACKPORT_LINUX_IF_H */
|
10
backport-include/linux/if_arp.h
Normal file
10
backport-include/linux/if_arp.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _BACKPORTS_LINUX_AF_ARP_H
|
||||
#define _BACKPORTS_LINUX_AF_ARP_H 1
|
||||
|
||||
#include_next <linux/if_arp.h>
|
||||
|
||||
#ifndef ARPHRD_IEEE802154_MONITOR
|
||||
#define ARPHRD_IEEE802154_MONITOR 805 /* IEEE 802.15.4 network monitor */
|
||||
#endif
|
||||
|
||||
#endif /* _BACKPORTS_LINUX_AF_ARP_H */
|
34
backport-include/linux/if_ether.h
Normal file
34
backport-include/linux/if_ether.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef __BACKPORT_IF_ETHER_H
|
||||
#define __BACKPORT_IF_ETHER_H
|
||||
#include_next <linux/if_ether.h>
|
||||
|
||||
/*
|
||||
* backport of:
|
||||
* commit e5c5d22e8dcf7c2d430336cbf8e180bd38e8daf1
|
||||
* Author: Simon Horman <horms@verge.net.au>
|
||||
* Date: Thu Mar 28 13:38:25 2013 +0900
|
||||
*
|
||||
* net: add ETH_P_802_3_MIN
|
||||
*/
|
||||
#ifndef ETH_P_802_3_MIN
|
||||
#define ETH_P_802_3_MIN 0x0600
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_TDLS
|
||||
#define ETH_P_TDLS 0x890D /* TDLS */
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_LINK_CTL
|
||||
#define ETH_P_LINK_CTL 0x886c
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
||||
#define mac_pton LINUX_BACKPORT(mac_pton)
|
||||
int mac_pton(const char *s, u8 *mac);
|
||||
#endif
|
||||
|
||||
#ifndef ETH_P_PAE
|
||||
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_IF_ETHER_H */
|
23
backport-include/linux/if_vlan.h
Normal file
23
backport-include/linux/if_vlan.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef __BACKPORT_LINUX_IF_VLAN_H_
|
||||
#define __BACKPORT_LINUX_IF_VLAN_H_
|
||||
#include_next <linux/if_vlan.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
|
||||
#define vlan_insert_tag(__skb, __vlan_proto, __vlan_tci) vlan_insert_tag(__skb, __vlan_tci)
|
||||
#define __vlan_put_tag(__skb, __vlan_proto, __vlan_tci) __vlan_put_tag(__skb, __vlan_tci)
|
||||
#define vlan_put_tag(__skb, __vlan_proto, __vlan_tci) vlan_put_tag(__skb, __vlan_tci)
|
||||
#define __vlan_hwaccel_put_tag(__skb, __vlan_proto, __vlan_tag) __vlan_hwaccel_put_tag(__skb, __vlan_tag)
|
||||
|
||||
#define __vlan_find_dev_deep(__real_dev, __vlan_proto, __vlan_id) __vlan_find_dev_deep(__real_dev, __vlan_id)
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef VLAN_PRIO_MASK
|
||||
#define VLAN_PRIO_MASK 0xe000 /* Priority Code Point */
|
||||
#endif
|
||||
|
||||
#ifndef VLAN_PRIO_SHIFT
|
||||
#define VLAN_PRIO_SHIFT 13
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_IF_VLAN_H_ */
|
25
backport-include/linux/in.h
Normal file
25
backport-include/linux/in.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef __BACKPORT_IN_H
|
||||
#define __BACKPORT_IN_H
|
||||
#include_next <linux/in.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
|
||||
static inline int proto_ports_offset(int proto)
|
||||
{
|
||||
switch (proto) {
|
||||
case IPPROTO_TCP:
|
||||
case IPPROTO_UDP:
|
||||
case IPPROTO_DCCP:
|
||||
case IPPROTO_ESP: /* SPI */
|
||||
case IPPROTO_SCTP:
|
||||
case IPPROTO_UDPLITE:
|
||||
return 0;
|
||||
case IPPROTO_AH: /* SPI */
|
||||
return 4;
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_IN_H */
|
19
backport-include/linux/init.h
Normal file
19
backport-include/linux/init.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef __BACKPORT_INIT_H
|
||||
#define __BACKPORT_INIT_H
|
||||
#include_next <linux/init.h>
|
||||
|
||||
/*
|
||||
* Backports 312b1485fb509c9bc32eda28ad29537896658cb8
|
||||
* Author: Sam Ravnborg <sam@ravnborg.org>
|
||||
* Date: Mon Jan 28 20:21:15 2008 +0100
|
||||
*
|
||||
* Introduce new section reference annotations tags: __ref, __refdata, __refconst
|
||||
*/
|
||||
#ifndef __ref
|
||||
#define __ref __init_refok
|
||||
#endif
|
||||
#ifndef __refdata
|
||||
#define __refdata __initdata_refok
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_INIT_H */
|
21
backport-include/linux/input.h
Normal file
21
backport-include/linux/input.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __BACKPORT_INPUT_H
|
||||
#define __BACKPORT_INPUT_H
|
||||
#include_next <linux/input.h>
|
||||
|
||||
#ifndef KEY_WIMAX
|
||||
#define KEY_WIMAX 246
|
||||
#endif
|
||||
|
||||
#ifndef KEY_WPS_BUTTON
|
||||
#define KEY_WPS_BUTTON 0x211
|
||||
#endif
|
||||
|
||||
#ifndef KEY_RFKILL
|
||||
#define KEY_RFKILL 247
|
||||
#endif
|
||||
|
||||
#ifndef SW_RFKILL_ALL
|
||||
#define SW_RFKILL_ALL 0x03
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_INPUT_H */
|
100
backport-include/linux/interrupt.h
Normal file
100
backport-include/linux/interrupt.h
Normal file
@ -0,0 +1,100 @@
|
||||
#ifndef __BACKPORT_LINUX_INTERRUPT_H
|
||||
#define __BACKPORT_LINUX_INTERRUPT_H
|
||||
#include_next <linux/interrupt.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
|
||||
static inline int irq_set_irq_wake(unsigned int irq, unsigned int on)
|
||||
{
|
||||
return set_irq_wake(irq, on);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||
#define IRQ_WAKE_THREAD (2)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
|
||||
struct compat_threaded_irq {
|
||||
unsigned int irq;
|
||||
irq_handler_t handler;
|
||||
irq_handler_t thread_fn;
|
||||
void *dev_id;
|
||||
char wq_name[64];
|
||||
struct workqueue_struct *wq;
|
||||
struct work_struct work;
|
||||
};
|
||||
|
||||
static inline
|
||||
void compat_irq_work(struct work_struct *work)
|
||||
{
|
||||
struct compat_threaded_irq *comp = container_of(work, struct compat_threaded_irq, work);
|
||||
comp->thread_fn(comp->irq, comp->dev_id);
|
||||
}
|
||||
|
||||
static inline
|
||||
irqreturn_t compat_irq_dispatcher(int irq, void *dev_id)
|
||||
{
|
||||
struct compat_threaded_irq *comp = dev_id;
|
||||
irqreturn_t res;
|
||||
|
||||
res = comp->handler(irq, comp->dev_id);
|
||||
if (res == IRQ_WAKE_THREAD) {
|
||||
queue_work(comp->wq, &comp->work);
|
||||
res = IRQ_HANDLED;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline
|
||||
int compat_request_threaded_irq(struct compat_threaded_irq *comp,
|
||||
unsigned int irq,
|
||||
irq_handler_t handler,
|
||||
irq_handler_t thread_fn,
|
||||
unsigned long flags,
|
||||
const char *name,
|
||||
void *dev_id)
|
||||
{
|
||||
comp->irq = irq;
|
||||
comp->handler = handler;
|
||||
comp->thread_fn = thread_fn;
|
||||
comp->dev_id = dev_id;
|
||||
INIT_WORK(&comp->work, compat_irq_work);
|
||||
|
||||
if (!comp->wq) {
|
||||
snprintf(comp->wq_name, sizeof(comp->wq_name),
|
||||
"compirq/%u-%s", irq, name);
|
||||
comp->wq = create_singlethread_workqueue(comp->wq_name);
|
||||
if (!comp->wq) {
|
||||
printk(KERN_ERR "Failed to create compat-threaded-IRQ workqueue %s\n",
|
||||
comp->wq_name);
|
||||
return -ENOMEM;
|
||||
}
|
||||
}
|
||||
return request_irq(irq, compat_irq_dispatcher, flags, name, comp);
|
||||
}
|
||||
|
||||
static inline
|
||||
void compat_free_threaded_irq(struct compat_threaded_irq *comp)
|
||||
{
|
||||
free_irq(comp->irq, comp);
|
||||
}
|
||||
|
||||
static inline
|
||||
void compat_destroy_threaded_irq(struct compat_threaded_irq *comp)
|
||||
{
|
||||
if (comp->wq)
|
||||
destroy_workqueue(comp->wq);
|
||||
comp->wq = NULL;
|
||||
}
|
||||
|
||||
static inline
|
||||
void compat_synchronize_threaded_irq(struct compat_threaded_irq *comp)
|
||||
{
|
||||
synchronize_irq(comp->irq);
|
||||
cancel_work_sync(&comp->work);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_INTERRUPT_H */
|
16
backport-include/linux/ioport.h
Normal file
16
backport-include/linux/ioport.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef __BACKPORT_LINUX_IOPORT_H
|
||||
#define __BACKPORT_LINUX_IOPORT_H
|
||||
#include_next <linux/ioport.h>
|
||||
|
||||
#ifndef IORESOURCE_REG
|
||||
#define IORESOURCE_REG 0x00000300
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
static inline resource_size_t resource_size(const struct resource *res)
|
||||
{
|
||||
return res->end - res->start + 1;
|
||||
}
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_IOPORT_H */
|
85
backport-include/linux/irq.h
Normal file
85
backport-include/linux/irq.h
Normal file
@ -0,0 +1,85 @@
|
||||
#ifndef __BACKPORT_LINUX_IRQ_H
|
||||
#define __BACKPORT_LINUX_IRQ_H
|
||||
#include_next <linux/irq.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
|
||||
static inline int irq_set_chip(unsigned int irq, struct irq_chip *chip)
|
||||
{
|
||||
return set_irq_chip(irq, chip);
|
||||
}
|
||||
static inline int irq_set_handler_data(unsigned int irq, void *data)
|
||||
{
|
||||
return set_irq_data(irq, data);
|
||||
}
|
||||
static inline int irq_set_chip_data(unsigned int irq, void *data)
|
||||
{
|
||||
return set_irq_chip_data(irq, data);
|
||||
}
|
||||
#ifndef irq_set_irq_type
|
||||
static inline int irq_set_irq_type(unsigned int irq, unsigned int type)
|
||||
{
|
||||
return set_irq_type(irq, type);
|
||||
}
|
||||
#endif
|
||||
static inline int irq_set_msi_desc(unsigned int irq, struct msi_desc *entry)
|
||||
{
|
||||
return set_irq_msi(irq, entry);
|
||||
}
|
||||
static inline struct irq_chip *irq_get_chip(unsigned int irq)
|
||||
{
|
||||
return get_irq_chip(irq);
|
||||
}
|
||||
static inline void *irq_get_chip_data(unsigned int irq)
|
||||
{
|
||||
return get_irq_chip_data(irq);
|
||||
}
|
||||
static inline void *irq_get_handler_data(unsigned int irq)
|
||||
{
|
||||
return get_irq_data(irq);
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37))
|
||||
static inline void *irq_data_get_irq_handler_data(struct irq_data *d)
|
||||
{
|
||||
return irq_data_get_irq_data(d);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline struct msi_desc *irq_get_msi_desc(unsigned int irq)
|
||||
{
|
||||
return get_irq_msi(irq);
|
||||
}
|
||||
|
||||
static inline void irq_set_noprobe(unsigned int irq)
|
||||
{
|
||||
set_irq_noprobe(irq);
|
||||
}
|
||||
static inline void irq_set_probe(unsigned int irq)
|
||||
{
|
||||
set_irq_probe(irq);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This is really in irqdesc.h, but nothing includes that directly */
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
|
||||
static inline struct irq_chip *irq_desc_get_chip(struct irq_desc *desc)
|
||||
{
|
||||
return get_irq_desc_chip(desc);
|
||||
}
|
||||
static inline void *irq_desc_get_handler_data(struct irq_desc *desc)
|
||||
{
|
||||
return get_irq_desc_data(desc);
|
||||
}
|
||||
static inline void *irq_desc_get_chip_data(struct irq_desc *desc)
|
||||
{
|
||||
return get_irq_desc_chip_data(desc);
|
||||
}
|
||||
static inline struct msi_desc *irq_desc_get_msi_desc(struct irq_desc *desc)
|
||||
{
|
||||
return get_irq_desc_msi(desc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_IRQ_H */
|
21
backport-include/linux/jiffies.h
Normal file
21
backport-include/linux/jiffies.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __BACKPORT_LNIUX_JIFFIES_H
|
||||
#define __BACKPORT_LNIUX_JIFFIES_H
|
||||
#include_next <linux/jiffies.h>
|
||||
|
||||
#ifndef time_is_before_jiffies
|
||||
#define time_is_before_jiffies(a) time_after(jiffies, a)
|
||||
#endif
|
||||
|
||||
#ifndef time_is_after_jiffies
|
||||
#define time_is_after_jiffies(a) time_before(jiffies, a)
|
||||
#endif
|
||||
|
||||
#ifndef time_is_before_eq_jiffies
|
||||
#define time_is_before_eq_jiffies(a) time_after_eq(jiffies, a)
|
||||
#endif
|
||||
|
||||
#ifndef time_is_after_eq_jiffies
|
||||
#define time_is_after_eq_jiffies(a) time_before_eq(jiffies, a)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LNIUX_JIFFIES_H */
|
24
backport-include/linux/kconfig.h
Normal file
24
backport-include/linux/kconfig.h
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __BACKPORT_LINUX_KCONFIG_H
|
||||
#define __BACKPORT_LINUX_KCONFIG_H
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
|
||||
#include_next <linux/kconfig.h>
|
||||
#endif
|
||||
|
||||
#ifndef __ARG_PLACEHOLDER_1
|
||||
#define __ARG_PLACEHOLDER_1 0,
|
||||
#define config_enabled(cfg) _config_enabled(cfg)
|
||||
#define _config_enabled(value) __config_enabled(__ARG_PLACEHOLDER_##value)
|
||||
#define __config_enabled(arg1_or_junk) ___config_enabled(arg1_or_junk 1, 0)
|
||||
#define ___config_enabled(__ignored, val, ...) val
|
||||
|
||||
/*
|
||||
* 3.1 - 3.3 had a broken version of this, so undef
|
||||
* (they didn't have __ARG_PLACEHOLDER_1)
|
||||
*/
|
||||
#undef IS_ENABLED
|
||||
#define IS_ENABLED(option) \
|
||||
(config_enabled(option) || config_enabled(option##_MODULE))
|
||||
#endif
|
||||
|
||||
#endif
|
263
backport-include/linux/kernel.h
Normal file
263
backport-include/linux/kernel.h
Normal file
@ -0,0 +1,263 @@
|
||||
#ifndef __BACKPORT_KERNEL_H
|
||||
#define __BACKPORT_KERNEL_H
|
||||
#include_next <linux/kernel.h>
|
||||
#include <linux/version.h>
|
||||
/*
|
||||
* some older kernels don't have this and thus don't
|
||||
* include it from kernel.h like new kernels
|
||||
*/
|
||||
#include <linux/printk.h>
|
||||
|
||||
/*
|
||||
* This backports:
|
||||
*
|
||||
* From a3860c1c5dd1137db23d7786d284939c5761d517 Mon Sep 17 00:00:00 2001
|
||||
* From: Xi Wang <xi.wang@gmail.com>
|
||||
* Date: Thu, 31 May 2012 16:26:04 -0700
|
||||
* Subject: [PATCH] introduce SIZE_MAX
|
||||
*/
|
||||
#ifndef SIZE_MAX
|
||||
#define SIZE_MAX (~(size_t)0)
|
||||
#endif
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 36a26c69b4c70396ef569c3452690fba0c1dec08
|
||||
* Author: Nicholas Bellinger <nab@linux-iscsi.org>
|
||||
* Date: Tue Jul 26 00:35:26 2011 -0700
|
||||
*
|
||||
* kernel.h: Add DIV_ROUND_UP_ULL and DIV_ROUND_UP_SECTOR_T macro usage
|
||||
*/
|
||||
#ifndef DIV_ROUND_UP_ULL
|
||||
#define DIV_ROUND_UP_ULL(ll,d) \
|
||||
({ unsigned long long _tmp = (ll)+(d)-1; do_div(_tmp, d); _tmp; })
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
||||
#define kstrtoull_from_user LINUX_BACKPORT(kstrtoull_from_user)
|
||||
int __must_check kstrtoull_from_user(const char __user *s, size_t count, unsigned int base, unsigned long long *res);
|
||||
#define kstrtoll_from_user LINUX_BACKPORT(kstrtoll_from_user)
|
||||
int __must_check kstrtoll_from_user(const char __user *s, size_t count, unsigned int base, long long *res);
|
||||
#define kstrtoul_from_user LINUX_BACKPORT(kstrtoul_from_user)
|
||||
int __must_check kstrtoul_from_user(const char __user *s, size_t count, unsigned int base, unsigned long *res);
|
||||
#define kstrtol_from_user LINUX_BACKPORT(kstrtol_from_user)
|
||||
int __must_check kstrtol_from_user(const char __user *s, size_t count, unsigned int base, long *res);
|
||||
#define kstrtouint_from_user LINUX_BACKPORT(kstrtouint_from_user)
|
||||
int __must_check kstrtouint_from_user(const char __user *s, size_t count, unsigned int base, unsigned int *res);
|
||||
#define kstrtoint_from_user LINUX_BACKPORT(kstrtoint_from_user)
|
||||
int __must_check kstrtoint_from_user(const char __user *s, size_t count, unsigned int base, int *res);
|
||||
#define kstrtou16_from_user LINUX_BACKPORT(kstrtou16_from_user)
|
||||
int __must_check kstrtou16_from_user(const char __user *s, size_t count, unsigned int base, u16 *res);
|
||||
#define kstrtos16_from_user LINUX_BACKPORT(kstrtos16_from_user)
|
||||
int __must_check kstrtos16_from_user(const char __user *s, size_t count, unsigned int base, s16 *res);
|
||||
#define kstrtou8_from_user LINUX_BACKPORT(kstrtou8_from_user)
|
||||
int __must_check kstrtou8_from_user(const char __user *s, size_t count, unsigned int base, u8 *res);
|
||||
#define kstrtos8_from_user LINUX_BACKPORT(kstrtos8_from_user)
|
||||
int __must_check kstrtos8_from_user(const char __user *s, size_t count, unsigned int base, s8 *res);
|
||||
|
||||
#define kstrtou64_from_user LINUX_BACKPORT(kstrtou64_from_user)
|
||||
static inline int __must_check kstrtou64_from_user(const char __user *s, size_t count, unsigned int base, u64 *res)
|
||||
{
|
||||
return kstrtoull_from_user(s, count, base, res);
|
||||
}
|
||||
|
||||
#define kstrtos64_from_user LINUX_BACKPORT(kstrtos64_from_user)
|
||||
static inline int __must_check kstrtos64_from_user(const char __user *s, size_t count, unsigned int base, s64 *res)
|
||||
{
|
||||
return kstrtoll_from_user(s, count, base, res);
|
||||
}
|
||||
|
||||
#define kstrtou32_from_user LINUX_BACKPORT(kstrtou32_from_user)
|
||||
static inline int __must_check kstrtou32_from_user(const char __user *s, size_t count, unsigned int base, u32 *res)
|
||||
{
|
||||
return kstrtouint_from_user(s, count, base, res);
|
||||
}
|
||||
|
||||
#define kstrtos32_from_user LINUX_BACKPORT(kstrtos32_from_user)
|
||||
static inline int __must_check kstrtos32_from_user(const char __user *s, size_t count, unsigned int base, s32 *res)
|
||||
{
|
||||
return kstrtoint_from_user(s, count, base, res);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
|
||||
/*
|
||||
* 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_strtoull
|
||||
/* Internal, do not use. */
|
||||
#define _kstrtoul LINUX_BACKPORT(_kstrtoul)
|
||||
int __must_check _kstrtoul(const char *s, unsigned int base, unsigned long *res);
|
||||
#define _kstrtol LINUX_BACKPORT(_kstrtol)
|
||||
int __must_check _kstrtol(const char *s, unsigned int base, long *res);
|
||||
|
||||
#define kstrtoull LINUX_BACKPORT(kstrtoull)
|
||||
int __must_check kstrtoull(const char *s, unsigned int base, unsigned long long *res);
|
||||
#define kstrtoll LINUX_BACKPORT(kstrtoll)
|
||||
int __must_check kstrtoll(const char *s, unsigned int base, long long *res);
|
||||
#define kstrtoul LINUX_BACKPORT(kstrtoul)
|
||||
static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
|
||||
{
|
||||
/*
|
||||
* We want to shortcut function call, but
|
||||
* __builtin_types_compatible_p(unsigned long, unsigned long long) = 0.
|
||||
*/
|
||||
if (sizeof(unsigned long) == sizeof(unsigned long long) &&
|
||||
__alignof__(unsigned long) == __alignof__(unsigned long long))
|
||||
return kstrtoull(s, base, (unsigned long long *)res);
|
||||
else
|
||||
return _kstrtoul(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtol LINUX_BACKPORT(kstrtol)
|
||||
static inline int __must_check kstrtol(const char *s, unsigned int base, long *res)
|
||||
{
|
||||
/*
|
||||
* We want to shortcut function call, but
|
||||
* __builtin_types_compatible_p(long, long long) = 0.
|
||||
*/
|
||||
if (sizeof(long) == sizeof(long long) &&
|
||||
__alignof__(long) == __alignof__(long long))
|
||||
return kstrtoll(s, base, (long long *)res);
|
||||
else
|
||||
return _kstrtol(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtouint LINUX_BACKPORT(kstrtouint)
|
||||
int __must_check kstrtouint(const char *s, unsigned int base, unsigned int *res);
|
||||
#define kstrtoint LINUX_BACKPORT(kstrtoint)
|
||||
int __must_check kstrtoint(const char *s, unsigned int base, int *res);
|
||||
|
||||
#define kstrtou64 LINUX_BACKPORT(kstrtou64)
|
||||
static inline int __must_check kstrtou64(const char *s, unsigned int base, u64 *res)
|
||||
{
|
||||
return kstrtoull(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtos64 LINUX_BACKPORT(kstrtos64)
|
||||
static inline int __must_check kstrtos64(const char *s, unsigned int base, s64 *res)
|
||||
{
|
||||
return kstrtoll(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtou32 LINUX_BACKPORT(kstrtou32)
|
||||
static inline int __must_check kstrtou32(const char *s, unsigned int base, u32 *res)
|
||||
{
|
||||
return kstrtouint(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtos32 LINUX_BACKPORT(kstrtos32)
|
||||
static inline int __must_check kstrtos32(const char *s, unsigned int base, s32 *res)
|
||||
{
|
||||
return kstrtoint(s, base, res);
|
||||
}
|
||||
|
||||
#define kstrtou16 LINUX_BACKPORT(kstrtou16)
|
||||
int __must_check kstrtou16(const char *s, unsigned int base, u16 *res);
|
||||
#define kstrtos16 LINUX_BACKPORT(kstrtos16)
|
||||
int __must_check kstrtos16(const char *s, unsigned int base, s16 *res);
|
||||
#define kstrtou8 LINUX_BACKPORT(kstrtou8)
|
||||
int __must_check kstrtou8(const char *s, unsigned int base, u8 *res);
|
||||
#define kstrtos8 LINUX_BACKPORT(kstrtos8)
|
||||
int __must_check kstrtos8(const char *s, unsigned int base, s8 *res);
|
||||
#endif /* ifndef strict_strtol */
|
||||
|
||||
#endif /* < 2.6.39 */
|
||||
|
||||
#ifndef USHRT_MAX
|
||||
#define USHRT_MAX ((u16)(~0U))
|
||||
#endif
|
||||
|
||||
#ifndef SHRT_MAX
|
||||
#define SHRT_MAX ((s16)(USHRT_MAX>>1))
|
||||
#endif
|
||||
|
||||
#ifndef SHRT_MIN
|
||||
#define SHRT_MIN ((s16)(-SHRT_MAX - 1))
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define hex_to_bin LINUX_BACKPORT(hex_to_bin)
|
||||
int hex_to_bin(char ch);
|
||||
#endif
|
||||
|
||||
#ifndef __round_mask
|
||||
#define __round_mask(x, y) ((__typeof__(x))((y)-1))
|
||||
#define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1)
|
||||
#define round_down(x, y) ((x) & ~__round_mask(x, y))
|
||||
#endif
|
||||
|
||||
#ifndef DIV_ROUND_CLOSEST
|
||||
#define DIV_ROUND_CLOSEST(x, divisor) ({ \
|
||||
typeof(divisor) __divisor = divisor; \
|
||||
(((x) + ((__divisor) / 2)) / (__divisor)); \
|
||||
})
|
||||
#endif
|
||||
|
||||
#ifndef swap
|
||||
#define swap(a, b) \
|
||||
do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
|
||||
#endif
|
||||
|
||||
#ifndef lower_32_bits
|
||||
#define lower_32_bits(n) ((u32)(n))
|
||||
#endif
|
||||
|
||||
#ifndef USHORT_MAX
|
||||
#define USHORT_MAX ((u16)(~0U))
|
||||
#define SHORT_MAX ((s16)(USHORT_MAX>>1))
|
||||
#define SHORT_MIN (-SHORT_MAX - 1)
|
||||
#endif
|
||||
|
||||
#ifndef clamp
|
||||
#define clamp(val, min, max) ({ \
|
||||
typeof(val) __val = (val); \
|
||||
typeof(min) __min = (min); \
|
||||
typeof(max) __max = (max); \
|
||||
(void) (&__val == &__min); \
|
||||
(void) (&__val == &__max); \
|
||||
__val = __val < __min ? __min: __val; \
|
||||
__val > __max ? __max: __val; })
|
||||
#endif
|
||||
|
||||
#ifndef clamp_t
|
||||
#define clamp_t(type, val, min, max) ({ \
|
||||
type __val = (val); \
|
||||
type __min = (min); \
|
||||
type __max = (max); \
|
||||
__val = __val < __min ? __min: __val; \
|
||||
__val > __max ? __max: __val; })
|
||||
#endif
|
||||
|
||||
#ifndef clamp_val
|
||||
#define clamp_val(val, min, max) ({ \
|
||||
typeof(val) __val = (val); \
|
||||
typeof(val) __min = (min); \
|
||||
typeof(val) __max = (max); \
|
||||
__val = __val < __min ? __min: __val; \
|
||||
__val > __max ? __max: __val; })
|
||||
#endif
|
||||
|
||||
#ifndef rounddown
|
||||
#define rounddown(x, y) ( \
|
||||
{ \
|
||||
typeof(x) __x = (x); \
|
||||
__x - (__x % (y)); \
|
||||
} \
|
||||
)
|
||||
#endif /* rounddown */
|
||||
|
||||
#endif /* __BACKPORT_KERNEL_H */
|
||||
|
||||
/*
|
||||
* We have to do this outside the include guard, because
|
||||
* out own header (linux/export.h) has to include kernel.h
|
||||
* indirectly (through module.h) and then undef's pr_fmt.
|
||||
* Then, when the real kernel.h gets included again, it's
|
||||
* not defined and we get problems ...
|
||||
*/
|
||||
#ifndef pr_fmt
|
||||
#define pr_fmt(msg) msg
|
||||
#endif
|
908
backport-include/linux/kfifo.h
Normal file
908
backport-include/linux/kfifo.h
Normal file
@ -0,0 +1,908 @@
|
||||
#include <linux/version.h>
|
||||
#ifndef CPTCFG_BACKPORT_BUILD_KFIFO
|
||||
#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4))
|
||||
#include_next <linux/kfifo.h>
|
||||
#else
|
||||
#include <linux/kfifo-new.h>
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)
|
||||
#undef kfifo_put
|
||||
/**
|
||||
* kfifo_put - put data into the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @val: the data to be added
|
||||
*
|
||||
* This macro copies the given value into the fifo.
|
||||
* It returns 0 if the fifo was full. Otherwise it returns the number
|
||||
* processed elements.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_put(fifo, val) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof((&val) + 1) __val = (&val); \
|
||||
unsigned int __ret; \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (0) { \
|
||||
typeof(__tmp->ptr_const) __dummy __attribute__ ((unused)); \
|
||||
__dummy = (typeof(__val))NULL; \
|
||||
} \
|
||||
if (__recsize) \
|
||||
__ret = __kfifo_in_r(__kfifo, __val, sizeof(*__val), \
|
||||
__recsize); \
|
||||
else { \
|
||||
__ret = !kfifo_is_full(__tmp); \
|
||||
if (__ret) { \
|
||||
(__is_kfifo_ptr(__tmp) ? \
|
||||
((typeof(__tmp->type))__kfifo->data) : \
|
||||
(__tmp->buf) \
|
||||
)[__kfifo->in & __tmp->kfifo.mask] = \
|
||||
*(typeof(__tmp->type))__val; \
|
||||
smp_wmb(); \
|
||||
__kfifo->in++; \
|
||||
} \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#else
|
||||
/*
|
||||
* A generic kernel FIFO implementation
|
||||
*
|
||||
* Copyright (C) 2013 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LINUX_KFIFO_H
|
||||
#define _LINUX_KFIFO_H
|
||||
|
||||
/*
|
||||
* How to porting drivers to the new generic FIFO API:
|
||||
*
|
||||
* - Modify the declaration of the "struct kfifo *" object into a
|
||||
* in-place "struct kfifo" object
|
||||
* - Init the in-place object with kfifo_alloc() or kfifo_init()
|
||||
* Note: The address of the in-place "struct kfifo" object must be
|
||||
* passed as the first argument to this functions
|
||||
* - Replace the use of __kfifo_put into kfifo_in and __kfifo_get
|
||||
* into kfifo_out
|
||||
* - Replace the use of kfifo_put into kfifo_in_spinlocked and kfifo_get
|
||||
* into kfifo_out_spinlocked
|
||||
* Note: the spinlock pointer formerly passed to kfifo_init/kfifo_alloc
|
||||
* must be passed now to the kfifo_in_spinlocked and kfifo_out_spinlocked
|
||||
* as the last parameter
|
||||
* - The formerly __kfifo_* functions are renamed into kfifo_*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Note about locking : There is no locking required until only * one reader
|
||||
* and one writer is using the fifo and no kfifo_reset() will be * called
|
||||
* kfifo_reset_out() can be safely used, until it will be only called
|
||||
* in the reader thread.
|
||||
* For multiple writer and one reader there is only a need to lock the writer.
|
||||
* And vice versa for only one writer and multiple reader there is only a need
|
||||
* to lock the reader.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/spinlock.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/scatterlist.h>
|
||||
|
||||
struct __kfifo {
|
||||
unsigned int in;
|
||||
unsigned int out;
|
||||
unsigned int mask;
|
||||
unsigned int esize;
|
||||
void *data;
|
||||
};
|
||||
|
||||
#define __STRUCT_KFIFO_COMMON(datatype, recsize, ptrtype) \
|
||||
union { \
|
||||
struct __kfifo kfifo; \
|
||||
datatype *type; \
|
||||
const datatype *const_type; \
|
||||
char (*rectype)[recsize]; \
|
||||
ptrtype *ptr; \
|
||||
ptrtype const *ptr_const; \
|
||||
}
|
||||
|
||||
#define __STRUCT_KFIFO(type, size, recsize, ptrtype) \
|
||||
{ \
|
||||
__STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
|
||||
type buf[((size < 2) || (size & (size - 1))) ? -1 : size]; \
|
||||
}
|
||||
|
||||
#define STRUCT_KFIFO(type, size) \
|
||||
struct __STRUCT_KFIFO(type, size, 0, type)
|
||||
|
||||
#define __STRUCT_KFIFO_PTR(type, recsize, ptrtype) \
|
||||
{ \
|
||||
__STRUCT_KFIFO_COMMON(type, recsize, ptrtype); \
|
||||
type buf[0]; \
|
||||
}
|
||||
|
||||
#define STRUCT_KFIFO_PTR(type) \
|
||||
struct __STRUCT_KFIFO_PTR(type, 0, type)
|
||||
|
||||
/*
|
||||
* define compatibility "struct kfifo" for dynamic allocated fifos
|
||||
*/
|
||||
struct kfifo __STRUCT_KFIFO_PTR(unsigned char, 0, void);
|
||||
|
||||
#define STRUCT_KFIFO_REC_1(size) \
|
||||
struct __STRUCT_KFIFO(unsigned char, size, 1, void)
|
||||
|
||||
#define STRUCT_KFIFO_REC_2(size) \
|
||||
struct __STRUCT_KFIFO(unsigned char, size, 2, void)
|
||||
|
||||
/*
|
||||
* define kfifo_rec types
|
||||
*/
|
||||
struct kfifo_rec_ptr_1 __STRUCT_KFIFO_PTR(unsigned char, 1, void);
|
||||
struct kfifo_rec_ptr_2 __STRUCT_KFIFO_PTR(unsigned char, 2, void);
|
||||
|
||||
/*
|
||||
* helper macro to distinguish between real in place fifo where the fifo
|
||||
* array is a part of the structure and the fifo type where the array is
|
||||
* outside of the fifo structure.
|
||||
*/
|
||||
#define __is_kfifo_ptr(fifo) (sizeof(*fifo) == sizeof(struct __kfifo))
|
||||
|
||||
/**
|
||||
* DECLARE_KFIFO_PTR - macro to declare a fifo pointer object
|
||||
* @fifo: name of the declared fifo
|
||||
* @type: type of the fifo elements
|
||||
*/
|
||||
#define DECLARE_KFIFO_PTR(fifo, type) STRUCT_KFIFO_PTR(type) fifo
|
||||
|
||||
/**
|
||||
* DECLARE_KFIFO - macro to declare a fifo object
|
||||
* @fifo: name of the declared fifo
|
||||
* @type: type of the fifo elements
|
||||
* @size: the number of elements in the fifo, this must be a power of 2
|
||||
*/
|
||||
#define DECLARE_KFIFO(fifo, type, size) STRUCT_KFIFO(type, size) fifo
|
||||
|
||||
/**
|
||||
* INIT_KFIFO - Initialize a fifo declared by DECLARE_KFIFO
|
||||
* @fifo: name of the declared fifo datatype
|
||||
*/
|
||||
#define INIT_KFIFO(fifo) \
|
||||
(void)({ \
|
||||
typeof(&(fifo)) __tmp = &(fifo); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
__kfifo->in = 0; \
|
||||
__kfifo->out = 0; \
|
||||
__kfifo->mask = __is_kfifo_ptr(__tmp) ? 0 : ARRAY_SIZE(__tmp->buf) - 1;\
|
||||
__kfifo->esize = sizeof(*__tmp->buf); \
|
||||
__kfifo->data = __is_kfifo_ptr(__tmp) ? NULL : __tmp->buf; \
|
||||
})
|
||||
|
||||
/**
|
||||
* DEFINE_KFIFO - macro to define and initialize a fifo
|
||||
* @fifo: name of the declared fifo datatype
|
||||
* @type: type of the fifo elements
|
||||
* @size: the number of elements in the fifo, this must be a power of 2
|
||||
*
|
||||
* Note: the macro can be used for global and local fifo data type variables.
|
||||
*/
|
||||
#define DEFINE_KFIFO(fifo, type, size) \
|
||||
DECLARE_KFIFO(fifo, type, size) = \
|
||||
(typeof(fifo)) { \
|
||||
{ \
|
||||
{ \
|
||||
.in = 0, \
|
||||
.out = 0, \
|
||||
.mask = __is_kfifo_ptr(&(fifo)) ? \
|
||||
0 : \
|
||||
ARRAY_SIZE((fifo).buf) - 1, \
|
||||
.esize = sizeof(*(fifo).buf), \
|
||||
.data = __is_kfifo_ptr(&(fifo)) ? \
|
||||
NULL : \
|
||||
(fifo).buf, \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
static inline unsigned int __must_check
|
||||
__kfifo_uint_must_check_helper(unsigned int val)
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
static inline int __must_check
|
||||
__kfifo_int_must_check_helper(int val)
|
||||
{
|
||||
return val;
|
||||
}
|
||||
|
||||
#define __kfifo_alloc LINUX_BACKPORT(__kfifo_alloc)
|
||||
extern int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
|
||||
size_t esize, gfp_t gfp_mask);
|
||||
|
||||
#define __kfifo_free LINUX_BACKPORT(__kfifo_free)
|
||||
extern void __kfifo_free(struct __kfifo *fifo);
|
||||
|
||||
#define __kfifo_init LINUX_BACKPORT(__kfifo_init)
|
||||
extern int __kfifo_init(struct __kfifo *fifo, void *buffer,
|
||||
unsigned int size, size_t esize);
|
||||
|
||||
#define __kfifo_in LINUX_BACKPORT(__kfifo_in)
|
||||
extern unsigned int __kfifo_in(struct __kfifo *fifo,
|
||||
const void *buf, unsigned int len);
|
||||
|
||||
#define __kfifo_out LINUX_BACKPORT(__kfifo_out)
|
||||
extern unsigned int __kfifo_out(struct __kfifo *fifo,
|
||||
void *buf, unsigned int len);
|
||||
|
||||
#define __kfifo_from_user LINUX_BACKPORT(__kfifo_from_user)
|
||||
extern int __kfifo_from_user(struct __kfifo *fifo,
|
||||
const void __user *from, unsigned long len, unsigned int *copied);
|
||||
|
||||
#define __kfifo_to_user LINUX_BACKPORT(__kfifo_to_user)
|
||||
extern int __kfifo_to_user(struct __kfifo *fifo,
|
||||
void __user *to, unsigned long len, unsigned int *copied);
|
||||
|
||||
#define __kfifo_dma_in_prepare LINUX_BACKPORT(__kfifo_dma_in_prepare)
|
||||
extern unsigned int __kfifo_dma_in_prepare(struct __kfifo *fifo,
|
||||
struct scatterlist *sgl, int nents, unsigned int len);
|
||||
|
||||
#define __kfifo_dma_out_prepare LINUX_BACKPORT(__kfifo_dma_out_prepare)
|
||||
extern unsigned int __kfifo_dma_out_prepare(struct __kfifo *fifo,
|
||||
struct scatterlist *sgl, int nents, unsigned int len);
|
||||
|
||||
#define __kfifo_out_peek LINUX_BACKPORT(__kfifo_out_peek)
|
||||
extern unsigned int __kfifo_out_peek(struct __kfifo *fifo,
|
||||
void *buf, unsigned int len);
|
||||
|
||||
#define __kfifo_in_r LINUX_BACKPORT(__kfifo_in_r)
|
||||
extern unsigned int __kfifo_in_r(struct __kfifo *fifo,
|
||||
const void *buf, unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_out_r LINUX_BACKPORT(__kfifo_out_r)
|
||||
extern unsigned int __kfifo_out_r(struct __kfifo *fifo,
|
||||
void *buf, unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_from_user_r LINUX_BACKPORT(__kfifo_from_user_r)
|
||||
extern int __kfifo_from_user_r(struct __kfifo *fifo,
|
||||
const void __user *from, unsigned long len, unsigned int *copied,
|
||||
size_t recsize);
|
||||
|
||||
#define __kfifo_to_user_r LINUX_BACKPORT(__kfifo_to_user_r)
|
||||
extern int __kfifo_to_user_r(struct __kfifo *fifo, void __user *to,
|
||||
unsigned long len, unsigned int *copied, size_t recsize);
|
||||
|
||||
#define __kfifo_dma_in_prepare_r LINUX_BACKPORT(__kfifo_dma_in_prepare_r)
|
||||
extern unsigned int __kfifo_dma_in_prepare_r(struct __kfifo *fifo,
|
||||
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_dma_in_finish_r LINUX_BACKPORT(__kfifo_dma_in_finish_r)
|
||||
extern void __kfifo_dma_in_finish_r(struct __kfifo *fifo,
|
||||
unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_dma_out_prepare_r LINUX_BACKPORT(__kfifo_dma_out_prepare_r)
|
||||
extern unsigned int __kfifo_dma_out_prepare_r(struct __kfifo *fifo,
|
||||
struct scatterlist *sgl, int nents, unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_dma_out_finish_r LINUX_BACKPORT(__kfifo_dma_out_finish_r)
|
||||
extern void __kfifo_dma_out_finish_r(struct __kfifo *fifo, size_t recsize);
|
||||
|
||||
#define __kfifo_len_r LINUX_BACKPORT(__kfifo_len_r)
|
||||
extern unsigned int __kfifo_len_r(struct __kfifo *fifo, size_t recsize);
|
||||
|
||||
#define __kfifo_skip_r LINUX_BACKPORT(__kfifo_skip_r)
|
||||
extern void __kfifo_skip_r(struct __kfifo *fifo, size_t recsize);
|
||||
|
||||
#define __kfifo_out_peek_r LINUX_BACKPORT(__kfifo_out_peek_r)
|
||||
extern unsigned int __kfifo_out_peek_r(struct __kfifo *fifo,
|
||||
void *buf, unsigned int len, size_t recsize);
|
||||
|
||||
#define __kfifo_max_r LINUX_BACKPORT(__kfifo_max_r)
|
||||
extern unsigned int __kfifo_max_r(unsigned int len, size_t recsize);
|
||||
|
||||
/**
|
||||
* kfifo_initialized - Check if the fifo is initialized
|
||||
* @fifo: address of the fifo to check
|
||||
*
|
||||
* Return %true if fifo is initialized, otherwise %false.
|
||||
* Assumes the fifo was 0 before.
|
||||
*/
|
||||
#define kfifo_initialized(fifo) ((fifo)->kfifo.mask)
|
||||
|
||||
/**
|
||||
* kfifo_esize - returns the size of the element managed by the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_esize(fifo) ((fifo)->kfifo.esize)
|
||||
|
||||
/**
|
||||
* kfifo_recsize - returns the size of the record length field
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_recsize(fifo) (sizeof(*(fifo)->rectype))
|
||||
|
||||
/**
|
||||
* kfifo_size - returns the size of the fifo in elements
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_size(fifo) ((fifo)->kfifo.mask + 1)
|
||||
|
||||
/**
|
||||
* kfifo_reset - removes the entire fifo content
|
||||
* @fifo: address of the fifo to be used
|
||||
*
|
||||
* Note: usage of kfifo_reset() is dangerous. It should be only called when the
|
||||
* fifo is exclusived locked or when it is secured that no other thread is
|
||||
* accessing the fifo.
|
||||
*/
|
||||
#define kfifo_reset(fifo) \
|
||||
(void)({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
__tmp->kfifo.in = __tmp->kfifo.out = 0; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_reset_out - skip fifo content
|
||||
* @fifo: address of the fifo to be used
|
||||
*
|
||||
* Note: The usage of kfifo_reset_out() is safe until it will be only called
|
||||
* from the reader thread and there is only one concurrent reader. Otherwise
|
||||
* it is dangerous and must be handled in the same way as kfifo_reset().
|
||||
*/
|
||||
#define kfifo_reset_out(fifo) \
|
||||
(void)({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
__tmp->kfifo.out = __tmp->kfifo.in; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_len - returns the number of used elements in the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_len(fifo) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmpl = (fifo); \
|
||||
__tmpl->kfifo.in - __tmpl->kfifo.out; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_is_empty - returns true if the fifo is empty
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_is_empty(fifo) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmpq = (fifo); \
|
||||
__tmpq->kfifo.in == __tmpq->kfifo.out; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_is_full - returns true if the fifo is full
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_is_full(fifo) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmpq = (fifo); \
|
||||
kfifo_len(__tmpq) > __tmpq->kfifo.mask; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_avail - returns the number of unused elements in the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_avail(fifo) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmpq = (fifo); \
|
||||
const size_t __recsize = sizeof(*__tmpq->rectype); \
|
||||
unsigned int __avail = kfifo_size(__tmpq) - kfifo_len(__tmpq); \
|
||||
(__recsize) ? ((__avail <= __recsize) ? 0 : \
|
||||
__kfifo_max_r(__avail - __recsize, __recsize)) : \
|
||||
__avail; \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_skip - skip output data
|
||||
* @fifo: address of the fifo to be used
|
||||
*/
|
||||
#define kfifo_skip(fifo) \
|
||||
(void)({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__kfifo_skip_r(__kfifo, __recsize); \
|
||||
else \
|
||||
__kfifo->out++; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_peek_len - gets the size of the next fifo record
|
||||
* @fifo: address of the fifo to be used
|
||||
*
|
||||
* This function returns the size of the next fifo record in number of bytes.
|
||||
*/
|
||||
#define kfifo_peek_len(fifo) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(!__recsize) ? kfifo_len(__tmp) * sizeof(*__tmp->type) : \
|
||||
__kfifo_len_r(__kfifo, __recsize); \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_alloc - dynamically allocates a new fifo buffer
|
||||
* @fifo: pointer to the fifo
|
||||
* @size: the number of elements in the fifo, this must be a power of 2
|
||||
* @gfp_mask: get_free_pages mask, passed to kmalloc()
|
||||
*
|
||||
* This macro dynamically allocates a new fifo buffer.
|
||||
*
|
||||
* The numer of elements will be rounded-up to a power of 2.
|
||||
* The fifo will be release with kfifo_free().
|
||||
* Return 0 if no error, otherwise an error code.
|
||||
*/
|
||||
#define kfifo_alloc(fifo, size, gfp_mask) \
|
||||
__kfifo_int_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
__is_kfifo_ptr(__tmp) ? \
|
||||
__kfifo_alloc(__kfifo, size, sizeof(*__tmp->type), gfp_mask) : \
|
||||
-EINVAL; \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_free - frees the fifo
|
||||
* @fifo: the fifo to be freed
|
||||
*/
|
||||
#define kfifo_free(fifo) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__is_kfifo_ptr(__tmp)) \
|
||||
__kfifo_free(__kfifo); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_init - initialize a fifo using a preallocated buffer
|
||||
* @fifo: the fifo to assign the buffer
|
||||
* @buffer: the preallocated buffer to be used
|
||||
* @size: the size of the internal buffer, this have to be a power of 2
|
||||
*
|
||||
* This macro initialize a fifo using a preallocated buffer.
|
||||
*
|
||||
* The numer of elements will be rounded-up to a power of 2.
|
||||
* Return 0 if no error, otherwise an error code.
|
||||
*/
|
||||
#define kfifo_init(fifo, buffer, size) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
__is_kfifo_ptr(__tmp) ? \
|
||||
__kfifo_init(__kfifo, buffer, size, sizeof(*__tmp->type)) : \
|
||||
-EINVAL; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_put - put data into the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @val: the data to be added
|
||||
*
|
||||
* This macro copies the given value into the fifo.
|
||||
* It returns 0 if the fifo was full. Otherwise it returns the number
|
||||
* processed elements.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_put(fifo, val) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(*__tmp->const_type) __val = (val); \
|
||||
unsigned int __ret; \
|
||||
size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__ret = __kfifo_in_r(__kfifo, &__val, sizeof(__val), \
|
||||
__recsize); \
|
||||
else { \
|
||||
__ret = !kfifo_is_full(__tmp); \
|
||||
if (__ret) { \
|
||||
(__is_kfifo_ptr(__tmp) ? \
|
||||
((typeof(__tmp->type))__kfifo->data) : \
|
||||
(__tmp->buf) \
|
||||
)[__kfifo->in & __tmp->kfifo.mask] = \
|
||||
(typeof(*__tmp->type))__val; \
|
||||
smp_wmb(); \
|
||||
__kfifo->in++; \
|
||||
} \
|
||||
} \
|
||||
__ret; \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_get - get data from the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @val: address where to store the data
|
||||
*
|
||||
* This macro reads the data from the fifo.
|
||||
* It returns 0 if the fifo was empty. Otherwise it returns the number
|
||||
* processed elements.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_get(fifo, val) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(__tmp->ptr) __val = (val); \
|
||||
unsigned int __ret; \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__ret = __kfifo_out_r(__kfifo, __val, sizeof(*__val), \
|
||||
__recsize); \
|
||||
else { \
|
||||
__ret = !kfifo_is_empty(__tmp); \
|
||||
if (__ret) { \
|
||||
*(typeof(__tmp->type))__val = \
|
||||
(__is_kfifo_ptr(__tmp) ? \
|
||||
((typeof(__tmp->type))__kfifo->data) : \
|
||||
(__tmp->buf) \
|
||||
)[__kfifo->out & __tmp->kfifo.mask]; \
|
||||
smp_wmb(); \
|
||||
__kfifo->out++; \
|
||||
} \
|
||||
} \
|
||||
__ret; \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_peek - get data from the fifo without removing
|
||||
* @fifo: address of the fifo to be used
|
||||
* @val: address where to store the data
|
||||
*
|
||||
* This reads the data from the fifo without removing it from the fifo.
|
||||
* It returns 0 if the fifo was empty. Otherwise it returns the number
|
||||
* processed elements.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_peek(fifo, val) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(__tmp->ptr) __val = (val); \
|
||||
unsigned int __ret; \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__ret = __kfifo_out_peek_r(__kfifo, __val, sizeof(*__val), \
|
||||
__recsize); \
|
||||
else { \
|
||||
__ret = !kfifo_is_empty(__tmp); \
|
||||
if (__ret) { \
|
||||
*(typeof(__tmp->type))__val = \
|
||||
(__is_kfifo_ptr(__tmp) ? \
|
||||
((typeof(__tmp->type))__kfifo->data) : \
|
||||
(__tmp->buf) \
|
||||
)[__kfifo->out & __tmp->kfifo.mask]; \
|
||||
smp_wmb(); \
|
||||
} \
|
||||
} \
|
||||
__ret; \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_in - put data into the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @buf: the data to be added
|
||||
* @n: number of elements to be added
|
||||
*
|
||||
* This macro copies the given buffer into the fifo and returns the
|
||||
* number of copied elements.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_in(fifo, buf, n) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(__tmp->ptr_const) __buf = (buf); \
|
||||
unsigned long __n = (n); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ?\
|
||||
__kfifo_in_r(__kfifo, __buf, __n, __recsize) : \
|
||||
__kfifo_in(__kfifo, __buf, __n); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_in_spinlocked - put data into the fifo using a spinlock for locking
|
||||
* @fifo: address of the fifo to be used
|
||||
* @buf: the data to be added
|
||||
* @n: number of elements to be added
|
||||
* @lock: pointer to the spinlock to use for locking
|
||||
*
|
||||
* This macro copies the given values buffer into the fifo and returns the
|
||||
* number of copied elements.
|
||||
*/
|
||||
#define kfifo_in_spinlocked(fifo, buf, n, lock) \
|
||||
({ \
|
||||
unsigned long __flags; \
|
||||
unsigned int __ret; \
|
||||
spin_lock_irqsave(lock, __flags); \
|
||||
__ret = kfifo_in(fifo, buf, n); \
|
||||
spin_unlock_irqrestore(lock, __flags); \
|
||||
__ret; \
|
||||
})
|
||||
|
||||
/* alias for kfifo_in_spinlocked, will be removed in a future release */
|
||||
#define kfifo_in_locked(fifo, buf, n, lock) \
|
||||
kfifo_in_spinlocked(fifo, buf, n, lock)
|
||||
|
||||
/**
|
||||
* kfifo_out - get data from the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @buf: pointer to the storage buffer
|
||||
* @n: max. number of elements to get
|
||||
*
|
||||
* This macro get some data from the fifo and return the numbers of elements
|
||||
* copied.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_out(fifo, buf, n) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(__tmp->ptr) __buf = (buf); \
|
||||
unsigned long __n = (n); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ?\
|
||||
__kfifo_out_r(__kfifo, __buf, __n, __recsize) : \
|
||||
__kfifo_out(__kfifo, __buf, __n); \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_out_spinlocked - get data from the fifo using a spinlock for locking
|
||||
* @fifo: address of the fifo to be used
|
||||
* @buf: pointer to the storage buffer
|
||||
* @n: max. number of elements to get
|
||||
* @lock: pointer to the spinlock to use for locking
|
||||
*
|
||||
* This macro get the data from the fifo and return the numbers of elements
|
||||
* copied.
|
||||
*/
|
||||
#define kfifo_out_spinlocked(fifo, buf, n, lock) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
unsigned long __flags; \
|
||||
unsigned int __ret; \
|
||||
spin_lock_irqsave(lock, __flags); \
|
||||
__ret = kfifo_out(fifo, buf, n); \
|
||||
spin_unlock_irqrestore(lock, __flags); \
|
||||
__ret; \
|
||||
}) \
|
||||
)
|
||||
|
||||
/* alias for kfifo_out_spinlocked, will be removed in a future release */
|
||||
#define kfifo_out_locked(fifo, buf, n, lock) \
|
||||
kfifo_out_spinlocked(fifo, buf, n, lock)
|
||||
|
||||
/**
|
||||
* kfifo_from_user - puts some data from user space into the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @from: pointer to the data to be added
|
||||
* @len: the length of the data to be added
|
||||
* @copied: pointer to output variable to store the number of copied bytes
|
||||
*
|
||||
* This macro copies at most @len bytes from the @from into the
|
||||
* fifo, depending of the available space and returns -EFAULT/0.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_from_user(fifo, from, len, copied) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
const void __user *__from = (from); \
|
||||
unsigned int __len = (len); \
|
||||
unsigned int *__copied = (copied); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ? \
|
||||
__kfifo_from_user_r(__kfifo, __from, __len, __copied, __recsize) : \
|
||||
__kfifo_from_user(__kfifo, __from, __len, __copied); \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_to_user - copies data from the fifo into user space
|
||||
* @fifo: address of the fifo to be used
|
||||
* @to: where the data must be copied
|
||||
* @len: the size of the destination buffer
|
||||
* @copied: pointer to output variable to store the number of copied bytes
|
||||
*
|
||||
* This macro copies at most @len bytes from the fifo into the
|
||||
* @to buffer and returns -EFAULT/0.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_to_user(fifo, to, len, copied) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
void __user *__to = (to); \
|
||||
unsigned int __len = (len); \
|
||||
unsigned int *__copied = (copied); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ? \
|
||||
__kfifo_to_user_r(__kfifo, __to, __len, __copied, __recsize) : \
|
||||
__kfifo_to_user(__kfifo, __to, __len, __copied); \
|
||||
}) \
|
||||
)
|
||||
|
||||
/**
|
||||
* kfifo_dma_in_prepare - setup a scatterlist for DMA input
|
||||
* @fifo: address of the fifo to be used
|
||||
* @sgl: pointer to the scatterlist array
|
||||
* @nents: number of entries in the scatterlist array
|
||||
* @len: number of elements to transfer
|
||||
*
|
||||
* This macro fills a scatterlist for DMA input.
|
||||
* It returns the number entries in the scatterlist array.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macros.
|
||||
*/
|
||||
#define kfifo_dma_in_prepare(fifo, sgl, nents, len) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
struct scatterlist *__sgl = (sgl); \
|
||||
int __nents = (nents); \
|
||||
unsigned int __len = (len); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ? \
|
||||
__kfifo_dma_in_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \
|
||||
__kfifo_dma_in_prepare(__kfifo, __sgl, __nents, __len); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_dma_in_finish - finish a DMA IN operation
|
||||
* @fifo: address of the fifo to be used
|
||||
* @len: number of bytes to received
|
||||
*
|
||||
* This macro finish a DMA IN operation. The in counter will be updated by
|
||||
* the len parameter. No error checking will be done.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macros.
|
||||
*/
|
||||
#define kfifo_dma_in_finish(fifo, len) \
|
||||
(void)({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
unsigned int __len = (len); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__kfifo_dma_in_finish_r(__kfifo, __len, __recsize); \
|
||||
else \
|
||||
__kfifo->in += __len / sizeof(*__tmp->type); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_dma_out_prepare - setup a scatterlist for DMA output
|
||||
* @fifo: address of the fifo to be used
|
||||
* @sgl: pointer to the scatterlist array
|
||||
* @nents: number of entries in the scatterlist array
|
||||
* @len: number of elements to transfer
|
||||
*
|
||||
* This macro fills a scatterlist for DMA output which at most @len bytes
|
||||
* to transfer.
|
||||
* It returns the number entries in the scatterlist array.
|
||||
* A zero means there is no space available and the scatterlist is not filled.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macros.
|
||||
*/
|
||||
#define kfifo_dma_out_prepare(fifo, sgl, nents, len) \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
struct scatterlist *__sgl = (sgl); \
|
||||
int __nents = (nents); \
|
||||
unsigned int __len = (len); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ? \
|
||||
__kfifo_dma_out_prepare_r(__kfifo, __sgl, __nents, __len, __recsize) : \
|
||||
__kfifo_dma_out_prepare(__kfifo, __sgl, __nents, __len); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_dma_out_finish - finish a DMA OUT operation
|
||||
* @fifo: address of the fifo to be used
|
||||
* @len: number of bytes transferd
|
||||
*
|
||||
* This macro finish a DMA OUT operation. The out counter will be updated by
|
||||
* the len parameter. No error checking will be done.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macros.
|
||||
*/
|
||||
#define kfifo_dma_out_finish(fifo, len) \
|
||||
(void)({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
unsigned int __len = (len); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
if (__recsize) \
|
||||
__kfifo_dma_out_finish_r(__kfifo, __recsize); \
|
||||
else \
|
||||
__kfifo->out += __len / sizeof(*__tmp->type); \
|
||||
})
|
||||
|
||||
/**
|
||||
* kfifo_out_peek - gets some data from the fifo
|
||||
* @fifo: address of the fifo to be used
|
||||
* @buf: pointer to the storage buffer
|
||||
* @n: max. number of elements to get
|
||||
*
|
||||
* This macro get the data from the fifo and return the numbers of elements
|
||||
* copied. The data is not removed from the fifo.
|
||||
*
|
||||
* Note that with only one concurrent reader and one concurrent
|
||||
* writer, you don't need extra locking to use these macro.
|
||||
*/
|
||||
#define kfifo_out_peek(fifo, buf, n) \
|
||||
__kfifo_uint_must_check_helper( \
|
||||
({ \
|
||||
typeof((fifo) + 1) __tmp = (fifo); \
|
||||
typeof(__tmp->ptr) __buf = (buf); \
|
||||
unsigned long __n = (n); \
|
||||
const size_t __recsize = sizeof(*__tmp->rectype); \
|
||||
struct __kfifo *__kfifo = &__tmp->kfifo; \
|
||||
(__recsize) ? \
|
||||
__kfifo_out_peek_r(__kfifo, __buf, __n, __recsize) : \
|
||||
__kfifo_out_peek(__kfifo, __buf, __n); \
|
||||
}) \
|
||||
)
|
||||
#endif
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)) */
|
24
backport-include/linux/kmemleak.h
Normal file
24
backport-include/linux/kmemleak.h
Normal file
@ -0,0 +1,24 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
|
||||
#include_next <linux/kmemleak.h>
|
||||
#else
|
||||
/*
|
||||
* kmemleak was introduced on 2.6.31, since older kernels do not have
|
||||
* we simply ignore its tuning.
|
||||
*/
|
||||
static inline void kmemleak_ignore(const void *ptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void kmemleak_not_leak(const void *ptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static inline void kmemleak_no_scan(const void *ptr)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
46
backport-include/linux/leds.h
Normal file
46
backport-include/linux/leds.h
Normal file
@ -0,0 +1,46 @@
|
||||
#ifndef __BACKPORT_LINUX_LEDS_H
|
||||
#define __BACKPORT_LINUX_LEDS_H
|
||||
#include_next <linux/leds.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,6,0)
|
||||
/*
|
||||
* Backports
|
||||
*
|
||||
* commit 959d62fa865d2e616b61a509e1cc5b88741f065e
|
||||
* Author: Shuah Khan <shuahkhan@gmail.com>
|
||||
* Date: Thu Jun 14 04:34:30 2012 +0800
|
||||
*
|
||||
* leds: Rename led_brightness_set() to led_set_brightness()
|
||||
*
|
||||
* Rename leds external interface led_brightness_set() to led_set_brightness().
|
||||
* This is the second phase of the change to reduce confusion between the
|
||||
* leds internal and external interfaces that set brightness. With this change,
|
||||
* now the external interface is led_set_brightness(). The first phase renamed
|
||||
* the internal interface led_set_brightness() to __led_set_brightness().
|
||||
* There are no changes to the interface implementations.
|
||||
*
|
||||
* Signed-off-by: Shuah Khan <shuahkhan@gmail.com>
|
||||
* Signed-off-by: Bryan Wu <bryan.wu@canonical.com>
|
||||
*/
|
||||
#define led_set_brightness(_dev, _switch) led_brightness_set(_dev, _switch)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37) && \
|
||||
!defined(CPTCFG_BACKPORT_BUILD_LEDS)
|
||||
#define led_blink_set LINUX_BACKPORT(led_blink_set)
|
||||
extern void led_blink_set(struct led_classdev *led_cdev,
|
||||
unsigned long *delay_on,
|
||||
unsigned long *delay_off);
|
||||
|
||||
#define led_classdev_unregister compat_led_classdev_unregister
|
||||
extern void compat_led_classdev_unregister(struct led_classdev *led_cdev);
|
||||
|
||||
#define led_brightness_set compat_led_brightness_set
|
||||
extern void compat_led_brightness_set(struct led_classdev *led_cdev,
|
||||
enum led_brightness brightness);
|
||||
#endif
|
||||
|
||||
#include <backport/leds-disabled.h>
|
||||
|
||||
#endif /* __BACKPORT_LINUX_LEDS_H */
|
131
backport-include/linux/list.h
Normal file
131
backport-include/linux/list.h
Normal file
@ -0,0 +1,131 @@
|
||||
#ifndef __BACKPORT_LIST_H
|
||||
#define __BACKPORT_LIST_H
|
||||
#include_next <linux/list.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
/**
|
||||
* backport:
|
||||
*
|
||||
* commit 0bbacca7c3911451cea923b0ad6389d58e3d9ce9
|
||||
* Author: Sasha Levin <sasha.levin@oracle.com>
|
||||
* Date: Thu Feb 7 12:32:18 2013 +1100
|
||||
*
|
||||
* hlist: drop the node parameter from iterators
|
||||
*/
|
||||
#include <backport/magic.h>
|
||||
|
||||
#undef hlist_entry_safe
|
||||
#define hlist_entry_safe(ptr, type, member) \
|
||||
(ptr) ? hlist_entry(ptr, type, member) : NULL
|
||||
|
||||
#define hlist_for_each_entry4(tpos, pos, head, member) \
|
||||
for (pos = (head)->first; \
|
||||
pos && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;});\
|
||||
pos = pos->next)
|
||||
|
||||
#define hlist_for_each_entry_safe5(tpos, pos, n, head, member) \
|
||||
for (pos = (head)->first; \
|
||||
pos && ({ n = pos->next; 1; }) && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1;});\
|
||||
pos = n)
|
||||
|
||||
#define hlist_for_each_entry3(pos, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*(pos)), member); \
|
||||
pos; \
|
||||
pos = hlist_entry_safe((pos)->member.next, typeof(*(pos)), member))
|
||||
|
||||
#define hlist_for_each_entry_safe4(pos, n, head, member) \
|
||||
for (pos = hlist_entry_safe((head)->first, typeof(*pos), member); \
|
||||
pos && ({ n = pos->member.next; 1; }); \
|
||||
pos = hlist_entry_safe(n, typeof(*pos), member))
|
||||
|
||||
#undef hlist_for_each_entry
|
||||
#define hlist_for_each_entry(...) \
|
||||
macro_dispatcher(hlist_for_each_entry, __VA_ARGS__)(__VA_ARGS__)
|
||||
#undef hlist_for_each_entry_safe
|
||||
#define hlist_for_each_entry_safe(...) \
|
||||
macro_dispatcher(hlist_for_each_entry_safe, __VA_ARGS__)(__VA_ARGS__)
|
||||
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
static inline int list_is_singular(const struct list_head *head)
|
||||
{
|
||||
return !list_empty(head) && (head->next == head->prev);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
static inline void __list_cut_position(struct list_head *list,
|
||||
struct list_head *head, struct list_head *entry)
|
||||
{
|
||||
struct list_head *new_first = entry->next;
|
||||
list->next = head->next;
|
||||
list->next->prev = list;
|
||||
list->prev = entry;
|
||||
entry->next = list;
|
||||
head->next = new_first;
|
||||
new_first->prev = head;
|
||||
}
|
||||
|
||||
static inline void list_cut_position(struct list_head *list,
|
||||
struct list_head *head, struct list_head *entry)
|
||||
{
|
||||
if (list_empty(head))
|
||||
return;
|
||||
if (list_is_singular(head) &&
|
||||
(head->next != entry && head != entry))
|
||||
return;
|
||||
if (entry == head)
|
||||
INIT_LIST_HEAD(list);
|
||||
else
|
||||
__list_cut_position(list, head, entry);
|
||||
}
|
||||
|
||||
static inline void __compat_list_splice_new_27(const struct list_head *list,
|
||||
struct list_head *prev,
|
||||
struct list_head *next)
|
||||
{
|
||||
struct list_head *first = list->next;
|
||||
struct list_head *last = list->prev;
|
||||
|
||||
first->prev = prev;
|
||||
prev->next = first;
|
||||
|
||||
last->next = next;
|
||||
next->prev = last;
|
||||
}
|
||||
|
||||
static inline void list_splice_tail(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list))
|
||||
__compat_list_splice_new_27(list, head->prev, head);
|
||||
}
|
||||
|
||||
static inline void list_splice_tail_init(struct list_head *list,
|
||||
struct list_head *head)
|
||||
{
|
||||
if (!list_empty(list)) {
|
||||
__compat_list_splice_new_27(list, head->prev, head);
|
||||
INIT_LIST_HEAD(list);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef list_first_entry_or_null
|
||||
/**
|
||||
* list_first_entry_or_null - get the first element from a list
|
||||
* @ptr: the list head to take the element from.
|
||||
* @type: the type of the struct this is embedded in.
|
||||
* @member: the name of the list_struct within the struct.
|
||||
*
|
||||
* Note that if the list is empty, it returns NULL.
|
||||
*/
|
||||
#define list_first_entry_or_null(ptr, type, member) \
|
||||
(!list_empty(ptr) ? list_first_entry(ptr, type, member) : NULL)
|
||||
#endif /* list_first_entry_or_null */
|
||||
|
||||
#endif /* __BACKPORT_LIST_H */
|
54
backport-include/linux/lockdep.h
Normal file
54
backport-include/linux/lockdep.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef __BACKPORT_LINUX_LOCKDEP_H
|
||||
#define __BACKPORT_LINUX_LOCKDEP_H
|
||||
#include_next <linux/lockdep.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
/* Backport of:
|
||||
*
|
||||
* commit e159489baa717dbae70f9903770a6a4990865887
|
||||
* Author: Tejun Heo <tj@kernel.org>
|
||||
* Date: Sun Jan 9 23:32:15 2011 +0100
|
||||
*
|
||||
* workqueue: relax lockdep annotation on flush_work()
|
||||
*/
|
||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
# ifdef CONFIG_PROVE_LOCKING
|
||||
# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 2, NULL, _THIS_IP_)
|
||||
# else
|
||||
# define lock_map_acquire_read(l) lock_acquire(l, 0, 0, 2, 1, NULL, _THIS_IP_)
|
||||
# endif
|
||||
#else
|
||||
# define lock_map_acquire_read(l) do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* < 2.6.38 */
|
||||
|
||||
#ifndef lockdep_assert_held
|
||||
#define lockdep_assert_held(l) do { } while (0)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
/* Backport of:
|
||||
*
|
||||
* commit 3295f0ef9ff048a4619ede597ad9ec9cab725654
|
||||
* Author: Ingo Molnar <mingo@elte.hu>
|
||||
* Date: Mon Aug 11 10:30:30 2008 +0200
|
||||
*
|
||||
* lockdep: rename map_[acquire|release]() => lock_map_[acquire|release]()
|
||||
*/
|
||||
#ifdef CONFIG_DEBUG_LOCK_ALLOC
|
||||
# ifdef CONFIG_PROVE_LOCKING
|
||||
# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 2, NULL, _THIS_IP_)
|
||||
# else
|
||||
# define lock_map_acquire(l) lock_acquire(l, 0, 0, 0, 1, NULL, _THIS_IP_)
|
||||
# endif
|
||||
# define lock_map_release(l) lock_release(l, 1, _THIS_IP_)
|
||||
#else
|
||||
# define lock_map_acquire(l) do { } while (0)
|
||||
# define lock_map_release(l) do { } while (0)
|
||||
#endif
|
||||
|
||||
#endif /* < 2.6.27 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_LOCKDEP_H */
|
43
backport-include/linux/math64.h
Normal file
43
backport-include/linux/math64.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef _COMPAT_LINUX_MATH64_H
|
||||
#define _COMPAT_LINUX_MATH64_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25))
|
||||
#include_next <linux/math64.h>
|
||||
#else
|
||||
#include <linux/types.h>
|
||||
#include <asm/div64.h>
|
||||
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
#if BITS_PER_LONG == 64
|
||||
|
||||
static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
|
||||
{
|
||||
*remainder = dividend % divisor;
|
||||
return dividend / divisor;
|
||||
}
|
||||
|
||||
#elif BITS_PER_LONG == 32
|
||||
|
||||
#ifndef div_u64_rem
|
||||
static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
|
||||
{
|
||||
*remainder = do_div(dividend, divisor);
|
||||
return dividend;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* BITS_PER_LONG */
|
||||
|
||||
#ifndef div_u64
|
||||
static inline u64 div_u64(u64 dividend, u32 divisor)
|
||||
{
|
||||
u32 remainder;
|
||||
return div_u64_rem(dividend, divisor, &remainder);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26) */
|
||||
|
||||
#endif /* _COMPAT_LINUX_MATH64_H */
|
147
backport-include/linux/mii.h
Normal file
147
backport-include/linux/mii.h
Normal file
@ -0,0 +1,147 @@
|
||||
#ifndef __BACKPORT_LINUX_MII_H
|
||||
#define __BACKPORT_LINUX_MII_H
|
||||
#include_next <linux/mii.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
|
||||
#include <linux/ethtool.h>
|
||||
|
||||
#define ethtool_adv_to_mii_adv_t LINUX_BACKPORT(ethtool_adv_to_mii_adv_t)
|
||||
static inline u32 ethtool_adv_to_mii_adv_t(u32 ethadv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (ethadv & ADVERTISED_10baseT_Half)
|
||||
result |= ADVERTISE_10HALF;
|
||||
if (ethadv & ADVERTISED_10baseT_Full)
|
||||
result |= ADVERTISE_10FULL;
|
||||
if (ethadv & ADVERTISED_100baseT_Half)
|
||||
result |= ADVERTISE_100HALF;
|
||||
if (ethadv & ADVERTISED_100baseT_Full)
|
||||
result |= ADVERTISE_100FULL;
|
||||
if (ethadv & ADVERTISED_Pause)
|
||||
result |= ADVERTISE_PAUSE_CAP;
|
||||
if (ethadv & ADVERTISED_Asym_Pause)
|
||||
result |= ADVERTISE_PAUSE_ASYM;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define mii_adv_to_ethtool_adv_t LINUX_BACKPORT(mii_adv_to_ethtool_adv_t)
|
||||
static inline u32 mii_adv_to_ethtool_adv_t(u32 adv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (adv & ADVERTISE_10HALF)
|
||||
result |= ADVERTISED_10baseT_Half;
|
||||
if (adv & ADVERTISE_10FULL)
|
||||
result |= ADVERTISED_10baseT_Full;
|
||||
if (adv & ADVERTISE_100HALF)
|
||||
result |= ADVERTISED_100baseT_Half;
|
||||
if (adv & ADVERTISE_100FULL)
|
||||
result |= ADVERTISED_100baseT_Full;
|
||||
if (adv & ADVERTISE_PAUSE_CAP)
|
||||
result |= ADVERTISED_Pause;
|
||||
if (adv & ADVERTISE_PAUSE_ASYM)
|
||||
result |= ADVERTISED_Asym_Pause;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define ethtool_adv_to_mii_ctrl1000_t LINUX_BACKPORT(ethtool_adv_to_mii_ctrl1000_t)
|
||||
static inline u32 ethtool_adv_to_mii_ctrl1000_t(u32 ethadv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (ethadv & ADVERTISED_1000baseT_Half)
|
||||
result |= ADVERTISE_1000HALF;
|
||||
if (ethadv & ADVERTISED_1000baseT_Full)
|
||||
result |= ADVERTISE_1000FULL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define mii_ctrl1000_to_ethtool_adv_t LINUX_BACKPORT(mii_ctrl1000_to_ethtool_adv_t)
|
||||
static inline u32 mii_ctrl1000_to_ethtool_adv_t(u32 adv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (adv & ADVERTISE_1000HALF)
|
||||
result |= ADVERTISED_1000baseT_Half;
|
||||
if (adv & ADVERTISE_1000FULL)
|
||||
result |= ADVERTISED_1000baseT_Full;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define mii_lpa_to_ethtool_lpa_t LINUX_BACKPORT(mii_lpa_to_ethtool_lpa_t)
|
||||
static inline u32 mii_lpa_to_ethtool_lpa_t(u32 lpa)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (lpa & LPA_LPACK)
|
||||
result |= ADVERTISED_Autoneg;
|
||||
|
||||
return result | mii_adv_to_ethtool_adv_t(lpa);
|
||||
}
|
||||
|
||||
#define mii_stat1000_to_ethtool_lpa_t LINUX_BACKPORT(mii_stat1000_to_ethtool_lpa_t)
|
||||
static inline u32 mii_stat1000_to_ethtool_lpa_t(u32 lpa)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (lpa & LPA_1000HALF)
|
||||
result |= ADVERTISED_1000baseT_Half;
|
||||
if (lpa & LPA_1000FULL)
|
||||
result |= ADVERTISED_1000baseT_Full;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define ethtool_adv_to_mii_adv_x LINUX_BACKPORT(ethtool_adv_to_mii_adv_x)
|
||||
static inline u32 ethtool_adv_to_mii_adv_x(u32 ethadv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (ethadv & ADVERTISED_1000baseT_Half)
|
||||
result |= ADVERTISE_1000XHALF;
|
||||
if (ethadv & ADVERTISED_1000baseT_Full)
|
||||
result |= ADVERTISE_1000XFULL;
|
||||
if (ethadv & ADVERTISED_Pause)
|
||||
result |= ADVERTISE_1000XPAUSE;
|
||||
if (ethadv & ADVERTISED_Asym_Pause)
|
||||
result |= ADVERTISE_1000XPSE_ASYM;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define mii_adv_to_ethtool_adv_x LINUX_BACKPORT(mii_adv_to_ethtool_adv_x)
|
||||
static inline u32 mii_adv_to_ethtool_adv_x(u32 adv)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (adv & ADVERTISE_1000XHALF)
|
||||
result |= ADVERTISED_1000baseT_Half;
|
||||
if (adv & ADVERTISE_1000XFULL)
|
||||
result |= ADVERTISED_1000baseT_Full;
|
||||
if (adv & ADVERTISE_1000XPAUSE)
|
||||
result |= ADVERTISED_Pause;
|
||||
if (adv & ADVERTISE_1000XPSE_ASYM)
|
||||
result |= ADVERTISED_Asym_Pause;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define mii_lpa_to_ethtool_lpa_x LINUX_BACKPORT(mii_lpa_to_ethtool_lpa_x)
|
||||
static inline u32 mii_lpa_to_ethtool_lpa_x(u32 lpa)
|
||||
{
|
||||
u32 result = 0;
|
||||
|
||||
if (lpa & LPA_LPACK)
|
||||
result |= ADVERTISED_Autoneg;
|
||||
|
||||
return result | mii_adv_to_ethtool_adv_x(lpa);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_MII_H */
|
28
backport-include/linux/mm.h
Normal file
28
backport-include/linux/mm.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef __BACKPORT_MM_H
|
||||
#define __BACKPORT_MM_H
|
||||
#include_next <linux/mm.h>
|
||||
|
||||
#ifndef VM_NODUMP
|
||||
/*
|
||||
* defined here to allow things to compile but technically
|
||||
* using this for memory regions will yield in a no-op on newer
|
||||
* kernels but on older kernels (v3.3 and older) this bit was used
|
||||
* for VM_ALWAYSDUMP. The goal was to remove this bit moving forward
|
||||
* and since we can't skip the core dump on old kernels we just make
|
||||
* this bit name now a no-op.
|
||||
*
|
||||
* For details see commits: 909af7 accb61fe cdaaa7003
|
||||
*/
|
||||
#define VM_NODUMP 0x0
|
||||
#endif
|
||||
|
||||
#ifndef VM_DONTDUMP
|
||||
#define VM_DONTDUMP VM_NODUMP
|
||||
#endif
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0))
|
||||
#define vm_iomap_memory LINUX_BACKPORT(vm_iomap_memory)
|
||||
int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len);
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_MM_H */
|
12
backport-include/linux/mmc/core.h
Normal file
12
backport-include/linux/mmc/core.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __BACKPORT_MMC_CORE_H
|
||||
#define __BACKPORT_MMC_CORE_H
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/mmc/core.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
|
||||
#define mmc_align_data_size LINUX_BACKPORT(mmc_align_data_size)
|
||||
extern unsigned int mmc_align_data_size(struct mmc_card *, unsigned int);
|
||||
#endif /* 2.6.24 - 2.6.26 */
|
||||
|
||||
#endif /* __BACKPORT_MMC_CORE_H */
|
11
backport-include/linux/mmc/host.h
Normal file
11
backport-include/linux/mmc/host.h
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __BACKPORT_MMC_HOST_H
|
||||
#define __BACKPORT_MMC_HOST_H
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/mmc/host.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
|
||||
/* rename member in struct mmc_host */
|
||||
#define max_segs max_hw_segs
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_MMC_HOST_H */
|
21
backport-include/linux/mmc/sdio.h
Normal file
21
backport-include/linux/mmc/sdio.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __BACKPORT_MMC_SDIO_H
|
||||
#define __BACKPORT_MMC_SDIO_H
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/mmc/sdio.h>
|
||||
|
||||
/* backports b4625dab */
|
||||
#ifndef SDIO_CCCR_REV_3_00
|
||||
#define SDIO_CCCR_REV_3_00 3 /* CCCR/FBR Version 3.00 */
|
||||
#endif
|
||||
#ifndef SDIO_SDIO_REV_3_00
|
||||
#define SDIO_SDIO_REV_3_00 4 /* SDIO Spec Version 3.00 */
|
||||
#endif
|
||||
|
||||
#ifndef SDIO_BUS_ECSI
|
||||
#define SDIO_BUS_ECSI 0x20 /* Enable continuous SPI interrupt */
|
||||
#endif
|
||||
#ifndef SDIO_BUS_SCSI
|
||||
#define SDIO_BUS_SCSI 0x40 /* Support continuous SPI interrupt */
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_MMC_SDIO_H */
|
40
backport-include/linux/mmc/sdio_func.h
Normal file
40
backport-include/linux/mmc/sdio_func.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __BACKPORT_MMC_SDIO_FUNC_H
|
||||
#define __BACKPORT_MMC_SDIO_FUNC_H
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/mmc/sdio_func.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define sdio_writeb_readb(func, write_byte, addr, err_ret) sdio_readb(func, addr, err_ret)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
/*
|
||||
* Backports da68c4eb25
|
||||
* sdio: introduce API for special power management features
|
||||
*
|
||||
* We simply carry around the data structures and flags, and
|
||||
* make the host return no flags set by the driver.
|
||||
*
|
||||
* This is declared in mmc/pm.h upstream, but that files
|
||||
* didn't exist before this commit and isn't included directly.
|
||||
*/
|
||||
typedef unsigned int mmc_pm_flag_t;
|
||||
|
||||
#define MMC_PM_KEEP_POWER (1 << 0) /* preserve card power during suspend */
|
||||
#define MMC_PM_WAKE_SDIO_IRQ (1 << 1) /* wake up host system on SDIO IRQ assertion */
|
||||
|
||||
extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func);
|
||||
extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags);
|
||||
#endif
|
||||
|
||||
#ifndef dev_to_sdio_func
|
||||
#define dev_to_sdio_func(d) container_of(d, struct sdio_func, dev)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
|
||||
#define sdio_align_size LINUX_BACKPORT(sdio_align_size)
|
||||
extern unsigned int sdio_align_size(struct sdio_func *func, unsigned int sz);
|
||||
#endif /* 2.6.24 - 2.6.26 */
|
||||
|
||||
#endif /* __BACKPORT_MMC_SDIO_FUNC_H */
|
14
backport-include/linux/mmc/sdio_ids.h
Normal file
14
backport-include/linux/mmc/sdio_ids.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef __BACKPORT_MMC_SDIO_IDS_H
|
||||
#define __BACKPORT_MMC_SDIO_IDS_H
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/mmc/sdio_ids.h>
|
||||
|
||||
#ifndef SDIO_CLASS_BT_AMP
|
||||
#define SDIO_CLASS_BT_AMP 0x09 /* Type-A Bluetooth AMP interface */
|
||||
#endif
|
||||
|
||||
#ifndef SDIO_DEVICE_ID_MARVELL_8688WLAN
|
||||
#define SDIO_DEVICE_ID_MARVELL_8688WLAN 0x9104
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_MMC_SDIO_IDS_H */
|
49
backport-include/linux/mod_devicetable.h
Normal file
49
backport-include/linux/mod_devicetable.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef __BACKPORT_MOD_DEVICETABLE_H
|
||||
#define __BACKPORT_MOD_DEVICETABLE_H
|
||||
#include_next <linux/mod_devicetable.h>
|
||||
|
||||
#ifndef HID_BUS_ANY
|
||||
#define HID_BUS_ANY 0xffff
|
||||
#endif
|
||||
|
||||
#ifndef HID_GROUP_ANY
|
||||
#define HID_GROUP_ANY 0x0000
|
||||
#endif
|
||||
|
||||
#ifndef HID_ANY_ID
|
||||
#define HID_ANY_ID (~0)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
|
||||
struct hid_device_id {
|
||||
__u16 bus;
|
||||
__u32 vendor;
|
||||
__u32 product;
|
||||
kernel_ulong_t driver_data
|
||||
__attribute__((aligned(sizeof(kernel_ulong_t))));
|
||||
};
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
||||
#ifndef BCMA_CORE
|
||||
/* Broadcom's specific AMBA core, see drivers/bcma/ */
|
||||
struct bcma_device_id {
|
||||
__u16 manuf;
|
||||
__u16 id;
|
||||
__u8 rev;
|
||||
__u8 class;
|
||||
};
|
||||
#define BCMA_CORE(_manuf, _id, _rev, _class) \
|
||||
{ .manuf = _manuf, .id = _id, .rev = _rev, .class = _class, }
|
||||
#define BCMA_CORETABLE_END \
|
||||
{ 0, },
|
||||
|
||||
#define BCMA_ANY_MANUF 0xFFFF
|
||||
#define BCMA_ANY_ID 0xFFFF
|
||||
#define BCMA_ANY_REV 0xFF
|
||||
#define BCMA_ANY_CLASS 0xFF
|
||||
#endif /* BCMA_CORE */
|
||||
|
||||
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)) */
|
||||
|
||||
#endif /* __BACKPORT_MOD_DEVICETABLE_H */
|
67
backport-include/linux/module.h
Normal file
67
backport-include/linux/module.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef __BACKPORT_LINUX_MODULE_H
|
||||
#define __BACKPORT_LINUX_MODULE_H
|
||||
#include_next <linux/module.h>
|
||||
#include <linux/rcupdate.h>
|
||||
|
||||
/*
|
||||
* The define overwriting module_init is based on the original module_init
|
||||
* which looks like this:
|
||||
* #define module_init(initfn) \
|
||||
* static inline initcall_t __inittest(void) \
|
||||
* { return initfn; } \
|
||||
* int init_module(void) __attribute__((alias(#initfn)));
|
||||
*
|
||||
* To the call to the initfn we added the symbol dependency on compat
|
||||
* to make sure that compat.ko gets loaded for any compat modules.
|
||||
*/
|
||||
extern void backport_dependency_symbol(void);
|
||||
|
||||
#ifdef BACKPORTS_GIT_TRACKED
|
||||
#define BACKPORT_MOD_VERSIONS MODULE_VERSION(BACKPORTS_GIT_TRACKED);
|
||||
#else
|
||||
#define BACKPORT_MOD_VERSIONS \
|
||||
MODULE_VERSION("backported from " BACKPORTED_KERNEL_NAME \
|
||||
" (" BACKPORTED_KERNEL_VERSION ")" \
|
||||
" using backports " BACKPORTS_VERSION);
|
||||
#endif
|
||||
|
||||
#undef module_init
|
||||
#define module_init(initfn) \
|
||||
static int __init __init_backport(void) \
|
||||
{ \
|
||||
backport_dependency_symbol(); \
|
||||
return initfn(); \
|
||||
} \
|
||||
int init_module(void) __attribute__((alias("__init_backport")));\
|
||||
BACKPORT_MOD_VERSIONS
|
||||
|
||||
/*
|
||||
* The define overwriting module_exit is based on the original module_exit
|
||||
* which looks like this:
|
||||
* #define module_exit(exitfn) \
|
||||
* static inline exitcall_t __exittest(void) \
|
||||
* { return exitfn; } \
|
||||
* void cleanup_module(void) __attribute__((alias(#exitfn)));
|
||||
*
|
||||
* We replaced the call to the actual function exitfn() with a call to our
|
||||
* function which calls the original exitfn() and then rcu_barrier()
|
||||
*
|
||||
* As a module will not be unloaded that ofter it should not have a big
|
||||
* performance impact when rcu_barrier() is called on every module exit,
|
||||
* also when no kfree_rcu() backport is used in that module.
|
||||
*/
|
||||
#undef module_exit
|
||||
#define module_exit(exitfn) \
|
||||
static void __exit __exit_compat(void) \
|
||||
{ \
|
||||
exitfn(); \
|
||||
rcu_barrier(); \
|
||||
} \
|
||||
void cleanup_module(void) __attribute__((alias("__exit_compat")));
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
|
||||
#undef param_check_bool
|
||||
#define param_check_bool(name, p) __param_check(name, p, bool)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_MODULE_H */
|
12
backport-include/linux/moduleparam.h
Normal file
12
backport-include/linux/moduleparam.h
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef __BACKPORT_LINUX_MODULEPARAM_H
|
||||
#define __BACKPORT_LINUX_MODULEPARAM_H
|
||||
#include_next <linux/moduleparam.h>
|
||||
|
||||
#ifndef kparam_block_sysfs_write
|
||||
#define kparam_block_sysfs_write(a)
|
||||
#endif
|
||||
#ifndef kparam_unblock_sysfs_write
|
||||
#define kparam_unblock_sysfs_write(a)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_MODULEPARAM_H */
|
44
backport-include/linux/net.h
Normal file
44
backport-include/linux/net.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef __BACKPORT_LINUX_NET_H
|
||||
#define __BACKPORT_LINUX_NET_H
|
||||
#include_next <linux/net.h>
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 2033e9bf06f07e049bbc77e9452856df846714cc
|
||||
* Author: Neil Horman <nhorman@tuxdriver.com>
|
||||
* Date: Tue May 29 09:30:40 2012 +0000
|
||||
*
|
||||
* net: add MODULE_ALIAS_NET_PF_PROTO_NAME
|
||||
*/
|
||||
#ifndef MODULE_ALIAS_NET_PF_PROTO_NAME
|
||||
#define MODULE_ALIAS_NET_PF_PROTO_NAME(pf, proto, name) \
|
||||
MODULE_ALIAS("net-pf-" __stringify(pf) "-proto-" __stringify(proto) \
|
||||
name)
|
||||
#endif
|
||||
|
||||
#ifndef net_ratelimited_function
|
||||
#define net_ratelimited_function(function, ...) \
|
||||
do { \
|
||||
if (net_ratelimit()) \
|
||||
function(__VA_ARGS__); \
|
||||
} while (0)
|
||||
|
||||
#define net_emerg_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_emerg, fmt, ##__VA_ARGS__)
|
||||
#define net_alert_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_alert, fmt, ##__VA_ARGS__)
|
||||
#define net_crit_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_crit, fmt, ##__VA_ARGS__)
|
||||
#define net_err_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_err, fmt, ##__VA_ARGS__)
|
||||
#define net_notice_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_notice, fmt, ##__VA_ARGS__)
|
||||
#define net_warn_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_warn, fmt, ##__VA_ARGS__)
|
||||
#define net_info_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_info, fmt, ##__VA_ARGS__)
|
||||
#define net_dbg_ratelimited(fmt, ...) \
|
||||
net_ratelimited_function(pr_debug, fmt, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_NET_H */
|
52
backport-include/linux/netdev_features.h
Normal file
52
backport-include/linux/netdev_features.h
Normal file
@ -0,0 +1,52 @@
|
||||
#ifndef __BACKPORT_NETDEV_FEATURES_H
|
||||
#define __BACKPORT_NETDEV_FEATURES_H
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
|
||||
#include <linux/netdevice.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
/* added via 9356b8fc */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,14)
|
||||
#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX
|
||||
#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
|
||||
#endif
|
||||
|
||||
/* added via d314774c */
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
|
||||
#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
|
||||
#endif
|
||||
|
||||
#if RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,5)
|
||||
typedef u32 netdev_features_t;
|
||||
#endif
|
||||
#else
|
||||
#include_next <linux/netdev_features.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
|
||||
/* See commit f646968f8f on next-20130423 */
|
||||
#define NETIF_F_HW_VLAN_CTAG_TX_BIT NETIF_F_HW_VLAN_TX_BIT
|
||||
#define NETIF_F_HW_VLAN_CTAG_RX_BIT NETIF_F_HW_VLAN_RX_BIT
|
||||
#define NETIF_F_HW_VLAN_CTAG_FILTER_BIT NETIF_F_HW_VLAN_FILTER_BIT
|
||||
|
||||
#define NETIF_F_HW_VLAN_CTAG_FILTER NETIF_F_HW_VLAN_FILTER
|
||||
#define NETIF_F_HW_VLAN_CTAG_RX NETIF_F_HW_VLAN_RX
|
||||
#define NETIF_F_HW_VLAN_CTAG_TX NETIF_F_HW_VLAN_TX
|
||||
#endif
|
||||
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0) */
|
||||
|
||||
#if !defined(NETIF_F_RXCSUM)
|
||||
#define NETIF_F_RXCSUM 0
|
||||
#endif
|
||||
|
||||
#if !defined(NETIF_F_RXALL)
|
||||
#define NETIF_F_RXALL 0
|
||||
#endif
|
||||
|
||||
#if !defined(NETIF_F_RXFCS)
|
||||
#define NETIF_F_RXFCS 0
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_NETDEV_FEATURES_H */
|
478
backport-include/linux/netdevice.h
Normal file
478
backport-include/linux/netdevice.h
Normal file
@ -0,0 +1,478 @@
|
||||
#ifndef __BACKPORT_NETDEVICE_H
|
||||
#define __BACKPORT_NETDEVICE_H
|
||||
#include_next <linux/netdevice.h>
|
||||
#include <linux/netdev_features.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/*
|
||||
* This is declared implicitly in newer kernels by netdevice.h using
|
||||
* this pointer in struct net_device, but declare it here anyway so
|
||||
* pointers to it are accepted as function arguments without warning.
|
||||
*/
|
||||
struct inet6_dev;
|
||||
|
||||
/* older kernels don't include this here, we need it */
|
||||
#include <linux/ethtool.h>
|
||||
#include <linux/rculist.h>
|
||||
/*
|
||||
* new kernels include <net/netprio_cgroup.h> which
|
||||
* has this ... and some drivers rely on it :-(
|
||||
*/
|
||||
#include <linux/hardirq.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
|
||||
#define dev_change_net_namespace(a, b, c) (-EOPNOTSUPP)
|
||||
|
||||
static inline void SET_NETDEV_DEVTYPE(struct net_device *dev, void *type)
|
||||
{
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
typedef int netdev_tx_t;
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||
/*
|
||||
* Older kernels do not have struct net_device_ops but what we can
|
||||
* do is just define the data structure and use a caller to let us
|
||||
* set the data structure's routines onto the old netdev, essentially
|
||||
* doing it the old way. This avoids huge deltas on our backports.
|
||||
*/
|
||||
#define HAVE_NET_DEVICE_OPS
|
||||
struct net_device_ops {
|
||||
int (*ndo_init)(struct net_device *dev);
|
||||
void (*ndo_uninit)(struct net_device *dev);
|
||||
int (*ndo_open)(struct net_device *dev);
|
||||
int (*ndo_stop)(struct net_device *dev);
|
||||
netdev_tx_t (*ndo_start_xmit) (struct sk_buff *skb,
|
||||
struct net_device *dev);
|
||||
u16 (*ndo_select_queue)(struct net_device *dev,
|
||||
struct sk_buff *skb);
|
||||
void (*ndo_change_rx_flags)(struct net_device *dev,
|
||||
int flags);
|
||||
void (*ndo_set_rx_mode)(struct net_device *dev);
|
||||
void (*ndo_set_multicast_list)(struct net_device *dev);
|
||||
int (*ndo_set_mac_address)(struct net_device *dev,
|
||||
void *addr);
|
||||
int (*ndo_validate_addr)(struct net_device *dev);
|
||||
int (*ndo_do_ioctl)(struct net_device *dev,
|
||||
struct ifreq *ifr, int cmd);
|
||||
int (*ndo_set_config)(struct net_device *dev,
|
||||
struct ifmap *map);
|
||||
int (*ndo_change_mtu)(struct net_device *dev,
|
||||
int new_mtu);
|
||||
int (*ndo_neigh_setup)(struct net_device *dev,
|
||||
struct neigh_parms *);
|
||||
void (*ndo_tx_timeout) (struct net_device *dev);
|
||||
|
||||
struct net_device_stats* (*ndo_get_stats)(struct net_device *dev);
|
||||
|
||||
void (*ndo_vlan_rx_register)(struct net_device *dev,
|
||||
struct vlan_group *grp);
|
||||
void (*ndo_vlan_rx_add_vid)(struct net_device *dev,
|
||||
unsigned short vid);
|
||||
void (*ndo_vlan_rx_kill_vid)(struct net_device *dev,
|
||||
unsigned short vid);
|
||||
#ifdef CONFIG_NET_POLL_CONTROLLER
|
||||
void (*ndo_poll_controller)(struct net_device *dev);
|
||||
#endif
|
||||
int (*ndo_set_vf_mac)(struct net_device *dev,
|
||||
int queue, u8 *mac);
|
||||
int (*ndo_set_vf_vlan)(struct net_device *dev,
|
||||
int queue, u16 vlan, u8 qos);
|
||||
int (*ndo_set_vf_tx_rate)(struct net_device *dev,
|
||||
int vf, int rate);
|
||||
#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
|
||||
int (*ndo_fcoe_enable)(struct net_device *dev);
|
||||
int (*ndo_fcoe_disable)(struct net_device *dev);
|
||||
int (*ndo_fcoe_ddp_setup)(struct net_device *dev,
|
||||
u16 xid,
|
||||
struct scatterlist *sgl,
|
||||
unsigned int sgc);
|
||||
int (*ndo_fcoe_ddp_done)(struct net_device *dev,
|
||||
u16 xid);
|
||||
#define NETDEV_FCOE_WWNN 0
|
||||
#define NETDEV_FCOE_WWPN 1
|
||||
int (*ndo_fcoe_get_wwn)(struct net_device *dev,
|
||||
u64 *wwn, int type);
|
||||
#endif
|
||||
};
|
||||
|
||||
static inline struct net_device_stats *dev_get_stats(struct net_device *dev)
|
||||
{
|
||||
return dev->get_stats(dev);
|
||||
}
|
||||
|
||||
#define init_dummy_netdev LINUX_BACKPORT(init_dummy_netdev)
|
||||
extern int init_dummy_netdev(struct net_device *dev);
|
||||
|
||||
#define napi_gro_receive(napi, skb) netif_receive_skb(skb)
|
||||
#endif /* < 2.6.29 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,8)
|
||||
#define netdev_set_default_ethtool_ops LINUX_BACKPORT(netdev_set_default_ethtool_ops)
|
||||
extern void netdev_set_default_ethtool_ops(struct net_device *dev,
|
||||
const struct ethtool_ops *ops);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||
#define netdev_attach_ops LINUX_BACKPORT(netdev_attach_ops)
|
||||
void netdev_attach_ops(struct net_device *dev,
|
||||
const struct net_device_ops *ops);
|
||||
|
||||
static inline int ndo_do_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr,
|
||||
int cmd)
|
||||
{
|
||||
if (dev->do_ioctl)
|
||||
return dev->do_ioctl(dev, ifr, cmd);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
#else
|
||||
/* XXX: this can probably just go upstream ! */
|
||||
static inline void netdev_attach_ops(struct net_device *dev,
|
||||
const struct net_device_ops *ops)
|
||||
{
|
||||
dev->netdev_ops = ops;
|
||||
}
|
||||
|
||||
/* XXX: this can probably just go upstream! */
|
||||
static inline int ndo_do_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr,
|
||||
int cmd)
|
||||
{
|
||||
if (dev->netdev_ops && dev->netdev_ops->ndo_do_ioctl)
|
||||
return dev->netdev_ops->ndo_do_ioctl(dev, ifr, cmd);
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
|
||||
/*
|
||||
* BQL was added as of v3.3 but some Linux distributions
|
||||
* have backported BQL to their v3.2 kernels or older. To
|
||||
* address this we assume that they also enabled CONFIG_BQL
|
||||
* and test for that here and simply avoid adding the static
|
||||
* inlines if it was defined
|
||||
*/
|
||||
#ifndef CONFIG_BQL
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
|
||||
#define netdev_tx_sent_queue LINUX_BACKPORT(netdev_tx_sent_queue)
|
||||
static inline void netdev_tx_sent_queue(struct netdev_queue *dev_queue,
|
||||
unsigned int bytes)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define netdev_sent_queue LINUX_BACKPORT(netdev_sent_queue)
|
||||
static inline void netdev_sent_queue(struct net_device *dev, unsigned int bytes)
|
||||
{
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
|
||||
#define netdev_tx_completed_queue LINUX_BACKPORT(netdev_tx_completed_queue)
|
||||
static inline void netdev_tx_completed_queue(struct netdev_queue *dev_queue,
|
||||
unsigned pkts, unsigned bytes)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define netdev_completed_queue LINUX_BACKPORT(netdev_completed_queue)
|
||||
static inline void netdev_completed_queue(struct net_device *dev,
|
||||
unsigned pkts, unsigned bytes)
|
||||
{
|
||||
}
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26))
|
||||
#define netdev_tx_reset_queue LINUX_BACKPORT(netdev_tx_reset_queue)
|
||||
static inline void netdev_tx_reset_queue(struct netdev_queue *q)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
#define netdev_reset_queue LINUX_BACKPORT(netdev_reset_queue)
|
||||
static inline void netdev_reset_queue(struct net_device *dev_queue)
|
||||
{
|
||||
}
|
||||
#endif /* CONFIG_BQL */
|
||||
#endif /* < 3.3 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,0,0)
|
||||
/*
|
||||
* since commit 1c5cae815d19ffe02bdfda1260949ef2b1806171
|
||||
* "net: call dev_alloc_name from register_netdevice" dev_alloc_name is
|
||||
* called automatically. This is not implemented in older kernel
|
||||
* versions so it will result in device wrong names.
|
||||
*/
|
||||
static inline int register_netdevice_name(struct net_device *dev)
|
||||
{
|
||||
int err;
|
||||
|
||||
if (strchr(dev->name, '%')) {
|
||||
err = dev_alloc_name(dev, dev->name);
|
||||
if (err < 0)
|
||||
return err;
|
||||
}
|
||||
|
||||
return register_netdevice(dev);
|
||||
}
|
||||
|
||||
#define register_netdevice(dev) register_netdevice_name(dev)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
#define alloc_netdev_mqs(sizeof_priv, name, setup, txqs, rxqs) \
|
||||
alloc_netdev_mq(sizeof_priv, name, setup, \
|
||||
max_t(unsigned int, txqs, rxqs))
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
|
||||
#define netdev_refcnt_read(a) atomic_read(&a->refcnt)
|
||||
|
||||
#define net_ns_type_operations LINUX_BACKPORT(net_ns_type_operations)
|
||||
extern struct kobj_ns_type_operations net_ns_type_operations;
|
||||
|
||||
#if (RHEL_RELEASE_CODE < RHEL_RELEASE_VERSION(6,4))
|
||||
#ifdef CONFIG_RPS
|
||||
extern int netif_set_real_num_rx_queues(struct net_device *dev,
|
||||
unsigned int rxq);
|
||||
#else
|
||||
static inline int netif_set_real_num_rx_queues(struct net_device *dev,
|
||||
unsigned int rxq)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* < 2.6.37 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
/*
|
||||
* etherdevice.h requires netdev_hw_addr to not have been redefined,
|
||||
* so while generally we shouldn't/wouldn't include unrelated header
|
||||
* files here it's unavoidable. However, if we got included through
|
||||
* it, then we let it sort out the netdev_hw_addr define so that it
|
||||
* still gets the correct one later ...
|
||||
*/
|
||||
#include <linux/etherdevice.h>
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define netif_set_real_num_tx_queues LINUX_BACKPORT(netif_set_real_num_tx_queues)
|
||||
extern int netif_set_real_num_tx_queues(struct net_device *dev,
|
||||
unsigned int txq);
|
||||
#define mc_addr(ha) (ha)->dmi_addr
|
||||
#else
|
||||
#define mc_addr(ha) (ha)->addr
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
#define netdev_mc_count(dev) ((dev)->mc_count)
|
||||
#define netdev_mc_empty(dev) (netdev_mc_count(dev) == 0)
|
||||
|
||||
/* mask netdev_for_each_mc_addr as RHEL6 backports this */
|
||||
#ifndef netdev_for_each_mc_addr
|
||||
#define netdev_for_each_mc_addr(mclist, dev) \
|
||||
for (mclist = dev->mc_list; mclist; mclist = mclist->next)
|
||||
#endif
|
||||
|
||||
#ifndef netdev_name
|
||||
#define netdev_name(__dev) \
|
||||
((__dev->reg_state != NETREG_REGISTERED) ? \
|
||||
"(unregistered net_device)" : __dev->name)
|
||||
#endif
|
||||
|
||||
#define netdev_printk(level, netdev, format, args...) \
|
||||
dev_printk(level, (netdev)->dev.parent, \
|
||||
"%s: " format, \
|
||||
netdev_name(netdev), ##args)
|
||||
|
||||
#define netdev_emerg(dev, format, args...) \
|
||||
netdev_printk(KERN_EMERG, dev, format, ##args)
|
||||
#define netdev_alert(dev, format, args...) \
|
||||
netdev_printk(KERN_ALERT, dev, format, ##args)
|
||||
#define netdev_crit(dev, format, args...) \
|
||||
netdev_printk(KERN_CRIT, dev, format, ##args)
|
||||
#define netdev_err(dev, format, args...) \
|
||||
netdev_printk(KERN_ERR, dev, format, ##args)
|
||||
#define netdev_warn(dev, format, args...) \
|
||||
netdev_printk(KERN_WARNING, dev, format, ##args)
|
||||
#define netdev_notice(dev, format, args...) \
|
||||
netdev_printk(KERN_NOTICE, dev, format, ##args)
|
||||
#define netdev_info(dev, format, args...) \
|
||||
netdev_printk(KERN_INFO, dev, format, ##args)
|
||||
|
||||
/* mask netdev_dbg as RHEL6 backports this */
|
||||
#if !defined(netdev_dbg)
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define netdev_dbg(__dev, format, args...) \
|
||||
netdev_printk(KERN_DEBUG, __dev, format, ##args)
|
||||
#elif defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#define netdev_dbg(__dev, format, args...) \
|
||||
do { \
|
||||
dynamic_dev_dbg((__dev)->dev.parent, "%s: " format, \
|
||||
netdev_name(__dev), ##args); \
|
||||
} while (0)
|
||||
#else
|
||||
#define netdev_dbg(__dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netdev_printk(KERN_DEBUG, __dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* mask netdev_vdbg as RHEL6 backports this */
|
||||
#if !defined(netdev_dbg)
|
||||
|
||||
#if defined(VERBOSE_DEBUG)
|
||||
#define netdev_vdbg netdev_dbg
|
||||
#else
|
||||
|
||||
#define netdev_vdbg(dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netdev_printk(KERN_DEBUG, dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* netdev_WARN() acts like dev_printk(), but with the key difference
|
||||
* of using a WARN/WARN_ON to get the message out, including the
|
||||
* file/line information and a backtrace.
|
||||
*/
|
||||
#define netdev_WARN(dev, format, args...) \
|
||||
WARN(1, "netdevice: %s\n" format, netdev_name(dev), ##args);
|
||||
|
||||
/* netif printk helpers, similar to netdev_printk */
|
||||
|
||||
#define netif_printk(priv, type, level, dev, fmt, args...) \
|
||||
do { \
|
||||
if (netif_msg_##type(priv)) \
|
||||
netdev_printk(level, (dev), fmt, ##args); \
|
||||
} while (0)
|
||||
|
||||
#define netif_emerg(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_EMERG, dev, fmt, ##args)
|
||||
#define netif_alert(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_ALERT, dev, fmt, ##args)
|
||||
#define netif_crit(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_CRIT, dev, fmt, ##args)
|
||||
#define netif_err(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_ERR, dev, fmt, ##args)
|
||||
#define netif_warn(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_WARNING, dev, fmt, ##args)
|
||||
#define netif_notice(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_NOTICE, dev, fmt, ##args)
|
||||
#define netif_info(priv, type, dev, fmt, args...) \
|
||||
netif_printk(priv, type, KERN_INFO, (dev), fmt, ##args)
|
||||
|
||||
/* mask netif_dbg as RHEL6 backports this */
|
||||
#if !defined(netif_dbg)
|
||||
|
||||
#if defined(DEBUG)
|
||||
#define netif_dbg(priv, type, dev, format, args...) \
|
||||
netif_printk(priv, type, KERN_DEBUG, dev, format, ##args)
|
||||
#elif defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#define netif_dbg(priv, type, netdev, format, args...) \
|
||||
do { \
|
||||
if (netif_msg_##type(priv)) \
|
||||
dynamic_dev_dbg((netdev)->dev.parent, \
|
||||
"%s: " format, \
|
||||
netdev_name(netdev), ##args); \
|
||||
} while (0)
|
||||
#else
|
||||
#define netif_dbg(priv, type, dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netif_printk(priv, type, KERN_DEBUG, dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* mask netif_vdbg as RHEL6 backports this */
|
||||
#if !defined(netif_vdbg)
|
||||
|
||||
#if defined(VERBOSE_DEBUG)
|
||||
#define netif_vdbg netdev_dbg
|
||||
#else
|
||||
#define netif_vdbg(priv, type, dev, format, args...) \
|
||||
({ \
|
||||
if (0) \
|
||||
netif_printk(KERN_DEBUG, dev, format, ##args); \
|
||||
0; \
|
||||
})
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* < 2.6.34 */
|
||||
|
||||
/* mask NETDEV_POST_INIT as RHEL6 backports this */
|
||||
/* this will never happen on older kernels */
|
||||
#ifndef NETDEV_POST_INIT
|
||||
#define NETDEV_POST_INIT 0xffff
|
||||
#endif
|
||||
|
||||
#ifndef NETDEV_PRE_UP
|
||||
#define NETDEV_PRE_UP 0x000D
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
/*
|
||||
* On older kernels we do not have net_device Multi Queue support, but
|
||||
* since we no longer use MQ on mac80211 we can simply use the 0 queue.
|
||||
* Note that if other fullmac drivers make use of this they then need
|
||||
* to be backported somehow or deal with just 1 queue from MQ.
|
||||
*/
|
||||
static inline void netif_tx_wake_all_queues(struct net_device *dev)
|
||||
{
|
||||
netif_wake_queue(dev);
|
||||
}
|
||||
static inline void netif_tx_start_all_queues(struct net_device *dev)
|
||||
{
|
||||
netif_start_queue(dev);
|
||||
}
|
||||
static inline void netif_tx_stop_all_queues(struct net_device *dev)
|
||||
{
|
||||
netif_stop_queue(dev);
|
||||
}
|
||||
|
||||
/*
|
||||
* The net_device has a spin_lock on newer kernels, on older kernels we're out of luck
|
||||
*/
|
||||
#define netif_addr_lock_bh(dev)
|
||||
#define netif_addr_unlock_bh(dev)
|
||||
|
||||
#define netif_wake_subqueue netif_start_subqueue
|
||||
#endif /* < 2.6.27 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
|
||||
static inline
|
||||
struct net *dev_net(const struct net_device *dev)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
/*
|
||||
* compat-wirelss backport note:
|
||||
* For older kernels we may just need to always return init_net,
|
||||
* not sure when we added dev->nd_net.
|
||||
*/
|
||||
return dev->nd_net;
|
||||
#else
|
||||
return &init_net;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,11,0)
|
||||
#define netdev_notifier_info_to_dev(ndev) ndev
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_NETDEVICE_H */
|
15
backport-include/linux/netlink.h
Normal file
15
backport-include/linux/netlink.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef __BACKPORT_LINUX_NETLINK_H
|
||||
#define __BACKPORT_LINUX_NETLINK_H
|
||||
#include_next <linux/netlink.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/* this is for patches we apply */
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
|
||||
#define netlink_notify_portid(__notify) (__notify->pid)
|
||||
#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).pid
|
||||
#else
|
||||
#define netlink_notify_portid(__notify) (__notify->portid)
|
||||
#define NETLINK_CB_PORTID(__skb) NETLINK_CB(__skb).portid
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_NETLINK_H */
|
10
backport-include/linux/nl80211.h
Normal file
10
backport-include/linux/nl80211.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef __BACKPORT_LINUX_NL80211_H
|
||||
#define __BACKPORT_LINUX_NL80211_H
|
||||
#include_next <linux/nl80211.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,3,0)
|
||||
#define NL80211_FEATURE_SK_TX_STATUS 0
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_NL80211_H */
|
49
backport-include/linux/of.h
Normal file
49
backport-include/linux/of.h
Normal file
@ -0,0 +1,49 @@
|
||||
#ifndef _COMPAT_LINUX_OF_H
|
||||
#define _COMPAT_LINUX_OF_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,34) || defined(CONFIG_OF)
|
||||
#include_next <linux/of.h>
|
||||
#else
|
||||
struct device_node;
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
|
||||
#ifdef CONFIG_OF
|
||||
extern struct device_node *of_get_child_by_name(const struct device_node *node,
|
||||
const char *name);
|
||||
#else
|
||||
static inline struct device_node *of_get_child_by_name(
|
||||
const struct device_node *node,
|
||||
const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif /* CONFIG_OF */
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
|
||||
#ifndef CONFIG_OF
|
||||
static inline struct device_node *of_find_node_by_name(struct device_node *from,
|
||||
const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif /* CONFIG_OF */
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||
#ifdef CONFIG_OF
|
||||
extern int of_property_read_u8_array(const struct device_node *np,
|
||||
const char *propname, u8 *out_values, size_t sz);
|
||||
#else
|
||||
static inline int of_property_read_u8_array(const struct device_node *np,
|
||||
const char *propname, u8 *out_values, size_t sz)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
#endif /* CONFIG_OF */
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0) */
|
||||
|
||||
#endif /* _COMPAT_LINUX_OF_H */
|
10
backport-include/linux/olpc-ec.h
Normal file
10
backport-include/linux/olpc-ec.h
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef _COMPAT_LINUX_OLPC_EC_H
|
||||
#define _COMPAT_LINUX_OLPC_EC_H
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
|
||||
#include_next <linux/olpc-ec.h>
|
||||
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(3,6,0)) */
|
||||
|
||||
#endif /* _COMPAT_LINUX_OLPC_EC_H */
|
13
backport-include/linux/pci-aspm.h
Normal file
13
backport-include/linux/pci-aspm.h
Normal file
@ -0,0 +1,13 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
|
||||
#include_next <linux/pci-aspm.h>
|
||||
#else
|
||||
#define PCIE_LINK_STATE_L0S 1
|
||||
#define PCIE_LINK_STATE_L1 2
|
||||
#define PCIE_LINK_STATE_CLKPM 4
|
||||
|
||||
static inline void pci_disable_link_state(struct pci_dev *pdev, int state)
|
||||
{
|
||||
}
|
||||
#endif
|
181
backport-include/linux/pci.h
Normal file
181
backport-include/linux/pci.h
Normal file
@ -0,0 +1,181 @@
|
||||
#ifndef _BACKPORT_LINUX_PCI_H
|
||||
#define _BACKPORT_LINUX_PCI_H
|
||||
#include_next <linux/pci.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
|
||||
#define compat_pci_suspend(fn) \
|
||||
int fn##_compat(struct pci_dev *pdev, pm_message_t state) \
|
||||
{ \
|
||||
int r; \
|
||||
\
|
||||
r = fn(&pdev->dev); \
|
||||
if (r) \
|
||||
return r; \
|
||||
\
|
||||
pci_save_state(pdev); \
|
||||
pci_disable_device(pdev); \
|
||||
pci_set_power_state(pdev, PCI_D3hot); \
|
||||
\
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define compat_pci_resume(fn) \
|
||||
int fn##_compat(struct pci_dev *pdev) \
|
||||
{ \
|
||||
int r; \
|
||||
\
|
||||
pci_set_power_state(pdev, PCI_D0); \
|
||||
r = pci_enable_device(pdev); \
|
||||
if (r) \
|
||||
return r; \
|
||||
pci_restore_state(pdev); \
|
||||
\
|
||||
return fn(&pdev->dev); \
|
||||
}
|
||||
#elif LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29)
|
||||
#define compat_pci_suspend(fn) \
|
||||
int fn##_compat(struct device *dev) \
|
||||
{ \
|
||||
struct pci_dev *pdev = to_pci_dev(dev); \
|
||||
int r; \
|
||||
\
|
||||
r = fn(&pdev->dev); \
|
||||
if (r) \
|
||||
return r; \
|
||||
\
|
||||
pci_save_state(pdev); \
|
||||
pci_disable_device(pdev); \
|
||||
pci_set_power_state(pdev, PCI_D3hot); \
|
||||
\
|
||||
return 0; \
|
||||
}
|
||||
|
||||
#define compat_pci_resume(fn) \
|
||||
int fn##_compat(struct device *dev) \
|
||||
{ \
|
||||
struct pci_dev *pdev = to_pci_dev(dev); \
|
||||
int r; \
|
||||
\
|
||||
pci_set_power_state(pdev, PCI_D0); \
|
||||
r = pci_enable_device(pdev); \
|
||||
if (r) \
|
||||
return r; \
|
||||
pci_restore_state(pdev); \
|
||||
\
|
||||
return fn(&pdev->dev); \
|
||||
}
|
||||
#else
|
||||
#define compat_pci_suspend(fn)
|
||||
#define compat_pci_resume(fn)
|
||||
#endif
|
||||
|
||||
#ifndef module_pci_driver
|
||||
/**
|
||||
* module_pci_driver() - Helper macro for registering a PCI driver
|
||||
* @__pci_driver: pci_driver struct
|
||||
*
|
||||
* Helper macro for PCI drivers which do not do anything special in module
|
||||
* init/exit. This eliminates a lot of boilerplate. Each module may only
|
||||
* use this macro once, and calling it replaces module_init() and module_exit()
|
||||
*/
|
||||
#define module_pci_driver(__pci_driver) \
|
||||
module_driver(__pci_driver, pci_register_driver, \
|
||||
pci_unregister_driver)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,7,0)
|
||||
#define pcie_capability_read_word LINUX_BACKPORT(pcie_capability_read_word)
|
||||
int pcie_capability_read_word(struct pci_dev *dev, int pos, u16 *val);
|
||||
#define pcie_capability_read_dword LINUX_BACKPORT(pcie_capability_read_dword)
|
||||
int pcie_capability_read_dword(struct pci_dev *dev, int pos, u32 *val);
|
||||
#define pcie_capability_write_word LINUX_BACKPORT(pcie_capability_write_word)
|
||||
int pcie_capability_write_word(struct pci_dev *dev, int pos, u16 val);
|
||||
#define pcie_capability_write_dword LINUX_BACKPORT(pcie_capability_write_dword)
|
||||
int pcie_capability_write_dword(struct pci_dev *dev, int pos, u32 val);
|
||||
#define pcie_capability_clear_and_set_word LINUX_BACKPORT(pcie_capability_clear_and_set_word)
|
||||
int pcie_capability_clear_and_set_word(struct pci_dev *dev, int pos,
|
||||
u16 clear, u16 set);
|
||||
#define pcie_capability_clear_and_set_dword LINUX_BACKPORT(pcie_capability_clear_and_set_dword)
|
||||
int pcie_capability_clear_and_set_dword(struct pci_dev *dev, int pos,
|
||||
u32 clear, u32 set);
|
||||
|
||||
#define pcie_capability_set_word LINUX_BACKPORT(pcie_capability_set_word)
|
||||
static inline int pcie_capability_set_word(struct pci_dev *dev, int pos,
|
||||
u16 set)
|
||||
{
|
||||
return pcie_capability_clear_and_set_word(dev, pos, 0, set);
|
||||
}
|
||||
|
||||
#define pcie_capability_set_dword LINUX_BACKPORT(pcie_capability_set_dword)
|
||||
static inline int pcie_capability_set_dword(struct pci_dev *dev, int pos,
|
||||
u32 set)
|
||||
{
|
||||
return pcie_capability_clear_and_set_dword(dev, pos, 0, set);
|
||||
}
|
||||
|
||||
#define pcie_capability_clear_word LINUX_BACKPORT(pcie_capability_clear_word)
|
||||
static inline int pcie_capability_clear_word(struct pci_dev *dev, int pos,
|
||||
u16 clear)
|
||||
{
|
||||
return pcie_capability_clear_and_set_word(dev, pos, clear, 0);
|
||||
}
|
||||
|
||||
#define pcie_capability_clear_dword LINUX_BACKPORT(pcie_capability_clear_dword)
|
||||
static inline int pcie_capability_clear_dword(struct pci_dev *dev, int pos,
|
||||
u32 clear)
|
||||
{
|
||||
return pcie_capability_clear_and_set_dword(dev, pos, clear, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
|
||||
/* mask pci_pcie_cap as debian squeeze also backports this */
|
||||
#define pci_pcie_cap LINUX_BACKPORT(pci_pcie_cap)
|
||||
static inline int pci_pcie_cap(struct pci_dev *dev)
|
||||
{
|
||||
return pci_find_capability(dev, PCI_CAP_ID_EXP);
|
||||
}
|
||||
|
||||
/* mask pci_is_pcie as RHEL6 backports this */
|
||||
#define pci_is_pcie LINUX_BACKPORT(pci_is_pcie)
|
||||
static inline bool pci_is_pcie(struct pci_dev *dev)
|
||||
{
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24))
|
||||
return dev->is_pcie;
|
||||
#else
|
||||
return !!pci_pcie_cap(dev);
|
||||
#endif
|
||||
}
|
||||
#endif /* < 2.6.33 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
|
||||
#define pci_ioremap_bar LINUX_BACKPORT(pci_ioremap_bar)
|
||||
void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar);
|
||||
|
||||
#define pci_wake_from_d3 LINUX_BACKPORT(pci_wake_from_d3)
|
||||
int pci_wake_from_d3(struct pci_dev *dev, bool enable);
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,27)
|
||||
#define pci_pme_capable LINUX_BACKPORT(pci_pme_capable)
|
||||
bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
|
||||
#endif
|
||||
|
||||
#ifndef PCI_DEVICE_SUB
|
||||
/**
|
||||
* PCI_DEVICE_SUB - macro used to describe a specific pci device with subsystem
|
||||
* @vend: the 16 bit PCI Vendor ID
|
||||
* @dev: the 16 bit PCI Device ID
|
||||
* @subvend: the 16 bit PCI Subvendor ID
|
||||
* @subdev: the 16 bit PCI Subdevice ID
|
||||
*
|
||||
* This macro is used to create a struct pci_device_id that matches a
|
||||
* specific device with subsystem information.
|
||||
*/
|
||||
#define PCI_DEVICE_SUB(vend, dev, subvend, subdev) \
|
||||
.vendor = (vend), .device = (dev), \
|
||||
.subvendor = (subvend), .subdevice = (subdev)
|
||||
#endif /* PCI_DEVICE_SUB */
|
||||
|
||||
#endif /* _BACKPORT_LINUX_PCI_H */
|
128
backport-include/linux/pci_regs.h
Normal file
128
backport-include/linux/pci_regs.h
Normal file
@ -0,0 +1,128 @@
|
||||
#ifndef __BACKPORT_UAPI_PCI_REGS_H
|
||||
#define __BACKPORT_UAPI_PCI_REGS_H
|
||||
#include_next <linux/pci_regs.h>
|
||||
|
||||
#ifndef PCI_EXP_LNKCTL_ASPM_L0S
|
||||
#define PCI_EXP_LNKCTL_ASPM_L0S 0x01 /* L0s Enable */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCTL_ASPM_L1
|
||||
#define PCI_EXP_LNKCTL_ASPM_L1 0x02 /* L1 Enable */
|
||||
#endif
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 130f1b8f35f14d27c43da755f3c9226318c17f57
|
||||
* Author: Bjorn Helgaas <bhelgaas@google.com>
|
||||
* Date: Wed Dec 26 10:39:23 2012 -0700
|
||||
*
|
||||
* PCI: Add PCIe Link Capability link speed and width names
|
||||
*/
|
||||
#ifndef PCI_EXP_LNKCAP_SLS_2_5GB
|
||||
#define PCI_EXP_LNKCAP_SLS_2_5GB 0x1 /* LNKCAP2 SLS Vector bit 0 (2.5GT/s) */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCAP_SLS_5_0GB
|
||||
#define PCI_EXP_LNKCAP_SLS_5_0GB 0x2 /* LNKCAP2 SLS Vector bit 1 (5.0GT/s) */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKSTA2
|
||||
#define PCI_EXP_LNKSTA2 50 /* Link Status 2 */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Backports
|
||||
*
|
||||
* commit cdcac9cd7741af2c2b9255cbf060f772596907bb
|
||||
* Author: Dave Airlie <airlied@redhat.com>
|
||||
* Date: Wed Jun 27 08:35:52 2012 +0100
|
||||
*
|
||||
* pci_regs: define LNKSTA2 pcie cap + bits.
|
||||
*
|
||||
* We need these for detecting the max link speed for drm drivers.
|
||||
*
|
||||
* Acked-by: Bjorn Helgaas <bhelgass@google.com>
|
||||
* Signed-off-by: Dave Airlie <airlied@redhat.com>
|
||||
*/
|
||||
#ifndef PCI_EXP_LNKCAP2
|
||||
#define PCI_EXP_LNKCAP2 44 /* Link Capability 2 */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCAP2_SLS_2_5GB
|
||||
#define PCI_EXP_LNKCAP2_SLS_2_5GB 0x01 /* Current Link Speed 2.5GT/s */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCAP2_SLS_5_0GB
|
||||
#define PCI_EXP_LNKCAP2_SLS_5_0GB 0x02 /* Current Link Speed 5.0GT/s */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCAP2_SLS_8_0GB
|
||||
#define PCI_EXP_LNKCAP2_SLS_8_0GB 0x04 /* Current Link Speed 8.0GT/s */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCAP2_CROSSLINK
|
||||
#define PCI_EXP_LNKCAP2_CROSSLINK 0x100 /* Crosslink supported */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PCI_EXP_TYPE_RC_EC was added via 1b6b8ce2 on v2.6.30-rc4~20 :
|
||||
*
|
||||
* mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 1b6b8ce2
|
||||
* v2.6.30-rc4~20^2
|
||||
*
|
||||
* but the fix for its definition was merged on v3.3-rc1~101^2~67
|
||||
*
|
||||
* mcgrof@frijol ~/linux-next (git::master)$ git describe --contains 1830ea91
|
||||
* v3.3-rc1~101^2~67
|
||||
*
|
||||
* while we can assume it got merged and backported on v3.2.28 (which it did
|
||||
* see c1c3cd9) we cannot assume every kernel has it fixed so lets just undef
|
||||
* it here and redefine it.
|
||||
*/
|
||||
#undef PCI_EXP_TYPE_RC_EC
|
||||
#define PCI_EXP_TYPE_RC_EC 0xa /* Root Complex Event Collector */
|
||||
|
||||
#ifndef PCI_MSIX_ENTRY_CTRL_MASKBIT
|
||||
#define PCI_MSIX_ENTRY_CTRL_MASKBIT 1
|
||||
#endif
|
||||
|
||||
/* MSI-X entry's format */
|
||||
#ifndef PCI_MSIX_ENTRY_SIZE
|
||||
#define PCI_MSIX_ENTRY_SIZE 16
|
||||
#define PCI_MSIX_ENTRY_LOWER_ADDR 0
|
||||
#define PCI_MSIX_ENTRY_UPPER_ADDR 4
|
||||
#define PCI_MSIX_ENTRY_DATA 8
|
||||
#define PCI_MSIX_ENTRY_VECTOR_CTRL 12
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCTL2
|
||||
#define PCI_EXP_LNKCTL2 48 /* Link Control 2 */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_SLTCTL2
|
||||
#define PCI_EXP_SLTCTL2 56 /* Slot Control 2 */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_LNKCTL_ES
|
||||
#define PCI_EXP_LNKCTL_ES 0x0080 /* Extended Synch */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_SLTSTA_PDS
|
||||
#define PCI_EXP_SLTSTA_PDS 0x0040 /* Presence Detect State */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_DEVCAP2
|
||||
#define PCI_EXP_DEVCAP2 36 /* Device Capabilities 2 */
|
||||
#define PCI_EXP_DEVCAP2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_EXP_DEVCTL2
|
||||
#define PCI_EXP_DEVCTL2 40 /* Device Control 2 */
|
||||
#define PCI_EXP_DEVCTL2_ARI 0x20 /* Alternative Routing-ID */
|
||||
#endif
|
||||
|
||||
#ifndef PCI_PM_CAP_PME_SHIFT
|
||||
#define PCI_PM_CAP_PME_SHIFT 11
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_UAPI_PCI_REGS_H */
|
106
backport-include/linux/pkt_sched.h
Normal file
106
backport-include/linux/pkt_sched.h
Normal file
@ -0,0 +1,106 @@
|
||||
#ifndef __BACKPORT_LINUX_PKT_SCHED_H
|
||||
#define __BACKPORT_LINUX_PKT_SCHED_H
|
||||
#include_next <linux/pkt_sched.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
/*
|
||||
* This backports:
|
||||
*
|
||||
* From 76e3cc126bb223013a6b9a0e2a51238d1ef2e409 Mon Sep 17 00:00:00 2001
|
||||
* From: Eric Dumazet <edumazet@google.com>
|
||||
* Date: Thu, 10 May 2012 07:51:25 +0000
|
||||
* Subject: [PATCH] codel: Controlled Delay AQM
|
||||
*/
|
||||
#ifndef TCA_CODEL_MAX
|
||||
/* CODEL */
|
||||
|
||||
#define COMPAT_CODEL_BACKPORT
|
||||
|
||||
enum {
|
||||
TCA_CODEL_UNSPEC,
|
||||
TCA_CODEL_TARGET,
|
||||
TCA_CODEL_LIMIT,
|
||||
TCA_CODEL_INTERVAL,
|
||||
TCA_CODEL_ECN,
|
||||
__TCA_CODEL_MAX
|
||||
};
|
||||
|
||||
#define TCA_CODEL_MAX (__TCA_CODEL_MAX - 1)
|
||||
|
||||
struct tc_codel_xstats {
|
||||
__u32 maxpacket; /* largest packet we've seen so far */
|
||||
__u32 count; /* how many drops we've done since the last time we
|
||||
* entered dropping state
|
||||
*/
|
||||
__u32 lastcount; /* count at entry to dropping state */
|
||||
__u32 ldelay; /* in-queue delay seen by most recently dequeued packet */
|
||||
__s32 drop_next; /* time to drop next packet */
|
||||
__u32 drop_overlimit; /* number of time max qdisc packet limit was hit */
|
||||
__u32 ecn_mark; /* number of packets we ECN marked instead of dropped */
|
||||
__u32 dropping; /* are we in dropping state ? */
|
||||
};
|
||||
|
||||
/* This backports:
|
||||
*
|
||||
* commit 4b549a2ef4bef9965d97cbd992ba67930cd3e0fe
|
||||
* Author: Eric Dumazet <edumazet@google.com>
|
||||
* Date: Fri May 11 09:30:50 2012 +0000
|
||||
* fq_codel: Fair Queue Codel AQM
|
||||
*/
|
||||
|
||||
/* FQ_CODEL */
|
||||
|
||||
enum {
|
||||
TCA_FQ_CODEL_UNSPEC,
|
||||
TCA_FQ_CODEL_TARGET,
|
||||
TCA_FQ_CODEL_LIMIT,
|
||||
TCA_FQ_CODEL_INTERVAL,
|
||||
TCA_FQ_CODEL_ECN,
|
||||
TCA_FQ_CODEL_FLOWS,
|
||||
TCA_FQ_CODEL_QUANTUM,
|
||||
__TCA_FQ_CODEL_MAX
|
||||
};
|
||||
|
||||
#define TCA_FQ_CODEL_MAX (__TCA_FQ_CODEL_MAX - 1)
|
||||
|
||||
enum {
|
||||
TCA_FQ_CODEL_XSTATS_QDISC,
|
||||
TCA_FQ_CODEL_XSTATS_CLASS,
|
||||
};
|
||||
|
||||
struct tc_fq_codel_qd_stats {
|
||||
__u32 maxpacket; /* largest packet we've seen so far */
|
||||
__u32 drop_overlimit; /* number of time max qdisc
|
||||
* packet limit was hit
|
||||
*/
|
||||
__u32 ecn_mark; /* number of packets we ECN marked
|
||||
* instead of being dropped
|
||||
*/
|
||||
__u32 new_flow_count; /* number of time packets
|
||||
* created a 'new flow'
|
||||
*/
|
||||
__u32 new_flows_len; /* count of flows in new list */
|
||||
__u32 old_flows_len; /* count of flows in old list */
|
||||
};
|
||||
|
||||
struct tc_fq_codel_cl_stats {
|
||||
__s32 deficit;
|
||||
__u32 ldelay; /* in-queue delay seen by most recently
|
||||
* dequeued packet
|
||||
*/
|
||||
__u32 count;
|
||||
__u32 lastcount;
|
||||
__u32 dropping;
|
||||
__s32 drop_next;
|
||||
};
|
||||
|
||||
struct tc_fq_codel_xstats {
|
||||
__u32 type;
|
||||
union {
|
||||
struct tc_fq_codel_qd_stats qdisc_stats;
|
||||
struct tc_fq_codel_cl_stats class_stats;
|
||||
};
|
||||
};
|
||||
#endif /* TCA_CODEL_MAX */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_PKT_SCHED_H */
|
42
backport-include/linux/platform_device.h
Normal file
42
backport-include/linux/platform_device.h
Normal file
@ -0,0 +1,42 @@
|
||||
#ifndef __BACKPORT_PLATFORM_DEVICE_H
|
||||
#define __BACKPORT_PLATFORM_DEVICE_H
|
||||
|
||||
#include_next <linux/platform_device.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifndef module_platform_driver_probe
|
||||
#define module_platform_driver_probe(__platform_driver, __platform_probe) \
|
||||
static int __init __platform_driver##_init(void) \
|
||||
{ \
|
||||
return platform_driver_probe(&(__platform_driver), \
|
||||
__platform_probe); \
|
||||
} \
|
||||
module_init(__platform_driver##_init); \
|
||||
static void __exit __platform_driver##_exit(void) \
|
||||
{ \
|
||||
platform_driver_unregister(&(__platform_driver)); \
|
||||
} \
|
||||
module_exit(__platform_driver##_exit);
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_DEVID_NONE
|
||||
#define PLATFORM_DEVID_NONE (-1)
|
||||
#endif
|
||||
|
||||
#ifndef PLATFORM_DEVID_AUTO
|
||||
#define PLATFORM_DEVID_AUTO (-1)
|
||||
#endif
|
||||
|
||||
#ifndef module_platform_driver
|
||||
#define module_platform_driver(__platform_driver) \
|
||||
module_driver(__platform_driver, platform_driver_register, \
|
||||
platform_driver_unregister)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
|
||||
#define platform_device_register_data LINUX_BACKPORT(platform_device_register_data)
|
||||
extern struct platform_device *platform_device_register_data(struct device *,
|
||||
const char *, int, const void *, size_t);
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_PLATFORM_DEVICE_H */
|
74
backport-include/linux/pm.h
Normal file
74
backport-include/linux/pm.h
Normal file
@ -0,0 +1,74 @@
|
||||
#ifndef __BACKPORT_PM_H
|
||||
#define __BACKPORT_PM_H
|
||||
#include_next <linux/pm.h>
|
||||
|
||||
#ifndef PM_EVENT_AUTO
|
||||
#define PM_EVENT_AUTO 0x0400
|
||||
#endif
|
||||
|
||||
#ifndef PM_EVENT_SLEEP
|
||||
#define PM_EVENT_SLEEP (PM_EVENT_SUSPEND)
|
||||
#endif
|
||||
|
||||
#ifndef PMSG_IS_AUTO
|
||||
#define PMSG_IS_AUTO(msg) (((msg).event & PM_EVENT_AUTO) != 0)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,32)
|
||||
#undef SIMPLE_DEV_PM_OPS
|
||||
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
||||
const struct dev_pm_ops name = { \
|
||||
.suspend = suspend_fn, \
|
||||
.resume = resume_fn, \
|
||||
.freeze = suspend_fn, \
|
||||
.thaw = resume_fn, \
|
||||
.poweroff = suspend_fn, \
|
||||
.restore = resume_fn, \
|
||||
}
|
||||
#endif /* 2.6.32 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
|
||||
/*
|
||||
* dev_pm_ops is only available on kernels >= 2.6.29, for
|
||||
* older kernels we rely on reverting the work to old
|
||||
* power management style stuff. On 2.6.29 the pci calls
|
||||
* weren't included yet though, so include them here.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,29)
|
||||
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
||||
struct dev_pm_ops name = { \
|
||||
.suspend = suspend_fn ## _compat, \
|
||||
.resume = resume_fn ## _compat, \
|
||||
.freeze = suspend_fn ## _compat, \
|
||||
.thaw = resume_fn ## _compat, \
|
||||
.poweroff = suspend_fn ## _compat, \
|
||||
.restore = resume_fn ## _compat, \
|
||||
}
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,30)
|
||||
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
||||
struct dev_pm_ops name = { \
|
||||
.suspend = suspend_fn, \
|
||||
.resume = resume_fn, \
|
||||
.freeze = suspend_fn, \
|
||||
.thaw = resume_fn, \
|
||||
.poweroff = suspend_fn, \
|
||||
.restore = resume_fn, \
|
||||
}
|
||||
#else
|
||||
#define ___BACKPORT_PASTE(a, b) a##b
|
||||
#define __BACKPORT_PASTE(a, b) ___BACKPORT_PASTE(a,b)
|
||||
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
||||
struct {} __maybe_unused __BACKPORT_PASTE(__backport_avoid_warning_, __LINE__)
|
||||
#endif /* >= 2.6.29 */
|
||||
#endif /* < 2.6.32 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,30)
|
||||
enum dpm_order {
|
||||
DPM_ORDER_NONE,
|
||||
DPM_ORDER_DEV_AFTER_PARENT,
|
||||
DPM_ORDER_PARENT_BEFORE_DEV,
|
||||
DPM_ORDER_DEV_LAST,
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_PM_H */
|
55
backport-include/linux/pm_qos.h
Normal file
55
backport-include/linux/pm_qos.h
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef _COMPAT_LINUX_PM_QOS_H
|
||||
#define _COMPAT_LINUX_PM_QOS_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0))
|
||||
#include_next <linux/pm_qos.h>
|
||||
#else
|
||||
#include <linux/pm_qos_params.h>
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) */
|
||||
|
||||
#ifndef PM_QOS_DEFAULT_VALUE
|
||||
#define PM_QOS_DEFAULT_VALUE -1
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
|
||||
struct pm_qos_request_list {
|
||||
u32 qos;
|
||||
void *request;
|
||||
};
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35))
|
||||
|
||||
#define pm_qos_add_request(_req, _class, _value) do { \
|
||||
(_req)->request = #_req; \
|
||||
(_req)->qos = _class; \
|
||||
pm_qos_add_requirement((_class), (_req)->request, (_value)); \
|
||||
} while(0)
|
||||
|
||||
#define pm_qos_update_request(_req, _value) \
|
||||
pm_qos_update_requirement((_req)->qos, (_req)->request, (_value))
|
||||
|
||||
#define pm_qos_remove_request(_req) \
|
||||
pm_qos_remove_requirement((_req)->qos, (_req)->request)
|
||||
|
||||
#else
|
||||
|
||||
#define pm_qos_add_request(_req, _class, _value) do { \
|
||||
(_req)->request = pm_qos_add_request((_class), (_value)); \
|
||||
} while (0)
|
||||
|
||||
#define pm_qos_update_request(_req, _value) \
|
||||
pm_qos_update_request((_req)->request, (_value))
|
||||
|
||||
#define pm_qos_remove_request(_req) \
|
||||
pm_qos_remove_request((_req)->request)
|
||||
|
||||
#endif /* < 2.6.35 */
|
||||
#endif /* < 2.6.36 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,35)
|
||||
#define pm_qos_request(_qos) pm_qos_requirement(_qos)
|
||||
#endif
|
||||
|
||||
#endif /* _COMPAT_LINUX_PM_QOS_H */
|
65
backport-include/linux/pm_runtime.h
Normal file
65
backport-include/linux/pm_runtime.h
Normal file
@ -0,0 +1,65 @@
|
||||
#include <linux/version.h>
|
||||
|
||||
#ifndef __COMPAT_LINUX_PM_RUNTIME_H
|
||||
#define __COMPAT_LINUX_PM_RUNTIME_H
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32))
|
||||
#include_next <linux/pm_runtime.h>
|
||||
#else
|
||||
|
||||
static inline void pm_runtime_enable(struct device *dev) {}
|
||||
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,32)) */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,32)
|
||||
/*
|
||||
* Backports 5e928f77a09a07f9dd595bb8a489965d69a83458
|
||||
* run-time power management cannot really be backported
|
||||
* given that the implementation added bus specific
|
||||
* callbacks that we won't have on older kernels. If
|
||||
* you really want run-time power management or good
|
||||
* power management upgrade your kernel. We'll just
|
||||
* compile this out as if run-time power management was
|
||||
* disabled just as the kernel disables run-time power management
|
||||
* when CONFIG_PM_RUNTIME is disabled.
|
||||
*/
|
||||
static inline void pm_runtime_init(struct device *dev) {}
|
||||
static inline void pm_runtime_remove(struct device *dev) {}
|
||||
static inline int pm_runtime_get(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pm_runtime_get_sync(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pm_runtime_put(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pm_runtime_put_sync(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int pm_runtime_set_active(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void pm_runtime_set_suspended(struct device *dev)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void pm_runtime_disable(struct device *dev)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void pm_runtime_put_noidle(struct device *dev) {}
|
||||
static inline void pm_runtime_get_noresume(struct device *dev) {}
|
||||
#endif
|
||||
|
||||
#endif
|
21
backport-include/linux/poll.h
Normal file
21
backport-include/linux/poll.h
Normal file
@ -0,0 +1,21 @@
|
||||
#ifndef __BACKPORT_LINUX_POLL_H
|
||||
#define __BACKPORT_LINUX_POLL_H
|
||||
#include_next <linux/poll.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
|
||||
#define poll_does_not_wait LINUX_BACKPORT(poll_does_not_wait)
|
||||
static inline bool poll_does_not_wait(const poll_table *p)
|
||||
{
|
||||
return p == NULL || p->qproc == NULL;
|
||||
}
|
||||
|
||||
#define poll_requested_events LINUX_BACKPORT(poll_requested_events)
|
||||
static inline unsigned long poll_requested_events(const poll_table *p)
|
||||
{
|
||||
return p ? p->key : ~0UL;
|
||||
}
|
||||
#endif /* 2.6.31 <= version < 3.4 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_POLL_H */
|
105
backport-include/linux/printk.h
Normal file
105
backport-include/linux/printk.h
Normal file
@ -0,0 +1,105 @@
|
||||
#ifndef _COMPAT_LINUX_PRINTK_H
|
||||
#define _COMPAT_LINUX_PRINTK_H 1
|
||||
|
||||
#include <linux/version.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,36))
|
||||
#include_next <linux/printk.h>
|
||||
#else
|
||||
#include <linux/kernel.h>
|
||||
#endif /* (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)) */
|
||||
|
||||
/* see pr_fmt at end of file */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
/* backports 7a555613 */
|
||||
#if defined(CONFIG_DYNAMIC_DEBUG)
|
||||
#define dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
do { \
|
||||
DEFINE_DYNAMIC_DEBUG_METADATA(descriptor, \
|
||||
__builtin_constant_p(prefix_str) ? prefix_str : "hexdump");\
|
||||
if (unlikely(descriptor.flags & _DPRINTK_FLAGS_PRINT)) \
|
||||
print_hex_dump(KERN_DEBUG, prefix_str, \
|
||||
prefix_type, rowsize, groupsize, \
|
||||
buf, len, ascii); \
|
||||
} while (0)
|
||||
#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii)
|
||||
#else
|
||||
#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii) \
|
||||
print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
|
||||
groupsize, buf, len, ascii)
|
||||
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
|
||||
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) */
|
||||
|
||||
#ifndef pr_warn
|
||||
#define pr_warn pr_warning
|
||||
#endif
|
||||
|
||||
#ifndef printk_once
|
||||
#define printk_once(x...) ({ \
|
||||
static bool __print_once; \
|
||||
\
|
||||
if (!__print_once) { \
|
||||
__print_once = true; \
|
||||
printk(x); \
|
||||
} \
|
||||
})
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
|
||||
#define pr_emerg_once(fmt, ...) \
|
||||
printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_alert_once(fmt, ...) \
|
||||
printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_crit_once(fmt, ...) \
|
||||
printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_err_once(fmt, ...) \
|
||||
printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_warn_once(fmt, ...) \
|
||||
printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_notice_once(fmt, ...) \
|
||||
printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_info_once(fmt, ...) \
|
||||
printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#define pr_cont_once(fmt, ...) \
|
||||
printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#if defined(DEBUG)
|
||||
#define pr_debug_once(fmt, ...) \
|
||||
printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#else
|
||||
#define pr_debug_once(fmt, ...) \
|
||||
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)
|
||||
/* mask va_format as RHEL6 backports this */
|
||||
#define va_format LINUX_BACKPORT(va_format)
|
||||
|
||||
struct va_format {
|
||||
const char *fmt;
|
||||
va_list *va;
|
||||
};
|
||||
|
||||
/*
|
||||
* Dummy printk for disabled debugging statements to use whilst maintaining
|
||||
* gcc's format and side-effect checking.
|
||||
*/
|
||||
/* mask no_printk as RHEL6 backports this */
|
||||
#define no_printk LINUX_BACKPORT(no_printk)
|
||||
static inline __attribute__ ((format (printf, 1, 2)))
|
||||
int no_printk(const char *s, ...) { return 0; }
|
||||
#endif
|
||||
|
||||
#endif /* _COMPAT_LINUX_PRINTK_H */
|
||||
|
||||
/* This must be outside -- see also kernel.h */
|
||||
#ifndef pr_fmt
|
||||
#define pr_fmt(fmt) fmt
|
||||
#endif
|
29
backport-include/linux/proc_fs.h
Normal file
29
backport-include/linux/proc_fs.h
Normal file
@ -0,0 +1,29 @@
|
||||
#ifndef __BACKPORT_PROC_FS_H
|
||||
#define __BACKPORT_PROC_FS_H
|
||||
#include_next <linux/proc_fs.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
|
||||
|
||||
#ifdef CONFIG_PROC_FS
|
||||
/*
|
||||
* backport of:
|
||||
* procfs: new helper - PDE_DATA(inode)
|
||||
*/
|
||||
#define PDE_DATA LINUX_BACKPORT(PDE_DATA)
|
||||
static inline void *PDE_DATA(const struct inode *inode)
|
||||
{
|
||||
return PROC_I(inode)->pde->data;
|
||||
}
|
||||
extern void proc_set_size(struct proc_dir_entry *, loff_t);
|
||||
extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
|
||||
#else
|
||||
#define PDE_DATA LINUX_BACKPORT(PDE_DATA)
|
||||
static inline void *PDE_DATA(const struct inode *inode) {BUG(); return NULL;}
|
||||
static inline void proc_set_size(struct proc_dir_entry *de, loff_t size) {}
|
||||
static inline void proc_set_user(struct proc_dir_entry *de, kuid_t uid, kgid_t gid) {}
|
||||
#endif /* CONFIG_PROC_FS */
|
||||
|
||||
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0) */
|
||||
|
||||
#endif /* __BACKPORT_PROC_FS_H */
|
13
backport-include/linux/random.h
Normal file
13
backport-include/linux/random.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef __BACKPORT_RANDOM_H
|
||||
#define __BACKPORT_RANDOM_H
|
||||
#include_next <linux/random.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,8,0)
|
||||
/* backports 496f2f9 */
|
||||
#define prandom_seed(_seed) srandom32(_seed)
|
||||
#define prandom_u32() random32()
|
||||
#define prandom_u32_state(_state) prandom32(_state)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_RANDOM_H */
|
54
backport-include/linux/rculist.h
Normal file
54
backport-include/linux/rculist.h
Normal file
@ -0,0 +1,54 @@
|
||||
#ifndef __BACKPORT_RCULIST_H
|
||||
#define __BACKPORT_RCULIST_H
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)
|
||||
#include_next <linux/rculist.h>
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
|
||||
#include <backport/magic.h>
|
||||
#define hlist_for_each_entry_rcu4(tpos, pos, head, member) \
|
||||
for (pos = rcu_dereference_raw(hlist_first_rcu(head)); \
|
||||
pos && \
|
||||
({ tpos = hlist_entry(pos, typeof(*tpos), member); 1; });\
|
||||
pos = rcu_dereference_raw(hlist_next_rcu(pos)))
|
||||
|
||||
#define hlist_for_each_entry_rcu3(pos, head, member) \
|
||||
for (pos = hlist_entry_safe (rcu_dereference_raw(hlist_first_rcu(head)),\
|
||||
typeof(*(pos)), member); \
|
||||
pos; \
|
||||
pos = hlist_entry_safe(rcu_dereference_raw(hlist_next_rcu( \
|
||||
&(pos)->member)), typeof(*(pos)), member))
|
||||
|
||||
#undef hlist_for_each_entry_rcu
|
||||
#define hlist_for_each_entry_rcu(...) \
|
||||
macro_dispatcher(hlist_for_each_entry_rcu, __VA_ARGS__)(__VA_ARGS__)
|
||||
#endif /* < 3.9 */
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,37)
|
||||
/**
|
||||
* backport:
|
||||
*
|
||||
* commit 67bdbffd696f29a0b68aa8daa285783a06651583
|
||||
* Author: Arnd Bergmann <arnd@arndb.de>
|
||||
* Date: Thu Feb 25 16:55:13 2010 +0100
|
||||
*
|
||||
* rculist: avoid __rcu annotations
|
||||
*/
|
||||
#define hlist_first_rcu(head) (*((struct hlist_node __rcu **)(&(head)->first)))
|
||||
#define hlist_next_rcu(node) (*((struct hlist_node __rcu **)(&(node)->next)))
|
||||
|
||||
#endif /* < 2.6.37 */
|
||||
|
||||
#ifndef list_for_each_entry_continue_rcu
|
||||
#define list_for_each_entry_continue_rcu(pos, head, member) \
|
||||
for (pos = list_entry_rcu(pos->member.next, typeof(*pos), member); \
|
||||
prefetch(pos->member.next), &pos->member != (head); \
|
||||
pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
|
||||
#endif
|
||||
|
||||
#ifndef list_entry_rcu
|
||||
#define list_entry_rcu(ptr, type, member) \
|
||||
container_of(rcu_dereference(ptr), type, member)
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_RCULIST_H */
|
51
backport-include/linux/rcupdate.h
Normal file
51
backport-include/linux/rcupdate.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __BACKPORT_LINUX_RCUPDATE_H
|
||||
#define __BACKPORT_LINUX_RCUPDATE_H
|
||||
#include_next <linux/rcupdate.h>
|
||||
|
||||
/*
|
||||
* This adds a nested function everywhere kfree_rcu() was called. This
|
||||
* function frees the memory and is given as a function to call_rcu().
|
||||
* The rcu callback could happen every time also after the module was
|
||||
* unloaded and this will cause problems. To address that problem, we
|
||||
* put rcu_barrier() into each module_exit() in module.h.
|
||||
*/
|
||||
#if !defined(kfree_rcu)
|
||||
#define kfree_rcu(data, rcuhead) do { \
|
||||
void __kfree_rcu_fn(struct rcu_head *rcu_head) \
|
||||
{ \
|
||||
void *___ptr; \
|
||||
___ptr = container_of(rcu_head, typeof(*(data)), rcuhead);\
|
||||
kfree(___ptr); \
|
||||
} \
|
||||
call_rcu(&(data)->rcuhead, __kfree_rcu_fn); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
#ifndef RCU_INIT_POINTER
|
||||
#define RCU_INIT_POINTER(p, v) \
|
||||
p = (typeof(*v) __force __rcu *)(v)
|
||||
#endif
|
||||
|
||||
#ifndef rcu_dereference_check
|
||||
#define rcu_dereference_check(p, c) rcu_dereference(p)
|
||||
#endif
|
||||
|
||||
#ifndef rcu_dereference_protected
|
||||
#define rcu_dereference_protected(p, c) (p)
|
||||
#endif
|
||||
#ifndef rcu_access_pointer
|
||||
#define rcu_access_pointer(p) ACCESS_ONCE(p)
|
||||
#endif
|
||||
|
||||
#ifndef rcu_dereference_raw
|
||||
#define rcu_dereference_raw(p) rcu_dereference(p)
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
static inline int rcu_read_lock_held(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_RCUPDATE_H */
|
51
backport-include/linux/regmap.h
Normal file
51
backport-include/linux/regmap.h
Normal file
@ -0,0 +1,51 @@
|
||||
#ifndef __BACKPORT_LINUX_REGMAP_H
|
||||
#define __BACKPORT_LINUX_REGMAP_H
|
||||
#include_next <linux/regmap.h>
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,5,0) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
|
||||
#define dev_get_regmap LINUX_BACKPORT(dev_get_regmap)
|
||||
static inline
|
||||
struct regmap *dev_get_regmap(struct device *dev, const char *name)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(3,4,0) && \
|
||||
LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)
|
||||
#if defined(CONFIG_REGMAP)
|
||||
#define devm_regmap_init LINUX_BACKPORT(devm_regmap_init)
|
||||
struct regmap *devm_regmap_init(struct device *dev,
|
||||
const struct regmap_bus *bus,
|
||||
const struct regmap_config *config);
|
||||
#if defined(CONFIG_REGMAP_I2C)
|
||||
#define devm_regmap_init_i2c LINUX_BACKPORT(devm_regmap_init_i2c)
|
||||
struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
|
||||
const struct regmap_config *config);
|
||||
#endif /* defined(CONFIG_REGMAP_I2C) */
|
||||
|
||||
/*
|
||||
* We can't backport these unless we try to backport
|
||||
* the full regmap into core so warn if used.
|
||||
* No drivers are using this yet anyway.
|
||||
*/
|
||||
#define regmap_raw_write_async LINUX_BACKPORT(regmap_raw_write_async)
|
||||
static inline int regmap_raw_write_async(struct regmap *map, unsigned int reg,
|
||||
const void *val, size_t val_len)
|
||||
{
|
||||
WARN_ONCE(1, "regmap API is disabled");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
#define regmap_async_complete LINUX_BACKPORT(regmap_async_complete)
|
||||
static inline void regmap_async_complete(struct regmap *map)
|
||||
{
|
||||
WARN_ONCE(1, "regmap API is disabled");
|
||||
}
|
||||
|
||||
#endif /* defined(CONFIG_REGMAP) */
|
||||
#endif /* 3.2 <= version < 3.4 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_REGMAP_H */
|
49
backport-include/linux/regulator/driver.h
Normal file
49
backport-include/linux/regulator/driver.h
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* driver.h -- SoC Regulator driver support.
|
||||
*
|
||||
* Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
|
||||
*
|
||||
* Author: Liam Girdwood <lrg@slimlogic.co.uk>
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* Regulator Driver Interface.
|
||||
*/
|
||||
|
||||
#ifndef __BACKPORT_LINUX_REGULATOR_DRIVER_H_
|
||||
#define __BACKPORT_LINUX_REGULATOR_DRIVER_H_
|
||||
|
||||
#include <linux/version.h>
|
||||
#include_next <linux/regulator/driver.h>
|
||||
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0))
|
||||
int regulator_map_voltage_ascend(struct regulator_dev *rdev,
|
||||
int min_uV, int max_uV);
|
||||
#endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) */
|
||||
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)) && \
|
||||
(LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0))
|
||||
#define devm_regulator_register LINUX_BACKPORT(devm_regulator_register)
|
||||
struct regulator_dev *
|
||||
devm_regulator_register(struct device *dev,
|
||||
const struct regulator_desc *regulator_desc,
|
||||
const struct regulator_config *config);
|
||||
#define devm_regulator_unregister LINUX_BACKPORT(devm_regulator_unregister)
|
||||
void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev);
|
||||
#endif /* (LINUX_VERSION_CODE < KERNEL_VERSION(3,13,0)) &&
|
||||
(LINUX_VERSION_CODE >= KERNEL_VERSION(3,5,0)) */
|
||||
|
||||
#ifndef REGULATOR_LINEAR_RANGE
|
||||
/* Initialize struct regulator_linear_range */
|
||||
#define REGULATOR_LINEAR_RANGE(_min_uV, _min_sel, _max_sel, _step_uV) \
|
||||
{ \
|
||||
.min_uV = _min_uV, \
|
||||
.min_sel = _min_sel, \
|
||||
.max_sel = _max_sel, \
|
||||
.uV_step = _step_uV, \
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __BACKPORT_LINUX_REGULATOR_DRIVER_H_ */
|
179
backport-include/linux/rfkill.h
Normal file
179
backport-include/linux/rfkill.h
Normal file
@ -0,0 +1,179 @@
|
||||
#ifndef __COMPAT_RFKILL_H
|
||||
#define __COMPAT_RFKILL_H
|
||||
#include <linux/version.h>
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
|
||||
#include_next <linux/rfkill.h>
|
||||
#else
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33)
|
||||
/* API only slightly changed since then */
|
||||
#define rfkill_type old_rfkill_type
|
||||
#define RFKILL_TYPE_ALL OLD_RFKILL_TYPE_ALL
|
||||
#define RFKILL_TYPE_WLAN OLD_RFKILL_TYPE_WLAN
|
||||
#define RFKILL_TYPE_BLUETOOTH OLD_RFKILL_TYPE_BLUETOOTH
|
||||
#define RFKILL_TYPE_UWB OLD_RFKILL_TYPE_UWB
|
||||
#define RFKILL_TYPE_WIMAX OLD_RFKILL_TYPE_WIMAX
|
||||
#define RFKILL_TYPE_WWAN OLD_RFKILL_TYPE_WWAN
|
||||
#define RFKILL_TYPE_GPS OLD_RFKILL_TYPE_GPS
|
||||
#define RFKILL_TYPE_FM OLD_RFKILL_TYPE_FM
|
||||
#define RFKILL_TYPE_NFC OLD_RFKILL_TYPE_NFC
|
||||
#define NUM_RFKILL_TYPES OLD_NUM_RFKILL_TYPES
|
||||
#include_next <linux/rfkill.h>
|
||||
#undef rfkill_type
|
||||
#undef RFKILL_TYPE_ALL
|
||||
#undef RFKILL_TYPE_WLAN
|
||||
#undef RFKILL_TYPE_BLUETOOTH
|
||||
#undef RFKILL_TYPE_UWB
|
||||
#undef RFKILL_TYPE_WIMAX
|
||||
#undef RFKILL_TYPE_WWAN
|
||||
#undef RFKILL_TYPE_GPS
|
||||
#undef RFKILL_TYPE_FM
|
||||
#undef RFKILL_TYPE_NFC
|
||||
#undef NUM_RFKILL_TYPES
|
||||
#define HAVE_OLD_RFKILL
|
||||
#else
|
||||
#undef HAVE_OLD_RFKILL
|
||||
#include <linux/device.h>
|
||||
struct rfkill;
|
||||
|
||||
struct rfkill_ops {
|
||||
void (*poll)(struct rfkill *rfkill, void *data);
|
||||
void (*query)(struct rfkill *rfkill, void *data);
|
||||
int (*set_block)(void *data, bool blocked);
|
||||
};
|
||||
#endif
|
||||
|
||||
/* this changes infrequently, backport manually */
|
||||
enum rfkill_type {
|
||||
RFKILL_TYPE_ALL = 0,
|
||||
RFKILL_TYPE_WLAN,
|
||||
RFKILL_TYPE_BLUETOOTH,
|
||||
RFKILL_TYPE_UWB,
|
||||
RFKILL_TYPE_WIMAX,
|
||||
RFKILL_TYPE_WWAN,
|
||||
RFKILL_TYPE_GPS,
|
||||
RFKILL_TYPE_FM,
|
||||
RFKILL_TYPE_NFC,
|
||||
NUM_RFKILL_TYPES,
|
||||
};
|
||||
|
||||
static inline struct rfkill * __must_check
|
||||
backport_rfkill_alloc(const char *name,
|
||||
struct device *parent,
|
||||
const enum rfkill_type type,
|
||||
const struct rfkill_ops *ops,
|
||||
void *ops_data)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if ((unsigned int)type >= (unsigned int)OLD_NUM_RFKILL_TYPES)
|
||||
return ERR_PTR(-ENODEV);
|
||||
return rfkill_alloc(name, parent, (enum old_rfkill_type)type,
|
||||
ops, ops_data);
|
||||
#else
|
||||
return ERR_PTR(-ENODEV);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_alloc backport_rfkill_alloc
|
||||
|
||||
static inline int __must_check backport_rfkill_register(struct rfkill *rfkill)
|
||||
{
|
||||
if (rfkill == ERR_PTR(-ENODEV))
|
||||
return 0;
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
return rfkill_register(rfkill);
|
||||
#else
|
||||
return -EINVAL;
|
||||
#endif
|
||||
}
|
||||
#define rfkill_register backport_rfkill_register
|
||||
|
||||
static inline void backport_rfkill_pause_polling(struct rfkill *rfkill)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
rfkill_pause_polling(rfkill);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_pause_polling backport_rfkill_pause_polling
|
||||
|
||||
static inline void backport_rfkill_resume_polling(struct rfkill *rfkill)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
rfkill_resume_polling(rfkill);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_resume_polling backport_rfkill_resume_polling
|
||||
|
||||
static inline void backport_rfkill_unregister(struct rfkill *rfkill)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill == ERR_PTR(-ENODEV))
|
||||
return;
|
||||
rfkill_unregister(rfkill);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_unregister backport_rfkill_unregister
|
||||
|
||||
static inline void backport_rfkill_destroy(struct rfkill *rfkill)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill == ERR_PTR(-ENODEV))
|
||||
return;
|
||||
rfkill_destroy(rfkill);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_destroy backport_rfkill_destroy
|
||||
|
||||
static inline bool backport_rfkill_set_hw_state(struct rfkill *rfkill,
|
||||
bool blocked)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill != ERR_PTR(-ENODEV))
|
||||
return rfkill_set_hw_state(rfkill, blocked);
|
||||
#endif
|
||||
return blocked;
|
||||
}
|
||||
#define rfkill_set_hw_state backport_rfkill_set_hw_state
|
||||
|
||||
static inline bool backport_rfkill_set_sw_state(struct rfkill *rfkill,
|
||||
bool blocked)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill != ERR_PTR(-ENODEV))
|
||||
return rfkill_set_sw_state(rfkill, blocked);
|
||||
#endif
|
||||
return blocked;
|
||||
}
|
||||
#define rfkill_set_sw_state backport_rfkill_set_sw_state
|
||||
|
||||
static inline void backport_rfkill_init_sw_state(struct rfkill *rfkill,
|
||||
bool blocked)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill != ERR_PTR(-ENODEV))
|
||||
rfkill_init_sw_state(rfkill, blocked);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_init_sw_state backport_rfkill_init_sw_state
|
||||
|
||||
static inline void backport_rfkill_set_states(struct rfkill *rfkill,
|
||||
bool sw, bool hw)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill != ERR_PTR(-ENODEV))
|
||||
rfkill_set_states(rfkill, sw, hw);
|
||||
#endif
|
||||
}
|
||||
#define rfkill_set_states backport_rfkill_set_states
|
||||
|
||||
static inline bool backport_rfkill_blocked(struct rfkill *rfkill)
|
||||
{
|
||||
#ifdef HAVE_OLD_RFKILL
|
||||
if (rfkill != ERR_PTR(-ENODEV))
|
||||
return rfkill_blocked(rfkill);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
#define rfkill_blocked backport_rfkill_blocked
|
||||
#endif
|
||||
|
||||
#endif
|
30
backport-include/linux/rtnetlink.h
Normal file
30
backport-include/linux/rtnetlink.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef __BACKPORT_LINUX_RTNETLINK_H
|
||||
#define __BACKPORT_LINUX_RTNETLINK_H
|
||||
#include_next <linux/rtnetlink.h>
|
||||
|
||||
#ifndef rtnl_dereference
|
||||
#define rtnl_dereference(p) \
|
||||
rcu_dereference_protected(p, lockdep_rtnl_is_held())
|
||||
#endif
|
||||
|
||||
#ifndef rcu_dereference_rtnl
|
||||
#define rcu_dereference_rtnl(p) \
|
||||
rcu_dereference_check(p, rcu_read_lock_held() || \
|
||||
lockdep_rtnl_is_held())
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,34)
|
||||
#ifdef CONFIG_PROVE_LOCKING
|
||||
/*
|
||||
* Obviously, this is wrong. But the base kernel will have rtnl_mutex
|
||||
* declared static, with no way to access it. I think this is the best
|
||||
* we can do...
|
||||
*/
|
||||
static inline int lockdep_rtnl_is_held(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
#endif /* #ifdef CONFIG_PROVE_LOCKING */
|
||||
#endif /* < 2.6.34 */
|
||||
|
||||
#endif /* __BACKPORT_LINUX_RTNETLINK_H */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user