From: Jean Delvare <khali@linux-fr.org>
To: Greg Kroah-Hartman <gregkh@suse.de>, Kay Sievers <kay.sievers@vrfy.org>
Cc: Hans Verkuil <hverkuil@xs4all.nl>, LKML <linux-kernel@vger.kernel.org>
Subject: device/driver binding notification
Date: Sat, 5 Jul 2008 20:54:55 +0200 [thread overview]
Message-ID: <20080705205455.7e6579ea@hyperion.delvare> (raw)
Hi Greg, hi Kay,
In the course of finally making the i2c subsystem comply with the Linux
2.6 device driver model, I am facing an issue which affects many v4l
drivers. I'm curious if the core device driver code has something to
offer to solve it.
Basically, a v4l driver creates an i2c bus, instantiates i2c devices on
that bus, and needs i2c chip drivers for these devices. In the past, i2c
devices were always bound to a driver by the time the v4l driver knew
they existed, so they were directly usable. But now that we follow the
device driver model, this is no longer the case. The sequence of events
is as follows:
1* v4l driver creates i2c bus.
2* v4l driver declares i2c devices in that bus.
At this point, the v4l driver can't be used yet.
3* Later on, the drivers for these devices in question are loaded
(typically thanks to udev), and they bind to the i2c devices.
4* Now the v4l driver can complete its initialization and users can make
use of the device.
For now, between steps 2 and 3, I made the v4l driver sleep and
repeatedly check whether i2c_client.driver is set or not. It works but
it's pretty ugly. I am curious if there's a way to be notified when a
driver is finally bound to a given device? That's what I would need.
This also raises another question on reference counting. Ideally, the
i2c chip drivers shouldn't be allowed to be removed before the v4l
driver itself is (without the i2c chip drivers, the v4l drivers cannot
work properly.) So I would like to increase the reference count to the
i2c chip drivers when they bind to my chips, and decrease it when I
quit. Should I just do a try_module_get(i2c_driver.driver.owner) at a
random time and just hope for the best? Or is there a cleaner way to
express that kind of dependency between drivers?
Thanks,
--
Jean Delvare
next reply other threads:[~2008-07-05 18:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-05 18:54 Jean Delvare [this message]
2008-07-07 12:41 ` device/driver binding notification Kay Sievers
2008-07-07 13:06 ` 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=20080705205455.7e6579ea@hyperion.delvare \
--to=khali@linux-fr.org \
--cc=gregkh@suse.de \
--cc=hverkuil@xs4all.nl \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.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