2002-06-07 09:59:19

by linux-kernel-owner

[permalink] [raw]
Subject:

& id <M3AL96JH>; Fri, 7 Jun 2002 08:38:00 +0200
Received: from mx3.postwall.mm.fr.atosorigin.com (mx003.axime.com [160.92.18.153]) by hermes8.segin.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13)
id MM6SML5B; Thu, 6 Jun 2002 18:46:19 +0200
Received: from vger.kernel.org (vger.kernel.org [209.116.70.75])
by mx3.postwall.mm.fr.atosorigin.com (Postfix) with ESMTP id 779F3180B5
for <[email protected]>; Thu, 6 Jun 2002 18:32:12 +0200 (CEST)
Received: ([email protected]) by vger.kernel.org via listexpand
id <S316996AbSFFQqm>; Thu, 6 Jun 2002 12:46:42 -0400
Received: ([email protected]) by vger.kernel.org
id <S317010AbSFFQql>; Thu, 6 Jun 2002 12:46:41 -0400
Received: from neon-gw-l3.transmeta.com ([63.209.4.196]:2314 "EHLO
neon-gw.transmeta.com") by vger.kernel.org with ESMTP
id <S316996AbSFFQql>; Thu, 6 Jun 2002 12:46:41 -0400
Received: (from root@localhost)
by neon-gw.transmeta.com (8.9.3/8.9.3) id JAA17531
for <[email protected]>; Thu, 6 Jun 2002 09:46:39 -0700
Received: from mailhost.transmeta.com(10.1.1.15) by neon-gw.transmeta.com via smap (V2.1)
id xma017519; Thu, 6 Jun 02 09:46:28 -0700
Received: from palladium.transmeta.com (palladium.transmeta.com [10.1.1.46])
by deepthought.transmeta.com (8.11.6/8.11.6) with ESMTP id g56GkUj06428
for <[email protected]>; Thu, 6 Jun 2002 09:46:30 -0700 (PDT)
Received: (from mail@localhost)
by palladium.transmeta.com (8.9.3/8.9.3) id JAA22361
for [email protected]; Thu, 6 Jun 2002 09:46:30 -0700
X-Authentication-Warning: palladium.transmeta.com: mail set sender to [email protected] using -f
To: [email protected]
From: [email protected] (Linus Torvalds)
Subject: Re: device model update 2/2
Date: Thu, 6 Jun 2002 16:45:25 +0000 (UTC)
Organization: Transmeta Corporation
Message-ID: <[email protected]>
In-Reply-To: <A183DF60AC72D5119B990002A5749CB301E9C106@ROMADG-MAIL01> <[email protected]>
X-Trace: palladium.transmeta.com 1023381990 22356 127.0.0.1 (6 Jun 2002 16:46:30 GMT)
X-Complaints-To: [email protected]
NNTP-Posting-Date: 6 Jun 2002 16:46:30 GMT
Cache-Post-Path: [email protected]
X-Cache: nntpcache 2.4.0b5 (see http://www.nntpcache.org/)
Sender: [email protected]
Precedence: bulk
X-Mailing-List: [email protected]

In article <[email protected]>,
Patrick Mochel <[email protected]> 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