Commit 72a9cc95 authored by Rasmus Villemoes's avatar Rasmus Villemoes Committed by Greg Kroah-Hartman

devtmpfs: factor out common tail of devtmpfs_{create,delete}_node

There's some common boilerplate in devtmpfs_{create,delete}_node, put
that in a little helper.
Signed-off-by: default avatarRasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20200115184154.3492-6-linux@rasmusvillemoes.dkSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent fad1db8a
...@@ -89,6 +89,23 @@ static inline int is_blockdev(struct device *dev) ...@@ -89,6 +89,23 @@ static inline int is_blockdev(struct device *dev)
static inline int is_blockdev(struct device *dev) { return 0; } static inline int is_blockdev(struct device *dev) { return 0; }
#endif #endif
static int devtmpfs_submit_req(struct req *req, const char *tmp)
{
init_completion(&req->done);
spin_lock(&req_lock);
req->next = requests;
requests = req;
spin_unlock(&req_lock);
wake_up_process(thread);
wait_for_completion(&req->done);
kfree(tmp);
return req->err;
}
int devtmpfs_create_node(struct device *dev) int devtmpfs_create_node(struct device *dev)
{ {
const char *tmp = NULL; const char *tmp = NULL;
...@@ -113,19 +130,7 @@ int devtmpfs_create_node(struct device *dev) ...@@ -113,19 +130,7 @@ int devtmpfs_create_node(struct device *dev)
req.dev = dev; req.dev = dev;
init_completion(&req.done); return devtmpfs_submit_req(&req, tmp);
spin_lock(&req_lock);
req.next = requests;
requests = &req;
spin_unlock(&req_lock);
wake_up_process(thread);
wait_for_completion(&req.done);
kfree(tmp);
return req.err;
} }
int devtmpfs_delete_node(struct device *dev) int devtmpfs_delete_node(struct device *dev)
...@@ -143,18 +148,7 @@ int devtmpfs_delete_node(struct device *dev) ...@@ -143,18 +148,7 @@ int devtmpfs_delete_node(struct device *dev)
req.mode = 0; req.mode = 0;
req.dev = dev; req.dev = dev;
init_completion(&req.done); return devtmpfs_submit_req(&req, tmp);
spin_lock(&req_lock);
req.next = requests;
requests = &req;
spin_unlock(&req_lock);
wake_up_process(thread);
wait_for_completion(&req.done);
kfree(tmp);
return req.err;
} }
static int dev_mkdir(const char *name, umode_t mode) static int dev_mkdir(const char *name, umode_t mode)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment