Skip to contentSkip to conversation

Replace numeric parameter like 0444 with macro

PATCH NAK Baole Ni 3 participants 4 messages Aug 2, 2016 – Aug 8, 2016 x86 platform drivers

lore
Share & tools
lore

Baole Ni

author
#0 lore raw

PATCH 857/1285 Replace numeric parameter like 0444 with macro

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

---
 drivers/platform/x86/thinkpad_acpi.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/platform/x86/thinkpad_acpi.c +16 -16
index b65ce75..898d185 100644
@@ -9553,57 +9553,57 @@ static int __init set_ibm_param(const char *val, struct kernel_param *kp)
 	return -EINVAL;
 }
 
-module_param(experimental, int, 0444);
+module_param(experimental, int, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(experimental,
 		 "Enables experimental features when non-zero");
 
 module_param_named(debug, dbg_level, uint, 0);
 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
 
-module_param(force_load, bool, 0444);
+module_param(force_load, bool, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(force_load,
 		 "Attempts to load the driver even on a "
 		 "mis-identified ThinkPad when true");
 
-module_param_named(fan_control, fan_control_allowed, bool, 0444);
+module_param_named(fan_control, fan_control_allowed, bool, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(fan_control,
 		 "Enables setting fan parameters features when true");
 
-module_param_named(brightness_mode, brightness_mode, uint, 0444);
+module_param_named(brightness_mode, brightness_mode, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(brightness_mode,
 		 "Selects brightness control strategy: "
 		 "0=auto, 1=EC, 2=UCMS, 3=EC+NVRAM");
 
-module_param(brightness_enable, uint, 0444);
+module_param(brightness_enable, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(brightness_enable,
 		 "Enables backlight control when 1, disables when 0");
 
 #ifdef CONFIG_THINKPAD_ACPI_ALSA_SUPPORT
-module_param_named(volume_mode, volume_mode, uint, 0444);
+module_param_named(volume_mode, volume_mode, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(volume_mode,
 		 "Selects volume control strategy: "
 		 "0=auto, 1=EC, 2=N/A, 3=EC+NVRAM");
 
-module_param_named(volume_capabilities, volume_capabilities, uint, 0444);
+module_param_named(volume_capabilities, volume_capabilities, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(volume_capabilities,
 		 "Selects the mixer capabilites: "
 		 "0=auto, 1=volume and mute, 2=mute only");
 
-module_param_named(volume_control, volume_control_allowed, bool, 0444);
+module_param_named(volume_control, volume_control_allowed, bool, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(volume_control,
 		 "Enables software override for the console audio "
 		 "control when true");
 
-module_param_named(software_mute, software_mute_requested, bool, 0444);
+module_param_named(software_mute, software_mute_requested, bool, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(software_mute,
 		 "Request full software mute control");
 
 /* ALSA module API parameters */
-module_param_named(index, alsa_index, int, 0444);
+module_param_named(index, alsa_index, int, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(index, "ALSA index for the ACPI EC Mixer");
-module_param_named(id, alsa_id, charp, 0444);
+module_param_named(id, alsa_id, charp, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(id, "ALSA id for the ACPI EC Mixer");
-module_param_named(enable, alsa_enable, bool, 0444);
+module_param_named(enable, alsa_enable, bool, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(enable, "Enable the ALSA interface for the ACPI EC Mixer");
 #endif /* CONFIG_THINKPAD_ACPI_ALSA_SUPPORT */
 
@@ -9624,25 +9624,25 @@ TPACPI_PARAM(volume);
 TPACPI_PARAM(fan);
 
 #ifdef CONFIG_THINKPAD_ACPI_DEBUGFACILITIES
-module_param(dbg_wlswemul, uint, 0444);
+module_param(dbg_wlswemul, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(dbg_wlswemul, "Enables WLSW emulation");
 module_param_named(wlsw_state, tpacpi_wlsw_emulstate, bool, 0);
 MODULE_PARM_DESC(wlsw_state,
 		 "Initial state of the emulated WLSW switch");
 
-module_param(dbg_bluetoothemul, uint, 0444);
+module_param(dbg_bluetoothemul, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(dbg_bluetoothemul, "Enables bluetooth switch emulation");
 module_param_named(bluetooth_state, tpacpi_bluetooth_emulstate, bool, 0);
 MODULE_PARM_DESC(bluetooth_state,
 		 "Initial state of the emulated bluetooth switch");
 
-module_param(dbg_wwanemul, uint, 0444);
+module_param(dbg_wwanemul, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(dbg_wwanemul, "Enables WWAN switch emulation");
 module_param_named(wwan_state, tpacpi_wwan_emulstate, bool, 0);
 MODULE_PARM_DESC(wwan_state,
 		 "Initial state of the emulated WWAN switch");
 
-module_param(dbg_uwbemul, uint, 0444);
+module_param(dbg_uwbemul, uint, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(dbg_uwbemul, "Enables UWB switch emulation");
 module_param_named(uwb_state, tpacpi_uwb_emulstate, bool, 0);
 MODULE_PARM_DESC(uwb_state,
Signature · 1 line
2.9.2
#1 lore raw

(cc list trimmed)

Quoted 8 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

NACK.

IMO, the proposed change reduces readiability for no good reason. Most people touching kernel code have 0444, 0644, 0755, etc. already hardwired into their pattern recognition neural network, while the POSIX S_* crap is actually bug food.

PS: no more ill-managed ultra-large patch bombs, *please*.

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
#2 lore raw
Quoted 12 lines · Henrique de Moraes Holschuh

(cc list trimmed)

Quoted 8 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

Quoted 6 lines

NACK.

IMO, the proposed change reduces readiability for no good reason. Most people touching kernel code have 0444, 0644, 0755, etc. already hardwired into their pattern recognition neural network, while the POSIX S_* crap is actually bug food.

While I'm generally in favor of using macros where they exist, I do agree with Henrique that this is actually less legible.

Quoted 2 lines

PS: no more ill-managed ultra-large patch bombs, *please*.

Indeed. 1285 patches with the same subject line is "not ideal". Prefixing with the subsystem at the very least would have been an improvement. An RFC on the concept, cc'ing the subsystem maintainers to get consensus and direction on how to manage the large change would have been advisable.

I'm dropping these for pdx86 unless a compelling argument arises for including them (like - the only subsystem not taking these is pdx86...)

Signature · 4 lines
Darren Hart
Intel Open Source Technology Center

------------------------------------------------------------------------------
author
#3 lore raw

Dear Darren,

Thank you very much! I'll be glad to take your advice.

Baole

-----Original Message-----
From: Darren Hart [mailto:[email protected]]
Sent: Saturday, August 06, 2016 6:57 AM
To: Henrique de Moraes Holschuh
Cc: Ni, BaoleX; [email protected]; [email protected]; [email protected]; Liu, Chuansheng
Subject: Re: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro

Quoted 12 lines · Henrique de Moraes Holschuh

(cc list trimmed)

Quoted 8 lines · Baole Ni

I find that the developers often just specified the numeric value
when calling a macro which is defined with a parameter for access permission. As we know, these numeric value for access permission have had the corresponding macro, and that using macro can improve the robustness
and readability of the code, thus, I suggest replacing the numeric parameter with the macro.

Quoted 7 lines

NACK.

IMO, the proposed change reduces readiability for no good reason. Most people touching kernel code have 0444, 0644, 0755, etc. already hardwired into their pattern recognition neural network, while the POSIX
S_* crap is actually bug food.

While I'm generally in favor of using macros where they exist, I do agree with Henrique that this is actually less legible.

Quoted 2 lines

PS: no more ill-managed ultra-large patch bombs, *please*.

Indeed. 1285 patches with the same subject line is "not ideal". Prefixing with the subsystem at the very least would have been an improvement. An RFC on the concept, cc'ing the subsystem maintainers to get consensus and direction on how to manage the large change would have been advisable.

I'm dropping these for pdx86 unless a compelling argument arises for including them (like - the only subsystem not taking these is pdx86...)

--
Darren Hart
Intel Open Source Technology Center