Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Christoph Hellwig
On Sun, Jul 26, 2020 at 09:43:06AM +0200, Greg Kroah-Hartman wrote:
> On Sun, Jul 26, 2020 at 09:13:39AM +0200, Christoph Hellwig wrote:
> > Split the main worker loop into a separate function.  This allows
> > devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
> > allows us to call __init routines for the setup work.
> > 
> > Signed-off-by: Christoph Hellwig 
> > ---
> >  drivers/base/devtmpfs.c | 47 +++--
> >  1 file changed, 26 insertions(+), 21 deletions(-)
> 
> Nice cleanup, thanks for doing this:

This was actualy Als idea, I should have probably mentioned that.


Re: [PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Greg Kroah-Hartman
On Sun, Jul 26, 2020 at 09:13:39AM +0200, Christoph Hellwig wrote:
> Split the main worker loop into a separate function.  This allows
> devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
> allows us to call __init routines for the setup work.
> 
> Signed-off-by: Christoph Hellwig 
> ---
>  drivers/base/devtmpfs.c | 47 +++--
>  1 file changed, 26 insertions(+), 21 deletions(-)

Nice cleanup, thanks for doing this:

Reviewed-by: Greg Kroah-Hartman 


[PATCH 04/21] devtmpfs: refactor devtmpfsd()

2020-07-26 Thread Christoph Hellwig
Split the main worker loop into a separate function.  This allows
devtmpfsd itself and devtmpfsd_setup to be marked __init, which will
allows us to call __init routines for the setup work.

Signed-off-by: Christoph Hellwig 
---
 drivers/base/devtmpfs.c | 47 +++--
 1 file changed, 26 insertions(+), 21 deletions(-)

diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
index c9017e0584c003..a103ee7e229930 100644
--- a/drivers/base/devtmpfs.c
+++ b/drivers/base/devtmpfs.c
@@ -378,7 +378,30 @@ static int handle(const char *name, umode_t mode, kuid_t 
uid, kgid_t gid,
return handle_remove(name, dev);
 }
 
-static int devtmpfs_setup(void *p)
+static void __noreturn devtmpfs_work_loop(void)
+{
+   while (1) {
+   spin_lock(_lock);
+   while (requests) {
+   struct req *req = requests;
+   requests = NULL;
+   spin_unlock(_lock);
+   while (req) {
+   struct req *next = req->next;
+   req->err = handle(req->name, req->mode,
+ req->uid, req->gid, req->dev);
+   complete(>done);
+   req = next;
+   }
+   spin_lock(_lock);
+   }
+   __set_current_state(TASK_INTERRUPTIBLE);
+   spin_unlock(_lock);
+   schedule();
+   }
+}
+
+static int __init devtmpfs_setup(void *p)
 {
int err;
 
@@ -396,31 +419,13 @@ static int devtmpfs_setup(void *p)
return err;
 }
 
-static int devtmpfsd(void *p)
+static int __init devtmpfsd(void *p)
 {
int err = devtmpfs_setup(p);
 
if (err)
return err;
-   while (1) {
-   spin_lock(_lock);
-   while (requests) {
-   struct req *req = requests;
-   requests = NULL;
-   spin_unlock(_lock);
-   while (req) {
-   struct req *next = req->next;
-   req->err = handle(req->name, req->mode,
- req->uid, req->gid, req->dev);
-   complete(>done);
-   req = next;
-   }
-   spin_lock(_lock);
-   }
-   __set_current_state(TASK_INTERRUPTIBLE);
-   spin_unlock(_lock);
-   schedule();
-   }
+   devtmpfs_work_loop();
return 0;
 }
 
-- 
2.27.0