Commit graph

53600 commits

Author SHA1 Message Date
Herbert Xu
a73e69965f [CRYPTO] api: Do not remove users unless new algorithm matches
As it is whenever a new algorithm with the same name is registered
users of the old algorithm will be removed so that they can take
advantage of the new algorithm.  This presents a problem when the
new algorithm is not equivalent to the old algorithm.  In particular,
the new algorithm might only function on top of the existing one.

Hence we should not remove users unless they can make use of the
new algorithm.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:32 +10:00
Herbert Xu
cf02f5da94 [CRYPTO] cryptomgr: Fix parsing of nested templates
This patch allows the use of nested templates by allowing the use of
brackets inside a template parameter.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:31 +10:00
Herbert Xu
b5b7f08869 [CRYPTO] api: Add async blkcipher type
This patch adds the mid-level interface for asynchronous block ciphers.
It also includes a generic queueing mechanism that can be used by other
asynchronous crypto operations in future.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:31 +10:00
Herbert Xu
ebc610e5bc [CRYPTO] templates: Pass type/mask when creating instances
This patch passes the type/mask along when constructing instances of
templates.  This is in preparation for templates that may support
multiple types of instances depending on what is requested.  For example,
the planned software async crypto driver will use this construct.

For the moment this allows us to check whether the instance constructed
is of the correct type and avoid returning success if the type does not
match.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:31 +10:00
Herbert Xu
6158efc090 [CRYPTO] tcrypt: Use async blkcipher interface
This patch converts the tcrypt module to use the asynchronous block cipher
interface.  As all synchronous block ciphers can be used through the async
interface, tcrypt is still able to test them.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:30 +10:00
Herbert Xu
32e3983fe5 [CRYPTO] api: Add async block cipher interface
This patch adds the frontend interface for asynchronous block ciphers.
In addition to the usual block cipher parameters, there is a callback
function pointer and a data pointer.  The callback will be invoked only
if the encrypt/decrypt handlers return -EINPROGRESS.  In other words,
if the return value of zero the completion handler (or the equivalent
code) needs to be invoked by the caller.

The request structure is allocated and freed by the caller.  Its size
is determined by calling crypto_ablkcipher_reqsize().  The helpers
ablkcipher_request_alloc/ablkcipher_request_free can be used to manage
the memory for a request.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:30 +10:00
Herbert Xu
03f5d8cedb [CRYPTO] api: Proc functions should be marked as unused
The proc functions were incorrectly marked as used rather than unused.
They may be unused if proc is disabled.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2007-05-02 14:38:29 +10:00
Ben Dooks
5b68790cd5 i2c-s3c2410: Fix bug in releasing driver
When compiled as a module, the i2c-s3c2410 driver does not
free either the IRQ or the i2c adapter it attached to the system.

As part of this fix, move to the usual kernel style
of freeing items as part of the probe error path
making the remove process easier.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:35 +02:00
Ben Dooks
e00a8cdf32 i2c-s3c2410: Fix I2C SDA to SCL setup time
Fix the setup time for SDA to SCL due to the way
the S3C24XX I2C controller works.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:35 +02:00
Till Harbaum
e8c76eed2e i2c: New i2c-tiny-usb bus driver
Add a driver for the i2c-tiny-usb interface. This is a simple
do-it-yourself USB to I2C interface targeted at experimental and
home use. See the i2c-tiny-usb homepage for hardware details:
http://www.harbaum.org/till/i2c_tiny_usb

Signed-off-by: Till Harbaum <till@harbaum.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:35 +02:00
Jean Delvare
eefcd75e72 i2c: Documentation update
Make the documentation on how to write and port i2c drivers more in
line with the current state of things:
* i2c-isa is deprecated and soon gone, so stop advertising it.
* Drop many sensors-specific references. Most of them were outdated
  anyway.
* Update the example code to reflect the recent and not-so-recent
  API and coding style preference changes.
* Simplify the example init and cleanup functions.

This should make things less complex to understand for newcomers.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:35 +02:00
Milind Arun Choudhary
35532d2003 i2c: SPIN_LOCK_UNLOCKED cleanup
SPIN_LOCK_UNLOCKED cleanup, use __SPIN_LOCK_UNLOCKED instead.

Signed-off-by: Milind Arun Choudhary <milindchoudhary@gmail.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:34 +02:00
Jean Delvare
11de70bd4d i2c: Obsolete i2c-ixp2000, i2c-ixp4xx and scx200_i2c
The new generic i2c-gpio driver should be used instead.
The obsolete drivers will be removed in September 2007.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Deepak Saxena <dsaxena@plexity.net>
Cc: Jordan Crouse <jordan.crouse@amd.com>
2007-05-01 23:26:34 +02:00
Ben Dooks
bcda9f1eb0 i2c: New Simtec I2C bus driver
Platform driver for the Simtec CPLD based simple I2C logic.

Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:34 +02:00
Haavard Skinnemoen
1c23af90dc i2c: Bitbanging I2C bus driver using the GPIO API
This is a very simple bitbanging I2C bus driver utilizing the new
arch-neutral GPIO API. Useful for chips that don't have a built-in
I2C controller, additional I2C busses, or testing purposes.

