linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/66] use permission-specific DEVICE_ATTR variants
@ 2016-12-22 12:04 Julia Lawall
  2016-12-22 12:04 ` [PATCH 01/66] hwmon: (adm1021) " Julia Lawall
                   ` (66 more replies)
  0 siblings, 67 replies; 71+ messages in thread
From: Julia Lawall @ 2016-12-22 12:04 UTC (permalink / raw)
  To: linux-kernel; +Cc: kernel-janitors, linux-hwmon, Jean Delvare, Guenter Roeck

Use DEVICE_ATTR_RO etc. for read only attributes etc.  This simplifies the
source code, improves readbility, and reduces the chance of
inconsistencies.  A previous version of this semantic patch transformed
only cases where the show and store functions followed particular naming
conventions.  This semantic patch additionally renames functions as
needed.  It can, however, fail to transform some occurrences where a single
function is used for multiple attributes.  In that case, the first case is
transformed an the others are left as is.

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

// <smpl>
@initialize:ocaml@
@@

let taken = Hashtbl.create 101

// -------------------------------------------------------------------------
// Easy case

@d@
declarer name DEVICE_ATTR;
identifier x;
@@

DEVICE_ATTR(x,...);

@script:ocaml depends on d@
@@

Hashtbl.clear taken

@script:ocaml expected@
x << d.x;
x_show;
x_store;
@@
x_show := make_ident (x^"_show");
x_store := make_ident (x^"_store")

@@
declarer name DEVICE_ATTR_RO;
identifier d.x,expected.x_show;
@@

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

@@
declarer name DEVICE_ATTR_WO;
identifier d.x,expected.x_store;
@@

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

@@
declarer name DEVICE_ATTR_RW;
identifier d.x,expected.x_show,expected.x_store;
@@

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

// -------------------------------------------------------------------------
// Other calls

@o@
declarer name DEVICE_ATTR;
identifier d.x,show,store;
@@

DEVICE_ATTR(x,\(0444\|S_IRUGO\|0200\|S_IWUSR\|0644\|S_IRUGO|S_IWUSR\),
            show,store);

@script:ocaml@
x << d.x;
show << o.show;
store << o.store;
@@

if (not(show = "NULL") && Hashtbl.mem taken show) ||
   (not(store = "NULL") && Hashtbl.mem taken store)
then Coccilib.include_match false
else (Hashtbl.add taken show (); Hashtbl.add taken store ())

// rename functions

@show1@
identifier o.show,expected.x_show;
parameter list ps;
@@

static
- show(ps)
+ x_show(ps)
  { ... }

@depends on show1@
identifier o.show,expected.x_show;
expression list es;
@@
- show(es)
+ x_show(es)

@depends on show1@
identifier o.show,expected.x_show;
@@
- show
+ x_show

@store1@
identifier o.store,expected.x_store;
parameter list ps;
@@

static
- store(ps)
+ x_store(ps)
  { ... }

@depends on store1@
identifier o.store,expected.x_store;
expression list es;
@@
- store(es)
+ x_store(es)

@depends on store1@
identifier o.store,expected.x_store;
@@
- store
+ x_store

// try again

@@
declarer name DEVICE_ATTR_RO;
identifier d.x,expected.x_show;
@@

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

@@
declarer name DEVICE_ATTR_WO;
identifier d.x,expected.x_store;
@@

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

@@
declarer name DEVICE_ATTR_RW;
identifier d.x,expected.x_show,expected.x_store;
@@

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

