mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baole Ni <baolex.ni@intel.com>
To: lee.jones@linaro.org, chaitra.basappa@broadcom.com,
	suganath-prabu.subramani@broadcom.com, mchehab@redhat.com,
	m.chehab@samsung.com, pawel@osciak.com, m.szyprowski@samsung.com,
	kyungmin.park@samsung.com, k.kozlowski@samsung.com
Cc: linux-kernel@vger.kernel.org, viresh.kumar@linaro.org,
	gregkh@linuxfoundation.org, jkosina@suse.cz, geliangtang@163.com,
	chuansheng.liu@intel.com, baolex.ni@intel.com
Subject: [PATCH 0681/1285] Replace numeric parameter like 0444 with macro
Date: Tue,  2 Aug 2016 19:36:21 +0800	[thread overview]
Message-ID: <20160802113621.27465-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/misc/c2port/core.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
index 1922cb8..4acad6d 100644
--- a/drivers/misc/c2port/core.c
+++ b/drivers/misc/c2port/core.c
@@ -311,7 +311,7 @@ static ssize_t c2port_show_name(struct device *dev,
 
 	return sprintf(buf, "%s\n", c2dev->name);
 }
-static DEVICE_ATTR(name, 0444, c2port_show_name, NULL);
+static DEVICE_ATTR(name, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_name, NULL);
 
 static ssize_t c2port_show_flash_blocks_num(struct device *dev,
 				struct device_attribute *attr, char *buf)
@@ -321,7 +321,7 @@ static ssize_t c2port_show_flash_blocks_num(struct device *dev,
 
 	return sprintf(buf, "%d\n", ops->blocks_num);
 }
-static DEVICE_ATTR(flash_blocks_num, 0444, c2port_show_flash_blocks_num, NULL);
+static DEVICE_ATTR(flash_blocks_num, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_flash_blocks_num, NULL);
 
 static ssize_t c2port_show_flash_block_size(struct device *dev,
 				struct device_attribute *attr, char *buf)
@@ -331,7 +331,7 @@ static ssize_t c2port_show_flash_block_size(struct device *dev,
 
 	return sprintf(buf, "%d\n", ops->block_size);
 }
-static DEVICE_ATTR(flash_block_size, 0444, c2port_show_flash_block_size, NULL);
+static DEVICE_ATTR(flash_block_size, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_flash_block_size, NULL);
 
 static ssize_t c2port_show_flash_size(struct device *dev,
 				struct device_attribute *attr, char *buf)
@@ -341,7 +341,7 @@ static ssize_t c2port_show_flash_size(struct device *dev,
 
 	return sprintf(buf, "%d\n", ops->blocks_num * ops->block_size);
 }
-static DEVICE_ATTR(flash_size, 0444, c2port_show_flash_size, NULL);
+static DEVICE_ATTR(flash_size, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_flash_size, NULL);
 
 static ssize_t access_show(struct device *dev, struct device_attribute *attr,
 			   char *buf)
@@ -399,7 +399,7 @@ static ssize_t c2port_store_reset(struct device *dev,
 
 	return count;
 }
-static DEVICE_ATTR(reset, 0200, NULL, c2port_store_reset);
+static DEVICE_ATTR(reset, S_IWUSR, NULL, c2port_store_reset);
 
 static ssize_t __c2port_show_dev_id(struct c2port_device *dev, char *buf)
 {
@@ -436,7 +436,7 @@ static ssize_t c2port_show_dev_id(struct device *dev,
 
 	return ret;
 }
-static DEVICE_ATTR(dev_id, 0444, c2port_show_dev_id, NULL);
+static DEVICE_ATTR(dev_id, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_dev_id, NULL);
 
 static ssize_t __c2port_show_rev_id(struct c2port_device *dev, char *buf)
 {
@@ -473,7 +473,7 @@ static ssize_t c2port_show_rev_id(struct device *dev,
 
 	return ret;
 }
-static DEVICE_ATTR(rev_id, 0444, c2port_show_rev_id, NULL);
+static DEVICE_ATTR(rev_id, S_IRUSR | S_IRGRP | S_IROTH, c2port_show_rev_id, NULL);
 
 static ssize_t c2port_show_flash_access(struct device *dev,
 				struct device_attribute *attr, char *buf)
@@ -543,7 +543,7 @@ static ssize_t c2port_store_flash_access(struct device *dev,
 
 	return count;
 }
-static DEVICE_ATTR(flash_access, 0644, c2port_show_flash_access,
+static DEVICE_ATTR(flash_access, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, c2port_show_flash_access,
 		   c2port_store_flash_access);
 
 static ssize_t __c2port_write_flash_erase(struct c2port_device *dev)
@@ -625,7 +625,7 @@ static ssize_t c2port_store_flash_erase(struct device *dev,
 
 	return count;
 }
-static DEVICE_ATTR(flash_erase, 0200, NULL, c2port_store_flash_erase);
+static DEVICE_ATTR(flash_erase, S_IWUSR, NULL, c2port_store_flash_erase);
 
 static ssize_t __c2port_read_flash_data(struct c2port_device *dev,
 				char *buffer, loff_t offset, size_t count)
@@ -853,7 +853,7 @@ static ssize_t c2port_write_flash_data(struct file *filp, struct kobject *kobj,
 	return ret;
 }
 /* size is computed at run-time */
-static BIN_ATTR(flash_data, 0644, c2port_read_flash_data,
+static BIN_ATTR(flash_data, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, c2port_read_flash_data,
 		c2port_write_flash_data, 0);
 
 /*
-- 
2.9.2

                 reply	other threads:[~2016-08-02 12:20 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=20160802113621.27465-1-baolex.ni@intel.com \
    --to=baolex.ni@intel.com \
    --cc=chaitra.basappa@broadcom.com \
    --cc=chuansheng.liu@intel.com \
    --cc=geliangtang@163.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkosina@suse.cz \
    --cc=k.kozlowski@samsung.com \
    --cc=kyungmin.park@samsung.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=m.szyprowski@samsung.com \
    --cc=mchehab@redhat.com \
    --cc=pawel@osciak.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    --cc=viresh.kumar@linaro.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®