To use, include something similar to the following in the
board-specific setup code:

  #include <linux/i2c-gpio.h>

  static struct i2c_gpio_platform_data i2c_gpio_data = {
	.sda_pin	= GPIO_PIN_FOO,
	.scl_pin	= GPIO_PIN_BAR,
  };
  static struct platform_device i2c_gpio_device = {
	.name		= "i2c-gpio",
	.id		= 0,
	.dev		= {
		.platform_data	= &i2c_gpio_data,
	},
  };

Register this platform_device, set up the I2C pins as GPIO if
required and you're ready to go. This will use default values for
udelay and timeout, and will work with GPIO hardware that does not
support open drain mode, but allows sensing of the SDA and SCL lines
even when they are being driven.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:34 +02:00
Jan Engelhardt
16538e6b32 Use menuconfig objects - I2C
Allow the whole I2C menu to be disabled at once without diving into
the submenus for deselecting all options (should the user desire so).

Signed-off-by: Jan Engelhardt <jengelh@gmx.de>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:34 +02:00
Jean Delvare
b86a1bc8e3 i2c: Restore i2c_smbus_read_block_data
Add back the i2c_smbus_read_block_data helper function, it is needed
by the upcoming lm93 hardware monitoring driver and possibly others.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:34 +02:00
Jean Delvare
7d054817b7 i2c-pxa: Clean transaction stop
It was reported to me that the i2c-pxa driver was not able to process
more that 50 transactions per second. Investigation revealed that the
I2C unit was busy for 20 ms after every transaction. The reason seems
to be that we forget to clear the STOP and ACKNACK bits at the end of
the transaction. According to the PXA27x developer's manual, we shall
do so.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Lennert Buytenhek <kernel@wantstofly.org>
Cc: Nicolas Pitre <nico@cam.org>
2007-05-01 23:26:33 +02:00
Jean Delvare
494dbb64dc i2c-algo-bit: Improve debugging
Improve the debugging features of the i2c-algo-bit driver:
* Make it possible to compile the driver without debugging support
  at all, making it much smaller.
* Use dev_dbg() for debugging messages where possible, and dev_err()
  for error messages.
* Remove redundant debugging messages.

These changes allowed for minor code cleanups, which are included
as well.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:33 +02:00
Jean Delvare
424ed67c7d i2c-algo-bit: Implement a 50/50 SCL duty cycle
The original i2c-algo-bit implementation uses a 33/66 SCL duty cycle
when bits are being written on the bus. While the I2C specification
doesn't forbid it, this prevents us from driving the I2C bus to its
max speed, limiting us to 66 kbps max on standard I2C busses.

Implementing a 50/50 duty cycle instead lets us max out the bandwidth
up to the theoretical max of 100 kbps on standard I2C busses. This is
particularly important when large amounts of data need to be transfered
over the bus, as is the case with some TV adapters when the firmware is
being uploaded.

In fact this change even allows, at least in theory, fast-mode I2C
support at 125, 166 and 250 kbps. There's no way to reach the
theoretical max of 400 kbps with this implementation. But I don't
think we want to put efforts in that direction anyway: software-driven
I2C is very CPU-intensive and bad for latency.

Other timing changes:
* Don't set SDA high explicitly on error, we're going to issue a stop
  condition before we leave anyway.
* If an error occurs when sending the slave address, yield the CPU
  before retrying, and remove the additional delay after the new start
  condition.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:33 +02:00
David Brownell
7c17549982 i2c-omap: Switch to static adapter numbering
Update the OMAP I2C driver to use i2c_add_numbered_adapter(), so that
later patches can convert boards to using new-style drivers.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Bryan Wu
d24ecfcc39 i2c: Blackfin Two Wire Interface driver
The i2c linux driver for blackfin architecture which supports blackfin
on-chip TWI controller i2c operation.

