Skip to contentSkip to conversation

module parameters: permissions as defines, readable to everyone

PATCH In review poma 2 participants 2 messages Apr 10, 2016 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

poma

author
#0 lore raw

PATCH 1/1 module parameters: permissions as defines, readable to everyone

For the purposes of the module parameters,
specifies the permissions of the corresponding files in sysfs in predefined S_I* form rather than in octal notation. Withal it makes the source code more consistent.
Moreover, because all parameters are readable to everyone, it is more user-friendly.

$ grep S_IRUGO include/linux/stat.h
#define S_IRUGO		(S_IRUSR|S_IRGRP|S_IROTH)
$ grep 'S_IRUSR\|S_IRGRP\|S_IROTH' include/uapi/linux/stat.h
#define S_IRUSR 00400
#define S_IRGRP 00040
#define S_IROTH 00004
$ ls -l /sys/module/nouveau/parameters/
total 0
-r--r--r--. 1 root root 4096 Apr 10 17:43 config
-r--r--r--. 1 root root 4096 Apr 10 17:43 debug
-r--r--r--. 1 root root 4096 Apr 10 17:43 duallink
-r--r--r--. 1 root root 4096 Apr 10 17:43 hdmimhz
-r--r--r--. 1 root root 4096 Apr 10 17:43 ignorelid
-r--r--r--. 1 root root 4096 Apr 10 17:43 modeset
-r--r--r--. 1 root root 4096 Apr 10 17:43 noaccel
-r--r--r--. 1 root root 4096 Apr 10 17:43 nofbaccel
-r--r--r--. 1 root root 4096 Apr 10 17:43 runpm
-r--r--r--. 1 root root 4096 Apr 10 17:43 tv_disable
-r--r--r--. 1 root root 4096 Apr 10 17:43 tv_norm
-r--r--r--. 1 root root 4096 Apr 10 17:43 vram_pushbuf
$ systool -vm nouveau | grep Parameters -A 12
  Parameters:
    config              =  28 6e 75 6c 6c 29 0a
    debug               = "(null)"
    duallink            = "1"
    hdmimhz             = "0"
    ignorelid           = "0"
    modeset             = "-1"
    noaccel             = "0"
    nofbaccel           = "0"
    runpm               = "-1"
    tv_disable          = "0"
    tv_norm             = "(null)"
    vram_pushbuf        = "0"
---
 drivers/gpu/drm/nouveau/dispnv04/tvnv17.c   |  2 +-
 drivers/gpu/drm/nouveau/nouveau_chan.c      |  2 +-
 drivers/gpu/drm/nouveau/nouveau_connector.c |  8 ++++----
 drivers/gpu/drm/nouveau/nouveau_drm.c       | 10 +++++-----
 drivers/gpu/drm/nouveau/nouveau_fbcon.c     |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)
drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +1 -1
index 163317d..af520d0 100644
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(tv_norm, "Default TV norm.\n"
 		 "\t\tDefault: PAL\n"
 		 "\t\t*NOTE* Ignored for cards with external TV encoders.");
 static char *nouveau_tv_norm;
-module_param_named(tv_norm, nouveau_tv_norm, charp, 0400);
+module_param_named(tv_norm, nouveau_tv_norm, charp, S_IRUGO);
 
 static uint32_t nv42_tv_sample_load(struct drm_encoder *encoder)
 {
drivers/gpu/drm/nouveau/nouveau_chan.c +1 -1
index 879655c..0bb1b9c 100644
@@ -43,7 +43,7 @@
 
 MODULE_PARM_DESC(vram_pushbuf, "Create DMA push buffers in VRAM");
 int nouveau_vram_pushbuf;
-module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, 0400);
+module_param_named(vram_pushbuf, nouveau_vram_pushbuf, int, S_IRUGO);
 
 int
 nouveau_channel_idle(struct nouveau_channel *chan)
drivers/gpu/drm/nouveau/nouveau_connector.c +4 -4
index ae96ebc..30785fb 100644
@@ -49,19 +49,19 @@
 
 MODULE_PARM_DESC(tv_disable, "Disable TV-out detection");
 int nouveau_tv_disable = 0;
-module_param_named(tv_disable, nouveau_tv_disable, int, 0400);
+module_param_named(tv_disable, nouveau_tv_disable, int, S_IRUGO);
 
 MODULE_PARM_DESC(ignorelid, "Ignore ACPI lid status");
 int nouveau_ignorelid = 0;
-module_param_named(ignorelid, nouveau_ignorelid, int, 0400);
+module_param_named(ignorelid, nouveau_ignorelid, int, S_IRUGO);
 
 MODULE_PARM_DESC(duallink, "Allow dual-link TMDS (default: enabled)");
 int nouveau_duallink = 1;
-module_param_named(duallink, nouveau_duallink, int, 0400);
+module_param_named(duallink, nouveau_duallink, int, S_IRUGO);
 
 MODULE_PARM_DESC(hdmimhz, "Force a maximum HDMI pixel clock (in MHz)");
 int nouveau_hdmimhz = 0;
