Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751705AbbGMCs7 (ORCPT ); Sun, 12 Jul 2015 22:48:59 -0400 Received: from mail-bn1bon0143.outbound.protection.outlook.com ([157.56.111.143]:41434 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751584AbbGMCs5 (ORCPT ); Sun, 12 Jul 2015 22:48:57 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Mon, 13 Jul 2015 09:39:49 +0800 From: Peter Chen To: Li Jun CC: Roger Quadros , , , , , , , , , , , Subject: Re: [PATCH v3 02/11] usb: otg-fsm: support multiple instances Message-ID: <20150713013948.GA27710@shlinux2> References: <1436350777-28056-1-git-send-email-rogerq@ti.com> <1436350777-28056-3-git-send-email-rogerq@ti.com> <20150710080642.GB14729@shlinux2> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150710080642.GB14729@shlinux2> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11FD050;1:TzmLJkYoQ5deCQYYMkmMf7fet1Q4cQfRUOWRhO/Dda2AXx9YNQk2qjBZ1dHokhZZN5+SXDm7scZRXGCeoUJ7IEXKf4vmVpGVrQ32bRHG0clsvoEOCouOwXe/ID12+LZKPiEQNbpx5nea0Hyev3Y+AcJsyG3/iPIvjb4FFVAj45wOJHbcCFacMWwJYCpblNboIFWbjMWsUHYD1/9mydz+bQD0zSFwI2QiFz5cxEO2kVC3aU/462a8fZG5c7inveHv3Cd1lLqLFgtaKZ/yhriyzchjCJ3/9vPHpDs8Ed16MHVssdCpRJvPfZSE/3eyf45oogxJYH3cUkKoSL9h7TygYS4wNeRTwDjtNctV4GpOjtg= X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(1060300003)(2980300002)(339900001)(51704005)(24454002)(189002)(199003)(85426001)(86362001)(97756001)(104016003)(19580405001)(33716001)(87936001)(19580395003)(6806004)(50466002)(62966003)(77096005)(2950100001)(77156002)(110136002)(105606002)(50986999)(5001960100002)(54356999)(4290100001)(23726002)(92566002)(110436001)(106466001)(47776003)(46102003)(46406003)(33656002)(76176999)(4001450100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1226;H:az84smr01.freescale.net;FPR:;SPF:Fail;MLV:sfv;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1226;2:cZ9mHE0PHI5EcW/9akcB37Gfm4oMgtMULO0mGub2EFXcixXJWilYVufMdGYm/W3/;3:HPB9zcoa/704DtN8u11Pi5+IbFQKVYJiR7uUx4kduBYtRazIRMlJvdUq1+VuV8yMhiYhf55YxlAsTzp/xV0OB+gImyVg8Eb1qfkLsu1NaCYtBpJ7fTy7NiAz4tL+CI2C2D0Y6oqA6/8cICfC0zpVaTD2gDBTnIFn1BIiEWBVi8HLvbN6tfveKRcpw/Sr1eVP5hhoYea3eooBdgPGpFCaD7GmIFGnl53dXJyafLkMsYc=;25:Tf60o9BhfbO34XEudwQ+Rz8/btvYP2lWX/h1n38CCMcisnrF/9K64/B8xTKyuqb0AZKuxOzUooQzHYSjCRKACmp2eF3F0hQQJtD726R4XQjkawshHd/lO0pKaXGmRMH7NPHajmAEgUYROtZluP+1JbJ2qU5JQkSWeEN/hx+/9O78ogTXrvVDipHizj1JQdFPuA+jClim7CIwCbYMiVWoiDS+uUc+jrWntl1CrCaGSVe4A2t8jXrnFu7bI3dbAh4qco3FY32XXwN0bl+551rbdg==;20:qQzGFdBPh5BomAgIX7A7+W03JB5ua7CPNCg0YAap/U3LGTE7q3asB0CHjbsuyTiTBnGo/AdJ66QmEL13KVJBOIBxIqh3gTq7c1jxUUHodHKzwrd/wy5fe3HZ48Aq3dV7u1mBHXQqitLFebCB2PF8wEqKB9AuTRMzHSkh21B6JpMbpIM1Pt8hHX6RYlJFyyIp0qq9NICEPVauWIq9boy0b5fzLbqpwYk6NmqSxwmEHj+NzLzFcognoVlMl3iFf49gVsyHJsnMcJ9yH08XtJusLSwZ3JmEQ2/n7GQseFahVwfAGVGEXFW59jUSxtSrGpkk1ZUXXFBhvF4z3an1rv3eHsGiW1ja2hUvj7i/Py7EX5U= X-Microsoft-Antispam: UriScan:;BCL:1;PCL:0;RULEID:;SRVR:CY1PR0301MB1226;UriScan:;BCL:1;PCL:0;RULEID:;SRVR:CY1PR0301MB1545; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:1;PCL:0;RULEID:(601004)(1201001)(5005006)(3002001);SRVR:CY1PR0301MB1226;BCL:1;PCL:0;RULEID:;SRVR:CY1PR0301MB1226; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1226;4:q9moeectF8Rex4Hu6aCcoo3Kwo0khzRE3v1V3tm7o22olHQDkHosqYUV7+SWa4rpbKH9wSI4P9qC8akNUIBxtlpgVLCcbEhaYCjkpYaxsfdJuUt+OUG8tLGvalpdBksramNOxn9OzmzqrwEliT3jZhV+bDNIsvIBVaR0FsOoIoF628JTakEQ71Q4SSA8vyIkP+4N6Tuex9lGsOWrhBtym8PHEnyqUxoQxG/Dyp2Vznj1RWACne4xw1SFg2TcxrCLF3FxRDrMf7OrsL4GW6xpBH7YqzwcILiStmQ/GELyzC+htEaE4sLqHmS0Cdyl1FrM X-Forefront-PRVS: 0636271852 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CY1PR0301MB1226;23:idDWZ9SF4TCNzdmSXGWWjnxaLCQ9SyoKhpkaIXk?= =?us-ascii?Q?9esyXQoO7wuuJ42DJQ22xiHYtn+BLPXlvnts+RLaHNrsaTAl7XNcPp978V85?= =?us-ascii?Q?kGRUsU1ccw3o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Tnw?= =?us-ascii?Q?WLzo/N/3bE9R2JjLTTwd+IPYk?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1226;5:sjf0dElggTP3WIDzX6CCLuzKJYtfV0/R8oQSe5CoLOD3dQSgxTZG5jQjmh+vqMPh8g6pjbt8yojzcHYn38GdtHbk+Lfl6SBqbmrPqgdQ7acz0sJKf0P4vZxh/gxFHKE6MSmLPTbKTlKZsrvYNT7g5A==;24:UyJV7OgjMlFg7gasizihPi2B3YIDJSoNecLJGeyawSGTq18CEAK8DljmA6fkEiH/q/shvkWbQ0x7mhwF3mUg1QTeHgEeYU6OyK1nC9vKmcg=;20:GNq6uM2O74VnvymeRg/gXYadGiWzfrcaja7xin9Y7uz9BzZ04V9ZYUorvhS4X2wWESYIRRfi2cGgwfOJP23Qgw== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2015 02:48:52.6191 (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: CY1PR0301MB1226 X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1545;2:pxtzHEl1BoSwmzckFHdRwXpc98I8+m+wfmW0HhZnQBMBW2h8uDJi9eL0HWqYeBsV;3:n1XIIsbT/wgp7vCXlIc00md6ANPByT/3x4++rPi+ksIChgH9tRezJ4I83neEpxAUqhvD+O9rztkLcyBNCvRkMgxwmsGFu6b1Z4HSmctc7Tsm6WiGhMPZPH41NdcR+WendV30W2/7mEwIqq7gShHvvw6tkB/OllZMDWvZ8m68FPkbioDQfICblK2b6X8fncEkTNsaTyR0HcLzMnqi1oZ2uexvhaevrhFH/qcpKzknxBQ=;25:/w6HiYaTLie7MFkI8Tplw7EARUI9bwfb4DSIvTb0Lj76D7I8vylRupMFEZZyavSC/TOKp883utiZE+3tNKUqg+c+UHACy/EjnLtbhV9ybQHlSdd3A4bu+DGSYALWHLt5Co+BzZ3biv53kdYAH3Ejxasn684to5ywsUkYCiVK4sthfYz/9SG2d0UWTSpOZDeTXe2wEpT8B9KawjXJQB4C6DUg2ccF/RDY1Bx/rwIKhEmGMJmdxdiKGBcy90YQfbkHTbMG5YiVHX1wHKNe7S5jcQ==;23:G1d7k56FDpHrCPMEFapCpNY6ZMb/Z9a05HykUGnWijx/EAbv2Dwi8RR0OpmLLU3hHSv3stNBLXhFdb3bdjCVfAloTnLDw7RnQjk4Rpq0/tiX1Z86PP+xEGlNBa+V2d5Ct8Rm825Bt4WxwsfbwhK037Sudge2dSgCJ71EdtMsFhdL1ZZ+QEpVh+9a8rVNN0ohbI5A09BGDLKv9gJ/Q9tVe8n8YrCTcnhpKcBOCNCEzFkLzDxCxZGrAJ+5et/QcwV4 X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3083 Lines: 94 On Fri, Jul 10, 2015 at 04:06:43PM +0800, Li Jun wrote: > On Wed, Jul 08, 2015 at 01:19:28PM +0300, Roger Quadros wrote: > > Move the state_changed variable into struct otg_fsm > > so that we can support multiple instances. > > > I am not sure if multiple instances may happen since OTG protocol requires > only one OTG port can be equipped on OTG device. > It is ok the software can support more than spec requires, the user can only use one and the spec may change in future :) > Li Jun > > > Signed-off-by: Roger Quadros > > --- > > drivers/usb/common/usb-otg-fsm.c | 10 ++++------ > > include/linux/usb/otg-fsm.h | 1 + > > 2 files changed, 5 insertions(+), 6 deletions(-) > > > > diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c > > index 61d538a..42c6376 100644 > > --- a/drivers/usb/common/usb-otg-fsm.c > > +++ b/drivers/usb/common/usb-otg-fsm.c > > @@ -61,8 +61,6 @@ static int otg_set_protocol(struct otg_fsm *fsm, int protocol) > > return 0; > > } > > > > -static int state_changed; > > - > > /* Called when leaving a state. Do state clean up jobs here */ > > static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) > > { > > @@ -123,7 +121,7 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) > > /* Called when entering a state */ > > static int otg_set_state(struct otg_fsm *fsm, enum usb_otg_state new_state) > > { > > - state_changed = 1; > > + fsm->state_changed = 1; > > if (fsm->otg->state == new_state) > > return 0; > > "fsm->state_changed = 1;" should be put here, I think. > Yes, seems it is the problem at current code. > Li Jun > > > VDBG("Set state: %s\n", usb_otg_state_string(new_state)); > > @@ -248,7 +246,7 @@ int otg_statemachine(struct otg_fsm *fsm) > > mutex_lock(&fsm->lock); > > > > state = fsm->otg->state; > > - state_changed = 0; > > + fsm->state_changed = 0; > > /* State machine state change judgement */ > > > > switch (state) { > > @@ -361,7 +359,7 @@ int otg_statemachine(struct otg_fsm *fsm) > > } > > mutex_unlock(&fsm->lock); > > > > - VDBG("quit statemachine, changed = %d\n", state_changed); > > - return state_changed; > > + VDBG("quit statemachine, changed = %d\n", fsm->state_changed); > > + return fsm->state_changed; > > } > > EXPORT_SYMBOL_GPL(otg_statemachine); > > diff --git a/include/linux/usb/otg-fsm.h b/include/linux/usb/otg-fsm.h > > index ca508c2..243274f 100644 > > --- a/include/linux/usb/otg-fsm.h > > +++ b/include/linux/usb/otg-fsm.h > > @@ -194,6 +194,7 @@ struct otg_fsm { > > /* Current usb protocol used: 0:undefine; 1:host; 2:client */ > > int protocol; > > struct mutex lock; > > + bool state_changed; > > }; > > > > struct otg_fsm_ops { > > -- > > 2.1.4 > > -- 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/