---

 drivers/hwmon/adm1021.c      |   14 ++--
 drivers/hwmon/adm1025.c      |   16 ++---
 drivers/hwmon/adm1026.c      |  128 ++++++++++++++++++++++---------------------
 drivers/hwmon/adm1031.c      |   15 ++---
 drivers/hwmon/adm9240.c      |   28 ++++-----
 drivers/hwmon/adt7470.c      |   48 +++++++---------
 drivers/hwmon/adt7475.c      |   28 ++++-----
 drivers/hwmon/adt7x10.c      |    7 +-
 drivers/hwmon/asb100.c       |   36 ++++++------
 drivers/hwmon/atxp1.c        |   35 +++++------
 drivers/hwmon/dme1737.c      |   18 +++---
 drivers/hwmon/ds1621.c       |   16 ++---
 drivers/hwmon/emc2103.c      |   36 ++++++------
 drivers/hwmon/f71805f.c      |   16 ++---
 drivers/hwmon/f71882fg.c     |    6 +-
 drivers/hwmon/fam15h_power.c |   34 +++++------
 drivers/hwmon/fschmd.c       |    6 +-
 drivers/hwmon/g760a.c        |   22 +++----
 drivers/hwmon/g762.c         |   86 ++++++++++++++--------------
 drivers/hwmon/gl520sm.c      |   48 ++++++++--------
 drivers/hwmon/gpio-fan.c     |   54 +++++++++---------
 drivers/hwmon/hwmon.c        |    4 -
 drivers/hwmon/i5500_temp.c   |    6 +-
 drivers/hwmon/i5k_amb.c      |    4 -
 drivers/hwmon/it87.c         |   20 +++---
 drivers/hwmon/jz4740-hwmon.c |    6 +-
 drivers/hwmon/k10temp.c      |   12 ++--
 drivers/hwmon/k8temp.c       |    4 -
 drivers/hwmon/lm63.c         |   48 +++++++---------
 drivers/hwmon/lm70.c         |    6 +-
 drivers/hwmon/lm78.c         |   38 ++++++------
 drivers/hwmon/lm80.c         |    4 -
 drivers/hwmon/lm83.c         |    4 -
 drivers/hwmon/lm85.c         |   22 +++----
 drivers/hwmon/lm87.c         |   43 +++++++-------
 drivers/hwmon/lm90.c         |    8 +-
 drivers/hwmon/lm92.c         |   10 +--
 drivers/hwmon/lm93.c         |   39 +++++--------
 drivers/hwmon/lm95234.c      |   12 ++--
 drivers/hwmon/max1111.c      |    4 -
 drivers/hwmon/max1619.c      |    4 -
 drivers/hwmon/max197.c       |    6 +-
 drivers/hwmon/max6650.c      |   44 ++++++++------
 drivers/hwmon/mc13783-adc.c  |    6 +-
 drivers/hwmon/mcp3021.c      |    6 +-
 drivers/hwmon/nct6683.c      |   17 ++---
 drivers/hwmon/nct6775.c      |    4 -
 drivers/hwmon/nsa320-hwmon.c |   12 ++--
 drivers/hwmon/pc87360.c      |   26 ++++----
 drivers/hwmon/pc87427.c      |    4 -
 drivers/hwmon/pcf8591.c      |   24 +++-----
 drivers/hwmon/sch5627.c      |    4 -
 drivers/hwmon/sht15.c        |    4 -
 drivers/hwmon/sis5595.c      |   36 ++++++------
 drivers/hwmon/smsc47m1.c     |   10 +--
 drivers/hwmon/smsc47m192.c   |   14 ++--
 drivers/hwmon/tmp401.c       |   11 +--
 drivers/hwmon/via-cputemp.c  |    6 +-
 drivers/hwmon/via686a.c      |    8 +-
 drivers/hwmon/vt8231.c       |   59 ++++++++++---------
 drivers/hwmon/w83627ehf.c    |    8 +-
 drivers/hwmon/w83627hf.c     |   53 +++++++++--------
 drivers/hwmon/w83781d.c      |   34 +++++------
 drivers/hwmon/w83791d.c      |   23 +++----
 drivers/hwmon/w83792d.c      |   15 ++---
 drivers/hwmon/w83793.c       |    6 +-
 66 files changed, 709 insertions(+), 726 deletions(-)

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

end of thread, other threads:[~2016-12-23 13:04 UTC | newest]

