From patchwork Wed Oct 23 13:44:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 1182169 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=st.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=st.com header.i=@st.com header.b="v/jocOaw"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46ysB56ZPZz9sPF for ; Thu, 24 Oct 2019 00:47:09 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5A95FC21DF3; Wed, 23 Oct 2019 13:46:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D9C27C21DD9; Wed, 23 Oct 2019 13:45:29 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 8EE33C21DCA; Wed, 23 Oct 2019 13:45:07 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id C3BCAC21DD7 for ; Wed, 23 Oct 2019 13:45:04 +0000 (UTC) Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9NDgx34013942; Wed, 23 Oct 2019 15:45:04 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=iAFRvROSIJnZgLCW8JxrHnRorgEqbGhMpQZ4WymeFJg=; b=v/jocOawLxTD1K+OB2Hr05eZLy0ClSSwe2nMMADwJA01ty4pITwpnApx8atrDdXX5kAS f63C3BcVYzC1HJGzDSg9IdgGHfhDFNrlGrvnFmgcnoCaQ4fGJDBiZNnyDW7pyl7sL4gW D8RWFegqrcszG0vQQvr2+2VR5rzjGCnIXuD0jzvDRbMNmP5/5XPj/CazajU2CNnCG6Ev s7ZNBqlslHhay5L5qt/hOhRLjcxMrvEvlhGQRkhIXogPsKlz6lTIYcMehELupxhTx/9f iaWU6iRpKVrfQdNgpfmdqQq6L/6sAEgXnYcgaL7LE1z1yu1/MzzCFRnGsUYz60ACrpxg VA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2vt9s4uxdq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 23 Oct 2019 15:45:04 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8248C10002A; Wed, 23 Oct 2019 15:44:59 +0200 (CEST) Received: from Webmail-eu.st.com (Safex1hubcas23.st.com [10.75.90.46]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 78DE72FF5FE; Wed, 23 Oct 2019 15:44:59 +0200 (CEST) Received: from SAFEX1HUBCAS22.st.com (10.75.90.93) by SAFEX1HUBCAS23.st.com (10.75.90.46) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 23 Oct 2019 15:44:59 +0200 Received: from localhost (10.201.21.107) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 23 Oct 2019 15:44:58 +0200 From: Patrick Delaunay To: Date: Wed, 23 Oct 2019 15:44:39 +0200 Message-ID: <20191023134448.20149-5-patrick.delaunay@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023134448.20149-1-patrick.delaunay@st.com> References: <20191023134448.20149-1-patrick.delaunay@st.com> MIME-Version: 1.0 X-Originating-IP: [10.201.21.107] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-23_03:2019-10-23,2019-10-23 signatures=0 Cc: U-Boot STM32 Subject: [U-Boot] [PATCH 04/13] dm: pinctrl: migrate pinctrl-generic to livetree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Migrate pinctrl-generic to livetree: - ofnode_get_first_property - ofnode_get_next_property - ofnode_get_property_by_prop - ofnode_read_string_count - ofnode_read_string_index and get rid of DECLARE_GLOBAL_DATA_PTR. This solve parsing issue during test in sandbox for pin configuration (OF_LIVE is activated in sandbox_defconfig and sub node are not correctly parsed in pinctrl_generic_set_state_subnode with fdt lib API). Signed-off-by: Patrick Delaunay --- drivers/pinctrl/pinctrl-generic.c | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/drivers/pinctrl/pinctrl-generic.c b/drivers/pinctrl/pinctrl-generic.c index eecf0f5dc1..474a2e65ca 100644 --- a/drivers/pinctrl/pinctrl-generic.c +++ b/drivers/pinctrl/pinctrl-generic.c @@ -8,8 +8,6 @@ #include #include -DECLARE_GLOBAL_DATA_PTR; - /** * pinctrl_pin_name_to_selector() - return the pin selector for a pin * @@ -243,18 +241,18 @@ static int pinctrl_generic_set_state_one(struct udevice *dev, struct udevice *config, bool is_group, unsigned selector) { - const void *fdt = gd->fdt_blob; - int node_offset = dev_of_offset(config); const char *propname; const void *value; - int prop_offset, len, func_selector, param, ret; + const void *property; + int len, func_selector, param, ret; u32 arg, default_val; - for (prop_offset = fdt_first_property_offset(fdt, node_offset); - prop_offset > 0; - prop_offset = fdt_next_property_offset(fdt, prop_offset)) { - value = fdt_getprop_by_offset(fdt, prop_offset, - &propname, &len); + for (property = ofnode_get_first_property(dev_ofnode(config)); + property; + property = ofnode_get_next_property(dev_ofnode(config), + property)) { + value = ofnode_get_property_by_prop(dev_ofnode(config), + property, &propname, &len); if (!value) return -EINVAL; @@ -298,19 +296,18 @@ static int pinctrl_generic_set_state_one(struct udevice *dev, static int pinctrl_generic_set_state_subnode(struct udevice *dev, struct udevice *config) { - const void *fdt = gd->fdt_blob; - int node = dev_of_offset(config); const char *subnode_target_type = "pins"; bool is_group = false; const char *name; int strings_count, selector, i, ret; - strings_count = fdt_stringlist_count(fdt, node, subnode_target_type); + strings_count = ofnode_read_string_count(dev_ofnode(config), + subnode_target_type); if (strings_count < 0) { subnode_target_type = "groups"; is_group = true; - strings_count = fdt_stringlist_count(fdt, node, - subnode_target_type); + strings_count = ofnode_read_string_count(dev_ofnode(config), + subnode_target_type); if (strings_count < 0) { /* skip this node; may contain config child nodes */ return 0; @@ -318,10 +315,11 @@ static int pinctrl_generic_set_state_subnode(struct udevice *dev, } for (i = 0; i < strings_count; i++) { - name = fdt_stringlist_get(fdt, node, subnode_target_type, i, - NULL); - if (!name) - return -EINVAL; + ret = ofnode_read_string_index(dev_ofnode(config), + subnode_target_type, i, + &name); + if (ret) + return ret; if (is_group) selector = pinctrl_group_name_to_selector(dev, name);