From patchwork Tue Nov 3 06:12:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 105285 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp1662469lbr; Mon, 2 Nov 2015 22:20:36 -0800 (PST) X-Received: by 10.107.170.220 with SMTP id g89mr25433860ioj.178.1446531606284; Mon, 02 Nov 2015 22:20:06 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o137si18146832ioe.150.2015.11.02.22.20.05; Mon, 02 Nov 2015 22:20:06 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932158AbbKCGMP (ORCPT + 28 others); Tue, 3 Nov 2015 01:12:15 -0500 Received: from mezzanine.sirena.org.uk ([106.187.55.193]:45639 "EHLO mezzanine.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754473AbbKCGMO (ORCPT ); Tue, 3 Nov 2015 01:12:14 -0500 Received: from cpc11-sgyl31-2-0-cust672.sgyl.cable.virginm.net ([94.175.94.161] helo=debutante) by mezzanine.sirena.org.uk with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1ZtUpE-0001g0-9l; Tue, 03 Nov 2015 06:12:09 +0000 Received: from broonie by debutante with local (Exim 4.86) (envelope-from ) id 1ZtUpB-000065-FU; Tue, 03 Nov 2015 06:12:05 +0000 From: Mark Brown To: Liam Girdwood , John Stultz Cc: linux-kernel@vger.kernel.org, Mark Brown Date: Tue, 3 Nov 2015 06:12:03 +0000 Message-Id: <1446531123-335-1-git-send-email-broonie@kernel.org> X-Mailer: git-send-email 2.6.2 X-SA-Exim-Connect-IP: 94.175.94.161 X-SA-Exim-Mail-From: broonie@sirena.org.uk X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on mezzanine.sirena.org.uk X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 Subject: [PATCH] regulator: Use regulator_lock_supply() for get_voltage() too X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on mezzanine.sirena.org.uk) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since we need to read voltages of parents as part of setting supply voltages we need to be able to do get_voltage() internally without taking locks so reorganize the locking to take locks on the full tree on entry rather than as we recurse when called externally. Reported-by: John Stultz Signed-off-by: Mark Brown --- drivers/regulator/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.6.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index ff9cc3a6895f..97749c3330a4 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -3110,7 +3110,7 @@ static int _regulator_get_voltage(struct regulator_dev *rdev) } else if (rdev->desc->fixed_uV && (rdev->desc->n_voltages == 1)) { ret = rdev->desc->fixed_uV; } else if (rdev->supply) { - ret = regulator_get_voltage(rdev->supply); + ret = _regulator_get_voltage(rdev->supply); } else { return -EINVAL; } @@ -3133,11 +3133,11 @@ int regulator_get_voltage(struct regulator *regulator) { int ret; - mutex_lock(®ulator->rdev->mutex); + regulator_lock_supply(regulator->rdev); ret = _regulator_get_voltage(regulator->rdev); - mutex_unlock(®ulator->rdev->mutex); + regulator_unlock_supply(®ulator->rdev->mutex); return ret; }