Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

wusbcore: wusbhc: use permission-specific DEVICE_ATTR variants

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Julia Lawall and committed by
Greg Kroah-Hartman
42cda7d8 4d055647

+5 -8
+5 -8
drivers/usb/wusbcore/wusbhc.c
··· 84 84 out: 85 85 return result < 0 ? result : size; 86 86 } 87 - static DEVICE_ATTR(wusb_trust_timeout, 0644, wusb_trust_timeout_show, 88 - wusb_trust_timeout_store); 87 + static DEVICE_ATTR_RW(wusb_trust_timeout); 89 88 90 89 /* 91 90 * Show the current WUSB CHID. ··· 144 145 result = wusbhc_chid_set(wusbhc, &chid); 145 146 return result < 0 ? result : size; 146 147 } 147 - static DEVICE_ATTR(wusb_chid, 0644, wusb_chid_show, wusb_chid_store); 148 + static DEVICE_ATTR_RW(wusb_chid); 148 149 149 150 150 151 static ssize_t wusb_phy_rate_show(struct device *dev, ··· 173 174 wusbhc->phy_rate = phy_rate; 174 175 return size; 175 176 } 176 - static DEVICE_ATTR(wusb_phy_rate, 0644, wusb_phy_rate_show, 177 - wusb_phy_rate_store); 177 + static DEVICE_ATTR_RW(wusb_phy_rate); 178 178 179 179 static ssize_t wusb_dnts_show(struct device *dev, 180 180 struct device_attribute *attr, ··· 203 205 204 206 return size; 205 207 } 206 - static DEVICE_ATTR(wusb_dnts, 0644, wusb_dnts_show, wusb_dnts_store); 208 + static DEVICE_ATTR_RW(wusb_dnts); 207 209 208 210 static ssize_t wusb_retry_count_show(struct device *dev, 209 211 struct device_attribute *attr, ··· 232 234 233 235 return size; 234 236 } 235 - static DEVICE_ATTR(wusb_retry_count, 0644, wusb_retry_count_show, 236 - wusb_retry_count_store); 237 + static DEVICE_ATTR_RW(wusb_retry_count); 237 238 238 239 /* Group all the WUSBHC attributes */ 239 240 static struct attribute *wusbhc_attrs[] = {