Message ID | 20210210074946.155417-2-drew@beagleboard.org |
---|---|
State | New |
Headers | show |
Series | pinctrl: pinmux: Add pinmux-select debugfs file | expand |
On Tue, 2021-02-09 at 23:49 -0800, Drew Fustini wrote: > Switch over pinctrl debugfs files to use octal permissions as they are > preferred over symbolic permissions. Refer to commit f90774e1fd27 > ("checkpatch: look for symbolic permissions and suggest octal instead"). > > Signed-off-by: Drew Fustini <drew@beagleboard.org> > --- > drivers/pinctrl/core.c | 6 +++--- > drivers/pinctrl/pinconf.c | 4 ++-- > drivers/pinctrl/pinmux.c | 4 ++-- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c > index 3663d87f51a0..c9c28f653799 100644 > --- a/drivers/pinctrl/core.c > +++ b/drivers/pinctrl/core.c > @@ -1914,11 +1914,11 @@ static void pinctrl_init_debugfs(void) > return; > } > > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > + debugfs_create_file("pinctrl-devices", 0400, > debugfs_root, NULL, &pinctrl_devices_fops); NAK. You've changed the permission levels. S_IRUGO is 0444 not 0400. And you have to keep the S_IFREG or'd along with the octal. include/linux/stat.h:#define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH) checkpatch does this conversion using this command line: $ ./scripts/checkpatch.pl -f --show-types --terse drivers/pinctrl/*.[ch] --types=SYMBOLIC_PERMS --fix-inplace drivers/pinctrl/core.c:1893: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/core.c:1895: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/core.c:1897: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/core.c:1919: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/core.c:1921: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/core.c:1923: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. total: 0 errors, 6 warnings, 2302 lines checked drivers/pinctrl/pinconf.c:373: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/pinconf.c:375: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. total: 0 errors, 2 warnings, 379 lines checked drivers/pinctrl/pinmux.c:679: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. drivers/pinctrl/pinmux.c:681: WARNING:SYMBOLIC_PERMS: Symbolic permissions 'S_IRUGO' are not preferred. Consider using octal permissions '0444'. total: 0 errors, 2 warnings, 854 lines checked $ git diff --stat -p drivers/pinctrl/ drivers/pinctrl/core.c | 12 ++++++------ drivers/pinctrl/pinconf.c | 4 ++-- drivers/pinctrl/pinmux.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 7d3370289938..6992b805ae41 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1890,11 +1890,11 @@ static void pinctrl_init_device_debugfs(struct pinctrl_dev *pctldev) dev_name(pctldev->dev)); return; } - debugfs_create_file("pins", S_IFREG | S_IRUGO, + debugfs_create_file("pins", S_IFREG | 0444, device_root, pctldev, &pinctrl_pins_fops); - debugfs_create_file("pingroups", S_IFREG | S_IRUGO, + debugfs_create_file("pingroups", S_IFREG | 0444, device_root, pctldev, &pinctrl_groups_fops); - debugfs_create_file("gpio-ranges", S_IFREG | S_IRUGO, + debugfs_create_file("gpio-ranges", S_IFREG | 0444, device_root, pctldev, &pinctrl_gpioranges_fops); if (pctldev->desc->pmxops) pinmux_init_device_debugfs(device_root, pctldev); @@ -1916,11 +1916,11 @@ static void pinctrl_init_debugfs(void) return; } - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-devices", S_IFREG | 0444, debugfs_root, NULL, &pinctrl_devices_fops); - debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-maps", S_IFREG | 0444, debugfs_root, NULL, &pinctrl_maps_fops); - debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-handles", S_IFREG | 0444, debugfs_root, NULL, &pinctrl_fops); } diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 02c075cc010b..f9ee12b50428 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c @@ -370,9 +370,9 @@ DEFINE_SHOW_ATTRIBUTE(pinconf_groups); void pinconf_init_device_debugfs(struct dentry *devroot, struct pinctrl_dev *pctldev) { - debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO, + debugfs_create_file("pinconf-pins", S_IFREG | 0444, devroot, pctldev, &pinconf_pins_fops); - debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO, + debugfs_create_file("pinconf-groups", S_IFREG | 0444, devroot, pctldev, &pinconf_groups_fops); } diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 36a11c9e893a..ea7559a25fed 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -676,9 +676,9 @@ DEFINE_SHOW_ATTRIBUTE(pinmux_pins); void pinmux_init_device_debugfs(struct dentry *devroot, struct pinctrl_dev *pctldev) { - debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO, + debugfs_create_file("pinmux-functions", S_IFREG | 0444, devroot, pctldev, &pinmux_functions_fops); - debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO, + debugfs_create_file("pinmux-pins", S_IFREG | 0444, devroot, pctldev, &pinmux_pins_fops); }
Hi Drew, On Wed, Feb 10, 2021 at 8:50 AM Drew Fustini <drew@beagleboard.org> wrote: > Switch over pinctrl debugfs files to use octal permissions as they are > preferred over symbolic permissions. Refer to commit f90774e1fd27 > ("checkpatch: look for symbolic permissions and suggest octal instead"). > > Signed-off-by: Drew Fustini <drew@beagleboard.org> Thanks for your patch! > --- a/drivers/pinctrl/core.c > +++ b/drivers/pinctrl/core.c > @@ -1914,11 +1914,11 @@ static void pinctrl_init_debugfs(void) > return; > } > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > + debugfs_create_file("pinctrl-devices", 0400, What about the loss of S_IFREG? S_IRUGO = 0444, not 0400. Gr{oetje,eeting}s, Geert
On Wed, Feb 10, 2021 at 10:31 AM Geert Uytterhoeven <geert@linux-m68k.org> wrote: > On Wed, Feb 10, 2021 at 8:50 AM Drew Fustini <drew@beagleboard.org> wrote: ... > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > > + debugfs_create_file("pinctrl-devices", 0400, > > What about the loss of S_IFREG? What do you mean? https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L387
On Wed, Feb 10, 2021 at 9:50 AM Drew Fustini <drew@beagleboard.org> wrote: > > Switch over pinctrl debugfs files to use octal permissions as they are > preferred over symbolic permissions. Refer to commit f90774e1fd27 > ("checkpatch: look for symbolic permissions and suggest octal instead"). You forgot: Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com> LGTM after addressing what Geert noticed. > Signed-off-by: Drew Fustini <drew@beagleboard.org> > --- > drivers/pinctrl/core.c | 6 +++--- > drivers/pinctrl/pinconf.c | 4 ++-- > drivers/pinctrl/pinmux.c | 4 ++-- > 3 files changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c > index 3663d87f51a0..c9c28f653799 100644 > --- a/drivers/pinctrl/core.c > +++ b/drivers/pinctrl/core.c > @@ -1914,11 +1914,11 @@ static void pinctrl_init_debugfs(void) > return; > } > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > + debugfs_create_file("pinctrl-devices", 0400, > debugfs_root, NULL, &pinctrl_devices_fops); > - debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO, > + debugfs_create_file("pinctrl-maps", 0400, > debugfs_root, NULL, &pinctrl_maps_fops); > - debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO, > + debugfs_create_file("pinctrl-handles", 0400, > debugfs_root, NULL, &pinctrl_fops); > } > > diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c > index 02c075cc010b..f005921bb49e 100644 > --- a/drivers/pinctrl/pinconf.c > +++ b/drivers/pinctrl/pinconf.c > @@ -370,9 +370,9 @@ DEFINE_SHOW_ATTRIBUTE(pinconf_groups); > void pinconf_init_device_debugfs(struct dentry *devroot, > struct pinctrl_dev *pctldev) > { > - debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO, > + debugfs_create_file("pinconf-pins", 0400, > devroot, pctldev, &pinconf_pins_fops); > - debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO, > + debugfs_create_file("pinconf-groups", 0400, > devroot, pctldev, &pinconf_groups_fops); > } > > diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c > index bab888fe3f8e..7f6190eaedbb 100644 > --- a/drivers/pinctrl/pinmux.c > +++ b/drivers/pinctrl/pinmux.c > @@ -676,9 +676,9 @@ DEFINE_SHOW_ATTRIBUTE(pinmux_pins); > void pinmux_init_device_debugfs(struct dentry *devroot, > struct pinctrl_dev *pctldev) > { > - debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO, > + debugfs_create_file("pinmux-functions", 0400, > devroot, pctldev, &pinmux_functions_fops); > - debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO, > + debugfs_create_file("pinmux-pins", 0400, > devroot, pctldev, &pinmux_pins_fops); > } > > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko
On Wed, Feb 10, 2021 at 10:30 AM Joe Perches <joe@perches.com> wrote: > On Tue, 2021-02-09 at 23:49 -0800, Drew Fustini wrote: > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > > + debugfs_create_file("pinctrl-devices", 0400, > > debugfs_root, NULL, &pinctrl_devices_fops); > > NAK. You've changed the permission levels. NAK is usually given when the whole idea is broken. Here is not the case and you may have helped to amend the patch. ... > And you have to keep the S_IFREG or'd along with the octal. Perhaps time to read the code? https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L387 ... > checkpatch does this conversion using this command line: > > $ ./scripts/checkpatch.pl -f --show-types --terse drivers/pinctrl/*.[ch] --types=SYMBOLIC_PERMS --fix-inplace NAK! See above. > - debugfs_create_file("pins", S_IFREG | S_IRUGO, > + debugfs_create_file("pins", S_IFREG | 0444, > device_root, pctldev, &pinctrl_pins_fops);
On Wed, 2021-02-10 at 12:18 +0200, Andy Shevchenko wrote: > On Wed, Feb 10, 2021 at 10:30 AM Joe Perches <joe@perches.com> wrote: > > On Tue, 2021-02-09 at 23:49 -0800, Drew Fustini wrote: > > > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > > > + debugfs_create_file("pinctrl-devices", 0400, > > > debugfs_root, NULL, &pinctrl_devices_fops); > > > > NAK. You've changed the permission levels. > > NAK is usually given when the whole idea is broken. Here is not the > case and you may have helped to amend the patch. NAK IMO just means the patch should not be applied, not that the concept is broken. > ... > > > And you have to keep the S_IFREG or'd along with the octal. > > Perhaps time to read the code? > https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L387 Then the commit message is also broken. > > checkpatch does this conversion using this command line: > > > > $ ./scripts/checkpatch.pl -f --show-types --terse drivers/pinctrl/*.[ch] --types=SYMBOLIC_PERMS --fix-inplace > > NAK! See above. The command line above is for octal conversion of the symbolic permissions. Any other conversion would be for a different purpose and that purpose and should be described in the commit message.
On Wed, Feb 10, 2021 at 04:36:00AM -0800, Joe Perches wrote: > On Wed, 2021-02-10 at 12:18 +0200, Andy Shevchenko wrote: > > On Wed, Feb 10, 2021 at 10:30 AM Joe Perches <joe@perches.com> wrote: > > > On Tue, 2021-02-09 at 23:49 -0800, Drew Fustini wrote: > > > > > > - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, > > > > + debugfs_create_file("pinctrl-devices", 0400, > > > > debugfs_root, NULL, &pinctrl_devices_fops); > > > > > > NAK. You've changed the permission levels. > > > > NAK is usually given when the whole idea is broken. Here is not the > > case and you may have helped to amend the patch. > > NAK IMO just means the patch should not be applied, not that the > concept is broken. > > > ... > > > > > And you have to keep the S_IFREG or'd along with the octal. > > > > Perhaps time to read the code? > > https://elixir.bootlin.com/linux/latest/source/fs/debugfs/inode.c#L387 > > Then the commit message is also broken. > > > > checkpatch does this conversion using this command line: > > > > > > $ ./scripts/checkpatch.pl -f --show-types --terse drivers/pinctrl/*.[ch] --types=SYMBOLIC_PERMS --fix-inplace > > > > NAK! See above. > > The command line above is for octal conversion of the symbolic permissions. > > Any other conversion would be for a different purpose and that purpose and > should be described in the commit message. > > Thanks for review comments from all. I will change from the incorrect 0400 to 0444. As for S_IFREG, it does seem like leaving off S_IFREG is the most common case when using octal permissions with debugfs_create_*(): $ git grep debugfs_create drivers/ |grep 0444 |grep -v S_IFREG | wc -l 302 $ git grep debugfs_create drivers/ |grep 0444 |grep S_IFREG | wc -l 9 As noted by Andy, this is okay as the S_IFREG flag is added to the mode __debugfs_create_file() inside fs/debugfs/inode.c. I will note this in the commit message. Thank you, Drew
On Wed, 2021-02-10 at 13:21 -0800, Drew Fustini wrote: > I will change from the incorrect 0400 to 0444. Thanks. > As for S_IFREG, it does seem like leaving off S_IFREG is the most common > case when using octal permissions with debugfs_create_*(): > > $ git grep debugfs_create drivers/ |grep 0444 |grep -v S_IFREG | wc -l > 302 > $ git grep debugfs_create drivers/ |grep 0444 |grep S_IFREG | wc -l > 9 It's ~2:1 when using S_IRUGO $ git grep debugfs_create_file drivers/ | grep S_IRUGO | grep -v S_IFREG | wc -l 109 $ git grep debugfs_create_file drivers/ | grep S_IRUGO | grep S_IFREG | wc -l 48
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 3663d87f51a0..c9c28f653799 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -1914,11 +1914,11 @@ static void pinctrl_init_debugfs(void) return; } - debugfs_create_file("pinctrl-devices", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-devices", 0400, debugfs_root, NULL, &pinctrl_devices_fops); - debugfs_create_file("pinctrl-maps", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-maps", 0400, debugfs_root, NULL, &pinctrl_maps_fops); - debugfs_create_file("pinctrl-handles", S_IFREG | S_IRUGO, + debugfs_create_file("pinctrl-handles", 0400, debugfs_root, NULL, &pinctrl_fops); } diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 02c075cc010b..f005921bb49e 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c @@ -370,9 +370,9 @@ DEFINE_SHOW_ATTRIBUTE(pinconf_groups); void pinconf_init_device_debugfs(struct dentry *devroot, struct pinctrl_dev *pctldev) { - debugfs_create_file("pinconf-pins", S_IFREG | S_IRUGO, + debugfs_create_file("pinconf-pins", 0400, devroot, pctldev, &pinconf_pins_fops); - debugfs_create_file("pinconf-groups", S_IFREG | S_IRUGO, + debugfs_create_file("pinconf-groups", 0400, devroot, pctldev, &pinconf_groups_fops); } diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index bab888fe3f8e..7f6190eaedbb 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c @@ -676,9 +676,9 @@ DEFINE_SHOW_ATTRIBUTE(pinmux_pins); void pinmux_init_device_debugfs(struct dentry *devroot, struct pinctrl_dev *pctldev) { - debugfs_create_file("pinmux-functions", S_IFREG | S_IRUGO, + debugfs_create_file("pinmux-functions", 0400, devroot, pctldev, &pinmux_functions_fops); - debugfs_create_file("pinmux-pins", S_IFREG | S_IRUGO, + debugfs_create_file("pinmux-pins", 0400, devroot, pctldev, &pinmux_pins_fops); }
Switch over pinctrl debugfs files to use octal permissions as they are preferred over symbolic permissions. Refer to commit f90774e1fd27 ("checkpatch: look for symbolic permissions and suggest octal instead"). Signed-off-by: Drew Fustini <drew@beagleboard.org> --- drivers/pinctrl/core.c | 6 +++--- drivers/pinctrl/pinconf.c | 4 ++-- drivers/pinctrl/pinmux.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-)