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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]