+/* YAFFS uses two locks per yaffs_Device.
+ * dirLock: r/w lock Must be held when accessing directory structure.
+ * grossLock: Lock when accessing yaffs internals.
+ *
+ * Locking rules:
+ * If you're going to take dirLock then you must take if before
+ * taking grossLock.
+ * ie. Don't call yaffs_DirLockxxx() while holding grossLock.
+ *
+ * Todo:
+ * Investigate changing to mutexes etc and improve debugging.
+ */
+static void yaffs_DirLockInitialise(yaffs_Device *dev)
+{
+ init_rwsem(&dev->dirLock);
+}
+
+static void yaffs_DirLockRead(yaffs_Device *dev)
+{
+ T(YAFFS_TRACE_OS, ("yaffs locking dir read %p\n", current));
+ down_read(&dev->dirLock);
+ T(YAFFS_TRACE_OS, ("yaffs locked dir read %p\n", current));
+}
+
+static void yaffs_DirUnlockRead(yaffs_Device *dev)
+{
+ T(YAFFS_TRACE_OS, ("yaffs unlocking dir read %p\n", current));
+ up_read(&dev->dirLock);
+}
+
+static void yaffs_DirLockWrite(yaffs_Device *dev)
+{
+ T(YAFFS_TRACE_OS, ("yaffs locking dir write %p\n", current));
+ down_write(&dev->dirLock);
+ T(YAFFS_TRACE_OS, ("yaffs locked dir write %p\n", current));
+}
+
+static void yaffs_DirUnlockWrite(yaffs_Device *dev)
+{
+ T(YAFFS_TRACE_OS, ("yaffs unlocking dir write %p\n", current));
+ up_write(&dev->dirLock);
+}
+
+static void yaffs_GrossLockInitialise(yaffs_Device *dev)
+{
+ init_MUTEX(&dev->grossLock);
+}
+