From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [Q] i2c_new_device vs i2c_del_driver
Date: Tue, 17 Mar 2009 18:38:09 +0100 [thread overview]
Message-ID: <20090317183809.55320908@hyperion.delvare> (raw)
In-Reply-To: <Pine.LNX.4.64.0903171710350.5318-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
Hi Guennadi,
On Tue, 17 Mar 2009 18:24:49 +0100 (CET), Guennadi Liakhovetski wrote:
> I have a question regarding dynimically created i2c devices. If I have a
> card with an i2c device on it. Once I load a driver for that card, it uses
> its knowledge of the hardware and registers a new i2c device using
> i2c_new_device. Then at some point a driver for that i2c device is loaded,
> it calls i2c_add_driver, then its probe() method is called with the
> dynamically created device. So far so good. Now I unload the i2c driver,
> it calls i2c_del_driver(), and then, IIUC, __detach_adapter will be called
> for all devices attached to this driver,
Actually, __detach_adapter will be called for all *adapters* on the
system. Then in turn __detach_adapter does a number of actions on
devices present on said adapters.
> including our device from above,
No. Your driver is a new-style one (otherwise you couldn't use
i2c_new_device) which means that __detach_adapter returns relatively
quickly. The only part of __detach_adapter which is run is the one
which removes auto-instantiated devices. This isn't the case of your
device (you instantiated it explicitly) so __detach_adapter is a no-op
for you.
> then i2c_unregister_device will be called for it, a comment to which says
>
> "reverse effect of i2c_new_device()"
>
> So, our newly created device is gone, and loading the i2c driver again
> will not find it any more?... This doesn't seem to be the case, so, I
> think, the comment is wrong and has to be fixed.
The comment is correct. What isn't is your understanding of the
(admittedly complex and often confusing) i2c-core code. But I hope to
solve it soon, by killing the legacy binding model altogether.
In the meantime, if you have more questions, I will be pleased to
answer them.
--
Jean Delvare
next prev parent reply other threads:[~2009-03-17 17:38 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-17 17:24 [Q] i2c_new_device vs i2c_del_driver Guennadi Liakhovetski
[not found] ` <Pine.LNX.4.64.0903171710350.5318-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2009-03-17 17:38 ` Jean Delvare [this message]
[not found] ` <20090317183809.55320908-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-17 17:50 ` Guennadi Liakhovetski
[not found] ` <Pine.LNX.4.64.0903171849060.5318-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2009-03-17 18:17 ` Jean Delvare
[not found] ` <20090317191724.7ace956f-ig7AzVSIIG7kN2dkZ6Wm7A@public.gmane.org>
2009-03-17 18:29 ` Guennadi Liakhovetski
[not found] ` <Pine.LNX.4.64.0903171923230.5318-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2009-03-20 17:48 ` 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=20090317183809.55320908@hyperion.delvare \
--to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
--cc=g.liakhovetski-Mmb7MZpHnFY@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox