Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755483AbbHGG40 (ORCPT ); Fri, 7 Aug 2015 02:56:26 -0400 Received: from mail-bn1bn0103.outbound.protection.outlook.com ([157.56.110.103]:38400 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755406AbbHGG4W (ORCPT ); Fri, 7 Aug 2015 02:56:22 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; lists.linuxfoundation.org; dkim=none (message not signed) header.d=none; Date: Fri, 7 Aug 2015 13:45:55 +0800 From: Peter Chen To: Baolin Wang CC: , , , , , , , , Subject: Re: [PATCH 2/2] gadget: Support for the usb charger framework Message-ID: <20150807054554.GE13200@shlinux2> References: <8fcb9ff7a8e01bec53813f0702ff606bf4982943.1438844454.git.baolin.wang@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <8fcb9ff7a8e01bec53813f0702ff606bf4982943.1438844454.git.baolin.wang@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11FD043;1:9f/fNDuMjnJqryQTqFfEXNtVWlb7/YGwMu8N7+4SybQidczr1tQaNQzneF4SFdZTVcLfhxIQC31gwB2h107HLpdMkT155H64pM+PNEd6Nje5rCKi3KXIbH12Q4j+tKU3+CeEtq4wJQydc/W7uueHFv0BhQ0wK11kfFqiwo5Z5ae/PHH4b2FtSu/TrGObYXm6BVk3wiihhOsFrFdMzc0cgHX3QjOkV2C/YYtBHSWquxynn4uHqCcxcGw0guQWhrYy9Fuse2ZcLdznIKqDZOrJlOqmPg8Y3ZFEYCme2opdCoTS76zpLVLJ0Jjx7bu85Dhp X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(339900001)(199003)(24454002)(189002)(50466002)(83506001)(69596002)(87936001)(76176999)(54356999)(86362001)(47776003)(64706001)(50986999)(2950100001)(77096005)(85426001)(46102003)(46406003)(68736005)(33656002)(97756001)(104016003)(23726002)(189998001)(110136002)(5001830100001)(105606002)(106466001)(4001540100001)(92566002)(97736004)(6806004)(5001860100001)(77156002)(4001350100001)(33716001)(19580405001)(5001960100002)(62966003)(81156007)(19580395003);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB1268;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1268;2:N86P2zckQEOlw9Hw2AjVp55rnZ5oPK0uYLgy5UxcwWyoWvacBqhLdEMs42wuzuZODFgzOvgz9nE/AKBYl6VtZq50d5AiU+PcphWfN7bIerQKX830lHUQ7V5CjQdRnTe+TGumtj56G68Bw3emDfmvzH1fiaUnuJ5MzzSIKfNCLDw=;3:HvqWfgceIvfdL5+fviFTLKjEMrkKPdyLuyK8JxVvPC+j4l88LupRwZwXzTp7yPHebTtzHIcnr3cj5flvD7c8QR0EBn3lbw9nuK+lVbX1tUGKKDgwOfvUd6GEJlL5Qh8cJ//IoSgz1TXVxz/7A1bAg4SD7nXjdr7C+1qR3SKzuAmmrMXBc62AexiQ1hD79repWkM6bXqpvn2RtjDGdTonZTEZgQuVmdYtEaIrX63wfuA=;25:Tj8PUXhPxyIMLTfTqEm+aLS9F9k2R1utXyVzovJpHvEEyuYwvxHbQ+SQzBsKRN6vwv1g2dxLC9/XeByQiZ7PggMkepCXTRa81xCw1yvjD4EewcF3SBmTFbhmpJA9a2vJVDNI6wEupkBPdiQV8ZIwUHP9+6cfuj+DetzjCTzUJzB6cvaasGiTHDsRYHrjgiuS2Y8m+icctlMuyOE/NWsWLm1i56vU1VVSjfeAVckWXb35+XuYDlsRIOMhafp2O5+N X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1268; X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1268;20:STElGEbzgId2ir7TVeh75XzilH102NUihb/De+g207Y5Of5WPQlTvoNJsMaJ5SlQygQgauEPpr9iV3LiQYhmufPc3VqM8rbhAN2z0kvm+cOXhVzzMAvMuhNQIrAt8l3SQRn+qdm3WYB1PLp9nOFl+FOhagpKXs3WR2h/rBYROr0fZ5Cgdj4NLMbQKBum4SMi1rpCpa8j8CgdDk/4Kwta7iZeTf0V+WlZGqasDijmYtnpwD8pzstVZND0zUPV6j2M+LkrYE3LWSDqJtx7FxGidPlgz3eBysj17VO4KzzVooBMsm+hNuYkB8zeP45jBbxxZ8y+ZBCR8pkKT2oUnIvIcZlWT9mtU9Pv0XaYEZmoK2o=;4:rhmQ6he3cQz72TTAbo14DGsUyVGZeoVsDRn4vaZG2q16+C9/+z8N7G3fjG3aDUhqYWUEQ0NcVX7VY31rRm18D4ULE4fQbR1nkH3CzIl6nqawlr6MsVJ1YUDf0xeNywNkWS//DDNEqjUTGDy/ELRUuPUdv+jsLqcgSid60Q9SDp4A8YjpdMRNtvcis8cOcbfEdDguwiOMFH2gTkVRskQP5pehWKg7yAhkJIIzzZwwVNuZtoCKFehMNAfXxa2z8h3tiOLTlhbVc47rFoAkUepbnZU/YqTOgRiIVMpxISODfzI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:BN3PR0301MB1268;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB1268; X-Forefront-PRVS: 066153096A X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BN3PR0301MB1268;23:wzfs5NtP7ntimDdvzHRRvld+X/B9/qqvUPTOlZC?= =?us-ascii?Q?MQ98dHdUhu8ERNVuFh9hqlyICdtWUobyYnIvDnb715wKGyDsfQe7OEdNsN9X?= =?us-ascii?Q?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bDw5A/29zl8ONf41X0+nBOW0IVRJl?= =?us-ascii?Q?mr5M0rWvpv/K37TPQZZoj2rRGyxhfQE5Zvy8U3797wh2/xeVzXlWtfvC0XCF?= =?us-ascii?Q?eXeC20tyRlUTzCwJSM8RS10LKxthQZMhvALAskhuiSpsTXFRN5RQitMJZTiG?= =?us-ascii?Q?8liXUL8ZsgPou5Xfv8cSAAYFdtSbNpr6L5VAGBqXRIVVasjo5ijWgNg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;BN3PR0301MB1268;5:EeibTqcj+WpGC5yyBfyjNVn/+/pzd5ZMUdSuEbGhAzhx1CHuj2zskK5I4EMkPawdTRXaZtE4f3fNY3uFBxTN+HXginIvZAmLmbwegaix5folBGcsbKC9GQt+B2vMpPyroAbCqFBKRxEDpfS0arSWAw==;24:4jy97E1UmqHdI8OJdmmiVqvwtpIMD0ouYyKOsvhy1OvMMdeTAbRoHiHxfemdd898cuvZ5dKC6RPpN+T4s7kcYfXzS3r4r3YEvQXoDLESO4I=;20:XZk29QbqJS/5CxhM66ziJooezmxwlaSsKuMQ2wmPysrtTSZcXib9JOz0VsqEQO4FuqcFZaP4CsCdk1870efVjw== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2015 06:56:19.9760 (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.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB1268 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1820 Lines: 52 On Thu, Aug 06, 2015 at 03:03:49PM +0800, Baolin Wang wrote: > The usb charger framework is based on usb gadget, and each usb gadget > can be one usb charger to set the current limitation. > > This patch adds a notifier mechanism for usb charger to report to usb > charger when the usb gadget state is changed. > > Also we introduce a callback 'get_charger_type' which will implemented > by user for usb gadget operations to get the usb charger type. > > Signed-off-by: Baolin Wang > --- > drivers/usb/gadget/udc/udc-core.c | 41 +++++++++++++++++++++++++++++++++++++ > include/linux/usb/gadget.h | 20 ++++++++++++++++++ > 2 files changed, 61 insertions(+) > > diff --git a/drivers/usb/gadget/udc/udc-core.c b/drivers/usb/gadget/udc/udc-core.c > index d69c355..d5368088 100644 > --- a/drivers/usb/gadget/udc/udc-core.c > +++ b/drivers/usb/gadget/udc/udc-core.c > @@ -28,6 +28,7 @@ > #include > #include > #include > +#include > > /** > * struct usb_udc - describes one usb device controller > @@ -127,12 +128,45 @@ void usb_gadget_giveback_request(struct usb_ep *ep, > } > EXPORT_SYMBOL_GPL(usb_gadget_giveback_request); > > +int usb_gadget_register_notify(struct usb_gadget *gadget, > + struct notifier_block *nb) > +{ > + unsigned long flags; > + int ret; > + > + spin_lock_irqsave(&gadget->lock, flags); I find you use so many spin_lock_irqsave, any reasons for that? Why mutex_lock can't be used? -- 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/