Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2284254imu; Thu, 29 Nov 2018 02:31:18 -0800 (PST) X-Google-Smtp-Source: AFSGD/VxSDHGDoNVYAtOr7Wqk7n7x2KBr4MN+NyyEpqoOq2ZNdHVUC0cFx9YY+q/JaHMVeNM2BlU X-Received: by 2002:a17:902:9a81:: with SMTP id w1mr857139plp.19.1543487477984; Thu, 29 Nov 2018 02:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543487477; cv=none; d=google.com; s=arc-20160816; b=ubc8Vv3ohkh7Yg2Yop7Fcr2XyakwKrWHe56IRwRjdg0LUlXCJuNMtcpjM3L2Ymj6Xd TPEcTo4+w8LwEoXzHH84tptow8jEyTO328FwXcyPXoBaQboDkKOl0IA30COijTw0s9V6 nsowaEjASLMskk4RmWcUTq8uC09aYvby0skjJUTyJzhiqrXQ4Ykf/Ct9OwNcCJDglq2l psAoJ1d+yp+cIZfL1OyzK2aV6YWCNxfkYxQ+m/+lsVsuU6Y3u+t6K4zN5Hoayu6ZC9Us +q0kxmlgOkzGfeLg6qMaROM87OdN71sMK42b5xNnQCXF72zU4uqlT1G7qdzTmQFkt/4/ CHjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=7mKfcWxJzXIf93VW/3N/VKyg8mQt/lJu2Coi7gHccEM=; b=cZZgx3MEhKpGB3UrVuXPCGPGWjF6kpDIwonwDiws9I6lxGur8ycUVyzPJSBuGTn2kh 5PMPdJLjMurzhnJSUFk5BOv+yBziOClTvPEpUhr99TT9RjX6Kttihv15BpKVNeByfxQO plylinemspWymouAiAu8cSKusw/X2QEA0rYAYD7vyQoAw/cEujX1g0ZJ2pQEMYnqzqBc BOSO9LwHAlQIktxDH/jR2ErLwCVlNEp/2MAwdrJTOZKMD7U7Kfup5HG4qHYmFiA9IWFJ aFwiU2Ye9AsPTYCNwG6WCq71P6W/LV1eB6d772+JFIYU30/lCuagZpcU04KrExM9OINy hykA== ARC-Authentication-Results: i=1; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t127si1804301pfd.21.2018.11.29.02.31.03; Thu, 29 Nov 2018 02:31:17 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728112AbeK2VdZ (ORCPT + 99 others); Thu, 29 Nov 2018 16:33:25 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:60820 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726823AbeK2VdZ (ORCPT ); Thu, 29 Nov 2018 16:33:25 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id wATAOWFh017069; Thu, 29 Nov 2018 04:28:30 -0600 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail4.cirrus.com ([87.246.98.35]) by mx0a-001ae601.pphosted.com with ESMTP id 2p2724rx8v-1; Thu, 29 Nov 2018 04:28:30 -0600 Received: from EX17.ad.cirrus.com (unknown [172.20.9.81]) by mail4.cirrus.com (Postfix) with ESMTP id 4AAD9611C8B7; Thu, 29 Nov 2018 04:32:01 -0600 (CST) Received: from imbe.wolfsonmicro.main (198.61.95.81) by EX17.ad.cirrus.com (172.20.9.81) with Microsoft SMTP Server id 14.3.408.0; Thu, 29 Nov 2018 10:28:29 +0000 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by imbe.wolfsonmicro.main (8.14.4/8.14.4) with ESMTP id wATASLba028814; Thu, 29 Nov 2018 10:28:21 GMT From: Charles Keepax To: CC: , , Subject: [PATCH 1/2] regulator: Factor out location of init data OF node Date: Thu, 29 Nov 2018 10:28:20 +0000 Message-ID: <20181129102821.18396-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181129102821.18396-1-ckeepax@opensource.cirrus.com> References: <20181129102821.18396-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811290091 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org To support future additions factor out the location of the OF node containing the init data for the regulator from the code that parses the init data. Signed-off-by: Charles Keepax --- drivers/regulator/of_regulator.c | 64 +++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index c711a0a2bc4b..4bb8928bdb3f 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -371,13 +371,10 @@ int of_regulator_match(struct device *dev, struct device_node *node, } EXPORT_SYMBOL_GPL(of_regulator_match); -struct regulator_init_data *regulator_of_get_init_data(struct device *dev, - const struct regulator_desc *desc, - struct regulator_config *config, - struct device_node **node) +struct device_node *regulator_of_get_init_node(struct device *dev, + const struct regulator_desc *desc) { struct device_node *search, *child; - struct regulator_init_data *init_data = NULL; const char *name; if (!dev->of_node || !desc->of_match) @@ -400,35 +397,48 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, if (!name) name = child->name; - if (strcmp(desc->of_match, name)) - continue; + if (!strcmp(desc->of_match, name)) + return of_node_get(child); + } - init_data = of_get_regulator_init_data(dev, child, desc); - if (!init_data) { - dev_err(dev, - "failed to parse DT for regulator %pOFn\n", - child); - break; - } + of_node_put(search); - if (desc->of_parse_cb) { - if (desc->of_parse_cb(child, desc, config)) { - dev_err(dev, - "driver callback failed to parse DT for regulator %pOFn\n", - child); - init_data = NULL; - break; - } - } + return NULL; +} - of_node_get(child); - *node = child; - break; +struct regulator_init_data *regulator_of_get_init_data(struct device *dev, + const struct regulator_desc *desc, + struct regulator_config *config, + struct device_node **node) +{ + struct device_node *child; + struct regulator_init_data *init_data = NULL; + + child = regulator_of_get_init_node(dev, desc); + if (!child) + return NULL; + + init_data = of_get_regulator_init_data(dev, child, desc); + if (!init_data) { + dev_err(dev, "failed to parse DT for regulator %pOFn\n", child); + goto error; } - of_node_put(search); + if (desc->of_parse_cb && desc->of_parse_cb(child, desc, config)) { + dev_err(dev, + "driver callback failed to parse DT for regulator %pOFn\n", + child); + goto error; + } + + *node = child; return init_data; + +error: + of_node_put(child); + + return NULL; } static int of_node_match(struct device *dev, const void *data) -- 2.11.0