Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 823e334e authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge tag 'docs-for-linus' of git://git.lwn.net/linux-2.6

Pull documentation update from Jonathan Corbet:
 "Here's my set of accumulated documentation changes for 3.19.

  It includes a couple of additions to the coding style document, some
  fixes for minor build problems within the documentation tree, the
  relocation of the kselftest docs, and various tweaks and additions.

  A couple of changes reach outside of Documentation/; they only make
  trivial comment changes and I did my best to get the required acks.

  Complete with a shiny signed tag this time around"

* tag 'docs-for-linus' of git://git.lwn.net/linux-2.6:
  kobject: grammar fix
  Input: xpad - update docs to reflect current state
  Documentation: Build mic/mpssd only for x86_64
  cgroups: Documentation: fix wrong cgroupfs paths
  Documentation/email-clients.txt: add info about Claws Mail
  CodingStyle: add some more error handling guidelines
  kselftest: Move the docs to the Documentation dir
  Documentation: fix formatting to make 's' happy
  Documentation: power: Fix typo in Documentation/power
  Documentation: vm: Add 1GB large page support information
  ipv4: add kernel parameter tcpmhash_entries
  Documentation: Fix a typo in mailbox.txt
  treewide: Fix typo in Documentation/DocBook/device-drivers
  CodingStyle: Add a chapter on conditional compilation
parents 6ce4436c 9b64c09b
Loading
Loading
Loading
Loading
+65 −5
Original line number Diff line number Diff line
@@ -392,7 +392,12 @@ The goto statement comes in handy when a function exits from multiple
locations and some common work such as cleanup has to be done.  If there is no
cleanup needed then just return directly.

The rationale is:
Choose label names which say what the goto does or why the goto exists.  An
example of a good name could be "out_buffer:" if the goto frees "buffer".  Avoid
using GW-BASIC names like "err1:" and "err2:".  Also don't name them after the
goto location like "err_kmalloc_failed:"

The rationale for using gotos is:

- unconditional statements are easier to understand and follow
- nesting is reduced
@@ -403,9 +408,10 @@ The rationale is:
int fun(int a)
{
	int result = 0;
	char *buffer = kmalloc(SIZE);
	char *buffer;

	if (buffer == NULL)
	buffer = kmalloc(SIZE, GFP_KERNEL);
	if (!buffer)
		return -ENOMEM;

	if (condition1) {
@@ -413,14 +419,25 @@ int fun(int a)
			...
		}
		result = 1;
		goto out;
		goto out_buffer;
	}
	...
out:
out_buffer:
	kfree(buffer);
	return result;
}

A common type of bug to be aware of it "one err bugs" which look like this:

err:
	kfree(foo->bar);
	kfree(foo);
	return ret;

The bug in this code is that on some exit paths "foo" is NULL.  Normally the
fix for this is to split it up into two error labels "err_bar:" and "err_foo:".


		Chapter 8: Commenting

Comments are good, but there is also a danger of over-commenting.  NEVER
@@ -845,6 +862,49 @@ next instruction in the assembly output:
	     : /* outputs */ : /* inputs */ : /* clobbers */);


		Chapter 20: Conditional Compilation

Wherever possible, don't use preprocessor conditionals (#if, #ifdef) in .c
files; doing so makes code harder to read and logic harder to follow.  Instead,
use such conditionals in a header file defining functions for use in those .c
files, providing no-op stub versions in the #else case, and then call those
functions unconditionally from .c files.  The compiler will avoid generating
any code for the stub calls, producing identical results, but the logic will
remain easy to follow.

Prefer to compile out entire functions, rather than portions of functions or
portions of expressions.  Rather than putting an ifdef in an expression, factor
out part or all of the expression into a separate helper function and apply the
conditional to that function.

If you have a function or variable which may potentially go unused in a
particular configuration, and the compiler would warn about its definition
going unused, mark the definition as __maybe_unused rather than wrapping it in
a preprocessor conditional.  (However, if a function or variable *always* goes
unused, delete it.)

Within code, where possible, use the IS_ENABLED macro to convert a Kconfig
symbol into a C boolean expression, and use it in a normal C conditional:

	if (IS_ENABLED(CONFIG_SOMETHING)) {
		...
	}

The compiler will constant-fold the conditional away, and include or exclude
the block of code just as with an #ifdef, so this will not add any runtime
overhead.  However, this approach still allows the C compiler to see the code
inside the block, and check it for correctness (syntax, types, symbol
references, etc).  Thus, you still have to use an #ifdef if the code inside the
block references symbols that will not exist if the condition is not met.

At the end of any non-trivial #if or #ifdef block (more than a few lines),
place a comment after the #endif on the same line, noting the conditional
expression used.  For instance:

#ifdef CONFIG_SOMETHING
...
#endif /* CONFIG_SOMETHING */


		Appendix I: References

