]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc: Use octal numbers for file permissions
authorRussell Currey <ruscur@russell.cc>
Thu, 12 Jan 2017 03:54:13 +0000 (14:54 +1100)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 21 Jan 2018 18:48:33 +0000 (05:48 +1100)
Symbolic macros are unintuitive and hard to read, whereas octal constants
are much easier to interpret.  Replace macros for the basic permission
flags (user/group/other read/write/execute) with numeric constants
instead, across the whole powerpc tree.

Introducing a significant number of changes across the tree for no runtime
benefit isn't exactly desirable, but so long as these macros are still
used in the tree people will keep sending patches that add them.  Not only
are they hard to parse at a glance, there are multiple ways of coming to
the same value (as you can see with 0444 and 0644 in this patch) which
hurts readability.

Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Cyril Bur <cyrilbur@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
23 files changed:
arch/powerpc/kernel/eeh_sysfs.c
arch/powerpc/kernel/proc_powerpc.c
arch/powerpc/kernel/rtas-proc.c
arch/powerpc/kernel/rtas_flash.c
arch/powerpc/kernel/rtasd.c
arch/powerpc/kernel/traps.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_xics.c
arch/powerpc/platforms/83xx/mcu_mpc8349emitx.c
arch/powerpc/platforms/cell/spufs/inode.c
arch/powerpc/platforms/powernv/opal-dump.c
arch/powerpc/platforms/powernv/opal-elog.c
arch/powerpc/platforms/powernv/opal-sysparam.c
arch/powerpc/platforms/pseries/cmm.c
arch/powerpc/platforms/pseries/hvCall_inst.c
arch/powerpc/platforms/pseries/ibmebus.c
arch/powerpc/platforms/pseries/lparcfg.c
arch/powerpc/platforms/pseries/mobility.c
arch/powerpc/platforms/pseries/reconfig.c
arch/powerpc/platforms/pseries/scanlog.c
arch/powerpc/platforms/pseries/suspend.c
arch/powerpc/sysdev/axonram.c
arch/powerpc/sysdev/mv64x60_pci.c

index 797549289798b33bf2e867c23d3047cf342e89f1..2fb6a2d0946137c5a29720db05bbd2d458c10f58 100644 (file)
@@ -48,7 +48,7 @@ static ssize_t eeh_show_##_name(struct device *dev,      \
                                                              \
        return sprintf(buf, _format "\n", edev->_memb);       \
 }                                                        \
