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

USB: move many drivers to use DEVICE_ATTR_RO

Instead of "open coding" a DEVICE_ATTR() define, use the
DEVICE_ATTR_RO() macro instead, which does everything properly instead.

This does require a few static functions to be renamed to work properly,
but thanks to a script from Joe Perches, this was easily done.

Reported-by: Joe Perches <joe@perches.com>
Cc: Matthieu CASTET <castet.matthieu@free.fr>
Cc: Stanislaw Gruszka <stf_xl@wp.pl>
Cc: Oliver Neukum <oneukum@suse.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Acked-by: Pete Zaitcev <zaitcev@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+18 -18
+4 -4
drivers/usb/atm/ueagle-atm.c
··· 2315 2315 2316 2316 static DEVICE_ATTR_RW(stat_status); 2317 2317 2318 - static ssize_t read_human_status(struct device *dev, 2318 + static ssize_t stat_human_status_show(struct device *dev, 2319 2319 struct device_attribute *attr, char *buf) 2320 2320 { 2321 2321 int ret = -ENODEV; ··· 2376 2376 return ret; 2377 2377 } 2378 2378 2379 - static DEVICE_ATTR(stat_human_status, S_IRUGO, read_human_status, NULL); 2379 + static DEVICE_ATTR_RO(stat_human_status); 2380 2380 2381 - static ssize_t read_delin(struct device *dev, struct device_attribute *attr, 2381 + static ssize_t stat_delin_show(struct device *dev, struct device_attribute *attr, 2382 2382 char *buf) 2383 2383 { 2384 2384 int ret = -ENODEV; ··· 2408 2408 return ret; 2409 2409 } 2410 2410 2411 - static DEVICE_ATTR(stat_delin, S_IRUGO, read_delin, NULL); 2411 + static DEVICE_ATTR_RO(stat_delin); 2412 2412 2413 2413 #define UEA_ATTR(name, reset) \ 2414 2414 \
+6 -6
drivers/usb/class/cdc-acm.c
··· 235 235 /* 236 236 * attributes exported through sysfs 237 237 */ 238 - static ssize_t show_caps 238 + static ssize_t bmCapabilities_show 239 239 (struct device *dev, struct device_attribute *attr, char *buf) 240 240 { 241 241 struct usb_interface *intf = to_usb_interface(dev); ··· 243 243 244 244 return sprintf(buf, "%d", acm->ctrl_caps); 245 245 } 246 - static DEVICE_ATTR(bmCapabilities, S_IRUGO, show_caps, NULL); 246 + static DEVICE_ATTR_RO(bmCapabilities); 247 247 248 - static ssize_t show_country_codes 248 + static ssize_t wCountryCodes_show 249 249 (struct device *dev, struct device_attribute *attr, char *buf) 250 250 { 251 251 struct usb_interface *intf = to_usb_interface(dev); ··· 255 255 return acm->country_code_size; 256 256 } 257 257 258 - static DEVICE_ATTR(wCountryCodes, S_IRUGO, show_country_codes, NULL); 258 + static DEVICE_ATTR_RO(wCountryCodes); 259 259 260 - static ssize_t show_country_rel_date 260 + static ssize_t iCountryCodeRelDate_show 261 261 (struct device *dev, struct device_attribute *attr, char *buf) 262 262 { 263 263 struct usb_interface *intf = to_usb_interface(dev); ··· 266 266 return sprintf(buf, "%d", acm->country_rel_date); 267 267 } 268 268 269 - static DEVICE_ATTR(iCountryCodeRelDate, S_IRUGO, show_country_rel_date, NULL); 269 + static DEVICE_ATTR_RO(iCountryCodeRelDate); 270 270 /* 271 271 * Interrupt handlers for various ACM device responses 272 272 */
+2 -2
drivers/usb/class/usblp.c
··· 1066 1066 .minor_base = USBLP_MINOR_BASE, 1067 1067 }; 1068 1068 1069 - static ssize_t usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf) 1069 + static ssize_t ieee1284_id_show(struct device *dev, struct device_attribute *attr, char *buf) 1070 1070 { 1071 1071 struct usb_interface *intf = to_usb_interface(dev); 1072 1072 struct usblp *usblp = usb_get_intfdata(intf); ··· 1078 1078 return sprintf(buf, "%s", usblp->device_id_string+2); 1079 1079 } 1080 1080 1081 - static DEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NULL); 1081 + static DEVICE_ATTR_RO(ieee1284_id); 1082 1082 1083 1083 static int usblp_probe(struct usb_interface *intf, 1084 1084 const struct usb_device_id *id)
+2 -2
drivers/usb/phy/phy-tahvo.c
··· 59 59 EXTCON_NONE, 60 60 }; 61 61 62 - static ssize_t vbus_state_show(struct device *device, 62 + static ssize_t vbus_show(struct device *device, 63 63 struct device_attribute *attr, char *buf) 64 64 { 65 65 struct tahvo_usb *tu = dev_get_drvdata(device); 66 66 return sprintf(buf, "%s\n", tu->vbus_state ? "on" : "off"); 67 67 } 68 - static DEVICE_ATTR(vbus, 0444, vbus_state_show, NULL); 68 + static DEVICE_ATTR_RO(vbus); 69 69 70 70 static void check_vbus_state(struct tahvo_usb *tu) 71 71 {
+2 -2
drivers/usb/phy/phy-twl6030-usb.c
··· 168 168 return 0; 169 169 } 170 170 171 - static ssize_t twl6030_usb_vbus_show(struct device *dev, 171 + static ssize_t vbus_show(struct device *dev, 172 172 struct device_attribute *attr, char *buf) 173 173 { 174 174 struct twl6030_usb *twl = dev_get_drvdata(dev); ··· 194 194 195 195 return ret; 196 196 } 197 - static DEVICE_ATTR(vbus, 0444, twl6030_usb_vbus_show, NULL); 197 + static DEVICE_ATTR_RO(vbus); 198 198 199 199 static irqreturn_t twl6030_usb_irq(int irq, void *_twl) 200 200 {
+2 -2
drivers/usb/storage/sierra_ms.c
··· 90 90 } 91 91 92 92 93 - static ssize_t show_truinst(struct device *dev, struct device_attribute *attr, 93 + static ssize_t truinst_show(struct device *dev, struct device_attribute *attr, 94 94 char *buf) 95 95 { 96 96 struct swoc_info *swocInfo; ··· 122 122 } 123 123 return result; 124 124 } 125 - static DEVICE_ATTR(truinst, S_IRUGO, show_truinst, NULL); 125 + static DEVICE_ATTR_RO(truinst); 126 126 127 127 int sierra_ms_init(struct us_data *us) 128 128 {