From patchwork Wed Jul 21 15:58:30 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: 1508316 X-Patchwork-Delegate: lokeshvutla@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.a=rsa-sha256 header.s=ti-com-17Q1 header.b=n/u57z43; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GVKyp4rLtz9s5R for ; Thu, 22 Jul 2021 01:59:30 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 407EE82C63; Wed, 21 Jul 2021 17:59:14 +0200 (CEST) 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="n/u57z43"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 440F482C46; Wed, 21 Jul 2021 17:59:06 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 3844882977 for ; Wed, 21 Jul 2021 17:58:59 +0200 (CEST) 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 16LFwv4k038365; Wed, 21 Jul 2021 10:58:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1626883137; bh=J4LUypvPTPbJnyFb6fDcxm6fxepI+m2o0/SAGmw0gYg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=n/u57z43qM7YLLk0sDVkzyZH+PxD0LibwaGIO7jcztj2vU8xXu9/ZuQBB2ZKswXkl kkE6Y4l/tNgXhqemd0GdH4RS3HTKpYTiinxc6+WBXkXtt9w6EpSc3N32kqrtPo4S0o ocJNzaXfZ4PgJROsU+hSxJpRg8eeDh9Ze3epTJ5s= Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 16LFwvJ2084005 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 21 Jul 2021 10:58:57 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE105.ent.ti.com (10.64.6.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 21 Jul 2021 10:58:56 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE103.ent.ti.com (10.64.6.24) 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; Wed, 21 Jul 2021 10:58:56 -0500 Received: from a0393678-ssd.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id 16LFwoVj091982; Wed, 21 Jul 2021 10:58:54 -0500 From: Kishon Vijay Abraham I To: Lokesh Vutla , Simon Glass , Tom Rini CC: Aswath Govindraju , Pratyush Yadav , Kishon Vijay Abraham I , Subject: [PATCH v5 01/20] dm: core: Add helper to compare node names Date: Wed, 21 Jul 2021 21:28:30 +0530 Message-ID: <20210721155849.20994-2-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210721155849.20994-1-kishon@ti.com> References: <20210721155849.20994-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 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.103.2 at phobos.denx.de X-Virus-Status: Clean Add helper to compare node names. Signed-off-by: Kishon Vijay Abraham I Reviewed-by: Simon Glass --- drivers/core/ofnode.c | 13 +++++++++++++ include/dm/ofnode.h | 10 ++++++++++ 2 files changed, 23 insertions(+) diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index eeeccfb446..e83d3141b2 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); +} + 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 3da05d8b21..4e1a8447e6 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -231,6 +231,16 @@ static inline ofnode ofnode_root(void) return node; } +/** + * ofnode_name_eq() - Check if the node name is equivalent to a given name + * ignoring the unit address + * + * @node: valid node reference that has to be compared + * @name: name that has to be compared with the node name + * @return true if matches, false 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 *