-static DEVICE_ATTR(_name, S_IRUGO, eeh_show_##_name, NULL);
+static DEVICE_ATTR(_name, 0444, eeh_show_##_name, NULL);
 
 EEH_SHOW_ATTR(eeh_mode,            mode,            "0x%x");
 EEH_SHOW_ATTR(eeh_pe_config_addr,  pe_config_addr,  "0x%x");
index 56548bf6231f8ef34e774411692b4857826a6940..9bfbd800d32f6e71a0caa2152a22d244e35d439a 100644 (file)
@@ -63,7 +63,7 @@ static int __init proc_ppc64_init(void)
 {
        struct proc_dir_entry *pde;
 
-       pde = proc_create_data("powerpc/systemcfg", S_IFREG|S_IRUGO, NULL,
+       pde = proc_create_data("powerpc/systemcfg", S_IFREG | 0444, NULL,
                               &page_map_fops, vdso_data);
        if (!pde)
                return 1;
index c8c5f3a550c26c8f0cf44b3c1a2b32b5d6f9baf2..fb070d8cad07d4d3d096c3d98be253b82b5ea617 100644 (file)
@@ -261,19 +261,19 @@ static int __init proc_rtas_init(void)
        if (rtas_node == NULL)
                return -ENODEV;
 
-       proc_create("powerpc/rtas/progress", S_IRUGO|S_IWUSR, NULL,
+       proc_create("powerpc/rtas/progress", 0644, NULL,
                    &ppc_rtas_progress_operations);
-       proc_create("powerpc/rtas/clock", S_IRUGO|S_IWUSR, NULL,
+       proc_create("powerpc/rtas/clock", 0644, NULL,
                    &ppc_rtas_clock_operations);
-       proc_create("powerpc/rtas/poweron", S_IWUSR|S_IRUGO, NULL,
+       proc_create("powerpc/rtas/poweron", 0644, NULL,
                    &ppc_rtas_poweron_operations);
-       proc_create("powerpc/rtas/sensors", S_IRUGO, NULL,
+       proc_create("powerpc/rtas/sensors", 0444, NULL,
                    &ppc_rtas_sensors_operations);
-       proc_create("powerpc/rtas/frequency", S_IWUSR|S_IRUGO, NULL,
+       proc_create("powerpc/rtas/frequency", 0644, NULL,
                    &ppc_rtas_tone_freq_operations);
-       proc_create("powerpc/rtas/volume", S_IWUSR|S_IRUGO, NULL,
+       proc_create("powerpc/rtas/volume", 0644, NULL,
                    &ppc_rtas_tone_volume_operations);
-       proc_create("powerpc/rtas/rmo_buffer", S_IRUSR, NULL,
+       proc_create("powerpc/rtas/rmo_buffer", 0400, NULL,
                    &ppc_rtas_rmo_buf_ops);
        return 0;
 }
index f6f6a8a5103ab954773f252bd11e804604df82ad..10fabae2574d5910b3cbf5ada83d912879d71351 100644 (file)
@@ -727,7 +727,7 @@ static int __init rtas_flash_init(void)
                const struct rtas_flash_file *f = &rtas_flash_files[i];
                int token;
 
-               if (!proc_create(f->filename, S_IRUSR | S_IWUSR, NULL, &f->fops))
+               if (!proc_create(f->filename, 0600, NULL, &f->fops))
                        goto enomem;
 
                /*
index 0f0b1b2f3b60068ea2a4e9ef9d63526383172841..7ae4b8ba7fd35fccd8b5c0e55169cb0ad6d2b70a 100644 (file)
@@ -581,7 +581,7 @@ static int __init rtas_init(void)
        if (!rtas_log_buf)
                return -ENODEV;
 
-       entry = proc_create("powerpc/rtas/error_log", S_IRUSR, NULL,
+       entry = proc_create("powerpc/rtas/error_log", 0400, NULL,
                            &proc_rtas_log_operations);
        if (!entry)
                printk(KERN_ERR "Failed to create error_log proc entry\n");
index 122a3c883f4ef791110ef0a9f873f7c60d2be2c2..cb07d65197836ec2f3cf0a113a60cd61b285a717 100644 (file)
@@ -2130,13 +2130,13 @@ static int __init ppc_warn_emulated_init(void)
        if (!dir)
                return -ENOMEM;
 
-       d = debugfs_create_u32("do_warn", S_IRUGO | S_IWUSR, dir,
+       d = debugfs_create_u32("do_warn", 0644, dir,
                               &ppc_warn_emulated);
        if (!d)
                goto fail;
 
        for (i = 0; i < sizeof(ppc_emulated)/sizeof(*entries); i++) {
-               d = debugfs_create_u32(entries[i].name, S_IRUGO | S_IWUSR, dir,
+               d = debugfs_create_u32(entries[i].name, 0644, dir,
                                       (u32 *)&entries[i].val.counter);
                if (!d)
                        goto fail;
index 2d46037ce93664199adee27806b8972d9130368d..e4f70c33fbc7db0c1d90b75bf134323625a676cf 100644 (file)
 static DECLARE_BITMAP(default_enabled_hcalls, MAX_HCALL_OPCODE/4 + 1);
 
 static int dynamic_mt_modes = 6;
-module_param(dynamic_mt_modes, int, S_IRUGO | S_IWUSR);
+module_param(dynamic_mt_modes, int, 0644);
 MODULE_PARM_DESC(dynamic_mt_modes, "Set of allowed dynamic micro-threading modes: 0 (= none), 2, 4, or 6 (= 2 or 4)");
 static int target_smt_mode;
-module_param(target_smt_mode, int, S_IRUGO | S_IWUSR);
+module_param(target_smt_mode, int, 0644);
 MODULE_PARM_DESC(target_smt_mode, "Target threads per core (0 = max)");
 
 static bool indep_threads_mode = true;
@@ -109,12 +109,10 @@ static struct kernel_param_ops module_param_ops = {
        .get = param_get_int,
 };
 
-module_param_cb(kvm_irq_bypass, &module_param_ops, &kvm_irq_bypass,
-                                                       S_IRUGO | S_IWUSR);
+module_param_cb(kvm_irq_bypass, &module_param_ops, &kvm_irq_bypass, 0644);
 MODULE_PARM_DESC(kvm_irq_bypass, "Bypass passthrough interrupt optimization");
 
-module_param_cb(h_ipi_redirect, &module_param_ops, &h_ipi_redirect,
-                                                       S_IRUGO | S_IWUSR);
+module_param_cb(h_ipi_redirect, &module_param_ops, &h_ipi_redirect, 0644);
 MODULE_PARM_DESC(h_ipi_redirect, "Redirect H_IPI wakeup to a free host core");
 #endif
 
index d329b2add7e2f007e7a24a24cd57b8ffa2b2ebfe..b8356cdc0c043d2407b6cbbe172deec8b56f5dbf 100644 (file)
@@ -1039,7 +1039,7 @@ static void xics_debugfs_init(struct kvmppc_xics *xics)
                return;
        }
 
-       xics->dentry = debugfs_create_file(name, S_IRUGO, powerpc_debugfs_root,
+       xics->dentry = debugfs_create_file(name, 0444, powerpc_debugfs_root,
                                           xics, &xics_debug_fops);
 
        pr_debug("%s: created %s\n", __func__, name);
index 96bb55ca61d39884b56550112791e9e6ac0dd7f5..d2ef39f0edc8fb05e384b706fc5405a90662796d 100644 (file)
@@ -84,7 +84,7 @@ static ssize_t show_status(struct device *d,
 
        return sprintf(buf, "%02x\n", ret);
 }
-static DEVICE_ATTR(status, S_IRUGO, show_status, NULL);
+static DEVICE_ATTR(status, 0444, show_status, NULL);
 
 static void mcu_power_off(void)
 {
index 9558d725a99b57347ed8d7d106536360e806210e..db329d4bf1c30610836bedf072c49cc40edf0d00 100644 (file)
@@ -455,7 +455,7 @@ spufs_create_context(struct inode *inode, struct dentry *dentry,
                }
        }
 
-       ret = spufs_mkdir(inode, dentry, flags, mode & S_IRWXUGO);
+       ret = spufs_mkdir(inode, dentry, flags, mode & 0777);
        if (ret)
                goto out_aff_unlock;
 
@@ -546,7 +546,7 @@ static int spufs_create_gang(struct inode *inode,
        struct path path = {.mnt = mnt, .dentry = dentry};
        int ret;
 
-       ret = spufs_mkgang(inode, dentry, mode & S_IRWXUGO);
+       ret = spufs_mkgang(inode, dentry, mode & 0777);
        if (!ret) {
                ret = spufs_gang_open(&path);
                if (ret < 0) {
index 4c827826c05eb13b09f4e0cd9f9c73d6967ec9a9..0dc8fa4e0af2a9d0015c3e8ad654e9280454e5b1 100644 (file)
@@ -103,9 +103,9 @@ static ssize_t dump_ack_store(struct dump_obj *dump_obj,
  * due to the dynamic size of the dump
  */
 static struct dump_attribute id_attribute =
-       __ATTR(id, S_IRUGO, dump_id_show, NULL);
+       __ATTR(id, 0444, dump_id_show, NULL);
 static struct dump_attribute type_attribute =
-       __ATTR(type, S_IRUGO, dump_type_show, NULL);
+       __ATTR(type, 0444, dump_type_show, NULL);
 static struct dump_attribute ack_attribute =
        __ATTR(acknowledge, 0660, dump_ack_show, dump_ack_store);
 
index ecd6d9177d13f31e35f2ef4c67bdd8d9e47bffa3..ba6e437abb4bb96fa8f78f18517208bb570a08c6 100644 (file)
@@ -83,9 +83,9 @@ static ssize_t elog_ack_store(struct elog_obj *elog_obj,
 }
 
 static struct elog_attribute id_attribute =
-       __ATTR(id, S_IRUGO, elog_id_show, NULL);
+       __ATTR(id, 0444, elog_id_show, NULL);
 static struct elog_attribute type_attribute =
-       __ATTR(type, S_IRUGO, elog_type_show, NULL);
+       __ATTR(type, 0444, elog_type_show, NULL);
 static struct elog_attribute ack_attribute =
        __ATTR(acknowledge, 0660, elog_ack_show, elog_ack_store);
 
index 23fb6647dced6b49967f1e977dd57cf91257526d..6fd4092798d5f5b415cd73e26211ddfc26e0359f 100644 (file)
@@ -260,13 +260,13 @@ void __init opal_sys_param_init(void)
                /* If the parameter is read-only or read-write */
                switch (perm[i] & 3) {
                case OPAL_SYSPARAM_READ:
-                       attr[i].kobj_attr.attr.mode = S_IRUGO;
+                       attr[i].kobj_attr.attr.mode = 0444;
                        break;
                case OPAL_SYSPARAM_WRITE:
-                       attr[i].kobj_attr.attr.mode = S_IWUSR;
+                       attr[i].kobj_attr.attr.mode = 0200;
                        break;
                case OPAL_SYSPARAM_RW:
-                       attr[i].kobj_attr.attr.mode = S_IRUGO | S_IWUSR;
+                       attr[i].kobj_attr.attr.mode = 0644;
                        break;
                default:
                        break;
index 560aefde06c0240a8c6071e3a92ff062337afc1d..25427a48feae3a2dcdee2182cd3bb6c5765066d9 100644 (file)
@@ -72,20 +72,20 @@ MODULE_DESCRIPTION("IBM System p Collaborative Memory Manager");
 MODULE_LICENSE("GPL");
 MODULE_VERSION(CMM_DRIVER_VERSION);
 
-module_param_named(delay, delay, uint, S_IRUGO | S_IWUSR);
+module_param_named(delay, delay, uint, 0644);
 MODULE_PARM_DESC(delay, "Delay (in seconds) between polls to query hypervisor paging requests. "
                 "[Default=" __stringify(CMM_DEFAULT_DELAY) "]");
-module_param_named(hotplug_delay, hotplug_delay, uint, S_IRUGO | S_IWUSR);
+module_param_named(hotplug_delay, hotplug_delay, uint, 0644);
 MODULE_PARM_DESC(hotplug_delay, "Delay (in seconds) after memory hotplug remove "
                 "before loaning resumes. "
                 "[Default=" __stringify(CMM_HOTPLUG_DELAY) "]");
-module_param_named(oom_kb, oom_kb, uint, S_IRUGO | S_IWUSR);
+module_param_named(oom_kb, oom_kb, uint, 0644);
 MODULE_PARM_DESC(oom_kb, "Amount of memory in kb to free on OOM. "
                 "[Default=" __stringify(CMM_OOM_KB) "]");
-module_param_named(min_mem_mb, min_mem_mb, ulong, S_IRUGO | S_IWUSR);
+module_param_named(min_mem_mb, min_mem_mb, ulong, 0644);
 MODULE_PARM_DESC(min_mem_mb, "Minimum amount of memory (in MB) to not balloon. "
                 "[Default=" __stringify(CMM_MIN_MEM_MB) "]");
-module_param_named(debug, cmm_debug, uint, S_IRUGO | S_IWUSR);
+module_param_named(debug, cmm_debug, uint, 0644);
 MODULE_PARM_DESC(debug, "Enable module debugging logging. Set to 1 to enable. "
                 "[Default=" __stringify(CMM_DEBUG) "]");
 
@@ -385,7 +385,7 @@ static int cmm_thread(void *dummy)
        {                                                       \
                return sprintf(buf, format, ##args);            \
        }                                                       \
-       static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
+       static DEVICE_ATTR(name, 0444, show_##name, NULL)
 
 CMM_SHOW(loaned_kb, "%lu\n", PAGES2KB(loaned_pages));
 CMM_SHOW(loaned_target_kb, "%lu\n", PAGES2KB(loaned_pages_target));
@@ -411,7 +411,7 @@ static ssize_t store_oom_pages(struct device *dev,
        return count;
 }
 
-static DEVICE_ATTR(oom_freed_kb, S_IWUSR | S_IRUGO,
+static DEVICE_ATTR(oom_freed_kb, 0644,
                   show_oom_pages, store_oom_pages);
 
 static struct device_attribute *cmm_attrs[] = {
@@ -765,7 +765,7 @@ static int cmm_set_disable(const char *val, const struct kernel_param *kp)
 }
 
 module_param_call(disable, cmm_set_disable, param_get_uint,
-                 &cmm_disabled, S_IRUGO | S_IWUSR);
+                 &cmm_disabled, 0644);
 MODULE_PARM_DESC(disable, "Disable CMM. Set to 1 to disable. "
                 "[Default=" __stringify(CMM_DISABLE) "]");
 
index 957ae347b0b31e6e46d82e0a904017626a4b1b7f..89b7ce807e70c950aa17e5f3de87f75aa36e6feb 100644 (file)
@@ -163,7 +163,7 @@ static int __init hcall_inst_init(void)
 
        for_each_possible_cpu(cpu) {
                snprintf(cpu_name_buf, CPU_NAME_BUF_SIZE, "cpu%d", cpu);
-               hcall_file = debugfs_create_file(cpu_name_buf, S_IRUGO,
+               hcall_file = debugfs_create_file(cpu_name_buf, 0444,
                                                 hcall_root,
                                                 per_cpu(hcall_stats, cpu),
                                                 &hcall_inst_seq_fops);
index 408a8604413300bd0085158f75247752318db8a6..c7c1140c13b6cb8707c4204c9266e2bd217022d3 100644 (file)
@@ -298,7 +298,7 @@ static ssize_t ibmebus_store_probe(struct bus_type *bus,
                return rc;
        return count;
 }
-static BUS_ATTR(probe, S_IWUSR, NULL, ibmebus_store_probe);
+static BUS_ATTR(probe, 0200, NULL, ibmebus_store_probe);
 
 static ssize_t ibmebus_store_remove(struct bus_type *bus,
                                    const char *buf, size_t count)
@@ -325,7 +325,7 @@ static ssize_t ibmebus_store_remove(struct bus_type *bus,
                return -ENODEV;
        }
 }
-static BUS_ATTR(remove, S_IWUSR, NULL, ibmebus_store_remove);
+static BUS_ATTR(remove, 0200, NULL, ibmebus_store_remove);
 
 static struct attribute *ibmbus_bus_attrs[] = {
        &bus_attr_probe.attr,
index f43eafe30c7fdde991d3639acca0d736804a3dd1..c508c938dc71e0bc0d76d0764ffe81ddcd5f8b8f 100644 (file)
@@ -697,11 +697,11 @@ static const struct file_operations lparcfg_fops = {
 
 static int __init lparcfg_init(void)
 {
-       umode_t mode = S_IRUSR | S_IRGRP | S_IROTH;
+       umode_t mode = 0444;
 
        /* Allow writing if we have FW_FEATURE_SPLPAR */
        if (firmware_has_feature(FW_FEATURE_SPLPAR))
-               mode |= S_IWUSR;
+               mode |= 0200;
 
        if (!proc_create("powerpc/lparcfg", mode, NULL, &lparcfg_fops)) {
                printk(KERN_ERR "Failed to create powerpc/lparcfg\n");
index f7042ad492bafba5ac21e3db9ce24977fd527169..0f7fb7170b03ce5646aa13b9b9b55f5965f09aae 100644 (file)
@@ -384,7 +384,7 @@ static ssize_t migration_store(struct class *class,
 #define MIGRATION_API_VERSION  1
 
 static CLASS_ATTR_WO(migration);
-static CLASS_ATTR_STRING(api_version, S_IRUGO, __stringify(MIGRATION_API_VERSION));
+static CLASS_ATTR_STRING(api_version, 0444, __stringify(MIGRATION_API_VERSION));
 
 static int __init mobility_sysfs_init(void)
 {
index f24d8159c9e1eed31a53f248c61ccdbdaec578b3..0e0208117e772407f33d772d7cfd8845926c4e98 100644 (file)
@@ -405,7 +405,7 @@ static int proc_ppc64_create_ofdt(void)
 {
        struct proc_dir_entry *ent;
 
-       ent = proc_create("powerpc/ofdt", S_IWUSR, NULL, &ofdt_fops);
+       ent = proc_create("powerpc/ofdt", 0200, NULL, &ofdt_fops);
        if (ent)
                proc_set_size(ent, 0);
 
index c47585a78b69158e8fb880689bd38d44d1d29db5..054ce7a16fc336b42b1c05243be5a45a68b91d5a 100644 (file)
@@ -179,7 +179,7 @@ static int __init scanlog_init(void)
        if (!scanlog_buffer)
                goto err;
 
-       ent = proc_create("powerpc/rtas/scan-log-dump", S_IRUSR, NULL,
+       ent = proc_create("powerpc/rtas/scan-log-dump", 0400, NULL,
                          &scanlog_fops);
        if (!ent)
                goto err;
index 89726f07d2492fd17beb05eea48c476fd2652550..52a021e1f86bfe6950d450ba03c3f7c881dec22a 100644 (file)
@@ -214,8 +214,7 @@ static ssize_t show_hibernate(struct device *dev,
        return sprintf(buf, "%d\n", KERN_DT_UPDATE);
 }
 
-static DEVICE_ATTR(hibernate, S_IWUSR | S_IRUGO,
-                  show_hibernate, store_hibernate);
+static DEVICE_ATTR(hibernate, 0644, show_hibernate, store_hibernate);
 
 static struct bus_type suspend_subsys = {
        .name = "power",
index 1b307c80b401083f50637daf1597f43ccabe70b9..53b7f8ef570ffb6588abbd48ed2e8679f7e681e9 100644 (file)
@@ -83,7 +83,7 @@ axon_ram_sysfs_ecc(struct device *dev, struct device_attribute *attr, char *buf)
        return sprintf(buf, "%ld\n", bank->ecc_counter);
 }
 
-static DEVICE_ATTR(ecc, S_IRUGO, axon_ram_sysfs_ecc, NULL);
+static DEVICE_ATTR(ecc, 0444, axon_ram_sysfs_ecc, NULL);
 
 /**
  * axon_ram_irq_handler - interrupt handler for Axon RAM ECC
index d52b3b81e05fba706af2012804fcf410f5d8c2b4..50c411b1761e0105bbe504dcf3f7cb628d21701f 100644 (file)
@@ -73,7 +73,7 @@ static ssize_t mv64x60_hs_reg_write(struct file *filp, struct kobject *kobj,
 static const struct bin_attribute mv64x60_hs_reg_attr = { /* Hotswap register */
        .attr = {
                .name = "hs_reg",
-               .mode = S_IRUGO | S_IWUSR,
+               .mode = 0644,
        },
        .size  = MV64X60_VAL_LEN_MAX,
        .read  = mv64x60_hs_reg_read,