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

USB: lvstest: convert to use dev_groups

USB drivers now support the ability for the driver core to handle the
creation and removal of device-specific sysfs files in a race-free
manner. Take advantage of that by converting the driver to use this by
moving the sysfs attributes into a group and assigning the dev_groups
pointer to it.

Link: https://lore.kernel.org/r/20190806144502.17792-10-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+4 -15
+4 -15
drivers/usb/misc/lvstest.c
··· 310 310 } 311 311 static DEVICE_ATTR_WO(enable_compliance); 312 312 313 - static struct attribute *lvs_attributes[] = { 313 + static struct attribute *lvs_attrs[] = { 314 314 &dev_attr_get_dev_desc.attr, 315 315 &dev_attr_u1_timeout.attr, 316 316 &dev_attr_u2_timeout.attr, ··· 321 321 &dev_attr_enable_compliance.attr, 322 322 NULL 323 323 }; 324 - 325 - static const struct attribute_group lvs_attr_group = { 326 - .attrs = lvs_attributes, 327 - }; 324 + ATTRIBUTE_GROUPS(lvs); 328 325 329 326 static void lvs_rh_work(struct work_struct *work) 330 327 { ··· 436 439 437 440 INIT_WORK(&lvs->rh_work, lvs_rh_work); 438 441 439 - ret = sysfs_create_group(&intf->dev.kobj, &lvs_attr_group); 440 - if (ret < 0) { 441 - dev_err(&intf->dev, "Failed to create sysfs node %d\n", ret); 442 - goto free_urb; 443 - } 444 - 445 442 pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); 446 443 maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); 447 444 usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp, ··· 444 453 ret = usb_submit_urb(lvs->urb, GFP_KERNEL); 445 454 if (ret < 0) { 446 455 dev_err(&intf->dev, "couldn't submit lvs urb %d\n", ret); 447 - goto sysfs_remove; 456 + goto free_urb; 448 457 } 449 458 450 459 return ret; 451 460 452 - sysfs_remove: 453 - sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group); 454 461 free_urb: 455 462 usb_free_urb(lvs->urb); 456 463 return ret; ··· 458 469 { 459 470 struct lvs_rh *lvs = usb_get_intfdata(intf); 460 471 461 - sysfs_remove_group(&intf->dev.kobj, &lvs_attr_group); 462 472 usb_poison_urb(lvs->urb); /* used in scheduled work */ 463 473 flush_work(&lvs->rh_work); 464 474 usb_free_urb(lvs->urb); ··· 467 479 .name = "lvs", 468 480 .probe = lvs_rh_probe, 469 481 .disconnect = lvs_rh_disconnect, 482 + .dev_groups = lvs_groups, 470 483 }; 471 484 472 485 module_usb_driver(lvs_driver);