From: Baole Ni <baolex.ni@intel.com>
To: gregkh@linuxfoundation.org, tj@kernel.org, lenb@kernel.org,
x86@kernel.org, hpa@zytor.com
Cc: linux-kernel@vger.kernel.org, chuansheng.liu@intel.com,
baolex.ni@intel.com
Subject: [PATCH 0074/1285] Replace numeric parameter like 0444 with macro
Date: Tue, 2 Aug 2016 18:38:43 +0800 [thread overview]
Message-ID: <20160802103843.18685-1-baolex.ni@intel.com> (raw)
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/base/cpu.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 691eeea..1496146 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -156,7 +156,7 @@ static ssize_t show_crash_notes(struct device *dev, struct device_attribute *att
rc = sprintf(buf, "%Lx\n", addr);
return rc;
}
-static DEVICE_ATTR(crash_notes, 0400, show_crash_notes, NULL);
+static DEVICE_ATTR(crash_notes, S_IRUSR, show_crash_notes, NULL);
static ssize_t show_crash_notes_size(struct device *dev,
struct device_attribute *attr,
@@ -167,7 +167,7 @@ static ssize_t show_crash_notes_size(struct device *dev,
rc = sprintf(buf, "%zu\n", sizeof(note_buf_t));
return rc;
}
-static DEVICE_ATTR(crash_notes_size, 0400, show_crash_notes_size, NULL);
+static DEVICE_ATTR(crash_notes_size, S_IRUSR, show_crash_notes_size, NULL);
static struct attribute *crash_note_cpu_attrs[] = {
&dev_attr_crash_notes.attr,
@@ -231,7 +231,7 @@ static ssize_t print_cpus_kernel_max(struct device *dev,
int n = snprintf(buf, PAGE_SIZE-2, "%d\n", NR_CPUS - 1);
return n;
}
-static DEVICE_ATTR(kernel_max, 0444, print_cpus_kernel_max, NULL);
+static DEVICE_ATTR(kernel_max, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_kernel_max, NULL);
/* arch-optional setting to enable display of offline cpus >= nr_cpu_ids */
unsigned int total_cpus;
@@ -264,7 +264,7 @@ static ssize_t print_cpus_offline(struct device *dev,
n += snprintf(&buf[n], len - n, "\n");
return n;
}
-static DEVICE_ATTR(offline, 0444, print_cpus_offline, NULL);
+static DEVICE_ATTR(offline, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_offline, NULL);
static ssize_t print_cpus_isolated(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -275,7 +275,7 @@ static ssize_t print_cpus_isolated(struct device *dev,
return n;
}
-static DEVICE_ATTR(isolated, 0444, print_cpus_isolated, NULL);
+static DEVICE_ATTR(isolated, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_isolated, NULL);
#ifdef CONFIG_NO_HZ_FULL
static ssize_t print_cpus_nohz_full(struct device *dev,
@@ -287,7 +287,7 @@ static ssize_t print_cpus_nohz_full(struct device *dev,
return n;
}
-static DEVICE_ATTR(nohz_full, 0444, print_cpus_nohz_full, NULL);
+static DEVICE_ATTR(nohz_full, S_IRUSR | S_IRGRP | S_IROTH, print_cpus_nohz_full, NULL);
#endif
static void cpu_device_release(struct device *dev)
@@ -443,7 +443,7 @@ struct device *cpu_device_create(struct device *parent, void *drvdata,
EXPORT_SYMBOL_GPL(cpu_device_create);
#ifdef CONFIG_GENERIC_CPU_AUTOPROBE
-static DEVICE_ATTR(modalias, 0444, print_cpu_modalias, NULL);
+static DEVICE_ATTR(modalias, S_IRUSR | S_IRGRP | S_IROTH, print_cpu_modalias, NULL);
#endif
static struct attribute *cpu_root_attrs[] = {
--
2.9.2
reply other threads:[~2016-08-02 18:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160802103843.18685-1-baolex.ni@intel.com \
--to=baolex.ni@intel.com \
--cc=chuansheng.liu@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tj@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®