Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752683AbdGMW3z (ORCPT ); Thu, 13 Jul 2017 18:29:55 -0400 Received: from mail-pf0-f172.google.com ([209.85.192.172]:34389 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752279AbdGMW3t (ORCPT ); Thu, 13 Jul 2017 18:29:49 -0400 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 To: Peter Chen , Peter Rosin From: Stephen Boyd In-Reply-To: <2db7bc39-9274-6007-d971-59e2a577d437@axentia.se> Cc: linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Rob Clark , Andy Gross , Greg Kroah-Hartman References: <20170712010255.26855-1-stephen.boyd@linaro.org> <20170712010255.26855-3-stephen.boyd@linaro.org> <2db7bc39-9274-6007-d971-59e2a577d437@axentia.se> Message-ID: <149998498328.4532.10720468535933872401@sboyd-linaro> User-Agent: alot/0.6.0dev Subject: Re: [PATCH 2/3] usb: chipidea: Hook into mux framework to toggle usb switch Date: Thu, 13 Jul 2017 15:29:43 -0700 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 quoted-printable to 8bit by nfs id v6DMU2Ir022921 Content-Length: 1702 Lines: 45 Quoting Peter Rosin (2017-07-11 23:45:24) > On 2017-07-12 03:02, Stephen Boyd wrote: > > @@ -102,4 +107,7 @@ Example: > > rx-burst-size-dword = <0x10>; > > extcon = <0>, <&usb_id>; > > phy-clkgate-delay-us = <400>; > > + mux-controls = <&usb_switch>; > > + mux-control-names = "usb_switch"; > > + usb-switch-states = <0>, <1>; > > I don't see the need for usb-switch-states? Just assume states 0/1 and > if someone later needs some other states, make them add a property that > overrides the defaults. Just document that 0 is host and 1 is device. > Fine by me. Rob H do you agree? > > diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c > > index 18cb8e46262d..9fd23ecc2da3 100644 > > --- a/drivers/usb/chipidea/host.c > > +++ b/drivers/usb/chipidea/host.c > > @@ -25,6 +25,7 @@ > > #include > > #include > > #include > > +#include > > > > #include "../host/ehci.h" > > > > @@ -123,6 +124,13 @@ static int host_start(struct ci_hdrc *ci) > > if (usb_disabled()) > > return -ENODEV; > > > > + if (!IS_ERR(ci->platdata->usb_switch.mux)) { > > + ret = mux_control_select(ci->platdata->usb_switch.mux, > > + ci->platdata->usb_switch.host); > > + if (ret) > > + return ret; > > + } > > + > > You *must* call mux_control_deselect to clean up if there is a failure > later in host_start. Is that handled in some non-obvious way? Good catch. Thanks. I'll add in the unwinding on the error path.