USB: musb: convert platform driver to use dev_groups
Subsystems (7)
Greg Kroah-Hartman
maintainerPATCH 1/1 USB: musb: convert platform driver to use dev_groups
Platform drivers now have the option to have the platform core create and remove any needed sysfs attribute files. So take advantage of that and do not register "by hand" any sysfs files.
--- drivers/usb/musb/musb_core.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
drivers/usb/musb/musb_core.c +3 -19
@@ -1829,16 +1829,13 @@ static ssize_t srp_store(struct device *dev, struct device_attribute *attr, }static DEVICE_ATTR_WO (srp); -static struct attribute *musb_attributes[] = { +static struct attribute *musb_attrs[] = { &dev_attr_mode.attr, &dev_attr_vbus.attr, &dev_attr_srp.attr,NULL }; - -static const struct attribute_group musb_attr_group = { - .attrs = musb_attributes, -}; +ATTRIBUTE_GROUPS (musb);#define MUSB_QUIRK_B_INVALID_VBUS_91 (MUSB_DEVCTL_BDEVICE | \ (2 << MUSB_DEVCTL_VBUS_SHIFT) | \
@@ -2038,10 +2035,6 @@ static void musb_free(struct musb *musb)* cleanup after everything's been de-activated. */ -#ifdef CONFIG_SYSFS -sysfs_remove_group (&musb->controller->kobj, &musb_attr_group); -#endif -if (musb->nIrq >=0 ) {if (musb->irq_wake)disable_irq_wake (musb->nIrq);
@@ -2390,22 +2383,12 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl)musb_init_debugfs (musb); - status =sysfs_create_group (&musb->controller->kobj, &musb_attr_group); -if (status) - goto fail5; - musb->is_initialized =1 ;pm_runtime_mark_last_busy (musb->controller);pm_runtime_put_autosuspend (musb->controller);return 0 ; -fail5: -musb_exit_debugfs (musb); - -musb_gadget_cleanup (musb); -musb_host_cleanup (musb); - fail3:cancel_delayed_work_sync (&musb->irq_work);cancel_delayed_work_sync (&musb->finish_resume_work);
@@ -2798,6 +2781,7 @@ static struct platform_driver musb_driver = { .name = (char *)musb_driver_name, .bus = &platform_bus_type, .pm = MUSB_DEV_PM_OPS, + .dev_groups = musb_groups, }, .probe = musb_probe, .remove = musb_remove,
Signature · 1 line
2.22.0
Quoted 6 lines · Greg Kroah-Hartman
Platform drivers now have the option to have the platform core create and remove any needed sysfs attribute files. So take advantage of that and do not register "by hand" any sysfs files.
Cc Bin Liu <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
-Bin.
Greg Kroah-Hartman
maintainercover USB: dev_groups support for usb drivers
Now that the driver core supports the ability for individual drivers to have attribute groups added/removed when a device is bound/unbound to a driver automatically, we should take advantage of that in the USB subsystem.
This patch series adds dev_groups support to struct usb_driver and struct usb_device_driver (needed for the usbip driver), and then converts a number of individual USB drivers over to use this api.
Greg Kroah-Hartman (12):
USB: add support for dev_groups to struct usb_driver
USB: add support for dev_groups to struct usb_device_driver
USB: atm: cxacru: convert to use dev_groups
USB: ueagle-atm: convert to use dev_groups
USB: usblp: convert to use dev_groups
USB: usbtmc: convert to use dev_groups
USB: cypress_cy7c63: convert to use dev_groups
USB: cytherm: convert to use dev_groups
USB: lvstest: convert to use dev_groups
USB: trancevibrator: convert to use dev_groups
USB: usbsevseg: convert to use dev_groups
USB: usbip: convert to use dev_groups
drivers/usb/atm/cxacru.c | 58 ++++++++++++++++------------ drivers/usb/atm/ueagle-atm.c | 16 ++------ drivers/usb/class/usblp.c | 13 ++++--- drivers/usb/class/usbtmc.c | 13 ++----- drivers/usb/core/driver.c | 2 + drivers/usb/misc/cypress_cy7c63.c | 29 ++++---------- drivers/usb/misc/cytherm.c | 64 +++++++++---------------------- drivers/usb/misc/lvstest.c | 19 ++------- drivers/usb/misc/trancevibrator.c | 15 ++++---- drivers/usb/misc/usbsevseg.c | 17 ++------ drivers/usb/usbip/stub_dev.c | 50 ++++-------------------- include/linux/usb.h | 6 +++ 12 files changed, 104 insertions(+), 198 deletions(-)
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 1/12 USB: add support for dev_groups to struct usb_driver
Now that the driver core supports dev_groups for individual drivers, expose that pointer to struct usb_driver to make it easier for USB drivers to also use it.
--- drivers/usb/core/driver.c | 1 + include/linux/usb.h | 3 +++ 2 files changed, 4 insertions(+)
drivers/usb/core/driver.c +1 -0
@@ -954,6 +954,7 @@ int usb_register_driver(struct usb_driver *new_driver, struct module *owner, new_driver->drvwrap.driver.remove = usb_unbind_interface; new_driver->drvwrap.driver.owner = owner; new_driver->drvwrap.driver.mod_name = mod_name; + new_driver->drvwrap.driver.dev_groups = new_driver->dev_groups;spin_lock_init (&new_driver->dynids.lock);INIT_LIST_HEAD (&new_driver->dynids.list);
include/linux/usb.h +3 -0
@@ -1151,6 +1151,8 @@ struct usbdrv_wrap {* @id_table: USB drivers use ID table to support hotplugging. * Export this with MODULE_DEVICE_TABLE(usb,...). This must be set * or your driver's probe function will never get called. +* @dev_groups: Attributes attached to the device that will be created once it +* is bound to the driver. * @dynids: used internally to hold the list of dynamically added device * ids for this driver. * @drvwrap: Driver-model core structure wrapper.
@@ -1198,6 +1200,7 @@ struct usb_driver {int (*post_reset)(struct usb_interface *intf);const struct usb_device_id *id_table; +const struct attribute_group **dev_groups;struct usb_dynids dynids;struct usbdrv_wrap drvwrap;
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 2/12 USB: add support for dev_groups to struct usb_device_driver
In reply to Greg Kroah-HartmanNow that the driver core supports dev_groups for individual drivers, expose that pointer to struct usb_device_driver to make it easier for USB drivers to also use it.
Yes, users of usb_device_driver are much rare, but there are instances already that use custom sysfs files, so adding this support will make things easier for those drivers. usbip is one example, hubs might be another one.
--- drivers/usb/core/driver.c | 1 + include/linux/usb.h | 3 +++ 2 files changed, 4 insertions(+)
drivers/usb/core/driver.c +1 -0
@@ -892,6 +892,7 @@ int usb_register_device_driver(struct usb_device_driver *new_udriver, new_udriver->drvwrap.driver.probe = usb_probe_device; new_udriver->drvwrap.driver.remove = usb_unbind_device; new_udriver->drvwrap.driver.owner = owner; + new_udriver->drvwrap.driver.dev_groups = new_udriver->dev_groups; retval =driver_register (&new_udriver->drvwrap.driver);
include/linux/usb.h +3 -0
@@ -1224,6 +1224,8 @@ struct usb_driver {* module is being unloaded. * @suspend: Called when the device is going to be suspended by the system. * @resume: Called when the device is being resumed by the system. +* @dev_groups: Attributes attached to the device that will be created once it +* is bound to the driver. * @drvwrap: Driver-model core structure wrapper. * @supports_autosuspend: if set to 0, the USB core will not allow autosuspend * for devices bound to this driver.
@@ -1238,6 +1240,7 @@ struct usb_device_driver {int (*suspend) (struct usb_device *udev,pm_message_t message);int (*resume) (struct usb_device *udev,pm_message_t message); +const struct attribute_group **dev_groups;struct usbdrv_wrap drvwrap; unsigned int supports_autosuspend:1; };
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 3/12 USB: atm: cxacru: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/atm/cxacru.c | 58 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-)
drivers/usb/atm/cxacru.c +33 -25
@@ -539,6 +539,37 @@ CXACRU_SET_##_action( adsl_config);CXACRU_ALL_FILES (INIT ); +static struct attribute *cxacru_attrs[] = { + &dev_attr_adsl_config.attr, + &dev_attr_adsl_state.attr, + &dev_attr_adsl_controller_version.attr, + &dev_attr_adsl_headend_environment.attr, + &dev_attr_adsl_headend.attr, + &dev_attr_modulation.attr, + &dev_attr_line_startable.attr, + &dev_attr_downstream_hec_errors.attr, + &dev_attr_upstream_hec_errors.attr, + &dev_attr_downstream_fec_errors.attr, + &dev_attr_upstream_fec_errors.attr, + &dev_attr_downstream_crc_errors.attr, + &dev_attr_upstream_crc_errors.attr, + &dev_attr_startup_attempts.attr, + &dev_attr_downstream_bits_per_frame.attr, + &dev_attr_upstream_bits_per_frame.attr, + &dev_attr_transmitter_power.attr, + &dev_attr_downstream_attenuation.attr, + &dev_attr_upstream_attenuation.attr, + &dev_attr_downstream_snr_margin.attr, + &dev_attr_upstream_snr_margin.attr, + &dev_attr_mac_address.attr, + &dev_attr_line_status.attr, + &dev_attr_link_status.attr, + &dev_attr_upstream_rate.attr, + &dev_attr_downstream_rate.attr, +NULL , +}; +ATTRIBUTE_GROUPS (cxacru); +/* the following three functions are stolen from drivers/usb/core/message.c */ static void cxacru_blocking_completion (struct urb *urb) {
@@ -736,17 +767,6 @@ static int cxacru_card_status(struct cxacru_data *instance)return 0 ; } -static void cxacru_remove_device_files (struct usbatm_data *usbatm_instance, -struct atm_dev *atm_dev) -{ -struct usb_interface *intf = usbatm_instance->usb_intf; - -#define CXACRU_DEVICE_REMOVE_FILE (_name) \ - device_remove_file(&intf->dev, &dev_attr_##_name); -CXACRU_ALL_FILES (REMOVE ); -#undef CXACRU_DEVICE_REMOVE_FILE -} -static int cxacru_atm_start (struct usbatm_data *usbatm_instance,struct atm_dev *atm_dev) {
@@ -765,13 +785,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,return ret; } -#define CXACRU_DEVICE_CREATE_FILE (_name) \ - ret = device_create_file(&intf->dev, &dev_attr_##_name); \ - if (unlikely(ret)) \ - goto fail_sysfs; -CXACRU_ALL_FILES (CREATE ); -#undef CXACRU_DEVICE_CREATE_FILE -/* start ADSL */ mutex_lock (&instance->adsl_state_serialize); ret =cxacru_cm (instance,CM_REQUEST_CHIP_ADSL_LINE_START ,NULL ,0 ,NULL ,0 );
@@ -804,11 +817,6 @@ static int cxacru_atm_start(struct usbatm_data *usbatm_instance,if (start_polling)cxacru_poll_status (&instance->poll_work.work);return 0 ; - -fail_sysfs: -usb_err (usbatm_instance,"cxacru_atm_start: device_create_file failed (%d)\n" , ret); -cxacru_remove_device_files (usbatm_instance, atm_dev); -return ret; }static void cxacru_poll_status (struct work_struct *work)
@@ -1332,7 +1340,6 @@ static struct usbatm_driver cxacru_driver = { .heavy_init = cxacru_heavy_init, .unbind = cxacru_unbind, .atm_start = cxacru_atm_start, - .atm_stop = cxacru_remove_device_files, .bulk_in = CXACRU_EP_DATA, .bulk_out = CXACRU_EP_DATA, .rx_padding = 3,
@@ -1364,7 +1371,8 @@ static struct usb_driver cxacru_usb_driver = { .name = cxacru_driver_name, .probe = cxacru_usb_probe, .disconnect = usbatm_usb_disconnect, - .id_table = cxacru_usb_ids + .id_table = cxacru_usb_ids, + .dev_groups = cxacru_groups, };module_usb_driver (cxacru_usb_driver);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 4/12 USB: ueagle-atm: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/atm/ueagle-atm.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/usb/atm/ueagle-atm.c +4 -12
@@ -2458,7 +2458,7 @@ static int claim_interface(struct usb_device *usb_dev,return ret; } -static struct attribute *attrs[] = { +static struct attribute *uea_attrs[] = { &dev_attr_stat_status.attr, &dev_attr_stat_mflags.attr, &dev_attr_stat_human_status.attr,
@@ -2479,9 +2479,7 @@ static struct attribute *attrs[] = { &dev_attr_stat_firmid.attr,NULL , }; -static const struct attribute_group attr_grp = { - .attrs = attrs, -}; +ATTRIBUTE_GROUPS (uea);static int uea_bind (struct usbatm_data *usbatm,struct usb_interface *intf,const struct usb_device_id *id)
@@ -2550,18 +2548,12 @@ static int uea_bind(struct usbatm_data *usbatm, struct usb_interface *intf, } } - ret =sysfs_create_group (&intf->dev.kobj, &attr_grp); -if (ret <0 ) - goto error; - ret =uea_boot (sc);if (ret <0 ) - goto error_rm_grp; + goto error;return 0 ; -error_rm_grp: -sysfs_remove_group (&intf->dev.kobj, &attr_grp); error:kfree (sc);return ret;
@@ -2571,7 +2563,6 @@ static void uea_unbind(struct usbatm_data *usbatm, struct usb_interface *intf) {struct uea_softc *sc = usbatm->driver_data; -sysfs_remove_group (&intf->dev.kobj, &attr_grp);uea_stop (sc);kfree (sc); }
@@ -2721,6 +2712,7 @@ static struct usb_driver uea_driver = { .id_table = uea_ids, .probe = uea_probe, .disconnect = uea_disconnect, + .dev_groups = uea_groups, };MODULE_DEVICE_TABLE (usb, uea_ids);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 5/12 USB: usblp: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/class/usblp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/usb/class/usblp.c +7 -6
@@ -1082,6 +1082,12 @@ static ssize_t ieee1284_id_show(struct device *dev, struct device_attribute *attstatic DEVICE_ATTR_RO (ieee1284_id); +static struct attribute *usblp_attrs[] = { + &dev_attr_ieee1284_id.attr, +NULL , +}; +ATTRIBUTE_GROUPS (usblp); +static int usblp_probe (struct usb_interface *intf,const struct usb_device_id *id) {
@@ -1156,9 +1162,6 @@ static int usblp_probe(struct usb_interface *intf,/* Retrieve and store the device ID string. */ usblp_cache_device_id_string (usblp); - retval =device_create_file (&intf->dev, &dev_attr_ieee1284_id); -if (retval) - goto abort_intfdata;#ifdef DEBUG usblp_check_status (usblp,0 );
@@ -1189,7 +1192,6 @@ static int usblp_probe(struct usb_interface *intf, abort_intfdata:usb_set_intfdata (intf,NULL ); -device_remove_file (&intf->dev, &dev_attr_ieee1284_id); abort:kfree (usblp->readbuf);kfree (usblp->statusbuf);
@@ -1360,8 +1362,6 @@ static void usblp_disconnect(struct usb_interface *intf)BUG (); } -device_remove_file (&intf->dev, &dev_attr_ieee1284_id); -mutex_lock (&usblp_mutex);mutex_lock (&usblp->mut); usblp->present =0 ;
@@ -1421,6 +1421,7 @@ static struct usb_driver usblp_driver = { .suspend = usblp_suspend, .resume = usblp_resume, .id_table = usblp_ids, + .dev_groups = usblp_groups, .supports_autosuspend = 1, };
Signature · 1 line
2.22.0
Pete Zaitcev
maintainerRe: [PATCH 05/12] USB: usblp: convert to use dev_groups
Quoted 2 lines · On Tue, 6 Aug 2019 16:44:55 +0200 Greg Kroah-Hartman…
Cc Pete Zaitcev <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Always hated that irregular error unrolling, but was too lazy to fix it.
-- Pete
Greg Kroah-Hartman
maintainerPATCH 6/12 USB: usbtmc: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/class/usbtmc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/usb/class/usbtmc.c +3 -10
@@ -1836,17 +1836,14 @@ capability_attribute(device_capabilities);capability_attribute (usb488_interface_capabilities);capability_attribute (usb488_device_capabilities); -static struct attribute *capability_attrs[] = { +static struct attribute *usbtmc_attrs[] = { &dev_attr_interface_capabilities.attr, &dev_attr_device_capabilities.attr, &dev_attr_usb488_interface_capabilities.attr, &dev_attr_usb488_device_capabilities.attr,NULL , }; - -static const struct attribute_group capability_attr_grp = { - .attrs = capability_attrs, -}; +ATTRIBUTE_GROUPS (usbtmc);static int usbtmc_ioctl_indicator_pulse (struct usbtmc_device_data *data) {
@@ -2383,9 +2380,6 @@ static int usbtmc_probe(struct usb_interface *intf, retcode =get_capabilities (data);if (retcode)dev_err (&intf->dev,"can't read capabilities\n" ); -else - retcode =sysfs_create_group (&intf->dev.kobj, - &capability_attr_grp);if (data->iin_ep_present) {/* allocate int urb */
@@ -2432,7 +2426,6 @@ static int usbtmc_probe(struct usb_interface *intf,return 0 ; error_register: -sysfs_remove_group (&intf->dev.kobj, &capability_attr_grp);usbtmc_free_int (data); err_put:kref_put (&data->kref, usbtmc_delete);
@@ -2445,7 +2438,6 @@ static void usbtmc_disconnect(struct usb_interface *intf)struct list_head *elem;usb_deregister_dev (intf, &usbtmc_class); -sysfs_remove_group (&intf->dev.kobj, &capability_attr_grp);mutex_lock (&data->io_mutex); data->zombie =1 ;wake_up_interruptible_all (&data->waitq);
@@ -2551,6 +2543,7 @@ static struct usb_driver usbtmc_driver = { .resume = usbtmc_resume, .pre_reset = usbtmc_pre_reset, .post_reset = usbtmc_post_reset, + .dev_groups = usbtmc_groups, };module_usb_driver (usbtmc_driver);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 7/12 USB: cypress_cy7c63: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/misc/cypress_cy7c63.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-)
drivers/usb/misc/cypress_cy7c63.c +8 -21
@@ -183,6 +183,7 @@ static ssize_t port0_show(struct device *dev, {return read_port (dev, attr, buf,0 ,CYPRESS_READ_PORT_ID0 ); } +static DEVICE_ATTR_RW (port0);/* attribute callback handler (read) */ static ssize_t port1_show(struct device *dev,
@@ -190,11 +191,14 @@ static ssize_t port1_show(struct device *dev, {return read_port (dev, attr, buf,1 ,CYPRESS_READ_PORT_ID1 ); } - -static DEVICE_ATTR_RW (port0); -static DEVICE_ATTR_RW (port1); +static struct attribute *cypress_attrs[] = { + &dev_attr_port0.attr, + &dev_attr_port1.attr, +NULL , +}; +ATTRIBUTE_GROUPS (cypress);static int cypress_probe (struct usb_interface *interface,const struct usb_device_id *id)
@@ -212,26 +216,11 @@ static int cypress_probe(struct usb_interface *interface,/* save our data pointer in this interface device */ usb_set_intfdata (interface, dev); -/* create device attribute files */ - retval =device_create_file (&interface->dev, &dev_attr_port0); -if (retval) - goto error; - retval =device_create_file (&interface->dev, &dev_attr_port1); -if (retval) - goto error; -/* let the user know that the device is now attached */ dev_info (&interface->dev,"Cypress CY7C63xxx device now attached\n" );return 0 ; -error: -device_remove_file (&interface->dev, &dev_attr_port0); -device_remove_file (&interface->dev, &dev_attr_port1); -usb_set_intfdata (interface,NULL ); -usb_put_dev (dev->udev); -kfree (dev); - error_mem:return retval; }
@@ -242,9 +231,6 @@ static void cypress_disconnect(struct usb_interface *interface) dev =usb_get_intfdata (interface); -/* remove device attribute files */ -device_remove_file (&interface->dev, &dev_attr_port0); -device_remove_file (&interface->dev, &dev_attr_port1);/* the intfdata can be set to NULL only after the * device files have been removed */ usb_set_intfdata (interface,NULL );
@@ -262,6 +248,7 @@ static struct usb_driver cypress_driver = { .probe = cypress_probe, .disconnect = cypress_disconnect, .id_table = cypress_table, + .dev_groups = cypress_groups, };module_usb_driver (cypress_driver);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 8/12 USB: cytherm: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/misc/cytherm.c | 64 +++++++++++--------------------------- 1 file changed, 19 insertions(+), 45 deletions(-)
drivers/usb/misc/cytherm.c +19 -45
@@ -36,20 +36,6 @@ struct usb_cytherm { }; -/* local function prototypes */ -static int cytherm_probe (struct usb_interface *interface, -const struct usb_device_id *id); -static void cytherm_disconnect (struct usb_interface *interface); - - -/* usb specific object needed to register this driver with the usb subsystem */ -static struct usb_driver cytherm_driver = { - .name ="cytherm" , - .probe = cytherm_probe, - .disconnect = cytherm_disconnect, - .id_table = id_table, -}; -/* Vendor requests */ /* They all operate on one byte at a time */ #define PING 0x00
@@ -304,6 +290,15 @@ static ssize_t port1_store(struct device *dev, struct device_attribute *attr, co }static DEVICE_ATTR_RW (port1); +static struct attribute *cytherm_attrs[] = { + &dev_attr_brightness.attr, + &dev_attr_temp.attr, + &dev_attr_button.attr, + &dev_attr_port0.attr, + &dev_attr_port1.attr, +NULL , +}; +ATTRIBUTE_GROUPS (cytherm);static int cytherm_probe (struct usb_interface *interface,const struct usb_device_id *id)
@@ -322,34 +317,10 @@ static int cytherm_probe(struct usb_interface *interface, dev->brightness =0xFF ; - retval =device_create_file (&interface->dev, &dev_attr_brightness); -if (retval) - goto error; - retval =device_create_file (&interface->dev, &dev_attr_temp); -if (retval) - goto error; - retval =device_create_file (&interface->dev, &dev_attr_button); -if (retval) - goto error; - retval =device_create_file (&interface->dev, &dev_attr_port0); -if (retval) - goto error; - retval =device_create_file (&interface->dev, &dev_attr_port1); -if (retval) - goto error; -dev_info (&interface->dev,"Cypress thermometer device now attached\n" );return 0 ; -error: -device_remove_file (&interface->dev, &dev_attr_brightness); -device_remove_file (&interface->dev, &dev_attr_temp); -device_remove_file (&interface->dev, &dev_attr_button); -device_remove_file (&interface->dev, &dev_attr_port0); -device_remove_file (&interface->dev, &dev_attr_port1); -usb_set_intfdata (interface,NULL ); -usb_put_dev (dev->udev); -kfree (dev); + error_mem:return retval; }
@@ -360,12 +331,6 @@ static void cytherm_disconnect(struct usb_interface *interface) dev =usb_get_intfdata (interface); -device_remove_file (&interface->dev, &dev_attr_brightness); -device_remove_file (&interface->dev, &dev_attr_temp); -device_remove_file (&interface->dev, &dev_attr_button); -device_remove_file (&interface->dev, &dev_attr_port0); -device_remove_file (&interface->dev, &dev_attr_port1); -/* first remove the files, then NULL the pointer */ usb_set_intfdata (interface,NULL );
@@ -376,6 +341,15 @@ static void cytherm_disconnect(struct usb_interface *interface)dev_info (&interface->dev,"Cypress thermometer now disconnected\n" ); } +/* usb specific object needed to register this driver with the usb subsystem */ +static struct usb_driver cytherm_driver = { + .name ="cytherm" , + .probe = cytherm_probe, + .disconnect = cytherm_disconnect, + .id_table = id_table, + .dev_groups = cytherm_groups, +}; +module_usb_driver (cytherm_driver);MODULE_AUTHOR (DRIVER_AUTHOR );
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 9/12 USB: lvstest: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/misc/lvstest.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-)
drivers/usb/misc/lvstest.c +4 -15
@@ -310,7 +310,7 @@ static ssize_t enable_compliance_store(struct device *dev, }static DEVICE_ATTR_WO (enable_compliance); -static struct attribute *lvs_attributes[] = { +static struct attribute *lvs_attrs[] = { &dev_attr_get_dev_desc.attr, &dev_attr_u1_timeout.attr, &dev_attr_u2_timeout.attr,
@@ -321,10 +321,7 @@ static struct attribute *lvs_attributes[] = { &dev_attr_enable_compliance.attr, NULL }; - -static const struct attribute_group lvs_attr_group = { - .attrs = lvs_attributes, -}; +ATTRIBUTE_GROUPS (lvs);static void lvs_rh_work (struct work_struct *work) {
@@ -439,12 +436,6 @@ static int lvs_rh_probe(struct usb_interface *intf,INIT_WORK (&lvs->rh_work, lvs_rh_work); - ret =sysfs_create_group (&intf->dev.kobj, &lvs_attr_group); -if (ret <0 ) { -dev_err (&intf->dev,"Failed to create sysfs node %d\n" , ret); - goto free_urb; - } - pipe =usb_rcvintpipe (hdev, endpoint->bEndpointAddress); maxp =usb_maxpacket (hdev, pipe,usb_pipeout (pipe)); usb_fill_int_urb(lvs->urb, hdev, pipe, &lvs->buffer[0], maxp,
@@ -453,13 +444,11 @@ static int lvs_rh_probe(struct usb_interface *intf, ret =usb_submit_urb (lvs->urb,GFP_KERNEL );if (ret <0 ) {dev_err (&intf->dev,"couldn't submit lvs urb %d\n" , ret); - goto sysfs_remove; + goto free_urb; }return ret; -sysfs_remove: -sysfs_remove_group (&intf->dev.kobj, &lvs_attr_group); free_urb:usb_free_urb (lvs->urb);return ret;
@@ -469,7 +458,6 @@ static void lvs_rh_disconnect(struct usb_interface *intf) {struct lvs_rh *lvs =usb_get_intfdata (intf); -sysfs_remove_group (&intf->dev.kobj, &lvs_attr_group);usb_poison_urb (lvs->urb);/* used in scheduled work */ flush_work (&lvs->rh_work);usb_free_urb (lvs->urb);
@@ -479,6 +467,7 @@ static struct usb_driver lvs_driver = { .name = "lvs", .probe = lvs_rh_probe, .disconnect = lvs_rh_disconnect, + .dev_groups = lvs_groups, };module_usb_driver (lvs_driver);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 10/12 USB: trancevibrator: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/misc/trancevibrator.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/usb/misc/trancevibrator.c +7 -8
@@ -71,9 +71,14 @@ static ssize_t speed_store(struct device *dev, struct device_attribute *attr, }return count; } -static DEVICE_ATTR_RW (speed); +static struct attribute *tv_attrs[] = { + &dev_attr_speed.attr, +NULL , +}; +ATTRIBUTE_GROUPS (tv); +static int tv_probe (struct usb_interface *interface,const struct usb_device_id *id) {
@@ -89,15 +94,9 @@ static int tv_probe(struct usb_interface *interface, dev->udev =usb_get_dev (udev);usb_set_intfdata (interface, dev); - retval =device_create_file (&interface->dev, &dev_attr_speed); -if (retval) - goto error_create_file;return 0 ; -error_create_file: -usb_put_dev (udev); -usb_set_intfdata (interface,NULL ); error:kfree (dev);return retval;
@@ -108,7 +107,6 @@ static void tv_disconnect(struct usb_interface *interface)struct trancevibrator *dev; dev =usb_get_intfdata (interface); -device_remove_file (&interface->dev, &dev_attr_speed);usb_set_intfdata (interface,NULL );usb_put_dev (dev->udev);kfree (dev);
@@ -120,6 +118,7 @@ static struct usb_driver tv_driver = { .probe = tv_probe, .disconnect = tv_disconnect, .id_table = id_table, + .dev_groups = tv_groups, };module_usb_driver (tv_driver);
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 11/12 USB: usbsevseg: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/misc/usbsevseg.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/usb/misc/usbsevseg.c +3 -14
@@ -316,7 +316,7 @@ MYDEV_ATTR_SIMPLE_UNSIGNED(powered, update_display_powered);MYDEV_ATTR_SIMPLE_UNSIGNED (mode_msb, update_display_mode);MYDEV_ATTR_SIMPLE_UNSIGNED (mode_lsb, update_display_mode); -static struct attribute *dev_attrs[] = { +static struct attribute *sevseg_attrs[] = { &dev_attr_powered.attr, &dev_attr_text.attr, &dev_attr_textmode.attr,
@@ -325,10 +325,7 @@ static struct attribute *dev_attrs[] = { &dev_attr_mode_lsb.attr, NULL }; - -static const struct attribute_group dev_attr_grp = { - .attrs = dev_attrs, -}; +ATTRIBUTE_GROUPS (sevseg);static int sevseg_probe (struct usb_interface *interface,const struct usb_device_id *id)
@@ -354,17 +351,9 @@ static int sevseg_probe(struct usb_interface *interface, mydev->mode_msb =0x06 ;/* 6 characters */ mydev->mode_lsb =0x3f ;/* scanmode for 6 chars */ - rc =sysfs_create_group (&interface->dev.kobj, &dev_attr_grp); -if (rc) - goto error; -dev_info (&interface->dev,"USB 7 Segment device now attached\n" );return 0 ; -error: -usb_set_intfdata (interface,NULL ); -usb_put_dev (mydev->udev); -kfree (mydev); error_mem:return rc; }
@@ -374,7 +363,6 @@ static void sevseg_disconnect(struct usb_interface *interface)struct usb_sevsegdev *mydev; mydev =usb_get_intfdata (interface); -sysfs_remove_group (&interface->dev.kobj, &dev_attr_grp);usb_set_intfdata (interface,NULL );usb_put_dev (mydev->udev);kfree (mydev);
@@ -423,6 +411,7 @@ static struct usb_driver sevseg_driver = { .resume = sevseg_resume, .reset_resume = sevseg_reset_resume, .id_table = id_table, + .dev_groups = sevseg_groups, .supports_autosuspend = 1, };
Signature · 1 line
2.22.0
Greg Kroah-Hartman
maintainerPATCH 12/12 USB: usbip: convert to use dev_groups
In reply to Greg Kroah-HartmanUSB 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.
--- drivers/usb/usbip/stub_dev.c | 50 ++++++------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-)
drivers/usb/usbip/stub_dev.c +8 -42
@@ -106,38 +106,13 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a }static DEVICE_ATTR_WO (usbip_sockfd); -static int stub_add_files (struct device *dev) -{ -int err =0 ; - - err =device_create_file (dev, &dev_attr_usbip_status); -if (err) - goto err_status; - - err =device_create_file (dev, &dev_attr_usbip_sockfd); -if (err) - goto err_sockfd; - - err =device_create_file (dev, &dev_attr_usbip_debug); -if (err) - goto err_debug; - -return 0 ; - -err_debug: -device_remove_file (dev, &dev_attr_usbip_sockfd); -err_sockfd: -device_remove_file (dev, &dev_attr_usbip_status); -err_status: -return err; -} - -static void stub_remove_files (struct device *dev) -{ -device_remove_file (dev, &dev_attr_usbip_status); -device_remove_file (dev, &dev_attr_usbip_sockfd); -device_remove_file (dev, &dev_attr_usbip_debug); -} +static struct attribute *usbip_attrs[] = { + &dev_attr_usbip_status.attr, + &dev_attr_usbip_sockfd.attr, + &dev_attr_usbip_debug.attr, +NULL , +}; +ATTRIBUTE_GROUPS (usbip);static void stub_shutdown_connection (struct usbip_device *ud) {
@@ -379,17 +354,8 @@ static int stub_probe(struct usb_device *udev) goto err_port; } - rc =stub_add_files (&udev->dev); -if (rc) { -dev_err (&udev->dev,"stub_add_files for %s\n" , udev_busid); - goto err_files; - } -return 0 ; -err_files: -usb_hub_release_port (udev->parent, udev->portnum, - (struct usb_dev_state *) udev); err_port:dev_set_drvdata (&udev->dev,NULL );usb_put_dev (udev);
@@ -457,7 +423,6 @@ static void stub_disconnect(struct usb_device *udev)/* * NOTE: rx/tx threads are invoked for each usb_device. */ -stub_remove_files (&udev->dev);/* release port */ rc = usb_hub_release_port(udev->parent, udev->portnum,
@@ -526,4 +491,5 @@ struct usb_device_driver stub_driver = { .resume = stub_resume, #endif .supports_autosuspend = 0, + .dev_groups = usbip_groups, };
Signature · 1 line
2.22.0