* [PATCH 0014/1285] Replace numeric parameter like 0444 with macro
@ 2016-08-02 10:34 Baole Ni
2016-08-02 13:44 ` Ralf Baechle
0 siblings, 1 reply; 2+ messages in thread
From: Baole Ni @ 2016-08-02 10:34 UTC (permalink / raw)
To: ralf, fenghua.yu, robert.jarzmik, linux
Cc: linux-mips, linux-kernel, chuansheng.liu, baolex.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.
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Signed-off-by: Baole Ni <baolex.ni@intel.com>
---
arch/mips/txx9/generic/7segled.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/mips/txx9/generic/7segled.c b/arch/mips/txx9/generic/7segled.c
index 566c58b..1fcd1ec 100644
--- a/arch/mips/txx9/generic/7segled.c
+++ b/arch/mips/txx9/generic/7segled.c
@@ -55,8 +55,8 @@ static ssize_t raw_store(struct device *dev,
return size;
}
-static DEVICE_ATTR(ascii, 0200, NULL, ascii_store);
-static DEVICE_ATTR(raw, 0200, NULL, raw_store);
+static DEVICE_ATTR(ascii, S_IWUSR, NULL, ascii_store);
+static DEVICE_ATTR(raw, S_IWUSR, NULL, raw_store);
static ssize_t map_seg7_show(struct device *dev,
struct device_attribute *attr,
@@ -76,7 +76,7 @@ static ssize_t map_seg7_store(struct device *dev,
return size;
}
-static DEVICE_ATTR(map_seg7, 0600, map_seg7_show, map_seg7_store);
+static DEVICE_ATTR(map_seg7, S_IRUSR | S_IWUSR, map_seg7_show, map_seg7_store);
static struct bus_type tx_7segled_subsys = {
.name = "7segled",
--
2.9.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH 0014/1285] Replace numeric parameter like 0444 with macro
2016-08-02 10:34 [PATCH 0014/1285] Replace numeric parameter like 0444 with macro Baole Ni
@ 2016-08-02 13:44 ` Ralf Baechle
0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2016-08-02 13:44 UTC (permalink / raw)
To: Baole Ni, Atsushi Nemoto
Cc: fenghua.yu, robert.jarzmik, linux, linux-mips, linux-kernel,
chuansheng.liu
On Tue, Aug 02, 2016 at 06:34:21PM +0800, 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>
> ---
> arch/mips/txx9/generic/7segled.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/txx9/generic/7segled.c b/arch/mips/txx9/generic/7segled.c
> index 566c58b..1fcd1ec 100644
> --- a/arch/mips/txx9/generic/7segled.c
> +++ b/arch/mips/txx9/generic/7segled.c
> @@ -55,8 +55,8 @@ static ssize_t raw_store(struct device *dev,
> return size;
> }
>
> -static DEVICE_ATTR(ascii, 0200, NULL, ascii_store);
> -static DEVICE_ATTR(raw, 0200, NULL, raw_store);
> +static DEVICE_ATTR(ascii, S_IWUSR, NULL, ascii_store);
> +static DEVICE_ATTR(raw, S_IWUSR, NULL, raw_store);
>
> static ssize_t map_seg7_show(struct device *dev,
> struct device_attribute *attr,
> @@ -76,7 +76,7 @@ static ssize_t map_seg7_store(struct device *dev,
> return size;
> }
>
> -static DEVICE_ATTR(map_seg7, 0600, map_seg7_show, map_seg7_store);
> +static DEVICE_ATTR(map_seg7, S_IRUSR | S_IWUSR, map_seg7_show, map_seg7_store);
>
> static struct bus_type tx_7segled_subsys = {
> .name = "7segled",
I find this one of the case where the number is much understandable than
a cryptic symbol whos name was chosen when C compilers still had
limitations on the symbol length and every byte was sacred.
Ralf
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-08-02 13:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 10:34 [PATCH 0014/1285] Replace numeric parameter like 0444 with macro Baole Ni
2016-08-02 13:44 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox