From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756156AbcBCGZP (ORCPT ); Wed, 3 Feb 2016 01:25:15 -0500 Received: from comal.ext.ti.com ([198.47.26.152]:34669 "EHLO comal.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559AbcBCGZO (ORCPT ); Wed, 3 Feb 2016 01:25:14 -0500 Subject: Re: [PATCH] phy: core: fix wrong err handle for phy_power_on To: Shawn Lin References: <1453968858-1026-1-git-send-email-shawn.lin@rock-chips.com> CC: , Roger Quadros , Axel Lin From: Kishon Vijay Abraham I Message-ID: <56B19D45.70705@ti.com> Date: Wed, 3 Feb 2016 11:55:09 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <1453968858-1026-1-git-send-email-shawn.lin@rock-chips.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Thursday 28 January 2016 01:44 PM, Shawn Lin wrote: > If phy_pm_runtime_get_sync failed but we already > enable regulator, current code return directly without > doing regulator_disable. This patch fix this problem > and cleanup err handle of phy_power_on to be more readable. > > Fixes: 3be88125d85d ("phy: core: Support regulator ...") > Cc: Roger Quadros > Cc: Axel Lin > Signed-off-by: Shawn Lin Thank you for fixing this. Merged it. Thanks Kishon > --- > > drivers/phy/phy-core.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c > index 8c7f27d..e7e574d 100644 > --- a/drivers/phy/phy-core.c > +++ b/drivers/phy/phy-core.c > @@ -275,20 +275,21 @@ EXPORT_SYMBOL_GPL(phy_exit); > > int phy_power_on(struct phy *phy) > { > - int ret; > + int ret = 0; > > if (!phy) > - return 0; > + goto out; > > if (phy->pwr) { > ret = regulator_enable(phy->pwr); > if (ret) > - return ret; > + goto out; > } > > ret = phy_pm_runtime_get_sync(phy); > if (ret < 0 && ret != -ENOTSUPP) > - return ret; > + goto err_pm_sync; > + > ret = 0; /* Override possible ret == -ENOTSUPP */ > > mutex_lock(&phy->mutex); > @@ -296,19 +297,20 @@ int phy_power_on(struct phy *phy) > ret = phy->ops->power_on(phy); > if (ret < 0) { > dev_err(&phy->dev, "phy poweron failed --> %d\n", ret); > - goto out; > + goto err_pwr_on; > } > } > ++phy->power_count; > mutex_unlock(&phy->mutex); > return 0; > > -out: > +err_pwr_on: > mutex_unlock(&phy->mutex); > phy_pm_runtime_put_sync(phy); > +err_pm_sync: > if (phy->pwr) > regulator_disable(phy->pwr); > - > +out: > return ret; > } > EXPORT_SYMBOL_GPL(phy_power_on); >