diff options
author | Rasmus Villemoes <linux@rasmusvillemoes.dk> | 2020-01-15 19:41:53 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-22 15:28:15 +0100 |
commit | 72a9cc952f123948ca1d1011a12e5e1312140b68 (patch) | |
tree | 04c5cc84d2a4d62af1415d2f492a8593369ed420 /drivers/base | |
parent | fad1db8a351cc913bbfb9ee4fe7ca4939cb19f2e (diff) | |
download | linux-72a9cc952f123948ca1d1011a12e5e1312140b68.tar.gz linux-72a9cc952f123948ca1d1011a12e5e1312140b68.tar.bz2 linux-72a9cc952f123948ca1d1011a12e5e1312140b68.zip |
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: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20200115184154.3492-6-linux@rasmusvillemoes.dk
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base')
-rw-r--r-- | drivers/base/devtmpfs.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c index 56632fb22fc0..5995c437cbdf 100644 --- a/drivers/base/devtmpfs.c +++ b/drivers/base/devtmpfs.c @@ -89,6 +89,23 @@ static inline int is_blockdev(struct device *dev) static inline int is_blockdev(struct device *dev) { return 0; } #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) { const char *tmp = NULL; @@ -113,19 +130,7 @@ int devtmpfs_create_node(struct device *dev) req.dev = dev; - 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; + return devtmpfs_submit_req(&req, tmp); } int devtmpfs_delete_node(struct device *dev) @@ -143,18 +148,7 @@ int devtmpfs_delete_node(struct device *dev) req.mode = 0; req.dev = dev; - 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; + return devtmpfs_submit_req(&req, tmp); } static int dev_mkdir(const char *name, umode_t mode) |