From: torvalds@transmeta.com (Linus Torvalds)
To: linux-kernel@vger.kernel.org
Subject: Re: device model update 2/2
Date: Thu, 6 Jun 2002 16:45:25 +0000 (UTC) [thread overview]
Message-ID: <ado3j5$304$1@penguin.transmeta.com> (raw)
In-Reply-To: <A183DF60AC72D5119B990002A5749CB301E9C106@ROMADG-MAIL01> <Pine.LNX.4.33.0206060808050.654-100000@geena.pdx.osdl.net>
In article <Pine.LNX.4.33.0206060808050.654-100000@geena.pdx.osdl.net>,
Patrick Mochel <mochel@osdl.org> wrote:
>-
> /* detach from driver */
> if (dev->driver->remove)
> dev->driver->remove(dev);
> put_driver(dev->driver);
>+
>+ lock_device(dev);
>+ dev->driver = NULL;
>+ unlock_device(dev);
Code like the above just basically can _never_ be correct.
The locking just doesn't make any sense like that.
Real locking looks something like this:
lock_device(dev);
driver = dev->driver;
dev->driver = NULL;
unlock_device(dev);
if (driver->remove)
driver->remove(dev);
put_driver(driver);
together with some promise that "dev" cannot go away from under us (ie a
refcount on "dev" itself).
Linus
next prev parent reply other threads:[~2002-06-06 16:46 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-06-06 8:56 device model update 2/2 Amici Alessandro
2002-06-06 15:14 ` Patrick Mochel
2002-06-06 16:45 ` Linus Torvalds [this message]
2002-06-06 16:56 ` Patrick Mochel
-- strict thread matches above, loose matches on Subject: below --
2002-06-05 23:20 Patrick Mochel
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='ado3j5$304$1@penguin.transmeta.com' \
--to=torvalds@transmeta.com \
--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