From patchwork Tue Mar 9 12:27:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 395970 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp2557329jai; Tue, 9 Mar 2021 04:53:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBMn2wWbQdiVjkOsDSrVexVTcaHPNlxM28TH+LalTJVuX4Xas/n/5ENgU3+IdrCwwXFzyP X-Received: by 2002:a17:907:788e:: with SMTP id ku14mr20715584ejc.17.1615294435588; Tue, 09 Mar 2021 04:53:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615294435; cv=none; d=google.com; s=arc-20160816; b=f6ABsMQkARtzOdnwLq28ro4UQ9Kg9nwIEW5KUkTspIYu19P/RFijR0SK+FtBWkaLad vE10n3u2TjRXB7AZgl0Pv/YZyiZK4rh42RlBrzjOvccED7aF78Lrhmuecr1KdAu8fbIl mgUsXfduJqjdrWTQS9AeQ/aYxWFxXVuqaSzbSDmZJNN4+ST2GSTAD+E7kQZukEY/YfUk 99Ct0sFC+Vz+p7WaV9cYFPr6ZbQxXbvYErgBG66ct628GbeHPVDPIHvDdCCKd/s7xVAa fXfWfi/onPQN8ZDm/x7376ujSEoaLI0BLU/6cG8Izo3LA7xfQXeZQf4J1qSmRxZHODob +CDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=4hsnqkCIB6N0XYIj0R08zSgvj2xVm5AH0SaihYxy1CE=; b=JD+Cos7h5b5U02mQa2CHrXbT4oTZ2+QInTCj3OZBwAI9bVFqG818p88OYaDRjs4RWC LGl7TrYfQZoUfTnCAfpzi6/JI1kelx6QywA8gV1LSV//iNCcTEg6kCUuQu37ip/WpnB0 7dwpRit2wDdFFL192ypdMxl7LyS8OINNeYiwkJIj1LkL8K8UWEc6cN/1qNAUyJ5i5aFb p4nVU06/bWmLl6h4HLwXTwCpzZRkow26XoVlxVvpKSLT7O5HhieRTTHw/jBtcowtnGx1 GEYcxSUWSH7IIN4wk1r+tUG575no8pDR8RtuWjju3cLRAIBe1BnHtNrDiDLObZPDxb7X Ksjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=XnnMplO0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id g19si1852721ejf.52.2021.03.09.04.53.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Mar 2021 04:53:55 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=XnnMplO0; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id F076E827A8; Tue, 9 Mar 2021 13:53:40 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="XnnMplO0"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id DDDBF82625; Tue, 9 Mar 2021 13:27:58 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 0DFF0825F1 for ; Tue, 9 Mar 2021 13:27:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=kishon@ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 129CRsnV123321; Tue, 9 Mar 2021 06:27:54 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1615292874; bh=4hsnqkCIB6N0XYIj0R08zSgvj2xVm5AH0SaihYxy1CE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=XnnMplO0u2dYntWzVgEX5LwsTyYX64spFSSrFbG/1mBfSsDfP7CMCER7a2upgKb8R aZwo0jBgj2vh9W17b67VKl5kJCIog9mq3eDfifDGG3/MtO/ggxXPGyJfFqsQEZjjhH XiQAbmBQnNu3WEE+S27iyPMs/gFTnrSQPkMA8//0= Received: from DLEE108.ent.ti.com (dlee108.ent.ti.com [157.170.170.38]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 129CRsbd075377 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Mar 2021 06:27:54 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE108.ent.ti.com (157.170.170.38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Tue, 9 Mar 2021 06:27:54 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2 via Frontend Transport; Tue, 9 Mar 2021 06:27:54 -0600 Received: from a0393678-ssd.dhcp.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 129CRncO119584; Tue, 9 Mar 2021 06:27:52 -0600 From: Kishon Vijay Abraham I To: Lokesh Vutla , Simon Glass , Aswath Govindraju CC: Subject: [PATCH 01/16] dm: core: Add helper to compare node names Date: Tue, 9 Mar 2021 17:57:33 +0530 Message-ID: <20210309122748.31842-2-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210309122748.31842-1-kishon@ti.com> References: <20210309122748.31842-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Tue, 09 Mar 2021 13:53:37 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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" X-Virus-Scanned: clamav-milter 0.102.4 at phobos.denx.de X-Virus-Status: Clean Add helper to compare node names. Signed-off-by: Kishon Vijay Abraham I --- drivers/core/ofnode.c | 13 +++++++++++++ include/dm/ofnode.h | 9 +++++++++ 2 files changed, 22 insertions(+) -- 2.17.1 diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index fa0bd2a9c4..4e196d680e 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -18,6 +18,19 @@ #include #include +bool ofnode_name_eq(ofnode node, const char *name) +{ + const char *node_name; + size_t len; + + assert(ofnode_valid(node)); + + node_name = ofnode_get_name(node); + len = strchrnul(node_name, '@') - node_name; + + return (strlen(name) == len) && (strncmp(node_name, name, len) == 0); +} + int ofnode_read_u32(ofnode node, const char *propname, u32 *outp) { return ofnode_read_u32_index(node, propname, 0, outp); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 2c0597c407..86a139276b 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -231,6 +231,15 @@ static inline ofnode ofnode_root(void) return node; } +/** + * ofnode_name_eq() - Check if the node name is equivalent to a given name + * + * @node: valid node reference that has to be compared + * @name: name that has to be compared with the node name + * @return 1 if matches, 0 if it doesn't match + */ +bool ofnode_name_eq(ofnode node, const char *name); + /** * ofnode_read_u32() - Read a 32-bit integer from a property *