public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Matti Kaasinen <matti.kaasinen-91aMuT3/2DXHOG6cAo2yLw@public.gmane.org>
To: i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
Subject: at24.c, how to get kobject for sysfs/bin_attribute methods?
Date: Mon, 28 Jul 2008 09:20:03 +0300	[thread overview]
Message-ID: <488D6513.6070701@sitecno.fi> (raw)

Hi all!

Background first (quite a lot of it) --------------

At24.c seems supporting:
ssize_t (*read)(struct kobject *, char *, loff_t, size_t) and
ssize_t (*write)(struct kobject *, char *, loff_t, size_t) methods to 
provide access to i2c clients through sysfs/bin_attribute interface. It 
expects "struct kobject *" parameter to be the embedded kobject of 
struct i2c_client    (->dev->kobj). Based on this facet at24.c expands 
koject parameter to i2c_client (container_of .. container_of) and 
executes required i2c_transfer transactions. Therefore, kernel modules 
wanting to access i2c devices through at24.c should be able to point the 
kobject embedded within the i2c_client structure.

I have not found quite solid method for this purpose in this "new" 
device model where drivers and devices get paired somewhere after boot 
up. Best choice I've found so far is using following helper functions 
iterating over devices and drivers on i2c_bus_type to find i2c_device 
matching required name/address:

int bus_for_each_dev(struct bus_type *bus, struct device *start,
void *data, int (*fn)(struct device *, void *));

int bus_for_each_drv(struct bus_type *bus, struct device_driver *start,
void *data, int (*fn)(struct device_driver *, void *));

Problem with these functions at the moment is that i2_bus_type is not 
exported at least in 2.6.24 kernel that I'm playing with. I've seen 
export patches around and discussion for exporting/not exporting it.

Questions ----------

Do anyone know plans for exporting it in future releases? Do anyone know 
better solution for other kernel module finding the correct kobject 
reference for selected i2c device (e.g. by name) to be used as parameter 
to bin_attribute read/write method?

thanks, Matti Kaasinen

_______________________________________________
i2c mailing list
i2c-GZX6beZjE8VD60Wz+7aTrA@public.gmane.org
http://lists.lm-sensors.org/mailman/listinfo/i2c

             reply	other threads:[~2008-07-28  6:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-28  6:20 Matti Kaasinen [this message]
     [not found] ` <488D6513.6070701-91aMuT3/2DXHOG6cAo2yLw@public.gmane.org>
2008-07-28 13:25   ` at24.c, how to get kobject for sysfs/bin_attribute methods? Jon Smirl

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=488D6513.6070701@sitecno.fi \
    --to=matti.kaasinen-91amut3/2dxhog6cao2ylw@public.gmane.org \
    --cc=i2c-GZX6beZjE8VD60Wz+7aTrA@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox