aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/i2c.h (follow)
AgeCommit message (Collapse)AuthorFilesLines
2011-03-20i2c: Drop i2c_adapter.idJean Delvare1-1/+0
There is no user left of i2c_adapter.id, so we can get rid of it. Finally! :) Signed-off-by: Jean Delvare <khali@linux-fr.org>
2011-03-20i2c: Deprecate i2c_driver.attach_adapter and .detach_adapterJean Delvare1-6/+6
The last legitimate user of i2c_driver.attach_adapter and .detach_adapter is gone, so we can finally deprecate these callbacks. The last few drivers which still use these will have to be updated to make use of standard I2C device instantiation ways instead. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2011-03-20i2c: Export i2c_for_each_devJean Delvare1-0/+2
Introduce i2c_for_each_dev(), an i2c device iterator with proper locking for use by i2c-dev. This is needed so that we can get rid of the attach_adapter and detach_adapter legacy callback functions. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2011-03-20i2c: Get rid of <linux/i2c-id.h>Jean Delvare1-1/+0
The last remaining ID in <linux/i2c-id.h> is no longer used anywhere, so we can finally get rid of it. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2011-03-20i2c: make i2c_get_adapter prototype clearerJean Delvare1-1/+1
Rename the parameter of i2c_get_adapter() to "nr", to make it clear we are passing an adapter number and not an adapter ID (which have gone away by now.) Signed-off-by: Jean Delvare <khali@linux-fr.org>
2011-01-21driver-core: remove conditionals around devicetree pointersGrant Likely1-2/+0
Having conditional around the of_match_table and the of_node pointers turns out to make driver code use ugly #ifdef blocks. Drop the conditionals and remove the #ifdef blocks from the affected drivers. Also tidy up minor whitespace issues within the same hunks. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
2011-01-10i2c: Constify i2c_client where possibleJean Delvare1-12/+15
Helper functions for I2C and SMBus transactions don't modify the i2c_client that is passed to them, so it can be marked const. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-11-15i2c: Mark i2c_adapter.id as deprecatedJean Delvare1-1/+1
It's about time to make it clear that i2c_adapter.id is deprecated. Hopefully this will remind the last user to move over to a different strategy. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Jarod Wilson <jarod@redhat.com> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Hans Verkuil <hverkuil@xs4all.nl>
2010-10-31i2c: Drop unused I2C_CLASS_TV flagsJean Delvare1-2/+0
There are no users left for I2C_CLASS_TV_ANALOG and I2C_CLASS_TV_DIGITAL, so we can get rid of them. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-10-24i2c: Let i2c_parent_is_i2c_adapter return the parent adapterJean Delvare1-3/+8
This makes the calling site's code clearer IMHO. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Michael Lawnick <ml.lawnick@gmx.de>
2010-10-24i2c: Simplify i2c_parent_is_i2c_adapterJean Delvare1-1/+0
Only i2c devices can have their type set to i2c_adapter_type, so testing the bus type is redundant. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Michael Lawnick <ml.lawnick@gmx.de>
2010-08-11i2c: Multiplexed I2C bus core supportMichael Lawnick1-0/+8
Add multiplexed bus core support. I2C multiplexer and switches like pca954x get instantiated as new adapters per port. Signed-off-by: Michael Lawnick <ml.lawnick@gmx.de> Acked-by: Rodolfo Giometti <giometti@linux.it> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-08-11i2c: Use a separate mutex for userspace client listsJean Delvare1-0/+1
Moving userspace-instantiated clients to separate lists wasn't nearly enough to avoid deadlocks in multiplexed bus cases. We also want to have a dedicated mutex to protect each list. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Michael Lawnick <ml.lawnick@gmx.de>
2010-08-11i2c: Move adapter locking helpers to i2c-coreJean Delvare1-17/+3
Uninline i2c adapter locking helper functions, move them to i2c-core, and use them in i2c-core itself. The functions are still exported for external users. This makes future updates to the locking model (which will be needed for multiplexing support) possible and transparent. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Michael Lawnick <ml.lawnick@gmx.de>
2010-08-11V4L/DVB: Use custom I2C probing function mechanismJean Delvare1-0/+3
Now that i2c-core offers the possibility to provide custom probing function for I2C devices, let's make use of it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-08-11i2c: Add support for custom probe functionJean Delvare1-2/+5
The probe method used by i2c_new_probed_device() may not be suitable for all cases. Let the caller provide its own, optional probe function. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com>
2010-08-10i2c.h: fix kernel-doc warningsRandy Dunlap1-0/+2
Fix kernel-doc warnings in linux/i2c.h: Warning(include/linux/i2c.h:176): No description found for parameter 'alert' Warning(include/linux/i2c.h:259): No description found for parameter 'of_node' Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-05-22Merge remote branch 'origin' into secretlab/next-devicetreeGrant Likely1-0/+2
Merging in current state of Linus' tree to deal with merge conflicts and build failures in vio.c after merge. Conflicts: drivers/i2c/busses/i2c-cpm.c drivers/i2c/busses/i2c-mpc.c drivers/net/gianfar.c Also fixed up one line in arch/powerpc/kernel/vio.c to use the correct node pointer. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-05-04i2c-core: Use per-adapter userspace device listsJean Delvare1-0/+2
Using a single list for all userspace devices leads to a dead lock on multiplexed buses in some circumstances (mux chip instantiated from userspace). This is solved by using a separate list for each bus segment. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Michael Lawnick <ml.lawnick@gmx.de>
2010-04-28i2c/of: Allow device node to be passed via i2c_board_infoGrant Likely1-0/+4
The struct device_node *of_node pointer is moving out of dev->archdata and into the struct device proper. of_i2c.c needs to set the of_node pointer before the device is registered. Since the i2c subsystem doesn't allow 2 stage allocation and registration of i2c devices, the of_node pointer needs to be passed via the i2c_board_info structure so that it is set prior to registration. This patch adds of_node to struct i2c_board_info (conditional on CONFIG_OF), sets of_node in i2c_new_device(), and modifies of_i2c.c to use the new parameter. The calling of dev_archdata_set_node() from of_i2c will be removed in a subsequent patch when of_node is removed from archdata and all users are converted over. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
2010-03-02i2c: Document the message size limitZhangfei Gao1-0/+1
i2c_master_send & i2c_master_recv do not support more than 64 kb transfer, since msg.len is u16. Signed-off-by: Zhangfei Gao <zgao6@marvell.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-03-02i2c: Add SMBus alert supportJean Delvare1-0/+7
SMBus alert support. The SMBus alert protocol allows several SMBus slave devices to share a single interrupt pin on the SMBus master, while still allowing the master to know which slave triggered the interrupt. This is based on preliminary work by David Brownell. The key difference between David's implementation and mine is that his was part of i2c-core, while mine is split into a separate, standalone module named i2c-smbus. The i2c-smbus module is meant to include support for all SMBus extensions to the I2C protocol in the future. The benefit of this approach is a zero cost for I2C bus segments which do not need SMBus alert support. Where David's implementation increased the size of struct i2c_adapter by 7% (40 bytes on i386), mine doesn't touch it. Where David's implementation added over 150 lines of code to i2c-core (+10%), mine doesn't touch it. The only change that touches all the users of the i2c subsystem is a new callback in struct i2c_driver (common to both implementations.) I seem to remember Trent was worried about the footprint of David'd implementation, hopefully mine addresses the issue. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Jonathan Cameron <jic23@cam.ac.uk> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Trent Piepho <tpiepho@freescale.com>
2009-12-14i2c: Get rid of I2C_CLIENT_MODULE_PARMJean Delvare1-35/+0
There is no user left of I2C_CLIENT_MODULE_PARM, so we can finally get rid of this ugly macro. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Drop I2C_CLIENT_INSMOD_2 to 8Jean Delvare1-24/+0
These macros simply declare an enum, so drivers might as well declare it themselves. This puts an end to the arbitrary limit of 8 chip types per i2c driver. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Drop I2C_CLIENT_INSMOD_1Jean Delvare1-5/+0
This macro simply declares an enum, so drivers might as well declare it themselves. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Get rid of struct i2c_client_address_dataJean Delvare1-33/+11
Struct i2c_client_address_data only contains one field at this point, which makes its usefulness questionable. Get rid of it and pass simple address lists around instead. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-14i2c: Drop the kind parameter from detect callbacksJean Delvare1-1/+1
The "kind" parameter always has value -1, and nobody is using it any longer, so we can remove it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Tested-by: Wolfram Sang <w.sang@pengutronix.de>
2009-12-06i2c: Drop probe, ignore and force module parametersJean Delvare1-90/+1
The legacy probe and force module parameters are obsolete now, the same can be achieved using the new_device sysfs interface, which is both more flexible and cheaper (it is implemented by i2c-core rather than replicated in every driver module.) The legacy ignore module parameters can be dropped as well. Ignoring can be done by instantiating a "dummy" device at the problematic address. This is the first step of a huge cleanup to i2c-core's i2c_detect function, i2c.h's I2C_CLIENT_INSMOD* macros, and all drivers that made use of them. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-12-06i2c: Prevent priority inversion on top of bus lockMika Kuoppala1-4/+3
Low priority thread holding the i2c bus mutex could block higher priority threads to access the bus resulting in unacceptable latencies. Change the mutex type to rt_mutex preventing priority inversion. Tested-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Signed-off-by: Mika Kuoppala <mika.kuoppala@nokia.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-11-07i2c: Add an interface to lock/unlock an I2C bus segmentJean Delvare1-0/+18
Some drivers need to be able to prevent access to an I2C bus segment for a specific period of time. Add an interface for them to do so without twiddling with i2c-core internals. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Ben Hutchings <bhutchings@solarflare.com>
2009-09-18i2c: Drop unused i2c_driver.id fieldJean Delvare1-2/+0
Nobody is using i2c_driver.id any longer, so we can drop that field. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-06-19i2c: New macro to initialize i2c address lists on the flyHans Verkuil1-0/+4
For video4linux we sometimes need to probe for a single i2c address. Normally you would do it like this: static const unsigned short addrs[] = { addr, I2C_CLIENT_END }; client = i2c_new_probed_device(adapter, &info, addrs); This is a bit awkward and I came up with this macro: #define V4L2_I2C_ADDRS(addr, addrs...) \ ((const unsigned short []){ addr, ## addrs, I2C_CLIENT_END }) This can construct a list of one or more i2c addresses on the fly. But this is something that really belongs in i2c.h, renamed to I2C_ADDRS. With this macro we can just do: client = i2c_new_probed_device(adapter, &info, I2C_ADDRS(addr)); Note that this can also be used to initialize an array: static const unsigned short addrs[] = I2C_ADDRS(0x2a, 0x2c); Whether you want to is another matter, but it works. This functionality is also available in the oldest supported gcc (3.2). Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-06-19i2c: Don't advertise i2c functions when not availableJean Delvare1-1/+7
Surround i2c function declarations with ifdefs, so that they aren't advertised when i2c-core isn't actually built. That way, drivers using these functions unconditionally will result in an immediate build failure, rather than a late linking failure which is harder to figure out. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Cc: Paul Mundt <lethal@linux-sh.org>
2009-06-19i2c: Add a sysfs interface to instantiate devicesJean Delvare1-1/+2
Add a sysfs interface to instantiate and delete I2C devices. This is primarily a replacement of the force_* module parameters implemented by some i2c drivers. These module parameters were implemented internally by the I2C_CLIENT_INSMOD* macros, which don't scale well. This can also be used when developing a driver on a self-soldered board which doesn't yet have proper I2C device declaration at the platform level, and presumably for various debugging situations. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-06-19i2c: Kill the redundant client listJean Delvare1-4/+0
We used to maintain our own per-adapter list of i2c clients, but this is redundant with what the driver core does, and no longer needed. Just drop the redundant list. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-06-19i2c: Kill is_newstyle_driverJean Delvare1-2/+0
Legacy i2c drivers are gone, all drivers are new-style now, so there is no point to check. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-06-19i2c: Drop i2c_probe functionJean Delvare1-8/+0
The legacy i2c_probe() function has no users left, get rid of it. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-06-19i2c: Get rid of the legacy binding modelJean Delvare1-29/+10
We converted all the legacy i2c drivers so we can finally get rid of the legacy binding model. Hooray! Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-06-19i2c: Kill client_register and client_unregister methodsJean Delvare1-4/+0
These methods were useful in the legacy binding model but no longer in the new (standard) binding model. There are no users left so we can drop them. Signed-off-by: Jean Delvare <khali@linux-fr.org> Cc: David Brownell <dbrownell@users.sourceforge.net>
2009-04-13i2c: Fix sparse warnings for I2C_BOARD_INFO()Ben Hutchings1-1/+1
Since the first argument to I2C_BOARD_INFO() must be a string constant, there is no need to parenthesise it, and adding parentheses results in an invalid initialiser for char[]. gcc obviously accepts this syntax as an extension, but sparse complains, e.g.: drivers/net/sfc/boards.c:173:2: warning: array initialized from parenthesized string constant Therefore, remove the parentheses. Signed-off-by: Ben Hutchings <bhutchings@solarflare.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-04-06i2c: Deprecate client_register and client_unregister methodsJean Delvare1-2/+2
The new i2c binding model makes the client_register and client_unregister methods of struct i2c_adapter useless, so we can remove them with the rest of the legacy model. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-02-24i2c-dev: Clarify the unit of ioctl I2C_TIMEOUTJean Delvare1-1/+1
The unit in which user-space can set the bus timeout value is jiffies for historical reasons (back when HZ was always 100.) This is however not good because user-space doesn't know how long a jiffy lasts. The timeout value should instead be set in a fixed time unit. Given the original value of HZ, this unit should be 10 ms, for compatibility. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
2009-01-26i2c: Warn on deprecated binding model useJean Delvare1-3/+5
Let the kernel developers know that i2c_attach_client() and i2c_detach_client() are deprecated and should no longer be used. Drivers using these should be converted to the standard device driver binding model (probe and remove methods.) Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Ben Dooks <ben-linux@fluff.org>
2009-01-07i2c: Drop I2C_CLASS_CAM_DIGITALJean Delvare1-1/+0
There are a number of drivers which set their i2c bus class to I2C_CLASS_CAM_DIGITAL, however no chip driver actually checks for this flag, so we might as well drop it now. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-01-07i2c: Drop I2C_CLASS_CAM_ANALOG and I2C_CLASS_SOUNDJean Delvare1-2/+0
There are no users left of these two i2c probe class flags so we can drop the now. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2009-01-07i2c: Drop I2C_CLASS_ALLJean Delvare1-1/+0
I2C_CLASS_ALL is almost never what bus driver authors really want. These i2c classes are really only about which devices must be probed, not what devices can be present. As device drivers get converted to the new i2c device driver model, only a few device types will keep relying on probing. Signed-off-by: Jean Delvare <khali@linux-fr.org> Acked-by: Sonic Zhang <sonic.zhang@analog.com>
2008-10-22i2c: Add info->archdata fieldAnton Vorontsov1-0/+2
If present the info->archdata is copied into the dev->archdata. Some (OpenFirmware) platforms need it. Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-10-22i2c: Clean up <linux/i2c.h>Jean Delvare1-74/+75
Fix most checkpatch.pl errors and warnings. This includes replacing spaces with tabs in many places, adding and removing spaces, and folding long lines. Also complete a couple prototypes to make it clearer what the parameters represent. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-10-22i2c: Drop 2-byte address block transfer definesJean Delvare1-4/+0
We have no users and no implementers for these transfer types so it makes little sense to define functionality bits for them. Signed-off-by: Jean Delvare <khali@linux-fr.org>
2008-10-22i2c: Constify i2c_get_clientdata's parameterJean Delvare1-2/+2
i2c_get_clientdata doesn't change the i2c_client it is passed as a parameter, so it can be constified. Same for i2c_get_adapdata. Signed-off-by: Jean Delvare <khali@linux-fr.org>