PM / Sleep: Add wakeup_source_activate and wakeup_source_deactivate tracepoints
[linux-2.6.git] / drivers / base / devtmpfs.c
index 1a16e1f..8493536 100644 (file)
@@ -40,7 +40,7 @@ static struct req {
        struct completion done;
        int err;
        const char *name;
-       mode_t mode;    /* 0 => delete */
+       umode_t mode;   /* 0 => delete */
        struct device *dev;
 } *requests;
 
@@ -142,103 +142,86 @@ int devtmpfs_delete_node(struct device *dev)
        return req.err;
 }
 
-static int dev_mkdir(const char *name, mode_t mode)
+static int dev_mkdir(const char *name, umode_t mode)
 {
-       struct nameidata nd;
        struct dentry *dentry;
+       struct path path;
        int err;
 
-       err = kern_path_parent(name, &nd);
-       if (err)
-               return err;
-
-       dentry = lookup_create(&nd, 1);
-       if (!IS_ERR(dentry)) {
-               err = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode);
-               if (!err)
-                       /* mark as kernel-created inode */
-                       dentry->d_inode->i_private = &thread;
-               dput(dentry);
-       } else {
-               err = PTR_ERR(dentry);
-       }
-
-       mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
-       path_put(&nd.path);
+       dentry = kern_path_create(AT_FDCWD, name, &path, 1);
+       if (IS_ERR(dentry))
+               return PTR_ERR(dentry);
+
+       err = vfs_mkdir(path.dentry->d_inode, dentry, mode);
+       if (!err)
+               /* mark as kernel-created inode */
+               dentry->d_inode->i_private = &thread;
+       dput(dentry);
+       mutex_unlock(&path.dentry->d_inode->i_mutex);
+       path_put(&path);
        return err;
 }
 
 static int create_path(const char *nodepath)
 {
-       int err;
+       char *path;
+       char *s;
+       int err = 0;
 
-       err = dev_mkdir(nodepath, 0755);
-       if (err == -ENOENT) {
-               char *path;
-               char *s;
+       /* parent directories do not exist, create them */
+       path = kstrdup(nodepath, GFP_KERNEL);
+       if (!path)
+               return -ENOMEM;
 
-               /* parent directories do not exist, create them */
-               path = kstrdup(nodepath, GFP_KERNEL);
-               if (!path) {
-                       err = -ENOMEM;
-                       goto out;
-               }
-               s = path;
-               for (;;) {
-                       s = strchr(s, '/');
-                       if (!s)
-                               break;
-                       s[0] = '\0';
-                       err = dev_mkdir(path, 0755);
-                       if (err && err != -EEXIST)
-                               break;
-                       s[0] = '/';
-                       s++;
-               }
-               kfree(path);
+       s = path;
+       for (;;) {
+               s = strchr(s, '/');
+               if (!s)
+                       break;
+               s[0] = '\0';
+               err = dev_mkdir(path, 0755);
+               if (err && err != -EEXIST)
+                       break;
+               s[0] = '/';
+               s++;
        }
-out:
+       kfree(path);
        return err;
 }
 
-static int handle_create(const char *nodename, mode_t mode, struct device *dev)
+static int handle_create(const char *nodename, umode_t mode, struct device *dev)
 {
-       struct nameidata nd;
        struct dentry *dentry;
+       struct path path;
        int err;
 
-       err = kern_path_parent(nodename, &nd);
-       if (err == -ENOENT) {
+       dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
+       if (dentry == ERR_PTR(-ENOENT)) {
                create_path(nodename);
-               err = kern_path_parent(nodename, &nd);
+               dentry = kern_path_create(AT_FDCWD, nodename, &path, 0);
        }
-       if (err)
-               return err;
-
-       dentry = lookup_create(&nd, 0);
-       if (!IS_ERR(dentry)) {
-               err = vfs_mknod(nd.path.dentry->d_inode,
-                               dentry, mode, dev->devt);
-               if (!err) {
-                       struct iattr newattrs;
-
-                       /* fixup possibly umasked mode */
-                       newattrs.ia_mode = mode;
-                       newattrs.ia_valid = ATTR_MODE;
-                       mutex_lock(&dentry->d_inode->i_mutex);
-                       notify_change(dentry, &newattrs);
-                       mutex_unlock(&dentry->d_inode->i_mutex);
-
-                       /* mark as kernel-created inode */
-                       dentry->d_inode->i_private = &thread;
-               }
-               dput(dentry);
-       } else {
-               err = PTR_ERR(dentry);
+       if (IS_ERR(dentry))
+               return PTR_ERR(dentry);
+
+       err = vfs_mknod(path.dentry->d_inode,
+                       dentry, mode, dev->devt);
+       if (!err) {
+               struct iattr newattrs;
+
+               /* fixup possibly umasked mode */
+               newattrs.ia_mode = mode;
+               newattrs.ia_valid = ATTR_MODE;
+               mutex_lock(&dentry->d_inode->i_mutex);
+               notify_change(dentry, &newattrs);
+               mutex_unlock(&dentry->d_inode->i_mutex);
+
+               /* mark as kernel-created inode */
+               dentry->d_inode->i_private = &thread;
        }
+       dput(dentry);
 
-       mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
-       path_put(&nd.path);
+       mutex_unlock(&path.dentry->d_inode->i_mutex);
+       path_put(&path);
        return err;
 }
 
@@ -393,9 +376,9 @@ int devtmpfs_mount(const char *mntdir)
        return err;
 }
 
-static __initdata DECLARE_COMPLETION(setup_done);
+static DECLARE_COMPLETION(setup_done);
 
-static int handle(const char *name, mode_t mode, struct device *dev)
+static int handle(const char *name, umode_t mode, struct device *dev)
 {
        if (mode)
                return handle_create(name, mode, dev);
@@ -423,16 +406,16 @@ static int devtmpfsd(void *p)
                        requests = NULL;
                        spin_unlock(&req_lock);
                        while (req) {
+                               struct req *next = req->next;
                                req->err = handle(req->name, req->mode, req->dev);
                                complete(&req->done);
-                               req = req->next;
+                               req = next;
                        }
                        spin_lock(&req_lock);
                }
-               set_current_state(TASK_INTERRUPTIBLE);
+               __set_current_state(TASK_INTERRUPTIBLE);
                spin_unlock(&req_lock);
                schedule();
-               __set_current_state(TASK_RUNNING);
        }
        return 0;
 out: