From patchwork Wed Dec 13 18:53:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 10110671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 429AF60327 for ; Wed, 13 Dec 2017 18:54:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3402628D3E for ; Wed, 13 Dec 2017 18:54:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 287C628DCD; Wed, 13 Dec 2017 18:54:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0D89228D3E for ; Wed, 13 Dec 2017 18:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=4LMxtjS1p1byvjnUQa5rE5MWFmiwORdAsN6tN8LINfs=; b=halQ9EeQBOwnNUC1nzSYgWnFQi xB/Tp5Z/Yj82ArElsMjPEqDcMFNhR2ltNcsqGnr7rzTAAjC5ERDDWQmlSVE73jJO24g63RHIobd5m K/4to7rLP6efPuXuypmb6u2DYfELsFZ9gxXqRrlR6XJp3DS79s7nkh+a/1VzpRSEXMYtCg3zx9Eil EJDngTdhfADA46SiZDH624uCBh8P1ENLZ6fwg2aLIi20dm5lGI+U1wqIw+79RjKaJiyG5vxfAoM8R J27t2sveWOgwQ2hnwbxX4zuXlsz7j0H47BGeyCBUK7PYN71jdLlMqNwYco3khwlrILHPisatR8JyM 19+IHDBg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePCAS-0005Yp-5d; Wed, 13 Dec 2017 18:54:08 +0000 Received: from mail.free-electrons.com ([62.4.15.54]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ePCAN-0005TI-S3 for linux-arm-kernel@lists.infradead.org; Wed, 13 Dec 2017 18:54:06 +0000 Received: by mail.free-electrons.com (Postfix, from userid 110) id A109E207B1; Wed, 13 Dec 2017 19:53:41 +0100 (CET) Received: from localhost (unknown [195.53.49.241]) by mail.free-electrons.com (Postfix) with ESMTPSA id 6492D20810; Wed, 13 Dec 2017 19:53:31 +0100 (CET) From: Alexandre Belloni To: Rob Herring , Daniel Lezcano Subject: [PATCH 2/3] clocksource/drivers: timer-of: parse the chosen node Date: Wed, 13 Dec 2017 19:53:12 +0100 Message-Id: <20171213185313.20017-3-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171213185313.20017-1-alexandre.belloni@free-electrons.com> References: <20171213185313.20017-1-alexandre.belloni@free-electrons.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171213_105404_066973_DC292936 X-CRM114-Status: GOOD ( 10.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Alexandre Belloni , Thomas Gleixner , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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