linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* How to use one I2C device from two modules?
@ 2011-05-06 11:30 Lars Michael
       [not found] ` <842687.69100.qm-sMamaaD5nQOvuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Michael @ 2011-05-06 11:30 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA

Hello,

On our custom board we have an I2C GPIO port expander. This is used for different things like power supply control and button control. Hence I wrote two modules; pscontrol and button. 

In the modules I use i2c_new_device to create the device and to get the i2c_client struct that I later use in the smbus calls. This works fine, one module at the time. Together the last insmod fails, because the device at that address is already created.

But how do I access the same I2C device from several modules? Ideally I want to specify the adapter and slave address. If a client is found, I get the i2c_client otherwise I have to create it by i2c_new_device (or probe it). Is it possible?

Since I know the I2C bus and slave addresses in advance, would it be better to predeclare them by i2c_register_board_info? And in that case, how do I get the i2c_client struct in the module?

Kernel version 2.6.29
Target is m68k (Coldfire)

Thanks and regards,
- Lars

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-05-20  8:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-06 11:30 How to use one I2C device from two modules? Lars Michael
     [not found] ` <842687.69100.qm-sMamaaD5nQOvuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
2011-05-07 13:28   ` Jean Delvare
     [not found]     ` <20110507152832.25276ac6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-05-13  7:47       ` Lars Michael
     [not found]         ` <135179.26946.qm-XzixtO+UlYSvuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
2011-05-13  8:46           ` Jean Delvare
     [not found]             ` <20110513104650.3d1b3ea6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2011-05-16  8:10               ` Lars Michael
     [not found]                 ` <184526.31465.qm-hgS9n0fW3jyvuULXzWHTWIglqE1Y4D90QQ4Iyu8u01E@public.gmane.org>
2011-05-20  8:07                   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).