Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752795AbdF0Q2n (ORCPT ); Tue, 27 Jun 2017 12:28:43 -0400 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:55806 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751501AbdF0Q2h (ORCPT ); Tue, 27 Jun 2017 12:28:37 -0400 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.wolfsonmicro.com Date: Tue, 27 Jun 2017 17:28:31 +0100 From: Charles Keepax To: Gaurav Gupta CC: , , Subject: Re: [PATCH] regulator: core: Lookup based on supply name alone as last option Message-ID: <20170627162831.qbzr6upde4srvgx3@localhost.localdomain> References: <20170627055712.GA2592@sjc-ads-988.cisco.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20170627055712.GA2592@sjc-ads-988.cisco.com> User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1703280000 definitions=main-1706270264 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1593 Lines: 50 On Mon, Jun 26, 2017 at 10:57:12PM -0700, Gaurav Gupta wrote: > 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 > --- A patch has already been merged to do this: https://lkml.org/lkml/2017/6/13/852 Thanks, Charles > 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); Also the loop above doesn't return it simply sets r so this would overwrite the discovered regulator with the lookup based on supply name alone. > if (r) > return r; > > -- > 2.10.2.dirty