Signed-off-by: Bryan Wu <bryan.wu@analog.com>
Reviewed-by: Alexey Dobriyan <adobriyan@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Ladislav Michl
6edac5803f i2c-algo-sgi: Comment and whitespace cleanups
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Jean Delvare
b3e820968a i2c: Make i2c_del_driver a void function
Make i2c_del_driver a void function, like all other driver removal
functions. It always returned 0 even when errors occured, and nobody
ever actually checked the return value anyway. And we cannot fail
a module removal anyway.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Jean Delvare
a97f1ed090 i2c: Move i2c-isa-only exported symbol declarations
Move the declaration of i2c-isa-only exported symbols to i2c-isa
itself, that's the best way to ensure nobody will attempt to use them.
Hopefully we'll get rid of the exports themselves soon anyway.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Jean Delvare
ce9e0794c2 i2c: Document i2c_new_device()
Document the new i2c_new_device(), i2c_new_probed_device() and
i2c_unregister_device() functions.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:32 +02:00
Jean Delvare
12b5053ac5 i2c: Add i2c_new_probed_device()
Add a new helper function to instantiate an i2c device. It is meant as a
replacement for i2c_new_device() when you don't know for sure at which
address your I2C/SMBus device lives. This happens frequently on TV
adapters for example, you know there is a tuner chip on the bus, but
depending on the exact board model and revision, it can live at different
addresses. So, the new i2c_new_probed_device() function will probe the bus
according to a list of addresses, and as soon as one of these addresses
responds, it will call i2c_new_device() on that one address.

This function will make it possible to port the old i2c drivers to the
new model quickly.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
Jean Delvare
0f3b483852 i2c-algo-bit: Add i2c_bit_add_numbered_bus
Add i2c_bit_add_numbered_bus(), which is equivalent to i2c_bit_add_bus
except that it calls i2c_add_numbered_adapter() at the end instead of
i2c_add_adapter().

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
David Brownell
c05646069c i2c: i2c EXPORT_SYMBOL cleanup
Make i2c-core.c obey Documentation/CodingStyle better by snugging
the EXPORT_SYMBOL declarations next to the relevant definitions.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
David Brownell
6e13e64184 i2c: Add i2c_add_numbered_adapter()
This adds a call, i2c_add_numbered_adapter(), registering an I2C adapter
with a specific bus number and then creating I2C device nodes for any
pre-declared devices on that bus.  It builds on previous patches adding
I2C probe() and remove() support, and that pre-declaration of devices.

This completes the core support for "new style" I2C device drivers.
Those follow the standard driver model for binding devices to drivers
(using probe and remove methods) rather than a legacy model (where the
driver tries to autoconfigure each bus, and registers devices itself).

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
David Brownell
9c1600eda4 i2c: Add i2c_board_info and i2c_new_device()
This provides partial support for new-style I2C driver binding.  It builds
on "struct i2c_board_info" declarations that identify I2C devices on a given
board.  This is needed on systems with I2C devices that can't be fully probed
and/or autoconfigured, such as many embedded Linux configurations where the
way a given I2C device is wired may affect how it must be used.

There are two models for declaring such devices:

 * LATE -- using a public function i2c_new_device().  This lets modules
   declare I2C devices found *AFTER* a given I2C adapter becomes available.
   
   For example, a PCI card could create adapters giving access to utility
   chips on that card, and this would be used to associate those chips with
   those adapters.

 * EARLY -- from arch_initcall() level code, using a non-exported function
   i2c_register_board_info().  This copies the declarations *BEFORE* such
   an i2c_adapter becomes available, arranging that i2c_new_device() will
   be called later when i2c-core registers the relevant i2c_adapter.

   For example, arch/.../.../board-*.c files would declare the I2C devices
   along with their platform data, and I2C devices would behave much like
   PNPACPI devices.  (That is, both enumerate from board-specific tables.)

To match the exported i2c_new_device(), the previously-private function
i2c_unregister_device() is now exported.

Pending later patches using these new APIs, this is effectively a NOP.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
David Brownell
4298cfc3eb i2c: i2c probe() and remove() documented
Update Documentation/i2c to match previous patches updating probe()
and remove() logic.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:31 +02:00
David Brownell
a1d9e6e49f i2c: i2c stack can remove()
More update for new style driver support:  add a remove() method, and
use it in the relevant code paths.

Again, nothing will use this yet since there's nothing to create devices
feeding this infrastructure.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
David Brownell
7b4fbc50fa i2c: i2c stack can probe()
One of a series of I2C infrastructure updates to support enumeration using
the standard Linux driver model.

This patch updates probe() and associated hotplug/coldplug support, but
not remove().  Nothing yet _uses_ it to create I2C devices, so those
hotplug/coldplug mechanisms will be the only externally visible change.
This patch will be an overall NOP since the I2C stack doesn't yet create
clients/devices except as part of binding them to legacy drivers.

Some code is moved earlier in the source code, helping group more of the
per-device infrastructure in one place and simplifying handling per-device
attributes.

