All of lore.kernel.org
 help / color / mirror / Atom feed
From: Biju Das <biju.das.jz@bp.renesas.com>
To: cip-dev@lists.cip-project.org,
	Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>,
	Pavel Machek <pavel@denx.de>
Cc: Chris Paterson <chris.paterson2@renesas.com>,
	Biju Das <biju.das.jz@bp.renesas.com>,
	Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>
Subject: [cip-dev] [PATCH 4.4.y-cip 2/9] of: add node name compare helper functions
Date: Tue, 28 Jul 2020 11:43:23 +0100	[thread overview]
Message-ID: <20200728104330.6182-3-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20200728104330.6182-1-biju.das.jz@bp.renesas.com>

[-- Attachment #1: Type: text/plain, Size: 2393 bytes --]

From: Rob Herring <robh@kernel.org>

commit f42b0e18f2e5cf34f73ef1b6327b49040b307a33 upstream.

In preparation to remove device_node.name pointer, add helper functions
for node name comparisons which are a common pattern throughout the kernel.

Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/of/base.c  | 22 ++++++++++++++++++++++
 include/linux/of.h | 13 +++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 164eb1306661..b02f4b272e5b 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -54,6 +54,28 @@ DEFINE_MUTEX(of_mutex);
  */
 DEFINE_RAW_SPINLOCK(devtree_lock);
 
+bool of_node_name_eq(const struct device_node *np, const char *name)
+{
+	const char *node_name;
+	size_t len;
+
+	if (!np)
+		return false;
+
+	node_name = kbasename(np->full_name);
+	len = strchrnul(node_name, '@') - node_name;
+
+	return (strlen(name) == len) && (strncmp(node_name, name, len) == 0);
+}
+
+bool of_node_name_prefix(const struct device_node *np, const char *prefix)
+{
+	if (!np)
+		return false;
+
+	return strncmp(kbasename(np->full_name), prefix, strlen(prefix)) == 0;
+}
+
 int of_n_addr_cells(struct device_node *np)
 {
 	const __be32 *ip;
diff --git a/include/linux/of.h b/include/linux/of.h
index a09b9fb8e67d..1bef273a1909 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -231,6 +231,9 @@ static inline unsigned long of_read_ulong(const __be32 *cell, int size)
 #define OF_IS_DYNAMIC(x) test_bit(OF_DYNAMIC, &x->_flags)
 #define OF_MARK_DYNAMIC(x) set_bit(OF_DYNAMIC, &x->_flags)
 
+extern bool of_node_name_eq(const struct device_node *np, const char *name);
+extern bool of_node_name_prefix(const struct device_node *np, const char *prefix);
+
 static inline const char *of_node_full_name(const struct device_node *np)
 {
 	return np ? np->full_name : "<no-node>";
@@ -397,6 +400,16 @@ static inline struct device_node *to_of_node(struct fwnode_handle *fwnode)
 	return NULL;
 }
 
+static inline bool of_node_name_eq(const struct device_node *np, const char *name)
+{
+	return false;
+}
+
+static inline bool of_node_name_prefix(const struct device_node *np, const char *prefix)
+{
+	return false;
+}
+
 static inline const char* of_node_full_name(const struct device_node *np)
 {
 	return "<no-node>";
-- 
2.17.1


[-- Attachment #2: Type: text/plain, Size: 419 bytes --]

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#5037): https://lists.cip-project.org/g/cip-dev/message/5037
Mute This Topic: https://lists.cip-project.org/mt/75842042/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy  [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-

  parent reply	other threads:[~2020-07-28 11:52 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-28 10:43 [cip-dev] [PATCH 4.4.y-cip 0/9] Add LCD Panel support for RZ/G1E board Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 1/9] drm: Add an encoder and connector type enum for DPI Biju Das
2020-07-28 10:43 ` Biju Das [this message]
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 3/9] dt-bindings: display: Add bindings for EDT panel Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 4/9] drm/panel: simple: Add EDT panel support Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 5/9] drm: rcar-du: Support panels connected directly to the DPAD outputs Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 6/9] drm: rcar-du: Use the DRM panel API Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 7/9] ARM: shmobile: defconfig: Enable frame buffer console for armadillo800eva Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 8/9] ARM: shmobile: defconfig: Enable support for panels from EDT Biju Das
2020-07-28 10:43 ` [cip-dev] [PATCH 4.4.y-cip 9/9] ARM: dts: iwg22d-sodimm: Enable LCD panel Biju Das
2020-07-28 20:40 ` [cip-dev] [PATCH 4.4.y-cip 0/9] Add LCD Panel support for RZ/G1E board Pavel Machek
2020-07-29  6:11   ` Nobuhiro Iwamatsu
2020-07-29  6:57     ` Biju Das

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200728104330.6182-3-biju.das.jz@bp.renesas.com \
    --to=biju.das.jz@bp.renesas.com \
    --cc=chris.paterson2@renesas.com \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro1.iwamatsu@toshiba.co.jp \
    --cc=pavel@denx.de \
    --cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.