Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752330AbdLMJZO (ORCPT ); Wed, 13 Dec 2017 04:25:14 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:51140 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbdLMJZF (ORCPT ); Wed, 13 Dec 2017 04:25:05 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171213092502euoutp02ae0cb97fd99e8bdf509d184d681b4bfb~-0F41xMfs0711607116euoutp02V X-AuditID: cbfec7f1-f793a6d00000326b-f8-5a30f1ee5096 Subject: Re: [PATCH v3 4/4] regulator: core: Balance coupled regulators voltages To: Mark Brown Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Liam Girdwood , Rob Herring , Mark Rutland , Marek Szyprowski , Bartlomiej Zolnierkiewicz From: Maciej Purski Message-id: <0bca0d20-1ca8-be4c-a60e-bbc0c640ae41@samsung.com> Date: Wed, 13 Dec 2017 10:25:00 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-version: 1.0 In-reply-to: <20171212115427.GG16323@sirena.org.uk> Content-type: text/plain; charset="windows-1252"; format="flowed" Content-language: en-US Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02Se0hTcRTH+e3e3V1Hq5/T8mSSMIlA8pEZzSxRiNofRTEibCRr6EUlp7Kp ZQVpoukKS6W0kSaJJj7S5vKZ5WO4UeCzfCTqxEoQLGX4Ks283gn773M4n3MO3x8/mhCX8d3p 2PgkRhOvipNQQrKxZ63X59eiv8L/XZ9A+raoji99Ov2dkr409fKly1+yedKh1heUtNY0IZCW jwzwpJntJkEoLaspqUGyFv2EQGaoyqFkucYqJLMZDl7iK4Snopi42BRG4xdyXRiz8MaIEnOd b5WUVfLTkFmkQ0404ED41NDM43gf9E/WUTokpMW4HMGacZb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JyywkLQsYWVYxiqSWFuem5xYb6RUn5haX5qXrJefnbmIERsi2Yz+37GDsehd8iFGAg1GJ h/fBA/0oIdbEsuLK3EOMEhzMSiK8PfEGUUK8KYmVValF+fFFpTmpxYcYpTlYlMR5e/esjhQS SE8sSc1OTS1ILYLJMnFwSjUwnvy6YVPytfu1kxQN3N/1GPtvZqy/EJ78n6f0Se/2g1NzZ2Qt di7lOLPC4krdfMGN7yJDrWrdmGZdMfFj75h9UegeZ6SEl93sf0qh9x23/X2cN1G8v17MxDFJ dt7+nKlfxAqOKFwweV530E7psS2/xyytSzxrOMxm/mBlPK526PQ+c28261VblViKMxINtZiL ihMBm6swA4wCAAA= X-CMS-MailID: 20171213092501eucas1p27b9283858052c371672a903bb3f3419e X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171207094754eucas1p1528c6c30135124430a5c703eb81de8d2 X-RootMTR: 20171207094754eucas1p1528c6c30135124430a5c703eb81de8d2 References: <1512639975-22241-1-git-send-email-m.purski@samsung.com> <1512639975-22241-5-git-send-email-m.purski@samsung.com> <20171212115427.GG16323@sirena.org.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2143 Lines: 51 On 12/12/2017 12:54 PM, Mark Brown wrote: > On Thu, Dec 07, 2017 at 10:46:15AM +0100, Maciej Purski wrote: > >> @@ -2447,10 +2482,9 @@ static int _regulator_is_enabled(struct regulator_dev *rdev) >> return rdev->desc->ops->is_enabled(rdev); >> } >> >> -static int _regulator_list_voltage(struct regulator *regulator, >> - unsigned selector, int lock) >> +static int _regulator_list_voltage(struct regulator_dev *rdev, >> + unsigned selector, int lock) >> { > > Please split this refactoring of _list_voltage() into a separate patch > for ease of review. It can go in separately which will make this change > smaller and easier to review. > >> @@ -2928,6 +2961,35 @@ static int regulator_set_voltage_unlocked(struct regulator *regulator, >> if (ret < 0) >> goto out2; >> >> + /* >> + * If the regulator is not coupled just set voltage normally, else >> + * return after changing consumer demands without changing voltage. >> + * This will be handled outside the function >> + * by regulator_balance_coupled() >> + */ >> + if (!rdev->coupling_desc) { >> + ret = regulator_set_voltage_rdev(regulator->rdev, >> + min_uV, max_uV); >> + if (ret < 0) >> + goto out2; >> + } > > As I think I said on the previous version I'm not enthusiastic about > having two separate code paths for setting the voltage, it makes it much > more likely that things will break especially given how rare coupled > regulators are. It would be cleaner to make uncoupled regulators just > be a special case of coupled regulators, that way more of the code is > shared. To that end I'd adjust the code so that we always have a > coupling descriptor and then handle the case where there's only one > regulator described in there. > Do you have any suggestion, how should I implement that path? The thing which makes it more complicated is locking, because set_voltage_unlocked is done under one regulator's mutex and its suppliers, while balance procedure locks every coupled regulator without its suppliers. The suppliers for a single regulator are locked when setting a single regulator's voltage takes place.