Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751612AbbHGJHQ (ORCPT ); Fri, 7 Aug 2015 05:07:16 -0400 Received: from mail-bn1on0138.outbound.protection.outlook.com ([157.56.110.138]:12306 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750809AbbHGJHM (ORCPT ); Fri, 7 Aug 2015 05:07:12 -0400 From: Peter Chen To: Baolin Wang CC: Felipe Balbi , Mark Brown , LKML , Greg KH , "sojka@merica.cz" , Alan Stern , "andreas@gaisler.com" , "linux-usb@vger.kernel.org" Subject: RE: [PATCH 2/2] gadget: Support for the usb charger framework Thread-Topic: [PATCH 2/2] gadget: Support for the usb charger framework Thread-Index: AQHQ0BaxZP3OMS4IlUyXJ34Mbmgr1J4AjpUA//+sWoCAAAPD8A== Date: Fri, 7 Aug 2015 09:07:09 +0000 Message-ID: References: <8fcb9ff7a8e01bec53813f0702ff606bf4982943.1438844454.git.baolin.wang@linaro.org> <20150807054554.GE13200@shlinux2> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Peter.Chen@freescale.com; x-originating-ip: [192.88.170.35] x-microsoft-exchange-diagnostics: 1;BN3PR0301MB0852;5:EiNVJ7OliTtbtEu2J6xq7fAfM4P40dgfTkDui+8tCcR2hdPRTePs1fOmSclxOcEbo/9A5HokxDXPsOlLaWLqNn6D+VDCr2Zyr8ewOTr1MeTwk0Jsji4MuYnPyYfxc48T5PjKMJgkNdNQQ7p59HjV1A==;24:5tAJjsDO0bZ3tABKtOX/5dJOFyL65kF1SR5kwkJqD2ac6oZwUdQirH6YFlLsEIXphZNuB4zXE5bqXSuTG68OVcdMVPMCJBYQeE3FVeiPaCA=;20:N1FiIOS0cKjDVqT8GMpCeWnACFfm8hi2SlRmqDdezMsWSdnXLMR1m4hn2YpuyUFUKGlRNsMftiPG6PnJ+MrUMA== x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB0852; 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:BN3PR0301MB0852;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0301MB0852; x-forefront-prvs: 066153096A x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(2900100001)(66066001)(81156007)(86362001)(68736005)(102836002)(2950100001)(77096005)(54356999)(46102003)(50986999)(87936001)(122556002)(76176999)(62966003)(77156002)(101416001)(93886004)(33656002)(2656002)(74316001)(92566002)(5001860100001)(97736004)(5001830100001)(106356001)(5002640100001)(64706001)(5003600100002)(106116001)(40100003)(10400500002)(76576001)(99286002)(110136002)(5001960100002)(105586002)(4001540100001)(189998001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0301MB0852;H:BN3PR0301MB0849.namprd03.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Aug 2015 09:07:09.8919 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR0301MB0852 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t7797MH3021350 Content-Length: 1065 Lines: 27 > >> /** > >> * 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? > > > > The spin_lock_irqsave() can make it as a atomic notifier, that can make sure the > gadget state event can be quickly reported to the user who register a notifier > on the gadget device. Is it OK? > I don't think it is a good reason, spin_lock_irqsave is usually used for protecting data which is accessed at atomic environment. Peter ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?