From patchwork Wed May 20 09:06:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48789 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A14DF21411 for ; Wed, 20 May 2015 09:12:08 +0000 (UTC) Received: by labcd2 with SMTP id cd2sf15066901lab.0 for ; Wed, 20 May 2015 02:12:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=c4q1YMkLsf7oRAUbRTK9Nn6mYt880EFIDo3qBfOBlEU=; b=HzsYWSkTAzVIdF2AXNL5ITeJrIv8Mci4bppvGEsYYJOuVJvxBaxiwHlkXRu5tObXYJ eEmBnEY/Qc0vYPVevcWVY6J6cK0ZFqDksqJj13lEh9DBqXcPfU0IkFKvwjnoZsv8N3dw JNfbQP870t4f05dnDDE8p4vyB8PX0jRafMzFxRbhdQ6lBGU0c2Z4lnm81BBaQEf8N1NS YfCNaKblm1NhATdvpIQKsVywoUlZ2PCgXqcgTBPMiT397SAQd9PdmOwDD1ILBigToSdh OocMUJ/8I1+zd8vlzC5s9S519jFgNqFSxplHb9FRtSYumac4eGA67yo2latXHoIoP0dE PW0g== X-Gm-Message-State: ALoCoQmc1yNn2gR4FmFV2ZlcPBeoOBeYEp+ApzB3tvGXS2KdhxnDiTCzOsCdFr9MDN1fKoSb6rQv X-Received: by 10.152.2.169 with SMTP id 9mr18811535lav.1.1432113127611; Wed, 20 May 2015 02:12:07 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.196 with SMTP id u4ls168987lau.6.gmail; Wed, 20 May 2015 02:12:07 -0700 (PDT) X-Received: by 10.152.246.34 with SMTP id xt2mr21827186lac.110.1432113127303; Wed, 20 May 2015 02:12:07 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id r2si10803253lbf.41.2015.05.20.02.12.06 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2015 02:12:06 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by labbd9 with SMTP id bd9so64503483lab.2 for ; Wed, 20 May 2015 02:12:06 -0700 (PDT) X-Received: by 10.152.87.204 with SMTP id ba12mr25652600lab.35.1432113126834; Wed, 20 May 2015 02:12:06 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp1385722lbb; Wed, 20 May 2015 02:12:05 -0700 (PDT) X-Received: by 10.69.18.10 with SMTP id gi10mr16353212pbd.16.1432113125014; Wed, 20 May 2015 02:12:05 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id px1si1525616pbb.240.2015.05.20.02.12.00; Wed, 20 May 2015 02:12:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753269AbbETJLk (ORCPT + 28 others); Wed, 20 May 2015 05:11:40 -0400 Received: from mail-pd0-f170.google.com ([209.85.192.170]:35320 "EHLO mail-pd0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752928AbbETJLR (ORCPT ); Wed, 20 May 2015 05:11:17 -0400 Received: by pdea3 with SMTP id a3so61701144pde.2 for ; Wed, 20 May 2015 02:11:16 -0700 (PDT) X-Received: by 10.70.98.145 with SMTP id ei17mr20174148pdb.92.1432113076343; Wed, 20 May 2015 02:11:16 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id l14sm15476779pdm.16.2015.05.20.02.11.14 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 20 May 2015 02:11:15 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Ingo Molnar , Peter Zijlstra , Viresh Kumar Subject: [PATCH 2/2] clockevents: Add helpers to verify state of a clockevent device Date: Wed, 20 May 2015 14:36:56 +0530 Message-Id: X-Mailer: git-send-email 2.4.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- 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) {