netdev.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:37 ` [PATCH 12/15] ptp: " Julia Lawall
  2016-10-29 19:37 ` [PATCH 15/15] solos-pci: " Julia Lawall
  0 siblings, 2 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 12/15] ptp: 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:37 ` Julia Lawall
  2016-10-31  9:30   ` Richard Cochran
  2016-10-31 19:32   ` David Miller
  2016-10-29 19:37 ` [PATCH 15/15] solos-pci: " Julia Lawall
  1 sibling, 2 replies; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:37 UTC (permalink / raw)
  To: Richard Cochran; +Cc: kernel-janitors, netdev, 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/ptp/ptp_sysfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ptp/ptp_sysfs.c b/drivers/ptp/ptp_sysfs.c
index 302e626..53d4395 100644
--- a/drivers/ptp/ptp_sysfs.c
+++ b/drivers/ptp/ptp_sysfs.c
@@ -28,7 +28,7 @@ static ssize_t clock_name_show(struct device *dev,
 	struct ptp_clock *ptp = dev_get_drvdata(dev);
 	return snprintf(page, PAGE_SIZE-1, "%s\n", ptp->info->name);
 }
-static DEVICE_ATTR(clock_name, 0444, clock_name_show, NULL);
+static DEVICE_ATTR_RO(clock_name);
 
 #define PTP_SHOW_INT(name, var)						\
 static ssize_t var##_show(struct device *dev,				\

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

* [PATCH 15/15] solos-pci: 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:37 ` [PATCH 12/15] ptp: " Julia Lawall
@ 2016-10-29 19:37 ` Julia Lawall
  2016-10-31 19:32   ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Julia Lawall @ 2016-10-29 19:37 UTC (permalink / raw)
  To: Chas Williams; +Cc: kernel-janitors, linux-atm-general, netdev, 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/atm/solos-pci.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
index 6ac2b2b..5ad037c 100644
--- a/drivers/atm/solos-pci.c
+++ b/drivers/atm/solos-pci.c
@@ -584,7 +584,7 @@ static ssize_t hardware_show(struct device *dev, struct device_attribute *attr,
 	return sprintf(buf, "%d\n", data32);
 }
 
-static DEVICE_ATTR(console, 0644, console_show, console_store);
+static DEVICE_ATTR_RW(console);
 
 
 #define SOLOS_ATTR_RO(x) static DEVICE_ATTR(x, 0444, solos_param_show, NULL);

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

* Re: [PATCH 12/15] ptp: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:37 ` [PATCH 12/15] ptp: " Julia Lawall
@ 2016-10-31  9:30   ` Richard Cochran
  2016-10-31 19:32   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: Richard Cochran @ 2016-10-31  9:30 UTC (permalink / raw)
  To: Julia Lawall; +Cc: kernel-janitors, netdev, linux-kernel

On Sat, Oct 29, 2016 at 09:37:06PM +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.

Acked-by: Richard Cochran <richardcochran@gmail.com>

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

* Re: [PATCH 15/15] solos-pci: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:37 ` [PATCH 15/15] solos-pci: " Julia Lawall
@ 2016-10-31 19:32   ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2016-10-31 19:32 UTC (permalink / raw)
  To: Julia.Lawall
  Cc: 3chas3, kernel-janitors, linux-atm-general, netdev, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sat, 29 Oct 2016 21:37:09 +0200

> 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/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Applied to net-next.

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

* Re: [PATCH 12/15] ptp: use permission-specific DEVICE_ATTR variants
  2016-10-29 19:37 ` [PATCH 12/15] ptp: " Julia Lawall
  2016-10-31  9:30   ` Richard Cochran
@ 2016-10-31 19:32   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2016-10-31 19:32 UTC (permalink / raw)
  To: Julia.Lawall; +Cc: richardcochran, kernel-janitors, netdev, linux-kernel

From: Julia Lawall <Julia.Lawall@lip6.fr>
Date: Sat, 29 Oct 2016 21:37:06 +0200

> 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/)
 ...
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Also applied to net-next, thank you.

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

end of thread, other threads:[~2016-10-31 19:32 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:37 ` [PATCH 12/15] ptp: " Julia Lawall
2016-10-31  9:30   ` Richard Cochran
2016-10-31 19:32   ` David Miller
2016-10-29 19:37 ` [PATCH 15/15] solos-pci: " Julia Lawall
2016-10-31 19:32   ` David Miller

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).