Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756350AbcDGOWp (ORCPT ); Thu, 7 Apr 2016 10:22:45 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:34968 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756268AbcDGOWo (ORCPT ); Thu, 7 Apr 2016 10:22:44 -0400 From: Thierry Reding To: Mark Brown Cc: Jon Hunter , Liam Girdwood , linux-kernel@vger.kernel.org Subject: [PATCH 1/5] regulator: core: Resolve supply earlier Date: Thu, 7 Apr 2016 16:22:35 +0200 Message-Id: <1460038959-21592-1-git-send-email-thierry.reding@gmail.com> X-Mailer: git-send-email 2.8.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2200 Lines: 70 From: Thierry Reding Subsequent patches will need access to the parent supply from within the set_machine_constraints() function to properly implement bypass mode. If the parent supply hasn't been resolved by that time the voltage can't be queried. Also, by making sure the supply is resolved early most of the changes in set_machine_constraints() don't have to be undone if resolution fails. Suggested-by: Mark Brown Signed-off-by: Thierry Reding --- drivers/regulator/core.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2786d251b1cc..cc0333a79924 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3972,18 +3972,27 @@ regulator_register(const struct regulator_desc *regulator_desc, dev_set_drvdata(&rdev->dev, rdev); + if (init_data && init_data->supply_regulator) + rdev->supply_name = init_data->supply_regulator; + else if (regulator_desc->supply_name) + rdev->supply_name = regulator_desc->supply_name; + + /* + * set_machine_constraints() needs the supply to be resolved in order + * to support querying the current voltage in bypass mode. Resolve it + * here to more easily handle deferred probing. + */ + ret = regulator_resolve_supply(rdev); + if (ret < 0) + goto scrub; + /* set regulator constraints */ if (init_data) constraints = &init_data->constraints; ret = set_machine_constraints(rdev, constraints); if (ret < 0) - goto scrub; - - if (init_data && init_data->supply_regulator) - rdev->supply_name = init_data->supply_regulator; - else if (regulator_desc->supply_name) - rdev->supply_name = regulator_desc->supply_name; + goto tumble; /* add consumers devices */ if (init_data) { @@ -4010,7 +4019,13 @@ regulator_register(const struct regulator_desc *regulator_desc, unset_supplies: unset_regulator_supplies(rdev); +tumble: + if (rdev->supply) { + if (_regulator_is_enabled(rdev)) + regulator_disable(rdev->supply); + _regulator_put(rdev->supply); + } scrub: regulator_ena_gpio_free(rdev); device_unregister(&rdev->dev); -- 2.8.0