Re: [-next PATCH 4/4] treewide: Use DEVICE_ATTR_WO

From: Zhang Rui
Date: Wed Dec 20 2017 - 19:50:48 EST


On Tue, 2017-12-19 at 10:15 -0800, Joe Perches wrote:
> Convert DEVICE_ATTR uses to DEVICE_ATTR_WO where possible.
>
> Done with perl script:
>
> $ git grep -w --name-only DEVICE_ATTR | \
> Â xargs perl -i -e 'local $/; while (<>) {
> s/\bDEVICE_ATTR\s*\(\s*(\w+)\s*,\s*\(?(?:\s*S_IWUSR\s*|\s*0200\s*)\)?
> \s*,\s*NULL\s*,\s*\s_store\s*\)/DEVICE_ATTR_WO(\1)/g; print;}'
>
> Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
> ---
> Âarch/s390/kernel/smp.cÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ| 2 +-
> Âarch/x86/kernel/cpu/microcode/core.cÂÂÂ| 2 +-
> Âdrivers/input/touchscreen/elants_i2c.c | 2 +-
> Âdrivers/net/ethernet/ibm/ibmvnic.cÂÂÂÂÂ| 2 +-
> Âdrivers/net/wimax/i2400m/sysfs.cÂÂÂÂÂÂÂ| 3 +--
> Âdrivers/scsi/lpfc/lpfc_attr.cÂÂÂÂÂÂÂÂÂÂ| 3 +--
> Âdrivers/thermal/thermal_sysfs.cÂÂÂÂÂÂÂÂ| 2 +-

For the thermal part,
Acked-by: Zhang Rui <rui.zhang@xxxxxxxxx>

thanks,
rui

> Â7 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
> index b8c1a85bcf2d..a919b2f0141d 100644
> --- a/arch/s390/kernel/smp.c
> +++ b/arch/s390/kernel/smp.c
> @@ -1151,7 +1151,7 @@ static ssize_t __ref rescan_store(struct device
> *dev,
> Â rc = smp_rescan_cpus();
> Â return rc ? rc : count;
> Â}
> -static DEVICE_ATTR(rescan, 0200, NULL, rescan_store);
> +static DEVICE_ATTR_WO(rescan);
> Â#endif /* CONFIG_HOTPLUG_CPU */
> Â
> Âstatic int __init s390_smp_init(void)
> diff --git a/arch/x86/kernel/cpu/microcode/core.c
> b/arch/x86/kernel/cpu/microcode/core.c
> index c4fa4a85d4cb..09c74b0560dd 100644
> --- a/arch/x86/kernel/cpu/microcode/core.c
> +++ b/arch/x86/kernel/cpu/microcode/core.c
> @@ -560,7 +560,7 @@ static ssize_t pf_show(struct device *dev,
> Â return sprintf(buf, "0x%x\n", uci->cpu_sig.pf);
> Â}
> Â
> -static DEVICE_ATTR(reload, 0200, NULL, reload_store);
> +static DEVICE_ATTR_WO(reload);
> Âstatic DEVICE_ATTR(version, 0400, version_show, NULL);
> Âstatic DEVICE_ATTR(processor_flags, 0400, pf_show, NULL);
> Â
> diff --git a/drivers/input/touchscreen/elants_i2c.c
> b/drivers/input/touchscreen/elants_i2c.c
> index a458e5ec9e41..819213e88f32 100644
> --- a/drivers/input/touchscreen/elants_i2c.c
> +++ b/drivers/input/touchscreen/elants_i2c.c
> @@ -1000,7 +1000,7 @@ static ssize_t show_iap_mode(struct device
> *dev,
> Â "Normal" : "Recovery");
> Â}
> Â
> -static DEVICE_ATTR(calibrate, S_IWUSR, NULL, calibrate_store);
> +static DEVICE_ATTR_WO(calibrate);
> Âstatic DEVICE_ATTR(iap_mode, S_IRUGO, show_iap_mode, NULL);
> Âstatic DEVICE_ATTR(update_fw, S_IWUSR, NULL, write_update_fw);
> Â
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c
> b/drivers/net/ethernet/ibm/ibmvnic.c
> index 1dc4aef37d3a..42b96e1a1b13 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -4411,7 +4411,7 @@ static ssize_t failover_store(struct device
> *dev, struct device_attribute *attr,
> Â return count;
> Â}
> Â
> -static DEVICE_ATTR(failover, 0200, NULL, failover_store);
> +static DEVICE_ATTR_WO(failover);
> Â
> Âstatic unsigned long ibmvnic_get_desired_dma(struct vio_dev *vdev)
> Â{
> diff --git a/drivers/net/wimax/i2400m/sysfs.c
> b/drivers/net/wimax/i2400m/sysfs.c
> index 1237109f251a..8c67df11105c 100644
> --- a/drivers/net/wimax/i2400m/sysfs.c
> +++ b/drivers/net/wimax/i2400m/sysfs.c
> @@ -65,8 +65,7 @@ ssize_t i2400m_idle_timeout_store(struct device
> *dev,
> Â}
> Â
> Âstatic
> -DEVICE_ATTR(i2400m_idle_timeout, S_IWUSR,
> - ÂÂÂÂNULL, i2400m_idle_timeout_store);
> +DEVICE_ATTR_WO(i2400m_idle_timeout);
> Â
> Âstatic
> Âstruct attribute *i2400m_dev_attrs[] = {
> diff --git a/drivers/scsi/lpfc/lpfc_attr.c
> b/drivers/scsi/lpfc/lpfc_attr.c
> index 517ff203cfde..6ddaf51a23f6 100644
> --- a/drivers/scsi/lpfc/lpfc_attr.c
> +++ b/drivers/scsi/lpfc/lpfc_attr.c
> @@ -2418,8 +2418,7 @@ lpfc_soft_wwn_enable_store(struct device *dev,
> struct device_attribute *attr,
> Â
> Â return count;
> Â}
> -static DEVICE_ATTR(lpfc_soft_wwn_enable, S_IWUSR, NULL,
> - ÂÂÂlpfc_soft_wwn_enable_store);
> +static DEVICE_ATTR_WO(lpfc_soft_wwn_enable);
> Â
> Â/**
> Â * lpfc_soft_wwpn_show - Return the cfg soft ww port name of the
> adapter
> diff --git a/drivers/thermal/thermal_sysfs.c
> b/drivers/thermal/thermal_sysfs.c
> index 2bc964392924..ba81c9080f6e 100644
> --- a/drivers/thermal/thermal_sysfs.c
> +++ b/drivers/thermal/thermal_sysfs.c
> @@ -317,7 +317,7 @@ emul_temp_store(struct device *dev, struct
> device_attribute *attr,
> Â
> Â return ret ? ret : count;
> Â}
> -static DEVICE_ATTR(emul_temp, S_IWUSR, NULL, emul_temp_store);
> +static DEVICE_ATTR_WO(emul_temp);
> Â#endif
> Â
> Âstatic ssize_t