-module_param_named(hdmimhz, nouveau_hdmimhz, int, 0400);
+module_param_named(hdmimhz, nouveau_hdmimhz, int, S_IRUGO);
 
 struct nouveau_encoder *
 find_encoder(struct drm_connector *connector, int type)
drivers/gpu/drm/nouveau/nouveau_drm.c +5 -5
index d06877d..98ead83 100644
@@ -63,24 +63,24 @@
 
 MODULE_PARM_DESC(config, "option string to pass to driver core");
 static char *nouveau_config;
-module_param_named(config, nouveau_config, charp, 0400);
+module_param_named(config, nouveau_config, charp, S_IRUGO);
 
 MODULE_PARM_DESC(debug, "debug string to pass to driver core");
 static char *nouveau_debug;
-module_param_named(debug, nouveau_debug, charp, 0400);
+module_param_named(debug, nouveau_debug, charp, S_IRUGO);
 
 MODULE_PARM_DESC(noaccel, "disable kernel/abi16 acceleration");
 static int nouveau_noaccel = 0;
-module_param_named(noaccel, nouveau_noaccel, int, 0400);
+module_param_named(noaccel, nouveau_noaccel, int, S_IRUGO);
 
 MODULE_PARM_DESC(modeset, "enable driver (default: auto, "
 		          "0 = disabled, 1 = enabled, 2 = headless)");
 int nouveau_modeset = -1;
-module_param_named(modeset, nouveau_modeset, int, 0400);
+module_param_named(modeset, nouveau_modeset, int, S_IRUGO);
 
 MODULE_PARM_DESC(runpm, "disable (0), force enable (1), optimus only default (-1)");
 int nouveau_runtime_pm = -1;
-module_param_named(runpm, nouveau_runtime_pm, int, 0400);
+module_param_named(runpm, nouveau_runtime_pm, int, S_IRUGO);
 
 static struct drm_driver driver_stub;
 static struct drm_driver driver_pci;
drivers/gpu/drm/nouveau/nouveau_fbcon.c +1 -1
index 59f27e7..425b423 100644
@@ -53,7 +53,7 @@
 
 MODULE_PARM_DESC(nofbaccel, "Disable fbcon acceleration");
 int nouveau_nofbaccel = 0;
-module_param_named(nofbaccel, nouveau_nofbaccel, int, 0400);
+module_param_named(nofbaccel, nouveau_nofbaccel, int, S_IRUGO);
 
 static void
 nouveau_fbcon_fillrect(struct fb_info *info, const struct fb_fillrect *rect)
Signature · 7 lines
2.4.11


_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau
#2 lore raw
In reply to a message not in the archive
Quoted 3 lines · poma

For the purposes of the module parameters,
specifies the permissions of the corresponding files in sysfs in predefined S_I* form rather than in octal notation.

I definitely find octal *way* more readable for permissions than those S_* macros. Apparently others agree with me, have a look at 'git grep module_param_named drivers/gpu/drm' - note lack of the silly macros.

I'd be fine with flipping everything to 0444 though. Not sure why it was so restrictive right now.

Quoted 41 lines

Withal it makes the source code more consistent.
Moreover, because all parameters are readable to everyone, it is more user-friendly.

$ grep S_IRUGO include/linux/stat.h
#define S_IRUGO         (S_IRUSR|S_IRGRP|S_IROTH)
$ grep 'S_IRUSR\|S_IRGRP\|S_IROTH' include/uapi/linux/stat.h
#define S_IRUSR 00400
#define S_IRGRP 00040
#define S_IROTH 00004
$ ls -l /sys/module/nouveau/parameters/
total 0
(quoted diff) +0 -12
-r--r--r--. 1 root root 4096 Apr 10 17:43 config
-r--r--r--. 1 root root 4096 Apr 10 17:43 debug
-r--r--r--. 1 root root 4096 Apr 10 17:43 duallink
-r--r--r--. 1 root root 4096 Apr 10 17:43 hdmimhz
-r--r--r--. 1 root root 4096 Apr 10 17:43 ignorelid
-r--r--r--. 1 root root 4096 Apr 10 17:43 modeset
-r--r--r--. 1 root root 4096 Apr 10 17:43 noaccel
-r--r--r--. 1 root root 4096 Apr 10 17:43 nofbaccel
-r--r--r--. 1 root root 4096 Apr 10 17:43 runpm
-r--r--r--. 1 root root 4096 Apr 10 17:43 tv_disable
-r--r--r--. 1 root root 4096 Apr 10 17:43 tv_norm
-r--r--r--. 1 root root 4096 Apr 10 17:43 vram_pushbuf
$ systool -vm nouveau | grep Parameters -A 12
  Parameters:
    config              =  28 6e 75 6c 6c 29 0a
    debug               = "(null)"
    duallink            = "1"
    hdmimhz             = "0"
    ignorelid           = "0"
    modeset             = "-1"
    noaccel             = "0"
    nofbaccel           = "0"
    runpm               = "-1"
    tv_disable          = "0"
    tv_norm             = "(null)"
    vram_pushbuf        = "0"
Quoted 1 line

From Documentation/SubmittingPatches

"""
then you just add a line saying

using your real name (sorry, no pseudonyms or anonymous contributions.) """

-ilia
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau