Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp942013ybi; Wed, 17 Jul 2019 07:15:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyE/Xy1i6CbnV6wyB3D/owS0awFHYcntKStgGTzDoYH2sHZeI2chIpCUN4MtXykuPxAhU7s X-Received: by 2002:a63:f04:: with SMTP id e4mr40175946pgl.38.1563372945786; Wed, 17 Jul 2019 07:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563372945; cv=none; d=google.com; s=arc-20160816; b=vJ3IBwq6Swmod+2jqJAN1e6NZDcOJbebYGpq9I3tichBNqys1WWaq6aOFALMnieKAL mRcBqVXoQxhskxVjSgHNj0mz6+8Ay1GTj1AvUbkf5oPrnl/J+wjrTD3gpP932pPIsDZ5 51RyyhvwLzPqqgdh/Y1Zi7o0m6rkS+wZn739HGA+1cDQYJBEs/II9U9/8cFoWZNmwQgV VhXhCuGxLzTNrGc1yz+DhxUSQvqKKtKvWqWTQH8XSAqoQ7++Rxgzj9ljsyVjsiUlIC0I gw+clAn9vpN43mWGv7O5zxqc9SJDxR3pYwwJKKfExa3COXQ2+9MsAQTcjPQAx5f/zfe6 3l4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type :content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:from:cc:to:subject:dkim-signature :dkim-filter; bh=fNdvBycqAzOsl6BRjfW8bEg4vOX4q3GZdaaLfQQ1784=; b=NaMBvLRUFIfGtmLfm+6rfMXHzY58ezwws1fKdnEFjc7opkLC/T0H0BkSJoG7HgYXaD fhPfIUTdV8tolRD6BmAE199Y+YfViMHcTtdp8xCK5Rp8Fuc/N5RUFIcavwunlWu5NySx ZylH/sM8w2UEZQg3MrNZqd+U/tR+746Pa/cl7Z0WouNW6I5ejmsfi+Y9y8gcmkIkVv5g cIF2ZXwWxfBd8+pzrK01+vjbk+VRVm6kUmN7AVSZiss/jd6wYY9/fNOjbnnYEcf2vMzc 4jt/hXOn2t2yqdZBziBqfCVwzT1VY219IAGJwlDP+A5bhDyRR/s94Lmt3FZqOg8/oRMk LGXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tpdvtAXV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si22171284pji.69.2019.07.17.07.15.29; Wed, 17 Jul 2019 07:15:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=tpdvtAXV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727248AbfGQOPA (ORCPT + 99 others); Wed, 17 Jul 2019 10:15:00 -0400 Received: from mailout2.w1.samsung.com ([210.118.77.12]:45238 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbfGQOO7 (ORCPT ); Wed, 17 Jul 2019 10:14:59 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20190717141458euoutp029d4c93c3ee643e1b04f90e05796783ff~yN14iY62C1446314463euoutp02S for ; Wed, 17 Jul 2019 14:14:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20190717141458euoutp029d4c93c3ee643e1b04f90e05796783ff~yN14iY62C1446314463euoutp02S DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1563372898; bh=fNdvBycqAzOsl6BRjfW8bEg4vOX4q3GZdaaLfQQ1784=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=tpdvtAXVZ5S1tm9BSWIhB/0HdF9nCiTtyGAlBO788Ho8Tki7Kh+mpWD6yD+dfB/JE 7scWmm0qPCSc7vQFF8UUltAt5GIpshsiQ/0K96dKTSgvSGTsZGPYElxVW4SY6P33tE aQjmXqbCHCcXDHqvT1VdNqEgVz0y97UAVLH2xM+0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20190717141457eucas1p18e06f7dfb9e56fc44f64ac71ef517c9c~yN13u7C9t2448224482eucas1p1s; Wed, 17 Jul 2019 14:14:57 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id C7.A7.04377.06D2F2D5; Wed, 17 Jul 2019 15:14:56 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20190717141456eucas1p188c4893c75ce04a9c1c10d41ecd9eef5~yN13CPcRo3260032600eucas1p1M; Wed, 17 Jul 2019 14:14:56 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190717141456eusmtrp17d1d73dbd2e54903ada6b09075072a25~yN13BgcCN1477414774eusmtrp1n; Wed, 17 Jul 2019 14:14:56 +0000 (GMT) X-AuditID: cbfec7f4-113ff70000001119-ae-5d2f2d60d555 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id CB.80.04140.06D2F2D5; Wed, 17 Jul 2019 15:14:56 +0100 (BST) Received: from [106.120.51.18] (unknown [106.120.51.18]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190717141455eusmtip1dd79072acb7a012c06e6ad5b0825b8a2~yN12UtBET2565325653eusmtip1H; Wed, 17 Jul 2019 14:14:55 +0000 (GMT) Subject: Re: [PATCH v2 1/4] opp: core: add regulators enable and disable To: Viresh Kumar Cc: Bartlomiej Zolnierkiewicz , Marek Szyprowski , Chanwoo Choi , Krzysztof Kozlowski , Kukjin Kim , Kyungmin Park , Mark Rutland , MyungJoo Ham , Nishanth Menon , Rob Herring , Stephen Boyd , Viresh Kumar , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-samsung-soc@vger.kernel.org From: Kamil Konieczny Message-ID: <237a3f15-7a44-01ce-5477-be94092295ec@partner.samsung.com> Date: Wed, 17 Jul 2019 16:14:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190716100539.4uqelbxqz7bmtmea@vireshk-i7> Content-Language: en-US Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTURzHPbv37l5Hq+PU/JVhMRBMUSuiTk8KLG4PwqCiB6IrL1o+2Zxm QZmllmlqD3RLpqWVmJaPUrPSsuUIX4gyHxUNp1mWUTrBIiznNfK/z/n9Pr9zfl84HKX4xCzm jkfHCepoVaRSKqNrmn+2+4b4+getyH69gVTmPWRIj22YIQXGdoZkWb9QpKOjgiVtyV9ZUmU1 M6SrPl9KxjONiOR1NEhIufE9S+70dErI23MlUvJ1sk1CUp4bWTJlrqRJ5QRPqi3N0i0KvsxQ hviq0ktS/p35mZSvLj7LX3lUinhTb62EH6/yCGQPyzaGCpHH4wW1/+YQWfhor46OTXM9ef7J BJuEfuB05MgBXg1ZDzKQnRW4BMHHbI90JJtmG4LLTROs2BhH8PvDmn8DxW0GRpTuIdCPd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cNoEZpIFNwFzi0fYzYFN5BdwkGq61soHYLAKqEtMXP2cHsUUFIiQO75jFCFEj KHFy5hMWEJtTwFJi3/RrYDazgLrEn3mXmCFscYlbT+YzQdjyEtvfzmGewCg0C0n7LCQts5C0 zELSsoCRZRWjSGppcW56brGRXnFibnFpXrpecn7uJkZgzG879nPLDsaud8GHGAU4GJV4eG8o 6ccKsSaWFVfmHmKU4GBWEuG1/aodK8SbklhZlVqUH19UmpNafIjRFOi5icxSosn5wHSUVxJv aGpobmFpaG5sbmxmoSTO2yFwMEZIID2xJDU7NbUgtQimj4mDU6qBcZbPs/c/3HJa8j3vOPm+ No7be7T93LkuXlutTqO+XhMmlo47c6+lf+x6U2OZaXlIt3uKlKnFEr5Zl2qye1NWXTL/GBhT FW/WKTdTZLXVydm3D++wWbc+hutk8fT5PxY09LhcWFh8+X5iQFyXrI16oI5B8sq3bELLbD+5 vZzQpRe5mVv15L2pSizFGYmGWsxFxYkAmjqHig8DAAA= X-CMS-MailID: 20190717141456eucas1p188c4893c75ce04a9c1c10d41ecd9eef5 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190715120430eucas1p19dddcc93756e6a110d3476229f9428b3 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190715120430eucas1p19dddcc93756e6a110d3476229f9428b3 References: <20190715120416.3561-1-k.konieczny@partner.samsung.com> <20190715120416.3561-2-k.konieczny@partner.samsung.com> <20190716100539.4uqelbxqz7bmtmea@vireshk-i7> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.07.2019 12:05, Viresh Kumar wrote: > On 15-07-19, 14:04, Kamil Konieczny wrote: >> Add enable regulators to dev_pm_opp_set_regulators() and disable >> regulators to dev_pm_opp_put_regulators(). This prepares for >> converting exynos-bus devfreq driver to use dev_pm_opp_set_rate(). >> >> Signed-off-by: Kamil Konieczny >> -- >> Changes in v2: >> >> - move regulator enable and disable into loop >> >> --- >> drivers/opp/core.c | 18 +++++++++++++++--- >> 1 file changed, 15 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/opp/core.c b/drivers/opp/core.c >> index 0e7703fe733f..069c5cf8827e 100644 >> --- a/drivers/opp/core.c >> +++ b/drivers/opp/core.c >> @@ -1570,6 +1570,10 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, >> goto free_regulators; >> } >> >> + ret = regulator_enable(reg); >> + if (ret < 0) >> + goto disable; > > The name of this label is logically incorrect because we won't disable > the regulator from there but put it. Over that, I would rather prefer > to remove the label and add regulator_put() here itself. I will change this and following according to your suggestions and will send v3. >> + >> opp_table->regulators[i] = reg; >> } >> >> @@ -1582,9 +1586,15 @@ struct opp_table *dev_pm_opp_set_regulators(struct device *dev, >> >> return opp_table; >> >> +disable: >> + regulator_put(reg); >> + --i; >> + >> free_regulators: >> - while (i != 0) >> - regulator_put(opp_table->regulators[--i]); >> + for (; i >= 0; --i) { >> + regulator_disable(opp_table->regulators[i]); >> + regulator_put(opp_table->regulators[i]); > > This is incorrect as this will now try to put/disable the regulator > which we failed to acquire. As --i happens only after the loop has run > once. You can rather do: > > while (i--) { > regulator_disable(opp_table->regulators[i]); > regulator_put(opp_table->regulators[i]); > } > > >> + } >> >> kfree(opp_table->regulators); >> opp_table->regulators = NULL; >> @@ -1610,8 +1620,10 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table) >> /* Make sure there are no concurrent readers while updating opp_table */ >> WARN_ON(!list_empty(&opp_table->opp_list)); >> >> - for (i = opp_table->regulator_count - 1; i >= 0; i--) >> + for (i = opp_table->regulator_count - 1; i >= 0; i--) { >> + regulator_disable(opp_table->regulators[i]); >> regulator_put(opp_table->regulators[i]); >> + } >> >> _free_set_opp_data(opp_table); >> >> -- >> 2.22.0 > -- Best regards, Kamil Konieczny Samsung R&D Institute Poland