diff options
Diffstat (limited to 'drivers/base/devtmpfs.c')
-rw-r--r-- | drivers/base/devtmpfs.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 50375bb8e51d..090dd4851301 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c | |||
@@ -32,7 +32,7 @@ static int dev_mount = 1; | |||
32 | static int dev_mount; | 32 | static int dev_mount; |
33 | #endif | 33 | #endif |
34 | 34 | ||
35 | static rwlock_t dirlock; | 35 | static DEFINE_MUTEX(dirlock); |
36 | 36 | ||
37 | static int __init mount_param(char *str) | 37 | static int __init mount_param(char *str) |
38 | { | 38 | { |
@@ -93,7 +93,7 @@ static int create_path(const char *nodepath) | |||
93 | { | 93 | { |
94 | int err; | 94 | int err; |
95 | 95 | ||
96 | read_lock(&dirlock); | 96 | mutex_lock(&dirlock); |
97 | err = dev_mkdir(nodepath, 0755); | 97 | err = dev_mkdir(nodepath, 0755); |
98 | if (err == -ENOENT) { | 98 | if (err == -ENOENT) { |
99 | char *path; | 99 | char *path; |
@@ -101,8 +101,10 @@ static int create_path(const char *nodepath) | |||
101 | 101 | ||
102 | /* parent directories do not exist, create them */ | 102 | /* parent directories do not exist, create them */ |
103 | path = kstrdup(nodepath, GFP_KERNEL); | 103 | path = kstrdup(nodepath, GFP_KERNEL); |
104 | if (!path) | 104 | if (!path) { |
105 | return -ENOMEM; | 105 | err = -ENOMEM; |
106 | goto out; | ||
107 | } | ||
106 | s = path; | 108 | s = path; |
107 | for (;;) { | 109 | for (;;) { |
108 | s = strchr(s, '/'); | 110 | s = strchr(s, '/'); |
@@ -117,7 +119,8 @@ static int create_path(const char *nodepath) | |||
117 | } | 119 | } |
118 | kfree(path); | 120 | kfree(path); |
119 | } | 121 | } |
120 | read_unlock(&dirlock); | 122 | out: |
123 | mutex_unlock(&dirlock); | ||
121 | return err; | 124 | return err; |
122 | } | 125 | } |
123 | 126 | ||
@@ -229,7 +232,7 @@ static int delete_path(const char *nodepath) | |||
229 | if (!path) | 232 | if (!path) |
230 | return -ENOMEM; | 233 | return -ENOMEM; |
231 | 234 | ||
232 | write_lock(&dirlock); | 235 | mutex_lock(&dirlock); |
233 | for (;;) { | 236 | for (;;) { |
234 | char *base; | 237 | char *base; |
235 | 238 | ||
@@ -241,7 +244,7 @@ static int delete_path(const char *nodepath) | |||
241 | if (err) | 244 | if (err) |
242 | break; | 245 | break; |
243 | } | 246 | } |
244 | write_unlock(&dirlock); | 247 | mutex_unlock(&dirlock); |
245 | 248 | ||
246 | kfree(path); | 249 | kfree(path); |
247 | return err; | 250 | return err; |
@@ -352,8 +355,6 @@ int __init devtmpfs_init(void) | |||
352 | int err; | 355 | int err; |
353 | struct vfsmount *mnt; | 356 | struct vfsmount *mnt; |
354 | 357 | ||
355 | rwlock_init(&dirlock); | ||
356 | |||
357 | err = register_filesystem(&dev_fs_type); | 358 | err = register_filesystem(&dev_fs_type); |
358 | if (err) { | 359 | if (err) { |
359 | printk(KERN_ERR "devtmpfs: unable to register devtmpfs " | 360 | printk(KERN_ERR "devtmpfs: unable to register devtmpfs " |