Re: [PATCH] debugfs: remove return value of debugfs_create_bool()

From: Greg Kroah-Hartman
Date: Mon May 24 2021 - 05:41:24 EST


On Mon, May 24, 2021 at 11:11:32AM +0200, Geert Uytterhoeven wrote:
> Hi Greg,
>
> Thanks for your patch!
>
> On Fri, May 21, 2021 at 10:28 PM Greg Kroah-Hartman
> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> > No one checks the return value of debugfs_create_bool(), as it's not
> > needed, so make the return value void, so that no one tries to do so in
>
> Please explain in the patch description why it is not needed.

Because you just do not need it, like almost all other debugfs calls
now.

> > the future.
> >
> > Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
>
> > --- a/fs/debugfs/file.c
> > +++ b/fs/debugfs/file.c
> > @@ -836,20 +836,11 @@ static const struct file_operations fops_bool_wo = {
> > * This function creates a file in debugfs with the given name that
> > * contains the value of the variable @value. If the @mode variable is so
> > * set, it can be read from, and written to.
> > - *
> > - * This function will return a pointer to a dentry if it succeeds. This
> > - * pointer must be passed to the debugfs_remove() function when the file is
> > - * to be removed (no automatic cleanup happens if your module is unloaded,
>
> Why isn't the above no longer true?

Because there is no return value.

> Are we no longer allowed to remove individual debugfs entries?

It's not something that is almost ever needed.

> Do we always have to remove the whole parent directory and all its
> contents together?

For 99% of all debugfs usages, yes, that is true.

If you really do need the file dentry, there is still a call to create
it, and you can always query debugfs for the dentry after it is created
if you need it later on.

thanks,

greg k-h