@@ -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 */
@@ -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)
{
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@linaro.org> --- include/linux/clockchips.h | 11 +++++++++++ kernel/time/clockevents.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+)