<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux-toradex.git/drivers/i2c/i2c-core.c, branch v3.11</title>
<subtitle>Linux kernel for Apalis and Colibri modules</subtitle>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/'/>
<entry>
<title>PM / Runtime: Rework the "runtime idle" helper routine</title>
<updated>2013-06-03T19:49:52+00:00</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2013-06-03T19:49:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=45f0a85c8258741d11bda25c0a5669c06267204a'/>
<id>45f0a85c8258741d11bda25c0a5669c06267204a</id>
<content type='text'>
The "runtime idle" helper routine, rpm_idle(), currently ignores
return values from .runtime_idle() callbacks executed by it.
However, it turns out that many subsystems use
pm_generic_runtime_idle() which checks the return value of the
driver's callback and executes pm_runtime_suspend() for the device
unless that value is not 0.  If that logic is moved to rpm_idle()
instead, pm_generic_runtime_idle() can be dropped and its users
will not need any .runtime_idle() callbacks any more.

Moreover, the PCI, SCSI, and SATA subsystems' .runtime_idle()
routines, pci_pm_runtime_idle(), scsi_runtime_idle(), and
ata_port_runtime_idle(), respectively, as well as a few drivers'
ones may be simplified if rpm_idle() calls rpm_suspend() after 0 has
been returned by the .runtime_idle() callback executed by it.

To reduce overall code bloat, make the changes described above.

Tested-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Tested-by: Kevin Hilman &lt;khilman@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Kevin Hilman &lt;khilman@linaro.org&gt;
Reviewed-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The "runtime idle" helper routine, rpm_idle(), currently ignores
return values from .runtime_idle() callbacks executed by it.
However, it turns out that many subsystems use
pm_generic_runtime_idle() which checks the return value of the
driver's callback and executes pm_runtime_suspend() for the device
unless that value is not 0.  If that logic is moved to rpm_idle()
instead, pm_generic_runtime_idle() can be dropped and its users
will not need any .runtime_idle() callbacks any more.

Moreover, the PCI, SCSI, and SATA subsystems' .runtime_idle()
routines, pci_pm_runtime_idle(), scsi_runtime_idle(), and
ata_port_runtime_idle(), respectively, as well as a few drivers'
ones may be simplified if rpm_idle() calls rpm_suspend() after 0 has
been returned by the .runtime_idle() callback executed by it.

To reduce overall code bloat, make the changes described above.

Tested-by: Mika Westerberg &lt;mika.westerberg@linux.intel.com&gt;
Tested-by: Kevin Hilman &lt;khilman@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Acked-by: Kevin Hilman &lt;khilman@linaro.org&gt;
Reviewed-by: Ulf Hansson &lt;ulf.hansson@linaro.org&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: suppress lockdep warning on delete_device</title>
<updated>2013-05-17T20:49:45+00:00</updated>
<author>
<name>Alexander Sverdlin</name>
<email>alexander.sverdlin@nsn.com</email>
</author>
<published>2013-05-17T12:56:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e9b526fe704812364bca07edd15eadeba163ebfb'/>
<id>e9b526fe704812364bca07edd15eadeba163ebfb</id>
<content type='text'>
i2c: suppress lockdep warning on delete_device

Since commit 846f99749ab68bbc7f75c74fec305de675b1a1bf the following lockdep
warning is thrown in case i2c device is removed (via delete_device sysfs
attribute) which contains subdevices (e.g. i2c multiplexer):

