Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754121AbbKWI56 (ORCPT ); Mon, 23 Nov 2015 03:57:58 -0500 Received: from mailout4.w1.samsung.com ([210.118.77.14]:56183 "EHLO mailout4.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754008AbbKWI4m (ORCPT ); Mon, 23 Nov 2015 03:56:42 -0500 X-AuditID: cbfec7f5-f79b16d000005389-49-5652d4c7abac From: Marek Szyprowski To: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Szyprowski , Ruslan Bilovol , Bartlomiej Zolnierkiewicz Subject: [PATCH v7 2/4] usb: gadget: configfs: pass UDC name via usb_gadget_driver struct Date: Mon, 23 Nov 2015 09:56:36 +0100 Message-id: <1448268998-4682-3-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1448268998-4682-1-git-send-email-m.szyprowski@samsung.com> References: <1448268998-4682-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgluLIzCtJLcpLzFFi42I5/e/4Fd3jV4LCDB58lLfYOGM9q8XlXXPY LBYta2W2WHvkLrtFz84TjA6sHjtn3WX36NuyitHj8ya5AOYoLpuU1JzMstQifbsErowTl6aw FLRLVjzcspWlgfGjSBcjJ4eEgInEn8/P2CFsMYkL99azdTFycQgJLGWU6Pr2mRnCaWKSWPhv GVgVm4ChRNfbLqAqDg4RAWuJvoNBIDXMAlMYJX7efsYEUiMsEC3x/+sqMJtFQFVi35vDrCA2 r4C7xMfF5xghtslJ/H+5AqyGU8BDYuGJLywgthBQTe/z+6wTGHkXMDKsYhRNLU0uKE5KzzXS K07MLS7NS9dLzs/dxAgJl687GJceszrEKMDBqMTDq6EfFCbEmlhWXJl7iFGCg1lJhPfIVqAQ b0piZVVqUX58UWlOavEhRmkOFiVx3pm73ocICaQnlqRmp6YWpBbBZJk4OKUaGLlMn9wvyXm+ QKjIQbA8Vsxexv6DyT3thS0mv721o7du7Lom3ci6fa7y1HPKTCYZhzyYC04qSBh8an1/a5n5 O/0J7QsTEg/YBMRe7ryaumPvGcW2Cbp9dh4Pfj3deWTZw4VbGzTqZcT7I851Gexqmmd3OtF1 VfWNxF0cuYmlKXPvX9DeLzmXW4mlOCPRUIu5qDgRAHXcgEoTAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3348 Lines: 109 From: Ruslan Bilovol Now when udc-core supports binding to specific UDC by passing its name via 'udc_name' member of usb_gadget_driver struct, switch to this generic approach. Tested-by: Maxime Ripard Signed-off-by: Ruslan Bilovol [rebased and fixed checkpatch issues] Signed-off-by: Marek Szyprowski Tested-by: Peter Chen --- drivers/usb/gadget/configfs.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c index 163d305..590c449 100644 --- a/drivers/usb/gadget/configfs.c +++ b/drivers/usb/gadget/configfs.c @@ -56,7 +56,6 @@ struct gadget_info { struct list_head string_list; struct list_head available_func; - const char *udc_name; struct usb_composite_driver composite; struct usb_composite_dev cdev; bool use_os_desc; @@ -233,21 +232,23 @@ static ssize_t gadget_dev_desc_bcdUSB_store(struct config_item *item, static ssize_t gadget_dev_desc_UDC_show(struct config_item *item, char *page) { - return sprintf(page, "%s\n", to_gadget_info(item)->udc_name ?: ""); + char *udc_name = to_gadget_info(item)->composite.gadget_driver.udc_name; + + return sprintf(page, "%s\n", udc_name ?: ""); } static int unregister_gadget(struct gadget_info *gi) { int ret; - if (!gi->udc_name) + if (!gi->composite.gadget_driver.udc_name) return -ENODEV; ret = usb_gadget_unregister_driver(&gi->composite.gadget_driver); if (ret) return ret; - kfree(gi->udc_name); - gi->udc_name = NULL; + kfree(gi->composite.gadget_driver.udc_name); + gi->composite.gadget_driver.udc_name = NULL; return 0; } @@ -271,14 +272,16 @@ static ssize_t gadget_dev_desc_UDC_store(struct config_item *item, if (ret) goto err; } else { - if (gi->udc_name) { + if (gi->composite.gadget_driver.udc_name) { ret = -EBUSY; goto err; } - ret = usb_udc_attach_driver(name, &gi->composite.gadget_driver); - if (ret) + gi->composite.gadget_driver.udc_name = name; + ret = usb_gadget_probe_driver(&gi->composite.gadget_driver); + if (ret) { + gi->composite.gadget_driver.udc_name = NULL; goto err; - gi->udc_name = name; + } } mutex_unlock(&gi->lock); return len; @@ -427,9 +430,9 @@ static int config_usb_cfg_unlink( * remove the function. */ mutex_lock(&gi->lock); - if (gi->udc_name) + if (gi->composite.gadget_driver.udc_name) unregister_gadget(gi); - WARN_ON(gi->udc_name); + WARN_ON(gi->composite.gadget_driver.udc_name); list_for_each_entry(f, &cfg->func_list, list) { if (f->fi == fi) { @@ -873,10 +876,10 @@ static int os_desc_unlink(struct config_item *os_desc_ci, struct usb_composite_dev *cdev = &gi->cdev; mutex_lock(&gi->lock); - if (gi->udc_name) + if (gi->composite.gadget_driver.udc_name) unregister_gadget(gi); cdev->os_desc_config = NULL; - WARN_ON(gi->udc_name); + WARN_ON(gi->composite.gadget_driver.udc_name); mutex_unlock(&gi->lock); return 0; } -- 1.9.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/