diff options
author | Julia Lawall <Julia.Lawall@lip6.fr> | 2016-10-29 15:36:55 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-07 04:19:49 -0500 |
commit | 4d055647509402b0cfbd41cd69b3ce3a6b7c7efc (patch) | |
tree | d9dd85643238f2a469697bde20cda868456848d1 /drivers/usb/wusbcore/dev-sysfs.c | |
parent | d79cda045e3bacb7e754a5324cd3d4ce80708eb1 (diff) |
wusbcore: dev-sysfs: use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_WO for write ony attributes and DEVICE_ATTR_RO for read
only attributes. This simplifies the source code, improves readbility,
and reduces the chance of inconsistencies.
The semantic patch for the RO case 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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/wusbcore/dev-sysfs.c')
-rw-r--r-- | drivers/usb/wusbcore/dev-sysfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/usb/wusbcore/dev-sysfs.c b/drivers/usb/wusbcore/dev-sysfs.c index 415b14002a61..d4de56b93d68 100644 --- a/drivers/usb/wusbcore/dev-sysfs.c +++ b/drivers/usb/wusbcore/dev-sysfs.c | |||
@@ -53,7 +53,7 @@ static ssize_t wusb_disconnect_store(struct device *dev, | |||
53 | wusbhc_put(wusbhc); | 53 | wusbhc_put(wusbhc); |
54 | return size; | 54 | return size; |
55 | } | 55 | } |
56 | static DEVICE_ATTR(wusb_disconnect, 0200, NULL, wusb_disconnect_store); | 56 | static DEVICE_ATTR_WO(wusb_disconnect); |
57 | 57 | ||
58 | static ssize_t wusb_cdid_show(struct device *dev, | 58 | static ssize_t wusb_cdid_show(struct device *dev, |
59 | struct device_attribute *attr, char *buf) | 59 | struct device_attribute *attr, char *buf) |
@@ -69,7 +69,7 @@ static ssize_t wusb_cdid_show(struct device *dev, | |||
69 | wusb_dev_put(wusb_dev); | 69 | wusb_dev_put(wusb_dev); |
70 | return result + 1; | 70 | return result + 1; |
71 | } | 71 | } |
72 | static DEVICE_ATTR(wusb_cdid, 0444, wusb_cdid_show, NULL); | 72 | static DEVICE_ATTR_RO(wusb_cdid); |
73 | 73 | ||
74 | static ssize_t wusb_ck_store(struct device *dev, | 74 | static ssize_t wusb_ck_store(struct device *dev, |
75 | struct device_attribute *attr, | 75 | struct device_attribute *attr, |
@@ -105,7 +105,7 @@ static ssize_t wusb_ck_store(struct device *dev, | |||
105 | wusbhc_put(wusbhc); | 105 | wusbhc_put(wusbhc); |
106 | return result < 0 ? result : size; | 106 | return result < 0 ? result : size; |
107 | } | 107 | } |
108 | static DEVICE_ATTR(wusb_ck, 0200, NULL, wusb_ck_store); | 108 | static DEVICE_ATTR_WO(wusb_ck); |
109 | 109 | ||
110 | static struct attribute *wusb_dev_attrs[] = { | 110 | static struct attribute *wusb_dev_attrs[] = { |
111 | &dev_attr_wusb_disconnect.attr, | 111 | &dev_attr_wusb_disconnect.attr, |