Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1454114 > unrolled thread

[PATCH 0857/1285] Replace numeric parameter like 0444 with macro

Started byBaole Ni <baolex.ni@intel.com>
First post2016-08-02 14:40 +0200
Last post2016-08-08 08:50 +0200
Articles 4 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0857/1285] Replace numeric parameter like 0444 with macro Baole Ni <baolex.ni@intel.com> - 2016-08-02 14:40 +0200
    Re: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro Henrique de Moraes Holschuh <hmh@hmh.eng.br> - 2016-08-02 19:50 +0200
      Re: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro Darren Hart <dvhart@infradead.org> - 2016-08-07 01:40 +0200
        RE: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro "Ni, BaoleX" <baolex.ni@intel.com> - 2016-08-08 08:50 +0200

#1454114 — [PATCH 0857/1285] Replace numeric parameter like 0444 with macro

FromBaole Ni <baolex.ni@intel.com>
Date2016-08-02 14:40 +0200
Subject[PATCH 0857/1285] Replace numeric parameter like 0444 with macro
Message-ID<s1H9g-4r7-19@gated-at.bofh.it>
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.

Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: Baole Ni <baolex.ni@intel.com>
---
 drivers/platform/x86/thinkpad_acpi.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
index b65ce75..898d185 100644
--- a/drivers/platform/x86/thinkpad_acpi.c
+++ b/drivers/platform/x86/thinkpad_acpi.c
@@ -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,
-- 
2.9.2

[toc] | [next] | [standalone]


#1455183

FromHenrique de Moraes Holschuh <hmh@hmh.eng.br>
Date2016-08-02 19:50 +0200
Message-ID<s1LZg-7Ht-15@gated-at.bofh.it>
In reply to#1454114
(cc list trimmed)

On Tue, 02 Aug 2016, Baole Ni wrote:
> 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.
> 
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> Signed-off-by: Baole Ni <baolex.ni@intel.com>

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*.

-- 
  "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

[toc] | [prev] | [next] | [standalone]


#1457403

FromDarren Hart <dvhart@infradead.org>
Date2016-08-07 01:40 +0200
Message-ID<s3jm9-44z-1@gated-at.bofh.it>
In reply to#1455183
On Tue, Aug 02, 2016 at 02:34:07PM -0300, Henrique de Moraes Holschuh wrote:
> (cc list trimmed)
> 
> On Tue, 02 Aug 2016, Baole Ni wrote:
> > 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.
> > 
> > Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> > Signed-off-by: Baole Ni <baolex.ni@intel.com>
> 
> 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.

> 
> 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

[toc] | [prev] | [next] | [standalone]


#1457568

From"Ni, BaoleX" <baolex.ni@intel.com>
Date2016-08-08 08:50 +0200
Message-ID<s3MxP-6io-15@gated-at.bofh.it>
In reply to#1457403
Dear Darren, 

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

Baole

-----Original Message-----
From: Darren Hart [mailto:dvhart@infradead.org] 
Sent: Saturday, August 06, 2016 6:57 AM
To: Henrique de Moraes Holschuh
Cc: Ni, BaoleX; ibm-acpi-devel@lists.sourceforge.net; platform-driver-x86@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, Chuansheng
Subject: Re: [PATCH 0857/1285] Replace numeric parameter like 0444 with macro

On Tue, Aug 02, 2016 at 02:34:07PM -0300, Henrique de Moraes Holschuh wrote:
> (cc list trimmed)
> 
> On Tue, 02 Aug 2016, Baole Ni wrote:
> > 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.
> > 
> > Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> > Signed-off-by: Baole Ni <baolex.ni@intel.com>
> 
> 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.

> 
> 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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web