From patchwork Tue Aug 6 14:44:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079019 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2D39B13B1 for ; Tue, 6 Aug 2019 14:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E117283A8 for ; Tue, 6 Aug 2019 14:45:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 128B128477; Tue, 6 Aug 2019 14:45:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A7B0285C9 for ; Tue, 6 Aug 2019 14:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732976AbfHFOpI (ORCPT ); Tue, 6 Aug 2019 10:45:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:45786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730289AbfHFOpH (ORCPT ); Tue, 6 Aug 2019 10:45:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 60FBA20C01; Tue, 6 Aug 2019 14:45:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102706; bh=FQsWFloR7lTfyDgEoh94sVGq3EGeWfDXbbVMGeMavbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u19hXoB+CP5pZQc0b2a5iaK42ZHpPc8oifh2AhG22KTc3tCLnY3YvuDMBwWbTsKE/ i6G5abm4xAxYvNxYZ6GJb1Vna685B+NaJJY6TizLF/OHL4jCUUIrhmsB9zTwJOePw6 FuJHBKYZCGARP7uAoIVRyriVXlIRKDnO7fnPRYlw= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 01/12] USB: add support for dev_groups to struct usb_driver Date: Tue, 6 Aug 2019 16:44:51 +0200 Message-Id: <20190806144502.17792-2-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 1 + include/linux/usb.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index ebcadaad89d1..687fc5df4c17 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -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); diff --git a/include/linux/usb.h b/include/linux/usb.h index 83d35d993e8c..af4eb6419ae8 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -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; From patchwork Tue Aug 6 14:44:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B189A912 for ; Tue, 6 Aug 2019 14:45:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3201266F3 for ; Tue, 6 Aug 2019 14:45:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 97B4728610; Tue, 6 Aug 2019 14:45:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36EF0266F3 for ; Tue, 6 Aug 2019 14:45:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733087AbfHFOpX (ORCPT ); Tue, 6 Aug 2019 10:45:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:45966 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpX (ORCPT ); Tue, 6 Aug 2019 10:45:23 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EEB05217D9; Tue, 6 Aug 2019 14:45:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102722; bh=fb+mzvlEhDrgHKPgRykgtR4zgEogYkeAAkZVBQzTQMI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZdU3PorYhKQxUQPE5aBTKMJT4wihfqzaVTOt/BrjbjbJ19Xz4/CDV6B7hSES+ytu j3i6FgiKbnpIzR+v7OWQe2GuP1Kg5w8m4e6c00PwGyA444SbfX4hHph+u09LzKvbjp rRLYTQOEsH+XL+KKG44/BEn82YVtwde9LuzJZfZs= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 02/12] USB: add support for dev_groups to struct usb_device_driver Date: Tue, 6 Aug 2019 16:44:52 +0200 Message-Id: <20190806144502.17792-3-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 1 + include/linux/usb.h | 3 +++ 2 files changed, 4 insertions(+) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 687fc5df4c17..2b27d232d7a7 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -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); diff --git a/include/linux/usb.h b/include/linux/usb.h index af4eb6419ae8..57f667cad3ec 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -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; }; From patchwork Tue Aug 6 14:44:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079031 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44369912 for ; Tue, 6 Aug 2019 14:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 340A5285C9 for ; Tue, 6 Aug 2019 14:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2854728837; Tue, 6 Aug 2019 14:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0EB3285C9 for ; Tue, 6 Aug 2019 14:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733095AbfHFOp0 (ORCPT ); Tue, 6 Aug 2019 10:45:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:45994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpZ (ORCPT ); Tue, 6 Aug 2019 10:45:25 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F983214C6; Tue, 6 Aug 2019 14:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102725; bh=y5sjjHF0mPrzkYSRuSdN76gCl6+KIgsGIjtdiuyGZn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txZUQvP21hkt67FnCY0FPO6SpWMgarv3o/t7h2Ax2SHkgsLeiVya5NQv4vJ0jqFlX RAE0sQ8PpI5HhFgjsEq1yUn3DIzTWQbMDGE9/kXgXqmu1tIqLPjYEDCDDAlL0zSlhi SJfx6Xv9z5SP5GsDFwNeksdXXEHkN43VDXBjuMqY= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 03/12] USB: atm: cxacru: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:53 +0200 Message-Id: <20190806144502.17792-4-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/cxacru.c | 58 +++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c index e57a2be8754a..5d41f85a7445 100644 --- a/drivers/usb/atm/cxacru.c +++ b/drivers/usb/atm/cxacru.c @@ -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); From patchwork Tue Aug 6 14:44:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079033 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AFBB513B1 for ; Tue, 6 Aug 2019 14:45:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A02D12832D for ; Tue, 6 Aug 2019 14:45:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9447F28610; Tue, 6 Aug 2019 14:45:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7A782832D for ; Tue, 6 Aug 2019 14:45:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733106AbfHFOp2 (ORCPT ); Tue, 6 Aug 2019 10:45:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:46022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOp2 (ORCPT ); Tue, 6 Aug 2019 10:45:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 15691214C6; Tue, 6 Aug 2019 14:45:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102727; bh=nw47svV7ciaRtpZCXUFUGDPT7q5ye7QHw6bCSEb1QPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8ysuxXN8IF8IdgmVHWDkRUFdlIgQ+HmseBfu1FblG9tSt8/KtOWr6MlhDJUSppSO JBCbRtMxd4uuPrnxfDlCKG8xIZqyYx2soPNrX5NOczLbqyYAGGS3cDIt7pA8m8nQth nUZ6Tby22AILuxPS9wrtVyuSJxTO7HgyDus6zjHc= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Matthieu CASTET , Stanislaw Gruszka Subject: [PATCH 04/12] USB: ueagle-atm: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:54 +0200 Message-Id: <20190806144502.17792-5-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Matthieu CASTET Cc: Stanislaw Gruszka Signed-off-by: Greg Kroah-Hartman --- drivers/usb/atm/ueagle-atm.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/usb/atm/ueagle-atm.c b/drivers/usb/atm/ueagle-atm.c index 8faa51b1a520..8b0ea8c70d73 100644 --- a/drivers/usb/atm/ueagle-atm.c +++ b/drivers/usb/atm/ueagle-atm.c @@ -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); From patchwork Tue Aug 6 14:44:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C009513B1 for ; Tue, 6 Aug 2019 14:45:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B25F7283A8 for ; Tue, 6 Aug 2019 14:45:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6D6D28837; Tue, 6 Aug 2019 14:45:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F6B1283A8 for ; Tue, 6 Aug 2019 14:45:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733113AbfHFOpa (ORCPT ); Tue, 6 Aug 2019 10:45:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:46054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpa (ORCPT ); Tue, 6 Aug 2019 10:45:30 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AB19520C01; Tue, 6 Aug 2019 14:45:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102730; bh=3PaS4HqYKW6BYTPsCIgrHSQXLDcj7T1Il/0XM9y3FeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NRI1QHHRxLlDUqDNen1f5jiT+qSQZTl9JyOXb2zpdAerP534oMwP+j354e/rd/sA/ iinD5EvrJiXa0LstCbFbJYs+olB4Gobr7P8cwHriB9cXje/Fb3kEgDPfy+q5K8XDUK dQipnarQB2r4Dzxw+P8BXiWEKiKAfUQkJkdCBvGs= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Pete Zaitcev Subject: [PATCH 05/12] USB: usblp: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:55 +0200 Message-Id: <20190806144502.17792-6-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Pete Zaitcev Signed-off-by: Greg Kroah-Hartman Signed-off-by: Pete Zaitcev --- drivers/usb/class/usblp.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c index 407a7a6198a2..7fea4999d352 100644 --- a/drivers/usb/class/usblp.c +++ b/drivers/usb/class/usblp.c @@ -1082,6 +1082,12 @@ static ssize_t ieee1284_id_show(struct device *dev, struct device_attribute *att static 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, }; From patchwork Tue Aug 6 14:44:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D59CB912 for ; Tue, 6 Aug 2019 14:45:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7087266F3 for ; Tue, 6 Aug 2019 14:45:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B15FC28876; Tue, 6 Aug 2019 14:45:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E211266F3 for ; Tue, 6 Aug 2019 14:45:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733115AbfHFOpe (ORCPT ); Tue, 6 Aug 2019 10:45:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:46084 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpe (ORCPT ); Tue, 6 Aug 2019 10:45:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4CC0A20C01; Tue, 6 Aug 2019 14:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102732; bh=BTvV1CThF/JUo51iU47xDDDbdE00Szro3HXoOb6Xuio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qG90LxUgaWu6vtxd0nt/WPndL+7yVfTY1CR0m5KX3+L69RUIKq5GESKUPTZpp8mJZ nipbhMK0+cGoWyM5wWvFOngnAhHZYD5uf1tmxdab3Xh8/SGQmggxJH6VOq7WjkPrb3 GgA9DEiQVaPzppeQKl62F3sw4MaHnZt8sZ2nQ1VU= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Guido Kiener , Steve Bayless Subject: [PATCH 06/12] USB: usbtmc: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:56 +0200 Message-Id: <20190806144502.17792-7-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Guido Kiener Cc: Steve Bayless Signed-off-by: Greg Kroah-Hartman --- drivers/usb/class/usbtmc.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/usb/class/usbtmc.c b/drivers/usb/class/usbtmc.c index 4942122b2346..7ff831f2fd21 100644 --- a/drivers/usb/class/usbtmc.c +++ b/drivers/usb/class/usbtmc.c @@ -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); From patchwork Tue Aug 6 14:44:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D8D8613B1 for ; Tue, 6 Aug 2019 14:45:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CABB21FFCA for ; Tue, 6 Aug 2019 14:45:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6FF2832D; Tue, 6 Aug 2019 14:45:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C7C028610 for ; Tue, 6 Aug 2019 14:45:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733118AbfHFOpg (ORCPT ); Tue, 6 Aug 2019 10:45:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpg (ORCPT ); Tue, 6 Aug 2019 10:45:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D95F4214C6; Tue, 6 Aug 2019 14:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102735; bh=fMTTJ97G/mUnj4BdI42YClaN06AMwAKfvjDVUD3gKZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q5bupg7/5gVea8egyutBoNUNec+TDCnoysZ5O3af4LoXICkGR+eAxeVZhQi/96kJW jXxhp7TmsR3U1p0ZluxjXxPN89CE6ZfpTKiVVgbTC4l2KzijbyE4MIak0KsoPjIwAq jmvqr2qiLTbMzCb6ehOpY6j5cyZctnM2w7UAkweQ= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 07/12] USB: cypress_cy7c63: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:57 +0200 Message-Id: <20190806144502.17792-8-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/cypress_cy7c63.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/drivers/usb/misc/cypress_cy7c63.c b/drivers/usb/misc/cypress_cy7c63.c index 9d780b77314b..14faec51d7a5 100644 --- a/drivers/usb/misc/cypress_cy7c63.c +++ b/drivers/usb/misc/cypress_cy7c63.c @@ -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); From patchwork Tue Aug 6 14:44:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E8E6B912 for ; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA4FD204BF for ; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE626223A4; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 656F31FFB1 for ; Tue, 6 Aug 2019 14:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733122AbfHFOpi (ORCPT ); Tue, 6 Aug 2019 10:45:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:46144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpi (ORCPT ); Tue, 6 Aug 2019 10:45:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6813B216F4; Tue, 6 Aug 2019 14:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102737; bh=weLGk/2GgTtDvPcWpOgMkCZKqbrbEYpScoiDM2AdE9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aAVKJYqnWnH2IFSZHdqof8fnlb/puB7uAjKR5hV17QZ1YMpbCuQFrhCeMnbIimpwi XLXcXtnh8blUCcFxcRgkIwEmTFto6yqsAhguofo7LO5LHSW74ktpe/zYYFqqNeHseS ArSbqnk11uX+4T5Q7+62h5dQflVIzpA6muVLbpSw= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 08/12] USB: cytherm: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:58 +0200 Message-Id: <20190806144502.17792-9-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/cytherm.c | 64 +++++++++++--------------------------- 1 file changed, 19 insertions(+), 45 deletions(-) diff --git a/drivers/usb/misc/cytherm.c b/drivers/usb/misc/cytherm.c index 8b15ab5e1450..3e3802aaefa3 100644 --- a/drivers/usb/misc/cytherm.c +++ b/drivers/usb/misc/cytherm.c @@ -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); From patchwork Tue Aug 6 14:44:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 08DD117E0 for ; Tue, 6 Aug 2019 14:45:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF4521FFB1 for ; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3B672623D; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 854611FFCA for ; Tue, 6 Aug 2019 14:45:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733124AbfHFOpl (ORCPT ); Tue, 6 Aug 2019 10:45:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:46172 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpk (ORCPT ); Tue, 6 Aug 2019 10:45:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0E2F920C01; Tue, 6 Aug 2019 14:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102740; bh=ChsaV8DxoOSEzBl5SDaNpJPPMMMa/0dZclujcX1tauo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OtOBRPiz+GACo0HA0MJHX4oDXs7VP3SlbF0xdNu+BZLJZmMI9noVL0atTW+A697rr y505s03y25PTmWrPLbKuUeI7/UQDBzp+yj442YW6okJR9u6Pxmq0WOd0yYhYc1KLXz B6zLQ94mx29Tra//+GrsbnIkgEFgUqoV4QF7yJo8= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 09/12] USB: lvstest: convert to use dev_groups Date: Tue, 6 Aug 2019 16:44:59 +0200 Message-Id: <20190806144502.17792-10-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/lvstest.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/drivers/usb/misc/lvstest.c b/drivers/usb/misc/lvstest.c index e5c03c6d16e9..407fe7570f3b 100644 --- a/drivers/usb/misc/lvstest.c +++ b/drivers/usb/misc/lvstest.c @@ -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); From patchwork Tue Aug 6 14:45:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EDC68912 for ; Tue, 6 Aug 2019 14:45:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF76C2832D for ; Tue, 6 Aug 2019 14:45:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3BD0287DE; Tue, 6 Aug 2019 14:45:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52B0C2832D for ; Tue, 6 Aug 2019 14:45:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733044AbfHFOpP (ORCPT ); Tue, 6 Aug 2019 10:45:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:45844 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730289AbfHFOpP (ORCPT ); Tue, 6 Aug 2019 10:45:15 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3C94120C01; Tue, 6 Aug 2019 14:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102714; bh=ZhEt7u4OqC6CjIcRt5N05jx3q1hDz3f2g1UMq5amwqM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=laIY0ZG4qBrFERtZamRTDBqfyCE9DvH+9cdBnpt74DUCog4di/Vq4wz4VX+9+GuE4 xNbQdklx343uX404j42+ZwFcVM0ux/wvUlWYFuLpaAoO9wiSBZx7z8n9R59xi+246u 2axJ0xCaFUnzOZN3JubrXqwZP0V3c1uUXa82HM3s= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Ding Xiang Subject: [PATCH 10/12] USB: trancevibrator: convert to use dev_groups Date: Tue, 6 Aug 2019 16:45:00 +0200 Message-Id: <20190806144502.17792-11-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Ding Xiang Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/trancevibrator.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/usb/misc/trancevibrator.c b/drivers/usb/misc/trancevibrator.c index ac357ce2d1a6..a3dfc77578ea 100644 --- a/drivers/usb/misc/trancevibrator.c +++ b/drivers/usb/misc/trancevibrator.c @@ -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); From patchwork Tue Aug 6 14:45:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 53D60912 for ; Tue, 6 Aug 2019 14:45:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 451B9283A8 for ; Tue, 6 Aug 2019 14:45:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3925527F88; Tue, 6 Aug 2019 14:45:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD73283A8 for ; Tue, 6 Aug 2019 14:45:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733065AbfHFOpS (ORCPT ); Tue, 6 Aug 2019 10:45:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:45872 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730289AbfHFOpS (ORCPT ); Tue, 6 Aug 2019 10:45:18 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C6DDA214C6; Tue, 6 Aug 2019 14:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102717; bh=vjl9pO5XLhUt6+WXZ1MT+7E4/kI123d72qUOkAyx8uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DMPsvcgfn1+Kk+R+bGQ9by+poTu05AtHebdrE+iaKSMqU71ogIyL+tL4+b9CIlTwv ZaT2uF0eVRqhXGtgcIQQ0tTAnkbhwUsVVV0Lu10hPMdU3clhbyGMlA5Unz4sR5hGtr /GOj7eMZGisuexJLo4IbXRbnvnZinbHRPlV0wGJk= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman Subject: [PATCH 11/12] USB: usbsevseg: convert to use dev_groups Date: Tue, 6 Aug 2019 16:45:01 +0200 Message-Id: <20190806144502.17792-12-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/usbsevseg.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index 1923d5b6d9c9..551074f5b7ad 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c @@ -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, }; From patchwork Tue Aug 6 14:45:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 11079027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DCF9E13B1 for ; Tue, 6 Aug 2019 14:45:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE862285C9 for ; Tue, 6 Aug 2019 14:45:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C2C1A287DE; Tue, 6 Aug 2019 14:45:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE2D285C9 for ; Tue, 6 Aug 2019 14:45:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733076AbfHFOpV (ORCPT ); Tue, 6 Aug 2019 10:45:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:45916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733066AbfHFOpV (ORCPT ); Tue, 6 Aug 2019 10:45:21 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6359F214C6; Tue, 6 Aug 2019 14:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565102719; bh=OlzchSyzpfZZvUBliJZhV89r2LswcZ3288cZR19mPlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jWnRuePtMBkqEfgVddVuL3FNs0xQrpVzEBMqGJ8W9rTt/+cIjKpLSUjl97nUcLwkP dyxU+X8SvFlPwabWQ12nyapc6D3TNgNRVVzq3R/2lwHeEhUJ+d1ex6scz9LzRCkJ2D 3ul8FzBbs2mw6fN/kQSAJvj4/ZDWYZToxDwqamuc= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , Valentina Manea , Shuah Khan Subject: [PATCH 12/12] USB: usbip: convert to use dev_groups Date: Tue, 6 Aug 2019 16:45:02 +0200 Message-Id: <20190806144502.17792-13-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190806144502.17792-1-gregkh@linuxfoundation.org> References: <20190806144502.17792-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Cc: Valentina Manea Cc: Shuah Khan Signed-off-by: Greg Kroah-Hartman --- drivers/usb/usbip/stub_dev.c | 50 ++++++------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c index 7931e6cecc70..2305d425e6c9 100644 --- a/drivers/usb/usbip/stub_dev.c +++ b/drivers/usb/usbip/stub_dev.c @@ -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, };