Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3702402imu; Sun, 11 Nov 2018 21:55:26 -0800 (PST) X-Google-Smtp-Source: AJdET5cSI+/fekKcfu/1CQTFquHSA1Mfb8lngX9pAw2SBJTBD+c5MbPsOsK0ilCPLh9vvjYEFqmC X-Received: by 2002:a62:d58a:: with SMTP id d132mr718853pfg.132.1542002126631; Sun, 11 Nov 2018 21:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542002126; cv=none; d=google.com; s=arc-20160816; b=yh3F/hruEWldk2mkzv6i67trHN9sH+/deCQH8IR9+SeyVUQJ6KJ9N+uje715nOqInc bIfSW5YTu5tJiVxgu3J1eu+T6k+C54rpvvh+T/wHMB52pVUDVxOpDip3souoKpbydzHG YbhtrqiMcP9rSJglYnm4NGfl2A0SH6/wEqc1s+yOewh9d9OZ/AyeAmulpYaobvqzoZuQ Eh7gTUvKZWvpk7OmPkYv4pbSb0ZuXFGIVdZgIwU/a8yuBvfAt5sUVF4Ox4w1I48AyV/y ycrgpNHNOeMW/M6g3LJmNpkPiUem6cDZEBh8n1asfgtv6aJYCABZnuUOCM5z+IoERvLP kgKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=FgcRd2b4juOl77/Wq+fjJ8rXj5ZhF0dhwhk50Q27hZ4=; b=DlHL+ms3WiJjG1ecTyIUlSF2Y9TQ8GK3kzcMgCyRXUf3Ac8cKBp/7FlatSj3NnuTw6 5m6SZTii47SPpNGJUUOUOrWsJkv5c84tMicP+loa/704TPmS9tOlFjh8UaKhHxHtWqxE //JXiMSRzzrj9Vhlgw/Tw7soj0GJINEJt/AzbUFQqkGSEsRCNmha55nQTzTEfFgS3egz hb2h4rsEoTk8TCU4ZU0f6THol/pvz0JUYiFW+sO7E6rJzKtG3RshVYZE71KBwc3gachn S0eSQGPNyfH57a1mJSnRJBMGgsCFgIkFz50U1CXd3Pn0WMenuOuBXHnwJdA+k2VUz6NY 0AyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@163.com header.s=s110527 header.b=axBrE55N; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si16104529plc.277.2018.11.11.21.55.11; Sun, 11 Nov 2018 21:55:26 -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; dkim=pass header.i=@163.com header.s=s110527 header.b=axBrE55N; 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 S1731472AbeKLPpH (ORCPT + 99 others); Mon, 12 Nov 2018 10:45:07 -0500 Received: from m50-135.163.com ([123.125.50.135]:56750 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731004AbeKLPpH (ORCPT ); Mon, 12 Nov 2018 10:45:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=FgcRd2b4juOl77/Wq+ fjJ8rXj5ZhF0dhwhk50Q27hZ4=; b=axBrE55NvPPZaahsECJ/TlLGrjx8YnkUX2 EHdHoTtn+4Aj6j1u6gyN4IL0GXJ8WAYENjFveEDT/i3039OGUVl1G2bRh5AiWOGH q2yDGVP3QjHovByM5il8IlzAX1vBpZ/OOjcZYo2X+dTP7hCoVAg9WCx6VTSh8+Kc WqHroRly8= Received: from localhost.localdomain (unknown [221.0.93.75]) by smtp5 (Coremail) with SMTP id D9GowADnSFRGFelbfYSgAQ--.50S2; Mon, 12 Nov 2018 13:53:20 +0800 (CST) From: zoro To: lgirdwood@gmail.com Cc: broonie@kernel.org, linux-kernel@vger.kernel.org, zoro Subject: [PATCH 4/4] regulator/of_get_regulator: add child path to find the regulator supplier Date: Mon, 12 Nov 2018 13:53:07 +0800 Message-Id: <1542001987-8352-1-git-send-email-long17.cool@163.com> X-Mailer: git-send-email 1.7.9.5 X-CM-TRANSID: D9GowADnSFRGFelbfYSgAQ--.50S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7uw45Jw1UJFy8XF4ftr15XFb_yoW8Kw17pr 4DWF9IkrsY9a4xuw4Syr12ya4Ygrn5Ca97Ar95Gw4fC3s5Jas3Jr1UAF1Yv3Z5Jr4kGw4j yrW8AF1xCF15XFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UBBTrUUUUU= X-Originating-IP: [221.0.93.75] X-CM-SenderInfo: 5orqwi2xof00ro6rljoofrz/1tbiDRD8F1QHKm73IwAAs1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org when the VIR_LDO1 regulator supplier is it's brother, we can't find the supplier. example code : &vir_regulator { ldo0_vir: ldo0-virtual { regulator-compatible = "VIR_LDO0"; regulator-name= "VIR_LDO0"; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <2000000>; }; ldo1_vir: ldo1-virtual { regulator-compatible = "VIR_LDO1"; regulator-name= "VIR_LDO1"; regulator-min-microvolt = <1000000>; regulator-max-microvolt = <3000000>; ldo1-supply = <&ldo0_vir>; }; } ... } so we add the child ptah to find the suppier. Signed-off-by: zoro --- drivers/regulator/core.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index 2c66b52..d328a84 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -228,6 +228,35 @@ static void regulator_unlock_supply(struct regulator_dev *rdev) } /** + * of_get_child_regulator - get a child regulator device node + * based on supply name + * @parent: Parent device node + * @prop_name: Combination regulator supply name and "-supply" + * + * Traverse all child nodes. + * Extract the child regulator device node corresponding to the supply name. + * returns the device node corresponding to the regulator if found, else + * returns NULL. + */ +static struct device_node *of_get_child_regulator(struct device_node *parent, + const char *prop_name) +{ + struct device_node *regnode = NULL; + struct device_node *child = NULL; + + for_each_child_of_node(parent, child) { + regnode = of_parse_phandle(child, prop_name, 0); + if (!regnode) { + regnode = of_get_child_regulator(child, prop_name); + if (regnode) + return regnode; + } else + return regnode; + } + return NULL; +} + +/** * of_get_regulator - get a regulator device node based on supply name * @dev: Device pointer for the consumer (of regulator) device * @supply: regulator supply name @@ -247,6 +276,10 @@ static struct device_node *of_get_regulator(struct device *dev, const char *supp regnode = of_parse_phandle(dev->of_node, prop_name, 0); if (!regnode) { + regnode = of_get_child_regulator(dev->of_node, prop_name); + if (regnode) + return regnode; + dev_dbg(dev, "Looking up %s property in node %pOF failed\n", prop_name, dev->of_node); return NULL; -- 1.7.9.5