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

From: Baole Ni
Date: Tue Aug 02 2016 - 08:30:32 EST


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@xxxxxxxxx>
Signed-off-by: Baole Ni <baolex.ni@xxxxxxxxx>
---
drivers/pcmcia/socket_sysfs.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/pcmcia/socket_sysfs.c b/drivers/pcmcia/socket_sysfs.c
index d688151..cb85dfb 100644
--- a/drivers/pcmcia/socket_sysfs.c
+++ b/drivers/pcmcia/socket_sysfs.c
@@ -44,7 +44,7 @@ static ssize_t pccard_show_type(struct device *dev, struct device_attribute *att
return sprintf(buf, "32-bit\n");
return sprintf(buf, "16-bit\n");
}
-static DEVICE_ATTR(card_type, 0444, pccard_show_type, NULL);
+static DEVICE_ATTR(card_type, S_IRUSR | S_IRGRP | S_IROTH, pccard_show_type, NULL);

static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -58,7 +58,7 @@ static ssize_t pccard_show_voltage(struct device *dev, struct device_attribute *
s->socket.Vcc % 10);
return sprintf(buf, "X.XV\n");
}
-static DEVICE_ATTR(card_voltage, 0444, pccard_show_voltage, NULL);
+static DEVICE_ATTR(card_voltage, S_IRUSR | S_IRGRP | S_IROTH, pccard_show_voltage, NULL);

static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -68,7 +68,7 @@ static ssize_t pccard_show_vpp(struct device *dev, struct device_attribute *attr
return -ENODEV;
return sprintf(buf, "%d.%dV\n", s->socket.Vpp / 10, s->socket.Vpp % 10);
}
-static DEVICE_ATTR(card_vpp, 0444, pccard_show_vpp, NULL);
+static DEVICE_ATTR(card_vpp, S_IRUSR | S_IRGRP | S_IROTH, pccard_show_vpp, NULL);

static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr,
char *buf)
@@ -78,7 +78,7 @@ static ssize_t pccard_show_vcc(struct device *dev, struct device_attribute *attr
return -ENODEV;
return sprintf(buf, "%d.%dV\n", s->socket.Vcc / 10, s->socket.Vcc % 10);
}
-static DEVICE_ATTR(card_vcc, 0444, pccard_show_vcc, NULL);
+static DEVICE_ATTR(card_vcc, S_IRUSR | S_IRGRP | S_IROTH, pccard_show_vcc, NULL);


static ssize_t pccard_store_insert(struct device *dev, struct device_attribute *attr,
@@ -93,7 +93,7 @@ static ssize_t pccard_store_insert(struct device *dev, struct device_attribute *

return count;
}
-static DEVICE_ATTR(card_insert, 0200, NULL, pccard_store_insert);
+static DEVICE_ATTR(card_insert, S_IWUSR, NULL, pccard_store_insert);


static ssize_t pccard_show_card_pm_state(struct device *dev,
@@ -125,7 +125,7 @@ static ssize_t pccard_store_card_pm_state(struct device *dev,

return ret;
}
-static DEVICE_ATTR(card_pm_state, 0644, pccard_show_card_pm_state, pccard_store_card_pm_state);
+static DEVICE_ATTR(card_pm_state, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, pccard_show_card_pm_state, pccard_store_card_pm_state);

static ssize_t pccard_store_eject(struct device *dev,
struct device_attribute *attr,
@@ -140,7 +140,7 @@ static ssize_t pccard_store_eject(struct device *dev,

return count;
}
-static DEVICE_ATTR(card_eject, 0200, NULL, pccard_store_eject);
+static DEVICE_ATTR(card_eject, S_IWUSR, NULL, pccard_store_eject);


static ssize_t pccard_show_irq_mask(struct device *dev,
@@ -173,7 +173,7 @@ static ssize_t pccard_store_irq_mask(struct device *dev,

return ret ? ret : count;
}
-static DEVICE_ATTR(card_irq_mask, 0600, pccard_show_irq_mask, pccard_store_irq_mask);
+static DEVICE_ATTR(card_irq_mask, S_IRUSR | S_IWUSR, pccard_show_irq_mask, pccard_store_irq_mask);


static ssize_t pccard_show_resource(struct device *dev,
@@ -201,7 +201,7 @@ static ssize_t pccard_store_resource(struct device *dev,

return count;
}
-static DEVICE_ATTR(available_resources_setup_done, 0600, pccard_show_resource, pccard_store_resource);
+static DEVICE_ATTR(available_resources_setup_done, S_IRUSR | S_IWUSR, pccard_show_resource, pccard_store_resource);

static struct attribute *pccard_socket_attributes[] = {
&dev_attr_card_type.attr,
--
2.9.2