Thread overview: 71+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-22 12:04 [PATCH 00/66] use permission-specific DEVICE_ATTR variants Julia Lawall
2016-12-22 12:04 ` [PATCH 01/66] hwmon: (adm1021) " Julia Lawall
2016-12-22 12:04 ` [PATCH 02/66] hwmon: (adm1026) " Julia Lawall
2016-12-22 12:04 ` [PATCH 03/66] hwmon: (adm1031) " Julia Lawall
2016-12-22 12:04 ` [PATCH 04/66] hwmon: (adm9240) " Julia Lawall
2016-12-22 12:04 ` [PATCH 05/66] hwmon: (adt7470) " Julia Lawall
2016-12-22 12:04 ` [PATCH 06/66] hwmon: (adt7x10) " Julia Lawall
2016-12-22 12:04 ` [PATCH 07/66] hwmon: (asb100) " Julia Lawall
2016-12-22 12:04 ` [PATCH 08/66] hwmon: (atxp1) " Julia Lawall
2016-12-22 12:04 ` [PATCH 09/66] hwmon: (ds1621) " Julia Lawall
2016-12-22 12:04 ` [PATCH 10/66] hwmon: (f71882fg) " Julia Lawall
2016-12-22 12:04 ` [PATCH 11/66] hwmon: (fschmd) " Julia Lawall
2016-12-22 12:04 ` [PATCH 12/66] hwmon: (g760a) " Julia Lawall
2016-12-22 12:04 ` [PATCH 13/66] hwmon: (g762) " Julia Lawall
2016-12-22 12:04 ` [PATCH 14/66] hwmon: (gl520sm) " Julia Lawall
2016-12-22 12:04 ` [PATCH 15/66] hwmon: (gpio-fan) " Julia Lawall
2016-12-22 12:04 ` [PATCH 16/66] hwmon: (core) " Julia Lawall
2016-12-22 12:04 ` [PATCH 17/66] hwmon: (i5500_temp) " Julia Lawall
2016-12-22 12:04 ` [PATCH 18/66] hwmon: (i5k_amb) " Julia Lawall
2016-12-22 12:04 ` [PATCH 19/66] hwmon: (jz4740) " Julia Lawall
2016-12-22 12:04 ` [PATCH 20/66] hwmon: (lm63) " Julia Lawall
2016-12-22 12:04 ` [PATCH 21/66] hwmon: (lm70) " Julia Lawall
2016-12-22 12:04 ` [PATCH 22/66] hwmon: (lm80) " Julia Lawall
2016-12-22 12:04 ` [PATCH 23/66] hwmon: (lm85) " Julia Lawall
2016-12-22 12:04 ` [PATCH 24/66] hwmon: (lm87) " Julia Lawall
2016-12-22 12:04 ` [PATCH 25/66] hwmon: (lm92) " Julia Lawall
2016-12-22 12:04 ` [PATCH 26/66] hwmon: (lm93) " Julia Lawall
2016-12-22 12:04 ` [PATCH 27/66] hwmon: (max1111) " Julia Lawall
2016-12-22 12:04 ` [PATCH 28/66] hwmon: (max1619) " Julia Lawall
2016-12-22 12:04 ` [PATCH 29/66] hwmon: (max197) " Julia Lawall
2016-12-22 12:04 ` [PATCH 30/66] hwmon: (mc13783-adc) " Julia Lawall
2016-12-22 12:05 ` [PATCH 31/66] hwmon: (mcp3021) " Julia Lawall
2016-12-22 12:05 ` [PATCH 32/66] hwmon: (nct6683) " Julia Lawall
2016-12-22 12:05 ` [PATCH 33/66] hwmon: (nsa320) " Julia Lawall
2016-12-22 12:05 ` [PATCH 34/66] hwmon: (pcf8591) " Julia Lawall
2016-12-22 12:05 ` [PATCH 35/66] hwmon: (sht15) " Julia Lawall
2016-12-22 12:05 ` [PATCH 36/66] hwmon: (sis5595) " Julia Lawall
2016-12-22 12:05 ` [PATCH 37/66] hwmon: (smsc47m1) " Julia Lawall
2016-12-22 12:05 ` [PATCH 38/66] hwmon: (smsc47m192) " Julia Lawall
2016-12-22 12:05 ` [PATCH 39/66] hwmon: (via-cputemp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 40/66] hwmon: (via686a) " Julia Lawall
2016-12-22 12:05 ` [PATCH 41/66] hwmon: (w83627ehf) " Julia Lawall
2016-12-22 12:05 ` [PATCH 42/66] hwmon: (w83627hf) " Julia Lawall
2016-12-22 12:05 ` [PATCH 43/66] hwmon: (w83781d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 44/66] hwmon: (w83792d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 45/66] hwmon: (w83791d) " Julia Lawall
2016-12-22 12:05 ` [PATCH 46/66] hwmon: (pc87427) " Julia Lawall
2016-12-22 12:05 ` [PATCH 47/66] hwmon: (f71805f) " Julia Lawall
2016-12-22 12:05 ` [PATCH 48/66] hwmon: (w83793) " Julia Lawall
2016-12-22 12:05 ` [PATCH 49/66] hwmon: (vt8231) " Julia Lawall
2016-12-22 12:05 ` [PATCH 50/66] hwmon: (k10temp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 51/66] hwmon: (dme1737) " Julia Lawall
2016-12-22 12:05 ` [PATCH 52/66] hwmon: (it87) " Julia Lawall
2016-12-22 12:05 ` [PATCH 53/66] hwmon: (lm90) " Julia Lawall
2016-12-22 12:05 ` [PATCH 54/66] hwmon: (nct6775) " Julia Lawall
2016-12-22 12:05 ` [PATCH 55/66] hwmon: (pc87360) " Julia Lawall
2016-12-22 12:05 ` [PATCH 56/66] hwmon: (lm78) " Julia Lawall
2016-12-22 12:05 ` [PATCH 57/66] hwmon: (sch5627) " Julia Lawall
2016-12-22 12:05 ` [PATCH 58/66] hwmon: (k8temp) " Julia Lawall
2016-12-22 12:05 ` [PATCH 59/66] hwmon: (adm1025) " Julia Lawall
2016-12-22 12:05 ` [PATCH 60/66] hwmon: (lm83) " Julia Lawall
2016-12-22 12:05 ` [PATCH 61/66] hwmon: (emc2103) " Julia Lawall
2016-12-22 12:05 ` [PATCH 62/66] hwmon: (max6650) " Julia Lawall
2016-12-22 12:05 ` [PATCH 63/66] hwmon: (lm95234) " Julia Lawall
2016-12-22 12:05 ` [PATCH 64/66] hwmon: (adt7475) " Julia Lawall
2016-12-22 12:05 ` [PATCH 65/66] hwmon: (fam15h_power) " Julia Lawall
2016-12-23  3:23   ` Huang Rui
2016-12-22 12:05 ` [PATCH 66/66] hwmon: (tmp401) " Julia Lawall
2016-12-23  2:38 ` [PATCH 00/66] " Guenter Roeck
2016-12-23  6:39   ` Julia Lawall
2016-12-23 13:03   ` 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).