From: Jean Delvare <khali@linux-fr.org>
To: Russell King <rmk+lkml@arm.linux.org.uk>
Cc: Dmitry Torokhov <dtor_core@ameritech.net>,
Greg KH <greg@kroah.com>, LKML <linux-kernel@vger.kernel.org>,
Alessandro Zummo <alessandro.zummo@towertech.it>
Subject: Re: More platform driver questions
Date: Tue, 13 Dec 2005 08:17:52 +0100 [thread overview]
Message-ID: <20051213081752.5de5eef4.khali@linux-fr.org> (raw)
In-Reply-To: <20051211221034.GE22537@flint.arm.linux.org.uk>
Hi Russell,
> On Sun, Dec 11, 2005 at 10:00:23PM +0100, Jean Delvare wrote:
> > The base I/O address seemed to belong to .platform_data, as this is the
> > only way I have to pass the information through the .probe mechanism
> > (or should I use platform_get_resource instead?) All the rest I have
> > put in .driver_data. Actually, I even duplicated the base I/O address
> > there, as it made the rest of the code much more simple.
>
> You should generally use the resources to pass address information.
OK, I've changed my code that way. Thanks for the hint.
> > It seems that in most .remove functions, we explicitely set the driver
> > data pointer to NULL before freeing the associated memory. I am
> > wondering why. Can someone explain? Given that the device is just being
> > deleted anyway, I don't quite see the benefit in doing so. But I guess
> > I am once again missing something obvious.
>
> This depends on your point of view - whether you think there's a
> possibility that the driver_data might be accessed somehow after
> you've freed the pointer. Having a NULL pointer will give you a
> very deterministic failure.
>
> Of course, it can also be viewed as needless code and therefore not
> required. Again, it's an opinion thing.
I don't mind the extra expense if it helps spotting race conditions. I
just wanted to make sure we agreed that doing so would simply change
the nature of the error we'll get if such a condition happens, but
won't actually prevent this error from happening. Unless each user of
the driver data has an explicit NULL check, which isn't the case for my
driver (and I *would* mind that extra expense.)
Now the question is, is there actually any race condition there? In my
case, the only users of the driver data are the sysfs callback
functions, so I guess that this is all down to whether the driver core
will unregister them before platform_driver.remove is called, or after
it is called. If .remove is called first, then yes my code is racy and
I'll have to fix it.
Thanks,
--
Jean Delvare
next prev parent reply other threads:[~2005-12-13 7:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-11 21:00 More platform driver questions Jean Delvare
2005-12-11 22:10 ` Russell King
2005-12-12 0:41 ` Dmitry Torokhov
2005-12-13 7:17 ` Jean Delvare [this message]
2005-12-13 7:23 ` Dmitry Torokhov
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=20051213081752.5de5eef4.khali@linux-fr.org \
--to=khali@linux-fr.org \
--cc=alessandro.zummo@towertech.it \
--cc=dtor_core@ameritech.net \
--cc=greg@kroah.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rmk+lkml@arm.linux.org.uk \
/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