lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <a027ed39f07a494d971c3b30806a00bd4f65cd4b.1432112458.git.viresh.kumar@linaro.org>
Date:	Wed, 20 May 2015 14:36:56 +0530
From:	Viresh Kumar <viresh.kumar@...aro.org>
To:	Thomas Gleixner <tglx@...utronix.de>
Cc:	linaro-kernel@...ts.linaro.org, linux-kernel@...r.kernel.org,
	Ingo Molnar <mingo@...hat.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Viresh Kumar <viresh.kumar@...aro.org>
Subject: [PATCH 2/2] clockevents: Add helpers to verify state of a clockevent device

Some clockevent drivers need to verify state of the clockevent device in
their callbacks or interrupt handler.

Because the symbols representing these states (defined by 'enum
clock_event_state') are internal to the core, they aren't accessible to
these driver.

Introduce helper routines that can verify state of clockevent device.

Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
---
 include/linux/clockchips.h | 11 +++++++++++
 kernel/time/clockevents.c  | 31 +++++++++++++++++++++++++++++++
 2 files changed, 42 insertions(+)

diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h
index 62d3007f8a8c..b0aa9c7b96c4 100644
--- a/include/linux/clockchips.h
+++ b/include/linux/clockchips.h
@@ -189,6 +189,12 @@ static inline void tick_setup_hrtimer_broadcast(void) { }
 
 extern int clockevents_notify(unsigned long reason, void *arg);
 
+extern bool clockevent_state_detached(struct clock_event_device *evt);
+extern bool clockevent_state_shutdown(struct clock_event_device *evt);
+extern bool clockevent_state_periodic(struct clock_event_device *evt);
+extern bool clockevent_state_oneshot(struct clock_event_device *evt);
+extern bool clockevent_state_oneshot_stopped(struct clock_event_device *evt);
+
 #else /* !CONFIG_GENERIC_CLOCKEVENTS: */
 
 static inline void clockevents_suspend(void) { }
@@ -197,6 +203,11 @@ static inline int clockevents_notify(unsigned long reason, void *arg) { return 0
 static inline int tick_check_broadcast_expired(void) { return 0; }
 static inline void tick_setup_hrtimer_broadcast(void) { }
 
+static inline bool clockevent_state_detached(struct clock_event_device *evt) { return false; };
+static inline bool clockevent_state_shutdown(struct clock_event_device *evt) { return false; };
+static inline bool clockevent_state_periodic(struct clock_event_device *evt) { return false; };
+static inline bool clockevent_state_oneshot(struct clock_event_device *evt) { return false; };
+static inline bool clockevent_state_oneshot_stopped(struct clock_event_device *evt) { return false; };
 #endif /* !CONFIG_GENERIC_CLOCKEVENTS */
 
 #endif /* _LINUX_CLOCKCHIPS_H */
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c
index 4922f1b805ea..ce9bb174d9bb 100644
--- a/kernel/time/clockevents.c
+++ b/kernel/time/clockevents.c
@@ -33,6 +33,37 @@ struct ce_unbind {
 	int res;
 };
 
+/* Helpers to verify state of a clockevent device */
+bool clockevent_state_detached(struct clock_event_device *evt)
+{
+	return evt->state == CLOCK_EVT_STATE_DETACHED;
+}
+EXPORT_SYMBOL_GPL(clockevent_state_detached);
+
+bool clockevent_state_shutdown(struct clock_event_device *evt)
+{
+	return evt->state == CLOCK_EVT_STATE_SHUTDOWN;
+}
+EXPORT_SYMBOL_GPL(clockevent_state_shutdown);
+
+bool clockevent_state_periodic(struct clock_event_device *evt)
+{
+	return evt->state == CLOCK_EVT_STATE_PERIODIC;
+}
+EXPORT_SYMBOL_GPL(clockevent_state_periodic);
+
+bool clockevent_state_oneshot(struct clock_event_device *evt)
+{
+	return evt->state == CLOCK_EVT_STATE_ONESHOT;
+}
+EXPORT_SYMBOL_GPL(clockevent_state_oneshot);
+
+bool clockevent_state_oneshot_stopped(struct clock_event_device *evt)
+{
+	return evt->state == CLOCK_EVT_STATE_ONESHOT_STOPPED;
+}
+EXPORT_SYMBOL_GPL(clockevent_state_oneshot_stopped);
+
 static u64 cev_delta2ns(unsigned long latch, struct clock_event_device *evt,
 			bool ismax)
 {
-- 
2.4.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