linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/15] use permission-specific DEVICE_ATTR variants
@ 2016-10-29 19:36 Julia Lawall
  2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:36 UTC (permalink / raw)
  To: netdev
  Cc: kernel-janitors, linux-omap, alsa-devel, linuxppc-dev, linux-mips,
	linux-pm, patches, linux-kernel, linux-usb, linux-arm-kernel,
	linux-fbdev, linux-pci, linux-atm-general


Use DEVICE_ATTR_RO etc. for read only attributes etc.  This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.

The complete semantic patch is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@ro@
declarer name DEVICE_ATTR;
identifier x,x_show;
@@

DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);

@wo@
declarer name DEVICE_ATTR;
identifier x,x_store;
@@

DEVICE_ATTR(x, \(0200\|S_IWUSR\), NULL, x_store);

@rw@
declarer name DEVICE_ATTR;
identifier x,x_show,x_store;
@@

DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);

@script:ocaml@
x << ro.x;
x_show << ro.x_show;
@@

if not (x^"_show" = x_show) then Coccilib.include_match false

@script:ocaml@
x << wo.x;
x_store << wo.x_store;
@@

if not (x^"_store" = x_store) then Coccilib.include_match false

@script:ocaml@
x << rw.x;
x_show << rw.x_show;
x_store << rw.x_store;
@@

if not (x^"_show" = x_show && x^"_store" = x_store)
then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RO;
identifier ro.x,ro.x_show;
@@

- DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
+ DEVICE_ATTR_RO(x);

@@
declarer name DEVICE_ATTR_WO;
identifier wo.x,wo.x_store;
@@

- DEVICE_ATTR(x, \(0200\|S_IWUSR\), NULL, x_store);
+ DEVICE_ATTR_WO(x);

@@
declarer name DEVICE_ATTR_RW;
identifier rw.x,rw.x_show,rw.x_store;
@@

- DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);
+ DEVICE_ATTR_RW(x);
// </smpl>

---

 arch/mips/txx9/generic/7segled.c                  |    4 ++--
 arch/powerpc/kernel/iommu.c                       |    3 +--
 arch/tile/kernel/sysfs.c                          |   14 +++++++-------
 drivers/atm/solos-pci.c                           |    2 +-
 drivers/pci/pcie/aspm.c                           |    4 ++--
 drivers/power/supply/wm8350_power.c               |    2 +-
 drivers/ptp/ptp_sysfs.c                           |    2 +-
 drivers/thermal/int340x_thermal/int3400_thermal.c |    2 +-
 drivers/thermal/thermal_hwmon.c                   |    2 +-
 drivers/tty/nozomi.c                              |    4 ++--
 drivers/usb/wusbcore/dev-sysfs.c                  |    6 +++---
 drivers/usb/wusbcore/wusbhc.c                     |   13 +++++--------
 drivers/video/fbdev/wm8505fb.c                    |    2 +-
 sound/soc/omap/mcbsp.c                            |    4 ++--
 sound/soc/soc-dapm.c                              |    2 +-
 15 files changed, 31 insertions(+), 35 deletions(-)

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 03/15] wm8350_power: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:36 [PATCH 00/15] use permission-specific DEVICE_ATTR variants Julia Lawall
@ 2016-10-29 19:36 ` Julia Lawall
  2016-10-30 15:03   ` Charles Keepax
  2016-11-23 23:10   ` Sebastian Reichel
  2016-10-29 19:37 ` [PATCH 06/15] thermal: int340x_thermal: " Julia Lawall
  2016-10-29 19:37 ` [PATCH 07/15] thermal: hwmon: " Julia Lawall
  2 siblings, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:36 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: kernel-janitors, patches, linux-pm, linux-kernel

Use DEVICE_ATTR_RO for read only attributes.  This simplifies the source
code, improves readbility, and reduces the chance of inconsistencies.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@ro@
declarer name DEVICE_ATTR;
identifier x,x_show;
@@

DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);

@script:ocaml@
x << ro.x;
x_show << ro.x_show;
@@

if not (x^"_show" = x_show) then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RO;
identifier ro.x,ro.x_show;
@@

- DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
+ DEVICE_ATTR_RO(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/power/supply/wm8350_power.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/power/supply/wm8350_power.c b/drivers/power/supply/wm8350_power.c
index 5c58806..a2740cf 100644
--- a/drivers/power/supply/wm8350_power.c
+++ b/drivers/power/supply/wm8350_power.c
@@ -182,7 +182,7 @@ static ssize_t charger_state_show(struct device *dev,
 	return sprintf(buf, "%s\n", charge);
 }
 
-static DEVICE_ATTR(charger_state, 0444, charger_state_show, NULL);
+static DEVICE_ATTR_RO(charger_state);
 
 static irqreturn_t wm8350_charger_handler(int irq, void *data)
 {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 06/15] thermal: int340x_thermal: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:36 [PATCH 00/15] use permission-specific DEVICE_ATTR variants Julia Lawall
  2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
@ 2016-10-29 19:37 ` Julia Lawall
  2016-10-29 19:37 ` [PATCH 07/15] thermal: hwmon: " Julia Lawall
  2 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:37 UTC (permalink / raw)
  To: Zhang Rui; +Cc: kernel-janitors, Eduardo Valentin, linux-pm, linux-kernel

Use DEVICE_ATTR_RW for read-write attributes.  This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@rw@
declarer name DEVICE_ATTR;
identifier x,x_show,x_store;
@@

DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);

@script:ocaml@
x << rw.x;
x_show << rw.x_show;
x_store << rw.x_store;
@@

if not (x^"_show" = x_show && x^"_store" = x_store)
then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RW;
identifier rw.x,rw.x_show,rw.x_store;
@@

- DEVICE_ATTR(x, \(0644\|S_IRUGO|S_IWUSR\), x_show, x_store);
+ DEVICE_ATTR_RW(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/thermal/int340x_thermal/int3400_thermal.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/int340x_thermal/int3400_thermal.c b/drivers/thermal/int340x_thermal/int3400_thermal.c
index 5836e55..9413c4a 100644
--- a/drivers/thermal/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/int340x_thermal/int3400_thermal.c
@@ -96,7 +96,7 @@ static ssize_t current_uuid_store(struct device *dev,
 	return -EINVAL;
 }
 
-static DEVICE_ATTR(current_uuid, 0644, current_uuid_show, current_uuid_store);
+static DEVICE_ATTR_RW(current_uuid);
 static DEVICE_ATTR_RO(available_uuids);
 static struct attribute *uuid_attrs[] = {
 	&dev_attr_available_uuids.attr,

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 07/15] thermal: hwmon: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:36 [PATCH 00/15] use permission-specific DEVICE_ATTR variants Julia Lawall
  2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
  2016-10-29 19:37 ` [PATCH 06/15] thermal: int340x_thermal: " Julia Lawall
