All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lars Michael <lh_post-/E1597aS9LQAvxtiuMwx3w@public.gmane.org>
To: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: How to use one I2C device from two modules?
Date: Fri, 13 May 2011 00:47:37 -0700 (PDT)	[thread overview]
Message-ID: <135179.26946.qm@web30203.mail.mud.yahoo.com> (raw)
In-Reply-To: <20110507152832.25276ac6-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>

--- On Sat, 7/5/11, Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org> wrote:
> On Fri, 6 May 2011 04:30:33 -0700 (PDT), Lars Michael
> wrote:
> > 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?
> > 
> 
> In general I would have pointed you to drivers/mfd and told
> you to
> write a mfd core driver for your chip. However in your case
> I don't
> think you have a multifunction device. You have a single
> function
> device (GPIO) with multiple users. So I suggest that you
> simply write a
> proper gpio driver for your chip, and get the device
> registered as an
> I2C GPIO device. Then, in your function drivers (power
> supply control
> and button control) get a reference to the gpio device in
> question, and
> use it.

Thanks for the advice. I wrote a simple driver for my chip and
instantiated it in the platform code. In order to access the
device from the function modules, I exported an i2c_client get
function, in order to get a reference to the client:

struct i2c_client *pca950x_get_i2c_client(void)
.....
EXPORT_SYMBOL(pca950x_get_i2c_client);

Not sure this is the perfect way to do it, but it works.

Thanks and regards,
- Lars

  parent reply	other threads:[~2011-05-13  7:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
     [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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=135179.26946.qm@web30203.mail.mud.yahoo.com \
    --to=lh_post-/e1597as9lqavxtiumwx3w@public.gmane.org \
    --cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.