Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162274AbbKTJYq (ORCPT ); Fri, 20 Nov 2015 04:24:46 -0500 Received: from mail-bn1bon0119.outbound.protection.outlook.com ([157.56.111.119]:39756 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934918AbbKTJYj (ORCPT ); Fri, 20 Nov 2015 04:24:39 -0500 X-Greylist: delayed 171605 seconds by postgrey-1.27 at vger.kernel.org; Fri, 20 Nov 2015 04:24:38 EST Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; samsung.com; dkim=none (message not signed) header.d=none;samsung.com; dmarc=none action=none header.from=freescale.com; Date: Fri, 20 Nov 2015 17:21:45 +0800 From: Peter Chen To: Marek Szyprowski CC: , , "Ruslan Bilovol" , Bartlomiej Zolnierkiewicz Subject: Re: [PATCH v6 1/4] usb: gadget: bind UDC by name passed via usb_gadget_driver structure Message-ID: <20151120092144.GD30829@shlinux2> References: <1448009652-14716-1-git-send-email-m.szyprowski@samsung.com> <1448009652-14716-2-git-send-email-m.szyprowski@samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1448009652-14716-2-git-send-email-m.szyprowski@samsung.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD014;1:EteVkZWmpU2UXrLvFbn+tunv9Dwuu4INJ7o0OhsIWzYSiZ+vWQPvr44G4P3ZwCM3jTpEmuxYfVSzCjPqNUlC/4UNL5+Vo5z0bVlszAnP3GHIzJGyjF9dO/RISIFqnE26qh6xTN9q6jVSrK/Myi+jH/lol8gXE30qdaRcjRWDH6h8/TP4ctAZ7ohAOunaFox8hYV+Ff3x02hd+FIErF/iXxV67L7yWDNmFLnQ8w1OjAGHriptKfKg/t+uDf+DQWW30+AAIIbxssrbBlrgArH6M1P4ehs4aHC24iM17nzqF45o0E8Sl8B7xXsw1FFgCaeolDd8mmmvsWQ/3FXTdP9CUOVj7jIACcV7d5N7EA3TLUhXWuruCsmCE8qJrQp+lQKViumRfoY2OpZIr1R0pP+GTg== X-Forefront-Antispam-Report: CIP:192.88.168.50;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(1060300003)(448002)(24454002)(189002)(199003)(50986999)(110136002)(81156007)(5890100001)(4001350100001)(5001920100001)(5001960100002)(50466002)(19580395003)(19580405001)(11100500001)(46406003)(92566002)(23726002)(33656002)(76176999)(5007970100001)(97736004)(54356999)(5008740100001)(97756001)(4290100001)(104016004)(6806005)(15975445007)(77096005)(47776003)(83506001)(606003)(86362001)(110436001)(2950100001)(33716001)(106466001)(85326001)(87936001);DIR:OUT;SFP:1102;SCL:1;SRVR:BY1PR0301MB1221;H:tx30smr01.am.freescale.net;FPR:;SPF:PermError;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1221;2:bL+Sgcm7aCX8L7hsAK8aF0OKLIJFzOmkoRq6BItLRtEaBGW6Dowq9Cj2u/saY0LGRaSB1xriaPN2HHIrnMc1ASnq0w6Sr3NxTsBkccH+STCfkJEAuf6dttxduKx3OOGWpafAsO65wLsQWMotqnj19Q==;3:kAKxlWzDRsdeZOU6hovEcmF2fBJ4yl8PvartZXjNshmD/L6oBleRt0QxHNoQmoO+rk3T6y1L+a9BUoPD8gL35lZ/92of99HV9sPZ74so4Zr5D6++GqsVtB00ap4bG4EnUtqg3Kih9GmZQ89R8fdqc1A5yUYt/G9U4AKt/8DYRaJzIhBmUcspF1bWA5GYU9IcCzInHrSZrgSMKm3VrzTYXkAcR9Rli9PHRepWYOVTYUrJOePJ1vtfgzrp0uXkhkuDOS18FJBgy7QC6EU8rBNz8A==;25:5BdjB2H1GNotnUmyxm4YsAg9Xcm3QZWxV2msE5zwfQ1i6tosJp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skOHTSK1Ly8dspJZkmGhBIchpFkv7eWfWJYijtven0QyPA== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(10201501046)(3002001);SRVR:BY1PR0301MB1221;BCL:1;PCL:0;RULEID:;SRVR:BY1PR0301MB1221; X-Forefront-PRVS: 07665BE9D1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0301MB1221;23:1Nbe3RL/QdijU3mdQlEBN2K8qalUZtwxt6yXhdG?= =?us-ascii?Q?+QU+b/+Faa5z7OrPJBgkycDNrbrAhwXun0S1pOwDvKVVfDU9SpV0F97KPbSp?= =?us-ascii?Q?MYS58qv8AUhOgEpIOwqh4DvnlC0bbfAcYp1ggAIMzPddXExc3T2UqSSOqOEW?= =?us-ascii?Q?55aI17LNHJJIwFQIF349pGSU5YLKxCekquXdhoqtvqBo7xHc3e7A1fEJ4bth?= =?us-ascii?Q?XtKrdLLZwR/X4UkaPm2giF/L8nIThG2YPGRtkzTxKnJJ2vQD0clu+x4i5ytE?= =?us-ascii?Q?UzH29XBVEWrG149+Yzi/gl8+BEh2PimF3TfwL2b1MTxnemgRMYldPhiOuQiE?= =?us-ascii?Q?KhGjpwA74nW07yNbgdntpHJpsfCbPnNGNYrkLt2oUANdcb5qT6cpZLtRpER+?= =?us-ascii?Q?noKMirskPFk/U29tR8sKuF72nbhIugw56bW+T5kKET/kUWqsbXuo94Rh96UU?= =?us-ascii?Q?JFG0aBXkKoc7P7Yodi5T4lMVbkcgfI+yAS8Wxp8SrKe40tsX9ygdgu2lOlkj?= =?us-ascii?Q?wEFNzNBY/WGNUpC04v45tMu58phEELuIIwm6RycO2AT8QyYLJN1jmYc8NcLW?= =?us-ascii?Q?AAyrfRrC5TiBdWRzaPJDGKAdL6KJpOYhe/giTEHATQ/hMrDQ76H/c+kqIk1p?= =?us-ascii?Q?1n5vRxU1xIpRIx0mZJHA+zwzWBL7U1qosv7nKbAvXWOXv12xL6ukmgan3k0G?= =?us-ascii?Q?TdKexxhbg/iaEFQN0rH0CRvNZzH7DgNXCaZOcR+gFR/pGSTM5dc9/wzu2gIt?= =?us-ascii?Q?yCaaBG6tX4LpuQ9AGC9gtbCE6WwR4Ecco1Wrwh+Nemyon9/SSupjyyE23azS?= =?us-ascii?Q?QFgnJIF1i/ZHiHdP1kTxAsSs2sRtUiRgpV5+xeNYiAx1U7+p8fsE1VUrKOOT?= =?us-ascii?Q?i2qDpqtZOREg7jZ2PnnF+mbM5ZR7WMsYG4AEwZ6beJoQ1n1n7HlCLOAQERpV?= =?us-ascii?Q?D+Hn4+eNFkAo3bEaqzJJkSxGYQp7sPKNZTvh4XAPpaZ7POZJ9KCBkd+N3Z3t?= =?us-ascii?Q?4uYYi/DESyzXIWNf+YK3qp1BPZEHdeZW4qJzNlxB1vqyCNX1U06rucAhLp3R?= =?us-ascii?Q?zO53Aj4WzcwrbxfyV0CeQL8APPxc3x2UQv/ZStBIO9Mu71rhSIDUlT0NFrQP?= =?us-ascii?Q?lN7w2oTBgSeTU9jaDHDHf0l8CFDvnENElWpNaneP66AoVVfhyin0weA=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0301MB1221;5:XUi4k34L6u3ubVAEAgwW9zjOmTxaHtlMb0a5gA0bX9XajAk4/bvMXgqu7IJLxHe9VPuRwtjSQe7ThujI9INCqrztUOWxvT59jXrAbfxNOHX+zoixx+k4jzFlfCoSu5iU2+9qUpX/+DzKNS3KrQFE8w==;24:AlDe5W/PpTWazJDAXtoAD9tNylej3Tr14so53rBFEcraEAoUctOWE5BWkF/vh1YE94GaLKdlRelCJTmB4GrvhpJer8M3e09NFJwZvJf60Yk= SpamDiagnosticOutput: 1:5 SpamDiagnosticMetadata: 00000000%2D0000%2D0000%2D0000%2D000000000000 SpamDiagnosticMetadata: 1 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Nov 2015 09:24:34.9903 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0301MB1221 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3624 Lines: 109 On Fri, Nov 20, 2015 at 09:54:09AM +0100, Marek Szyprowski wrote: > From: Ruslan Bilovol > > Introduce new 'udc_name' member to usb_gadget_driver structure. > The 'udc_name' is a name of UDC that usb_gadget_driver should > be bound to. If udc_name is NULL, it will be bound to any > available UDC. > > Tested-by: Maxime Ripard > Signed-off-by: Ruslan Bilovol > Signed-off-by: Marek Szyprowski > --- > drivers/usb/gadget/udc/udc-core.c | 24 +++++++++++++++++++----- > include/linux/usb/gadget.h | 4 ++++ > 2 files changed, 23 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c > index f660afb..429d64e 100644 > --- a/drivers/usb/gadget/udc/udc-core.c > +++ b/drivers/usb/gadget/udc/udc-core.c > @@ -549,21 +549,35 @@ EXPORT_SYMBOL_GPL(usb_udc_attach_driver); > int usb_gadget_probe_driver(struct usb_gadget_driver *driver) > { > struct usb_udc *udc = NULL; > - int ret; > + int ret = -ENODEV; > > if (!driver || !driver->bind || !driver->setup) > return -EINVAL; > > mutex_lock(&udc_lock); > - list_for_each_entry(udc, &udc_list, list) { > - /* For now we take the first one */ > - if (!udc->driver) > + if (driver->udc_name) { > + list_for_each_entry(udc, &udc_list, list) { > + ret = strcmp(driver->udc_name, dev_name(&udc->dev)); > + if (!ret) > + break; > + } > + if (ret) > + ret = -ENODEV; > + else if (udc->driver) > + ret = -EBUSY; > + else > goto found; > + } else { > + list_for_each_entry(udc, &udc_list, list) { > + /* For now we take the first one */ > + if (!udc->driver) > + goto found; > + } > } > > pr_debug("couldn't find an available UDC\n"); > mutex_unlock(&udc_lock); > - return -ENODEV; > + return ret; > found: > ret = udc_bind_to_driver(udc, driver); > mutex_unlock(&udc_lock); > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h > index 3d583a1..b32e44f 100644 > --- a/include/linux/usb/gadget.h > +++ b/include/linux/usb/gadget.h > @@ -1012,6 +1012,8 @@ static inline int usb_gadget_activate(struct usb_gadget *gadget) > * @reset: Invoked on USB bus reset. It is mandatory for all gadget drivers > * and should be called in_interrupt. > * @driver: Driver model state for this driver. > + * @udc_name: A name of UDC this driver should be bound to. If udc_name is NULL, > + * this driver will be bound to any available UDC. > * > * Devices are disabled till a gadget driver successfully bind()s, which > * means the driver will handle setup() requests needed to enumerate (and > @@ -1072,6 +1074,8 @@ struct usb_gadget_driver { > > /* FIXME support safe rmmod */ > struct device_driver driver; > + > + char *udc_name; > }; > When trying to apply for testing, I meet below warning: Applying: usb: gadget: bind UDC by name passed via usb_gadget_driver structure WARNING: please, no space before tabs #55: FILE: include/linux/usb/gadget.h:1016: + * ^Ithis driver will be bound to any available UDC.$ > > -- > 1.9.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-usb" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Best Regards, Peter Chen -- 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/