Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751553AbdF0GG7 (ORCPT ); Tue, 27 Jun 2017 02:06:59 -0400 Received: from rcdn-iport-7.cisco.com ([173.37.86.78]:17893 "EHLO rcdn-iport-7.cisco.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751312AbdF0GGx (ORCPT ); Tue, 27 Jun 2017 02:06:53 -0400 X-Greylist: delayed 579 seconds by postgrey-1.27 at vger.kernel.org; Tue, 27 Jun 2017 02:06:53 EDT X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0AKAgCj8lFZ/4sNJK1cGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBg1iBb7VjghGJFEEWAQIBAQEBAQEBayiFWXs0BRgyEoojDAGyDYtbAQE?= =?us-ascii?q?BAQYBAQEBJIMng0yNMoIxBZBFgQmNIZNdkh8ChleOTSYELYEKMCEIGxVJhzNWi?= =?us-ascii?q?RwBAQE?= X-IronPort-AV: E=Sophos;i="5.39,399,1493683200"; d="scan'208";a="260986407" Date: Mon, 26 Jun 2017 22:57:12 -0700 From: Gaurav Gupta To: lgirdwood@gmail.com, broonie@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] regulator: core: Lookup based on supply name alone as last option Message-ID: <20170627055712.GA2592@sjc-ads-988.cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1212 Lines: 36 If there are two regulators with the same supply name, the current lookup just based on the supply name would always return the first one. Further in the function, there is code to check both dev name and supply name and return the matching regulator. This should be done before the lookup based on supply name alone, which should be a last resort. Signed-off-by: Gaurav Gupta --- drivers/regulator/core.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index c0d9ae8..80460df 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1489,10 +1489,6 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, if (dev) devname = dev_name(dev); - r = regulator_lookup_by_name(supply); - if (r) - return r; - mutex_lock(®ulator_list_mutex); list_for_each_entry(map, ®ulator_map_list, list) { /* If the mapping has a device set up it must match */ @@ -1508,6 +1504,7 @@ static struct regulator_dev *regulator_dev_lookup(struct device *dev, } mutex_unlock(®ulator_list_mutex); + r = regulator_lookup_by_name(supply); if (r) return r; -- 2.10.2.dirty