+2 −2
Original line number Diff line number Diff line
@@ -312,10 +312,10 @@ the "cpuset" cgroup subsystem, the steps are something like:
 2) mkdir /sys/fs/cgroup/cpuset
 3) mount -t cgroup -ocpuset cpuset /sys/fs/cgroup/cpuset
 4) Create the new cgroup by doing mkdir's and write's (or echo's) in
    the /sys/fs/cgroup virtual file system.
    the /sys/fs/cgroup/cpuset virtual file system.
 5) Start a task that will be the "founding father" of the new job.
 6) Attach that task to the new cgroup by writing its PID to the
    /sys/fs/cgroup/cpuset/tasks file for that cgroup.
    /sys/fs/cgroup/cpuset tasks file for that cgroup.
 7) fork, exec or clone the job tasks from this founding father task.

For example, the following sequence of commands will setup a cgroup
+11 −0
Original line number Diff line number Diff line
@@ -76,6 +76,17 @@ When composing the message, the cursor should be placed where the patch
should appear, and then pressing CTRL-R let you specify the patch file
to insert into the message.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Claws Mail (GUI)

Works. Some people use this successfully for patches.

To insert a patch use Message->Insert File (CTRL+i) or an external editor.

If the inserted patch has to be edited in the Claws composition window
"Auto wrapping" in Configuration->Preferences->Compose->Wrapping should be
disabled.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Evolution (GUI)

+1 −1
Original line number Diff line number Diff line
@@ -1272,7 +1272,7 @@ softirq.


1.9 Ext4 file system parameters
------------------------------
-------------------------------

Information about mounted ext4 file systems can be found in
/proc/fs/ext4.  Each mounted filesystem will have a directory in
+83 −40
Original line number Diff line number Diff line
xpad - Linux USB driver for X-Box gamepads
xpad - Linux USB driver for Xbox compatible controllers

This is the very first release of a driver for X-Box gamepads.
Basically, this was hacked away in just a few hours, so don't expect
miracles.
This driver exposes all first-party and third-party Xbox compatible
controllers. It has a long history and has enjoyed considerable usage
as Window's xinput library caused most PC games to focus on Xbox
controller compatibility.

In particular, there is currently NO support for the rumble pack.
You won't find many ff-aware linux applications anyway.
Due to backwards compatibility all buttons are reported as digital.
This only effects Original Xbox controllers. All later controller models
have only digital face buttons.

Rumble is supported on some models of Xbox 360 controllers but not of
Original Xbox controllers nor on Xbox One controllers. As of writing
the Xbox One's rumble protocol has not been reverse engineered but in
the future could be supported.


0. Notes
--------

Driver updated for kernel 2.6.17.11. (Based on a patch for 2.6.11.4.)

The number of buttons/axes reported varies based on 3 things:
- if you are using a known controller
- if you are using a known dance pad
@@ -20,12 +24,16 @@ The number of buttons/axes reported varies based on 3 things:
  module configuration for "Map D-PAD to buttons rather than axes for unknown
  pads" (module option dpad_to_buttons)

If you set dpad_to_buttons to 0 and you are using an unknown device (one
not listed below), the driver will map the directional pad to axes (X/Y),
if you said N it will map the d-pad to buttons, which is needed for dance
If you set dpad_to_buttons to N and you are using an unknown device
the driver will map the directional pad to axes (X/Y).
If you said Y it will map the d-pad to buttons, which is needed for dance
style games to function correctly. The default is Y.

dpad_to_buttons has no effect for known pads.
dpad_to_buttons has no effect for known pads. A erroneous commit message
claimed dpad_to_buttons could be used to force behavior on known devices.
This is not true. Both dpad_to_buttons and triggers_to_buttons only affect
unknown controllers.


0.1 Normal Controllers
----------------------
@@ -80,17 +88,29 @@ to the list of supported devices, ensuring that it will work out of the
box in the future.


1. USB adapter
1. USB adapters
--------------
All generations of Xbox controllers speak USB over the wire.
- Original Xbox controllers use a proprietary connector and require adapters.
- Wireless Xbox 360 controllers require a 'Xbox 360 Wireless Gaming Receiver
  for Windows'
- Wired Xbox 360 controllers use standard USB connectors.
- Xbox One controllers can be wireless but speak Wi-Fi Direct and are not
  yet supported.
- Xbox One controllers can be wired and use standard Micro-USB connectors.


Before you can actually use the driver, you need to get yourself an
adapter cable to connect the X-Box controller to your Linux-Box. You
can buy these online fairly cheap, or build your own.

1.1 Original Xbox USB adapters
--------------
Using this driver with an Original Xbox controller requires an
adapter cable to break out the proprietary connector's pins to USB.
You can buy these online fairly cheap, or build your own.

