Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S261800AbVCaFsR (ORCPT ); Thu, 31 Mar 2005 00:48:17 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S262006AbVCaFsR (ORCPT ); Thu, 31 Mar 2005 00:48:17 -0500 Received: from digitalimplant.org ([64.62.235.95]:46828 "HELO digitalimplant.org") by vger.kernel.org with SMTP id S261800AbVCaFsB (ORCPT ); Thu, 31 Mar 2005 00:48:01 -0500 Date: Wed, 30 Mar 2005 21:47:48 -0800 (PST) From: Patrick Mochel X-X-Sender: mochel@monsoon.he.net To: Dmitry Torokhov cc: Alan Stern , David Brownell , Kernel development list Subject: Re: klists and struct device semaphores In-Reply-To: <200503302201.53487.dtor_core@ameritech.net> Message-ID: References: <200503302201.53487.dtor_core@ameritech.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1695 Lines: 69 On Wed, 30 Mar 2005, Dmitry Torokhov wrote: > Will the lock be exported (via helper functions)? I always felt dirty using > subsys.rwsem because it I think it was supposed to be implementation detail. Sure, why not? See the attached patch for helpers, exported GPL only of course. Thanks, Pat ===== drivers/base/core.c 1.97 vs edited ===== --- 1.97/drivers/base/core.c 2005-03-24 19:07:33 -08:00 +++ edited/drivers/base/core.c 2005-03-30 21:20:54 -08:00 @@ -196,6 +196,33 @@ /** + * device_lock - lock device by taking its semaphore + * @dev: Device to lock + */ + +void device_lock(struct device * dev) +{ + if (dev) + down(&dev->sem); +} + +EXPORT_SYMBOL_GPL(device_lock); + + +/** + * device_unlock - unlock device + * @dev: Device we're unlocking + */ + +void device_unlock(struct device * dev) +{ + if (dev) + up(&dev->sem); +} + +EXPORT_SYMBOL_GPL(device_unlock); + +/** * device_initialize - init device structure. * @dev: device. * ===== include/linux/device.h 1.147 vs edited ===== --- 1.147/include/linux/device.h 2005-03-24 19:07:33 -08:00 +++ edited/include/linux/device.h 2005-03-30 21:17:28 -08:00 @@ -325,6 +325,9 @@ extern int device_for_each_child(struct device *, void *, int (*fn)(struct device *, void *)); +extern void device_lock(struct device * dev); +extern void device_unlock(struct device * dev); + /* * Manual binding of a device to driver. See drivers/base/bus.c * for information on use. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/