@ 2016-10-29 19:37 ` Julia Lawall
  2 siblings, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:37 UTC (permalink / raw)
  To: Zhang Rui; +Cc: kernel-janitors, Eduardo Valentin, linux-pm, linux-kernel

Use DEVICE_ATTR_RO for read only attributes.  This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@ro@
declarer name DEVICE_ATTR;
identifier x,x_show;
@@

DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);

@script:ocaml@
x << ro.x;
x_show << ro.x_show;
@@

if not (x^"_show" = x_show) then Coccilib.include_match false

@@
declarer name DEVICE_ATTR_RO;
identifier ro.x,ro.x_show;
@@

- DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
+ DEVICE_ATTR_RO(x);
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 drivers/thermal/thermal_hwmon.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index c41c774..8c45de6 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -64,7 +64,7 @@ struct thermal_hwmon_temp {
 	struct thermal_hwmon_device *hwmon = dev_get_drvdata(dev);
 	return sprintf(buf, "%s\n", hwmon->type);
 }
-static DEVICE_ATTR(name, 0444, name_show, NULL);
+static DEVICE_ATTR_RO(name);
 
 static ssize_t
 temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 03/15] wm8350_power: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
@ 2016-10-30 15:03   ` Charles Keepax
  2016-11-23 23:10   ` Sebastian Reichel
  1 sibling, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2016-10-30 15:03 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Sebastian Reichel, kernel-janitors, patches, linux-pm,
	linux-kernel

On Sat, Oct 29, 2016 at 09:36:57PM +0200, Julia Lawall wrote:
> Use DEVICE_ATTR_RO for read only attributes.  This simplifies the source
> code, improves readbility, and reduces the chance of inconsistencies.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @ro@
> declarer name DEVICE_ATTR;
> identifier x,x_show;
> @@
> 
> DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
> 
> @script:ocaml@
> x << ro.x;
> x_show << ro.x_show;
> @@
> 
> if not (x^"_show" = x_show) then Coccilib.include_match false
> 
> @@
> declarer name DEVICE_ATTR_RO;
> identifier ro.x,ro.x_show;
> @@
> 
> - DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
> + DEVICE_ATTR_RO(x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---

Acked-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> 

Thanks,
Charles

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 03/15] wm8350_power: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
  2016-10-30 15:03   ` Charles Keepax
@ 2016-11-23 23:10   ` Sebastian Reichel
  1 sibling, 0 replies; 6+ messages in thread
From: Sebastian Reichel @ 2016-11-23 23:10 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kernel-janitors, patches, linux-pm, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

Hi Julia,

On Sat, Oct 29, 2016 at 09:36:57PM +0200, Julia Lawall wrote:
> Use DEVICE_ATTR_RO for read only attributes.  This simplifies the source
> code, improves readbility, and reduces the chance of inconsistencies.
> 
> The semantic patch that makes this change is as follows:
> (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @ro@
> declarer name DEVICE_ATTR;
> identifier x,x_show;
> @@
> 
> DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
> 
> @script:ocaml@
> x << ro.x;
> x_show << ro.x_show;
> @@
> 
> if not (x^"_show" = x_show) then Coccilib.include_match false
> 
> @@
> declarer name DEVICE_ATTR_RO;
> identifier ro.x,ro.x_show;
> @@
> 
> - DEVICE_ATTR(x, \(0444\|S_IRUGO\), x_show, NULL);
> + DEVICE_ATTR_RO(x);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
> 
> ---
>  drivers/power/supply/wm8350_power.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, queued.

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-11-23 23:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-29 19:36 [PATCH 00/15] use permission-specific DEVICE_ATTR variants Julia Lawall
2016-10-29 19:36 ` [PATCH 03/15] wm8350_power: " Julia Lawall
2016-10-30 15:03   ` Charles Keepax
2016-11-23 23:10   ` Sebastian Reichel
2016-10-29 19:37 ` [PATCH 06/15] thermal: int340x_thermal: " Julia Lawall
2016-10-29 19:37 ` [PATCH 07/15] thermal: hwmon: " Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).