Such a cable is pretty easy to build. The Controller itself is a USB
compound device (a hub with three ports for two expansion slots and
the controller device) with the only difference in a nonstandard connector
(5 pins vs. 4 on standard USB connector).
(5 pins vs. 4 on standard USB 1.0 connectors).

You just need to solder a USB connector onto the cable and keep the
yellow wire unconnected. The other pins have the same order on both
@@ -102,26 +122,41 @@ original one. You can buy an extension cable and cut that instead. That way,
you can still use the controller with your X-Box, if you have one ;)



2. Driver Installation
----------------------

Once you have the adapter cable and the controller is connected, you need
to load your USB subsystem and should cat /proc/bus/usb/devices.
There should be an entry like the one at the end [4].
Once you have the adapter cable, if needed, and the controller connected
the xpad module should be auto loaded. To confirm you can cat
/proc/bus/usb/devices. There should be an entry like the one at the end [4].



Currently (as of version 0.0.6), the following devices are included:
3. Supported Controllers
------------------------
For a full list of supported controllers and associated vendor and product
IDs see the xpad_device[] array[6].

As of the historic version 0.0.6 (2006-10-10) the following devices
were supported:
 original Microsoft XBOX controller (US),    vendor=0x045e, product=0x0202
 smaller  Microsoft XBOX controller (US),    vendor=0x045e, product=0x0289
 original Microsoft XBOX controller (Japan), vendor=0x045e, product=0x0285
 InterAct PowerPad Pro (Germany),            vendor=0x05fd, product=0x107a
 RedOctane Xbox Dance Pad (US),              vendor=0x0c12, product=0x8809

The driver should work with xbox pads not listed above as well, however
you will need to do something extra for dance pads to work.
Unrecognized models of Xbox controllers should function as Generic
Xbox controllers. Unrecognized Dance Pad controllers require setting
the module option 'dpad_to_buttons'.

If you have an unrecognized controller please see 0.3 - Unknown Controllers


If you have a controller not listed above, see 0.3 - Unknown Controllers
4. Manual Testing
-----------------
To test this driver's functionality you may use 'jstest'.

If you compiled and installed the driver, test the functionality:
For example:
> modprobe xpad
> modprobe joydev
> jstest /dev/js0
@@ -134,7 +169,8 @@ show 20 inputs (6 axes, 14 buttons).
It works? Voila, you're done ;)


3. Thanks

5. Thanks
---------

I have to thank ITO Takayuki for the detailed info on his site
@@ -145,14 +181,14 @@ His useful info and both the usb-skeleton as well as the iforce input driver
the basic functionality.


4. References
-------------

1. http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
2. http://xpad.xbox-scene.com/
3. http://www.markosweb.com/www/xboxhackz.com/ 
6. References
-------------

4. /proc/bus/usb/devices - dump from InterAct PowerPad Pro (Germany):
[1]: http://euc.jp/periphs/xbox-controller.ja.html (ITO Takayuki)
[2]: http://xpad.xbox-scene.com/
[3]: http://www.markosweb.com/www/xboxhackz.com/
[4]: /proc/bus/usb/devices - dump from InterAct PowerPad Pro (Germany):

T:  Bus=01 Lev=03 Prnt=04 Port=00 Cnt=01 Dev#=  5 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=32 #Cfgs=  1
@@ -162,7 +198,7 @@ I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=(none)
E:  Ad=81(I) Atr=03(Int.) MxPS=  32 Ivl= 10ms
E:  Ad=02(O) Atr=03(Int.) MxPS=  32 Ivl= 10ms

5. /proc/bus/usb/devices - dump from Redoctane Xbox Dance Pad (US):
[5]: /proc/bus/usb/devices - dump from Redoctane Xbox Dance Pad (US):

T:  Bus=01 Lev=02 Prnt=09 Port=00 Cnt=01 Dev#= 10 Spd=12  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
@@ -173,7 +209,12 @@ I: If#= 0 Alt= 0 #EPs= 2 Cls=58(unk. ) Sub=42 Prot=00 Driver=xpad
E:  Ad=82(I) Atr=03(Int.) MxPS=  32 Ivl=4ms
E:  Ad=02(O) Atr=03(Int.) MxPS=  32 Ivl=4ms

-- 
[6]: http://lxr.free-electrons.com/ident?i=xpad_device



7. Historic Edits
-----------------
Marko Friedemann <mfr@bmx-chemnitz.de>
2002-07-16
 - original doc
@@ -181,3 +222,5 @@ Marko Friedemann <mfr@bmx-chemnitz.de>
Dominic Cerquetti <binary1230@yahoo.com>
2005-03-19
 - added stuff for dance pads, new d-pad->axes mappings

Later changes may be viewed with 'git log Documentation/input/xpad.txt'
Loading