Terminology being adopted:  "legacy drivers" create devices (i2c_client)
themselves, while "new style" ones follow the driver model (the i2c_client
is handed to the probe routine).  It's an either/or thing; the two models
don't mix, and drivers that try mixing them won't even be registered.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
5cedb05db3 i2c-pca-isa: Port to the new device driver model
Port the i2c-pca-isa driver to the new device driver model. I'm
using Rene Herman's new isa bus type, as it fits the needs nicely. One
benefit is that we can now give a proper parent to our i2c adapter.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
4a5d30302e i2c-elektor: Port to the new device driver model
Port the i2c-elektor driver to the new device driver model. I'm
using Rene Herman's new isa bus type, as it fits the needs nicely. One
benefit is that we can now give a proper parent to our i2c adapter.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
c6e8bb2ca5 i2c-parport-light: Port to the new device driver model
Also fix a small race on driver unload: we need to unregister the
i2c adapter before we power it off.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
3af07bd297 i2c-parport: Fix a minor race on driver unload
When unloading the driver, we really want to unregister the i2c adapter
before we power it off, rather than the other way around.

Also speed up the bus a bit when we can sense SCL. The slaves will
stretch the line as needed.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
4b4686e7a6 scx200_acb: Fix PCI device reference count
The scx200_acb driver supports two kind of devices, PCI ones and ISA
ones. Even ISA ones are detected using the presence of a given PCI
device, and we get a reference to it, but never put it back, so we
have a leak. Fix it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:30 +02:00
Jean Delvare
7c59b6615f i2c: Cleanup the includes of <linux/i2c.h>
Clean up the includes of <linux/i2c.h>. Only include this header file
when we actually need it.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:29 +02:00
Jean Delvare
f75803de6a i2c-nforce2: Add support for the MCP61 and MCP65
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Hans-Frieder Vogt <hfvogt@gmx.net>
2007-05-01 23:26:29 +02:00
Jean Delvare
cacf2269b6 i2c-parport: Optimize binary size
Initialize the fields of the i2c_adapter structure individually,
rather than copying a whole static template structure. This shaves
off 474 bytes or 14% (on i386) from the binary size.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:29 +02:00
Jean Delvare
3c4bb241d3 i2c-algo-bit: Emulate SMBus block read
Now that i2c-core lets the i2c bus drivers emulate the SMBus block read
and SMBus block process call transaction types, let's implement that in
the popular i2c bit-banging driver. This will also act as a reference
implementation for other bus drivers which want to do the same.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:29 +02:00
Jean Delvare
209d27c3b1 i2c: Emulate SMBus block read over I2C
Let the I2C bus drivers emulate the SMBus Block Read and Block Process
Call transactions if they wish. This requires to define a new message
flag, which i2c-core will use to let the underlying I2C bus driver
know that the first received byte will specify the length of the read
message.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:29 +02:00
Jean Delvare
1ecac07aba i2c-algo-bit: Always send a stop condition before leaving
The i2c-algo-bit driver doesn't behave well on read errors: it'll
bail out without even sending a stop condition on the bus, so the bus
will be stuck. So make sure that we always send a stop condition on
the bus before we leave. The best way to make sure is to always send
it at the end of function bit_xfer.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00
David Brownell
ef2c8321f5 i2c: Rename dev_to_i2c_adapter()
Rename dev_to_i2c_adapter() as to_i2c_adapter(), since the previous
syntax was a surprising and needless difference from normal naming
conventions in Linux.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00
David Brownell
16ffadfc68 i2c: Class attribute cleanup
This patch is a minor cleanup/code shrink, using class infrastructure
in i2c-core to manage the i2c_adapter attribute.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00
David Brownell
2096b956d2 i2c: Shrink struct i2c_client
This shrinks the size of "struct i2c_client" by 40 bytes:

 - Substantially shrinks the string used to identify the chip type
 - The "flags" don't need to be so big
 - Removes some internal padding

It also adds kerneldoc for that struct, explaining how "name" is really a
chip type identifier; it's otherwise potentially confusing.

Because the I2C_NAME_SIZE symbol was abused for both i2c_client.name
and for i2c_adapter.name, this needed to affect i2c_adapter too.  The
adapters which used that symbol now use the more-obviously-correct
idiom of taking the size of that field.

JD: Shorten i2c_adapter.name from 50 to 48 bytes while we're here, to
avoid wasting space in padding.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00
David Brownell
4ad4eac606 i2c: i2c_register_driver() cleanup
Minor cleanup in i2c_register_driver():  use list_for_each_entry().

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00
Jean Delvare
b31366f439 i2c: i2c_adapter devices need no driver
Kill i2c_adapter_driver as it doesn't make sense and it prevents
further i2c-core cleanups. i2c_adapter devices are virtual devices
(ex-class devices) and as such they don't need a driver.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
2007-05-01 23:26:28 +02:00