Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753753AbcD0K3h (ORCPT ); Wed, 27 Apr 2016 06:29:37 -0400 Received: from mx0a-0016f401.pphosted.com ([67.231.148.174]:2882 "EHLO mx0a-0016f401.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752505AbcD0K3g (ORCPT ); Wed, 27 Apr 2016 06:29:36 -0400 Date: Wed, 27 Apr 2016 18:25:16 +0800 From: Jisheng Zhang To: Mark Brown CC: Felipe Balbi , , , , , , Subject: Re: [RESEND PATCH v2 7/7] usb: xhci: plat: add vbus regulator control Message-ID: <20160427182516.36bd5fb5@xhacker> In-Reply-To: <20160427095738.GG3217@sirena.org.uk> References: <1461675460-2295-1-git-send-email-jszhang@marvell.com> <1461675460-2295-8-git-send-email-jszhang@marvell.com> <87bn4vpq7j.fsf@intel.com> <20160427095738.GG3217@sirena.org.uk> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2016-04-27_06:,, signatures=0 X-Proofpoint-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1603290000 definitions=main-1604270166 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1055 Lines: 40 Dear Mark, On Wed, 27 Apr 2016 10:57:39 +0100 Mark Brown wrote: > On Wed, Apr 27, 2016 at 08:37:20AM +0300, Felipe Balbi wrote: > > Jisheng Zhang writes: > > > > + vbus = devm_regulator_get(&pdev->dev, "vbus"); > > > devm_regulator_get_optional() ?? > > Does USB work without a VBUS? Unless the answer is yes then I'd expect > this to be just a normal regulator_get(). Per spec no. But the vbus may be transparent to SW on some platforms, so I think devm_regulator_get_optional() is better. > > > > > > + if (PTR_ERR(vbus) == -ENODEV) { > > > + vbus = NULL; > > > + } else if (IS_ERR(vbus)) { > > > + ret = PTR_ERR(vbus); > > > + goto disable_clk; > > > + } else if (vbus) { > > > + ret = regulator_enable(vbus); > > > + if (ret) { > > > + dev_err(&pdev->dev, > > > + "failed to enable usb vbus regulator: %d\n", > > > + ret); > > > + goto disable_clk; > > > + } > > > + } > > This is all completely broken unless the supply is optional. The supply is optional. Thanks for your review, Jisheng