linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
To: Rob Herring <robh+dt@kernel.org>,
	Daniel Lezcano <daniel.lezcano@linaro.org>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Alexandre Belloni <alexandre.belloni@free-electrons.com>
Subject: [PATCH 2/3] clocksource/drivers: timer-of: parse the chosen node
Date: Wed, 13 Dec 2017 19:53:12 +0100	[thread overview]
Message-ID: <20171213185313.20017-3-alexandre.belloni@free-electrons.com> (raw)
In-Reply-To: <20171213185313.20017-1-alexandre.belloni@free-electrons.com>

Add a way for drivers to know whether the timer they are currently handling
is a clocksource or a clockevent.

Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
 drivers/clocksource/timer-of.c | 22 ++++++++++++++++++++++
 drivers/clocksource/timer-of.h |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/drivers/clocksource/timer-of.c b/drivers/clocksource/timer-of.c
index a31990408153..71680eacd390 100644
--- a/drivers/clocksource/timer-of.c
+++ b/drivers/clocksource/timer-of.c
@@ -195,3 +195,25 @@ void __init timer_of_cleanup(struct timer_of *to)
 	if (to->flags & TIMER_OF_BASE)
 		timer_base_exit(&to->of_base);
 }
+
+int __init timer_of_is_type(struct device_node *np, char *type)
+{
+	struct device_node *node, *timer;
+
+	if (!of_chosen)
+		return 0;
+
+	node = of_get_child_by_name(of_chosen, type);
+	if (!node)
+		return 0;
+
+	timer = of_parse_phandle(node, "timer", 0);
+	of_node_put(node);
+	if (!timer)
+		return 0;
+
+	if (timer == np)
+		return 1;
+
+	return 0;
+}
diff --git a/drivers/clocksource/timer-of.h b/drivers/clocksource/timer-of.h
index 3f708f1be43d..24923cfe748d 100644
--- a/drivers/clocksource/timer-of.h
+++ b/drivers/clocksource/timer-of.h
@@ -70,4 +70,7 @@ extern int __init timer_of_init(struct device_node *np,
 
 extern void __init timer_of_cleanup(struct timer_of *to);
 
+extern int __init timer_of_is_type(struct device_node *np, char *type);
+#define timer_of_is_clocksource(np) timer_of_is_type(np, "linux,clocksource")
+#define timer_of_is_clockevent(np) timer_of_is_type(np, "linux,clockevent")
 #endif
-- 
2.15.1

  parent reply	other threads:[~2017-12-13 18:54 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-13 18:53 [PATCH 0/3] clocksource/drivers: introduce DT based selection Alexandre Belloni
2017-12-13 18:53 ` [PATCH 1/3] dt-bindings: chosen: Add clocksource and clockevent selection Alexandre Belloni
2017-12-13 22:57   ` Rob Herring
2017-12-14 20:01     ` Boris Brezillon
2017-12-14 20:37       ` Boris Brezillon
2017-12-15 11:40       ` Mark Rutland
2017-12-15 12:30         ` Boris Brezillon
2017-12-15 11:32   ` Mark Rutland
2017-12-18 19:46     ` Boris Brezillon
2017-12-16  1:57   ` Grygorii Strashko
2017-12-18 17:12     ` Tony Lindgren
2017-12-19 23:20     ` Rob Herring
2017-12-13 18:53 ` Alexandre Belloni [this message]
2017-12-13 18:53 ` [PATCH 3/3] clocksource/drivers: integrator-ap: parse the chosen node Alexandre Belloni

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=20171213185313.20017-3-alexandre.belloni@free-electrons.com \
    --to=alexandre.belloni@free-electrons.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nicolas.ferre@microchip.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).