=============================================
[ INFO: possible recursive locking detected ]
3.8.7-0-sampleversion-fct #8 Tainted: G           O
---------------------------------------------
bash/3743 is trying to acquire lock:
  (s_active#110){++++.+}, at: [&lt;ffffffff802b3048&gt;] sysfs_hash_and_remove+0x58/0xc8

but task is already holding lock:
  (s_active#110){++++.+}, at: [&lt;ffffffff802b3cb8&gt;] sysfs_write_file+0xc8/0x208

other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(s_active#110);
   lock(s_active#110);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

4 locks held by bash/3743:
  #0:  (&amp;buffer-&gt;mutex){+.+.+.}, at: [&lt;ffffffff802b3c3c&gt;] sysfs_write_file+0x4c/0x208
  #1:  (s_active#110){++++.+}, at: [&lt;ffffffff802b3cb8&gt;] sysfs_write_file+0xc8/0x208
  #2:  (&amp;adap-&gt;userspace_clients_lock/1){+.+.+.}, at: [&lt;ffffffff80454a18&gt;] i2c_sysfs_delete_device+0x90/0x238
  #3:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff803dcc24&gt;] device_release_driver+0x24/0x48

stack backtrace:
Call Trace:
[&lt;ffffffff80575cc8&gt;] dump_stack+0x8/0x34
[&lt;ffffffff801b50fc&gt;] __lock_acquire+0x161c/0x2110
[&lt;ffffffff801b5c3c&gt;] lock_acquire+0x4c/0x70
[&lt;ffffffff802b60cc&gt;] sysfs_addrm_finish+0x19c/0x1e0
[&lt;ffffffff802b3048&gt;] sysfs_hash_and_remove+0x58/0xc8
[&lt;ffffffff802b7d8c&gt;] sysfs_remove_group+0x64/0x148
[&lt;ffffffff803d990c&gt;] device_remove_attrs+0x9c/0x1a8
[&lt;ffffffff803d9b1c&gt;] device_del+0x104/0x1d8
[&lt;ffffffff803d9c18&gt;] device_unregister+0x28/0x70
[&lt;ffffffff8045505c&gt;] i2c_del_adapter+0x1cc/0x328
[&lt;ffffffff8045802c&gt;] i2c_del_mux_adapter+0x14/0x38
[&lt;ffffffffc025c108&gt;] pca954x_remove+0x90/0xe0 [pca954x]
[&lt;ffffffff804542f8&gt;] i2c_device_remove+0x80/0xe8
[&lt;ffffffff803dca9c&gt;] __device_release_driver+0x74/0xf8
[&lt;ffffffff803dcc2c&gt;] device_release_driver+0x2c/0x48
[&lt;ffffffff803dbc14&gt;] bus_remove_device+0x13c/0x1d8
[&lt;ffffffff803d9b24&gt;] device_del+0x10c/0x1d8
[&lt;ffffffff803d9c18&gt;] device_unregister+0x28/0x70
[&lt;ffffffff80454b08&gt;] i2c_sysfs_delete_device+0x180/0x238
[&lt;ffffffff802b3cd4&gt;] sysfs_write_file+0xe4/0x208
[&lt;ffffffff8023ddc4&gt;] vfs_write+0xbc/0x160
[&lt;ffffffff8023df6c&gt;] SyS_write+0x54/0xd8
[&lt;ffffffff8013d424&gt;] handle_sys64+0x44/0x64

The problem is already known for USB and PCI subsystems. The reason is that
delete_device attribute is defined statically in i2c-core.c and used for all
devices in i2c subsystem.

Discussion of original USB problem:
http://lkml.indiana.edu/hypermail/linux/kernel/1204.3/01160.html

Commit 356c05d58af05d582e634b54b40050c73609617b introduced new macro to suppress
lockdep warnings for this special case and included workaround for USB code.

LKML discussion of the workaround:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.1/03634.html

As i2c case is in principle the same, the same workaround could be used here.

Signed-off-by: Alexander Sverdlin &lt;alexander.sverdlin@nsn.com&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
i2c: suppress lockdep warning on delete_device

Since commit 846f99749ab68bbc7f75c74fec305de675b1a1bf the following lockdep
warning is thrown in case i2c device is removed (via delete_device sysfs
attribute) which contains subdevices (e.g. i2c multiplexer):

=============================================
[ INFO: possible recursive locking detected ]
3.8.7-0-sampleversion-fct #8 Tainted: G           O
---------------------------------------------
bash/3743 is trying to acquire lock:
  (s_active#110){++++.+}, at: [&lt;ffffffff802b3048&gt;] sysfs_hash_and_remove+0x58/0xc8

but task is already holding lock:
  (s_active#110){++++.+}, at: [&lt;ffffffff802b3cb8&gt;] sysfs_write_file+0xc8/0x208

other info that might help us debug this:
  Possible unsafe locking scenario:

        CPU0
        ----
   lock(s_active#110);
   lock(s_active#110);

  *** DEADLOCK ***

  May be due to missing lock nesting notation

4 locks held by bash/3743:
  #0:  (&amp;buffer-&gt;mutex){+.+.+.}, at: [&lt;ffffffff802b3c3c&gt;] sysfs_write_file+0x4c/0x208
  #1:  (s_active#110){++++.+}, at: [&lt;ffffffff802b3cb8&gt;] sysfs_write_file+0xc8/0x208
  #2:  (&amp;adap-&gt;userspace_clients_lock/1){+.+.+.}, at: [&lt;ffffffff80454a18&gt;] i2c_sysfs_delete_device+0x90/0x238
  #3:  (&amp;__lockdep_no_validate__){......}, at: [&lt;ffffffff803dcc24&gt;] device_release_driver+0x24/0x48

stack backtrace:
Call Trace:
[&lt;ffffffff80575cc8&gt;] dump_stack+0x8/0x34
[&lt;ffffffff801b50fc&gt;] __lock_acquire+0x161c/0x2110
[&lt;ffffffff801b5c3c&gt;] lock_acquire+0x4c/0x70
[&lt;ffffffff802b60cc&gt;] sysfs_addrm_finish+0x19c/0x1e0
[&lt;ffffffff802b3048&gt;] sysfs_hash_and_remove+0x58/0xc8
[&lt;ffffffff802b7d8c&gt;] sysfs_remove_group+0x64/0x148
[&lt;ffffffff803d990c&gt;] device_remove_attrs+0x9c/0x1a8
[&lt;ffffffff803d9b1c&gt;] device_del+0x104/0x1d8
[&lt;ffffffff803d9c18&gt;] device_unregister+0x28/0x70
[&lt;ffffffff8045505c&gt;] i2c_del_adapter+0x1cc/0x328
[&lt;ffffffff8045802c&gt;] i2c_del_mux_adapter+0x14/0x38
[&lt;ffffffffc025c108&gt;] pca954x_remove+0x90/0xe0 [pca954x]
[&lt;ffffffff804542f8&gt;] i2c_device_remove+0x80/0xe8
[&lt;ffffffff803dca9c&gt;] __device_release_driver+0x74/0xf8
[&lt;ffffffff803dcc2c&gt;] device_release_driver+0x2c/0x48
[&lt;ffffffff803dbc14&gt;] bus_remove_device+0x13c/0x1d8
[&lt;ffffffff803d9b24&gt;] device_del+0x10c/0x1d8
[&lt;ffffffff803d9c18&gt;] device_unregister+0x28/0x70
[&lt;ffffffff80454b08&gt;] i2c_sysfs_delete_device+0x180/0x238
[&lt;ffffffff802b3cd4&gt;] sysfs_write_file+0xe4/0x208
[&lt;ffffffff8023ddc4&gt;] vfs_write+0xbc/0x160
[&lt;ffffffff8023df6c&gt;] SyS_write+0x54/0xd8
[&lt;ffffffff8013d424&gt;] handle_sys64+0x44/0x64

The problem is already known for USB and PCI subsystems. The reason is that
delete_device attribute is defined statically in i2c-core.c and used for all
devices in i2c subsystem.

Discussion of original USB problem:
http://lkml.indiana.edu/hypermail/linux/kernel/1204.3/01160.html

Commit 356c05d58af05d582e634b54b40050c73609617b introduced new macro to suppress
lockdep warnings for this special case and included workaround for USB code.

LKML discussion of the workaround:
http://lkml.indiana.edu/hypermail/linux/kernel/1205.1/03634.html

As i2c case is in principle the same, the same workaround could be used here.

Signed-off-by: Alexander Sverdlin &lt;alexander.sverdlin@nsn.com&gt;
Acked-by: Alan Stern &lt;stern@rowland.harvard.edu&gt;
Cc: Eric W. Biederman &lt;ebiederm@xmission.com&gt;
Cc: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: remove CONFIG_HOTPLUG ifdefs</title>
<updated>2013-04-09T09:57:55+00:00</updated>
<author>
<name>Yijing Wang</name>
<email>wangyijing@huawei.com</email>
</author>
<published>2013-04-08T15:46:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e5a7074a753623505ad20289abbea7a6c8c47bf7'/>
<id>e5a7074a753623505ad20289abbea7a6c8c47bf7</id>
<content type='text'>
CONFIG_HOTPLUG is going away as an option, cleanup CONFIG_HOTPLUG
ifdefs in i2c files.

Signed-off-by: Yijing Wang &lt;wangyijing@huawei.com&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
CONFIG_HOTPLUG is going away as an option, cleanup CONFIG_HOTPLUG
ifdefs in i2c files.

Signed-off-by: Yijing Wang &lt;wangyijing@huawei.com&gt;
Acked-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: Make return type of i2c_del_adapter() void</title>
<updated>2013-04-02T05:06:17+00:00</updated>
<author>
<name>Lars-Peter Clausen</name>
<email>lars@metafoo.de</email>
</author>
<published>2013-03-09T08:16:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=71546300c8684eb69286604c79624582c16f2f5b'/>
<id>71546300c8684eb69286604c79624582c16f2f5b</id>
<content type='text'>
i2c_del_adapter() is usually called from a drivers remove callback. The Linux
device driver model does not allow the remove callback to fail and all resources
allocated in the probe callback need to be freed, as well as all resources which
have been provided to the rest of the kernel(for example a I2C adapter) need to
be revoked. So any function revoking such resources isn't allowed to fail
either. i2c_del_adapter() adheres to this requirement and will never fail. But
i2c_del_adapter()'s return type is int, which may cause driver authors to think
that it can fail. This led to code constructs like:

	ret = i2c_del_adapter(...);
	BUG_ON(ret);

Since i2c_del_adapter() always returns 0 the BUG_ON is never hit and essentially
becomes dead code, which means it can be removed. Making the return type of
i2c_del_adapter() void makes it explicit that the function will never fail and
should prevent constructs like the above from re-appearing in the kernel code.

All callers of i2c_del_adapter() have already been updated in a previous patch
to ignore the return value, so the conversion of the return type from int to
void can be done without causing any build failures.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
i2c_del_adapter() is usually called from a drivers remove callback. The Linux
device driver model does not allow the remove callback to fail and all resources
allocated in the probe callback need to be freed, as well as all resources which
have been provided to the rest of the kernel(for example a I2C adapter) need to
be revoked. So any function revoking such resources isn't allowed to fail
either. i2c_del_adapter() adheres to this requirement and will never fail. But
i2c_del_adapter()'s return type is int, which may cause driver authors to think
that it can fail. This led to code constructs like:

	ret = i2c_del_adapter(...);
	BUG_ON(ret);

Since i2c_del_adapter() always returns 0 the BUG_ON is never hit and essentially
becomes dead code, which means it can be removed. Making the return type of
i2c_del_adapter() void makes it explicit that the function will never fail and
should prevent constructs like the above from re-appearing in the kernel code.

All callers of i2c_del_adapter() have already been updated in a previous patch
to ignore the return value, so the conversion of the return type from int to
void can be done without causing any build failures.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: i2c_del_adapter: Don't treat removing a non-registered adapter as error</title>
<updated>2013-04-02T05:03:37+00:00</updated>
<author>
<name>Lars-Peter Clausen</name>
<email>lars@metafoo.de</email>
</author>
<published>2013-03-09T08:16:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=f5fb0822957b914ab7022cc4bfe000ec3bc9c82c'/>
<id>f5fb0822957b914ab7022cc4bfe000ec3bc9c82c</id>
<content type='text'>
Currently i2c_del_adapter() returns -EINVAL when it gets an adapter which is not
registered. But none of the users of i2c_del_adapter() depend on this behavior,
so for the sake of being able to sanitize the return type of i2c_del_adapter
argue, that the purpose of i2c_del_adapter() is to remove an I2C adapter from
the system. If the adapter is not registered in the first place this becomes a
no-op. So we can return success without having to do anything.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Currently i2c_del_adapter() returns -EINVAL when it gets an adapter which is not
registered. But none of the users of i2c_del_adapter() depend on this behavior,
so for the sake of being able to sanitize the return type of i2c_del_adapter
argue, that the purpose of i2c_del_adapter() is to remove an I2C adapter from
the system. If the adapter is not registered in the first place this becomes a
no-op. So we can return success without having to do anything.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: Remove detach_adapter</title>
<updated>2013-04-02T05:03:28+00:00</updated>
<author>
<name>Lars-Peter Clausen</name>
<email>lars@metafoo.de</email>
</author>
<published>2013-03-09T08:16:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=19baba4cb6843bbe3dfde87e1e913f6a9cd27da9'/>
<id>19baba4cb6843bbe3dfde87e1e913f6a9cd27da9</id>
<content type='text'>
The detach_adapter callback has been deprecated for quite some time and has no
user left. Keeping it alive blocks other cleanups, so remove it.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The detach_adapter callback has been deprecated for quite some time and has no
user left. Keeping it alive blocks other cleanups, so remove it.

Signed-off-by: Lars-Peter Clausen &lt;lars@metafoo.de&gt;
Reviewed-by: Jean Delvare &lt;khali@linux-fr.org&gt;
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: Add bus recovery infrastructure</title>
<updated>2013-03-24T09:30:54+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2012-02-28T12:56:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=5f9296ba21b3c395e53dd84e7ff9578f97f24295'/>
<id>5f9296ba21b3c395e53dd84e7ff9578f97f24295</id>
<content type='text'>
Add i2c bus recovery infrastructure to i2c adapters as specified in the i2c
protocol Rev. 03 section 3.1.16 titled "Bus clear".

http://www.nxp.com/documents/user_manual/UM10204.pdf

Sometimes during operation i2c bus hangs and we need to give dummy clocks to
slave device to start the transfer again. Now we may have capability in the bus
controller to generate these clocks or platform may have gpio pins which can be
toggled to generate dummy clocks. This patch supports both.

This patch also adds in generic bus recovery routines gpio or scl line based
which can be used by bus controller. In addition controller driver may provide
its own version of the bus recovery routine.

This doesn't support multi-master recovery for now.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[wsa: changed gpio type to int and minor reformatting]
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add i2c bus recovery infrastructure to i2c adapters as specified in the i2c
protocol Rev. 03 section 3.1.16 titled "Bus clear".

http://www.nxp.com/documents/user_manual/UM10204.pdf

Sometimes during operation i2c bus hangs and we need to give dummy clocks to
slave device to start the transfer again. Now we may have capability in the bus
controller to generate these clocks or platform may have gpio pins which can be
toggled to generate dummy clocks. This patch supports both.

This patch also adds in generic bus recovery routines gpio or scl line based
which can be used by bus controller. In addition controller driver may provide
its own version of the bus recovery routine.

This doesn't support multi-master recovery for now.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[wsa: changed gpio type to int and minor reformatting]
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: core: Pick i2c bus number from dt alias if present</title>
<updated>2013-03-24T09:30:53+00:00</updated>
<author>
<name>Doug Anderson</name>
<email>dianders@chromium.org</email>
</author>
<published>2013-03-01T16:57:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=ee5c27440cc24d62ec463cce4c000bb32c5692c7'/>
<id>ee5c27440cc24d62ec463cce4c000bb32c5692c7</id>
<content type='text'>
This allows you to get the equivalent functionality of
i2c_add_numbered_adapter() with all data in the device tree and no
special case code in your driver.  This is a common device tree
technique.

For quick reference, the FDT syntax for using an alias to provide an
ID looks like:
  aliases {
    i2c0 = &amp;i2c_0;
    i2c1 = &amp;i2c_1;
  };

Signed-off-by: Doug Anderson &lt;dianders@chromium.org&gt;
[wsa: removed one check from static function. We know our callers]
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This allows you to get the equivalent functionality of
i2c_add_numbered_adapter() with all data in the device tree and no
special case code in your driver.  This is a common device tree
technique.

For quick reference, the FDT syntax for using an alias to provide an
ID looks like:
  aliases {
    i2c0 = &amp;i2c_0;
    i2c1 = &amp;i2c_1;
  };

Signed-off-by: Doug Anderson &lt;dianders@chromium.org&gt;
[wsa: removed one check from static function. We know our callers]
Signed-off-by: Wolfram Sang &lt;wsa@the-dreams.de&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>idr: remove MAX_IDR_MASK and move left MAX_IDR_* into idr.c</title>
<updated>2013-02-28T03:10:20+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2013-02-28T01:05:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=e8c8d1bc063bc88cfa1356266027b5075d3a82d7'/>
<id>e8c8d1bc063bc88cfa1356266027b5075d3a82d7</id>
<content type='text'>
MAX_IDR_MASK is another weirdness in the idr interface.  As idr covers
whole positive integer range, it's defined as 0x7fffffff or INT_MAX.

Its usage in idr_find(), idr_replace() and idr_remove() is bizarre.
They basically mask off the sign bit and operate on the rest, so if
the caller, by accident, passes in a negative number, the sign bit
will be masked off and the remaining part will be used as if that was
the input, which is worse than crashing.

The constant is visible in idr.h and there are several users in the
kernel.

* drivers/i2c/i2c-core.c:i2c_add_numbered_adapter()

  Basically used to test if adap-&gt;nr is a negative number which isn't
  -1 and returns -EINVAL if so.  idr_alloc() already has negative
  @start checking (w/ WARN_ON_ONCE), so this can go away.

* drivers/infiniband/core/cm.c:cm_alloc_id()
  drivers/infiniband/hw/mlx4/cm.c:id_map_alloc()

  Used to wrap cyclic @start.  Can be replaced with max(next, 0).
  Note that this type of cyclic allocation using idr is buggy.  These
  are prone to spurious -ENOSPC failure after the first wraparound.

* fs/super.c:get_anon_bdev()

  The ID allocated from ida is masked off before being tested whether
  it's inside valid range.  ida allocated ID can never be a negative
  number and the masking is unnecessary.

Update idr_*() functions to fail with -EINVAL when negative @id is
specified and update other MAX_IDR_MASK users as described above.

This leaves MAX_IDR_MASK without any user, remove it and relocate
other MAX_IDR_* constants to lib/idr.c.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Jean Delvare &lt;khali@linux-fr.org&gt;
Cc: Roland Dreier &lt;roland@kernel.org&gt;
Cc: Sean Hefty &lt;sean.hefty@intel.com&gt;
Cc: Hal Rosenstock &lt;hal.rosenstock@gmail.com&gt;
Cc: "Marciniszyn, Mike" &lt;mike.marciniszyn@intel.com&gt;
Cc: Jack Morgenstein &lt;jackm@dev.mellanox.co.il&gt;
Cc: Or Gerlitz &lt;ogerlitz@mellanox.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Acked-by: Wolfram Sang &lt;wolfram@the-dreams.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
MAX_IDR_MASK is another weirdness in the idr interface.  As idr covers
whole positive integer range, it's defined as 0x7fffffff or INT_MAX.

Its usage in idr_find(), idr_replace() and idr_remove() is bizarre.
They basically mask off the sign bit and operate on the rest, so if
the caller, by accident, passes in a negative number, the sign bit
will be masked off and the remaining part will be used as if that was
the input, which is worse than crashing.

The constant is visible in idr.h and there are several users in the
kernel.

* drivers/i2c/i2c-core.c:i2c_add_numbered_adapter()

  Basically used to test if adap-&gt;nr is a negative number which isn't
  -1 and returns -EINVAL if so.  idr_alloc() already has negative
  @start checking (w/ WARN_ON_ONCE), so this can go away.

* drivers/infiniband/core/cm.c:cm_alloc_id()
  drivers/infiniband/hw/mlx4/cm.c:id_map_alloc()

  Used to wrap cyclic @start.  Can be replaced with max(next, 0).
  Note that this type of cyclic allocation using idr is buggy.  These
  are prone to spurious -ENOSPC failure after the first wraparound.

* fs/super.c:get_anon_bdev()

  The ID allocated from ida is masked off before being tested whether
  it's inside valid range.  ida allocated ID can never be a negative
  number and the masking is unnecessary.

Update idr_*() functions to fail with -EINVAL when negative @id is
specified and update other MAX_IDR_MASK users as described above.

This leaves MAX_IDR_MASK without any user, remove it and relocate
other MAX_IDR_* constants to lib/idr.c.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Jean Delvare &lt;khali@linux-fr.org&gt;
Cc: Roland Dreier &lt;roland@kernel.org&gt;
Cc: Sean Hefty &lt;sean.hefty@intel.com&gt;
Cc: Hal Rosenstock &lt;hal.rosenstock@gmail.com&gt;
Cc: "Marciniszyn, Mike" &lt;mike.marciniszyn@intel.com&gt;
Cc: Jack Morgenstein &lt;jackm@dev.mellanox.co.il&gt;
Cc: Or Gerlitz &lt;ogerlitz@mellanox.com&gt;
Cc: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Acked-by: Wolfram Sang &lt;wolfram@the-dreams.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>i2c: convert to idr_alloc()</title>
<updated>2013-02-28T03:10:16+00:00</updated>
<author>
<name>Tejun Heo</name>
<email>tj@kernel.org</email>
</author>
<published>2013-02-28T01:04:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.toradex.cn/cgit/linux-toradex.git/commit/?id=4ae42b0ff0f9993c79d7282218b98d8a8a4263f5'/>
<id>4ae42b0ff0f9993c79d7282218b98d8a8a4263f5</id>
<content type='text'>
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Jean Delvare &lt;khali@linux-fr.org&gt;
Cc: Wolfram Sang &lt;wolfram@the-dreams.de&gt;
Tested-by: Mark Brown &lt;broonie@opensource.wolfsonmicro.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Convert to the much saner new idr interface.

Signed-off-by: Tejun Heo &lt;tj@kernel.org&gt;
Cc: Jean Delvare &lt;khali@linux-fr.org&gt;
Cc: Wolfram Sang &lt;wolfram@the-dreams.de&gt;
Tested-by: Mark Brown &lt;broonie@opensource.wolfsonmicro.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
