From patchwork Thu May 21 08:03:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 48846 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f198.google.com (mail-lb0-f198.google.com [209.85.217.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 824C121411 for ; Thu, 21 May 2015 08:08:31 +0000 (UTC) Received: by lbbuh7 with SMTP id uh7sf4434675lbb.3 for ; Thu, 21 May 2015 01:08:30 -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=VSZG5v/cYJAhzb5q9ohrD8UZxhoUM5E0kI9FZ+mbCqA=; b=DqfZt3Afu1mpVksdf564bwZqcgo+vdhG2j/lnq4eM+3SOkwx4OVTg3Eo/2l0q34Kqv 40EWoXsjhU4aq6DAcgyn1Eiqh5Wa9eGbS2+OlpveNUlfpXPmMKax+Xk9w5BlYOcNLt26 +IoZl1wzO9ZtDLN/F2wMfkf+M5PRuHedTT8098XzTLxto5If07qBJ/MkWdcpQFdDN1gU 5LPF3NroR1VFUxUgrUGhJ21fx05cwTatJ9IMPgUrT6cs5rfJel6tJPNwi2rI1tzLkL0+ YgKdVsDqMX3jcBOQheiOo/dbEicI/f0rmqJX/FHyPQ1FmNeAr1CdxNlqjPTABykpWtLp Vh2Q== X-Gm-Message-State: ALoCoQlksF79Qdr8vat3zQIR4UZyUUvVlFkqtO2iQcgOKoJzrLghUsx7NtVcpMSPzo5SgA2Zxt6q X-Received: by 10.152.37.101 with SMTP id x5mr1529122laj.5.1432195710506; Thu, 21 May 2015 01:08:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.179.12 with SMTP id dc12ls265346lac.17.gmail; Thu, 21 May 2015 01:08:30 -0700 (PDT) X-Received: by 10.152.7.7 with SMTP id f7mr1210762laa.106.1432195710327; Thu, 21 May 2015 01:08:30 -0700 (PDT) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id ps10si12800504lbb.26.2015.05.21.01.08.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2015 01:08:30 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by lbbuc2 with SMTP id uc2so12245975lbb.2 for ; Thu, 21 May 2015 01:08:30 -0700 (PDT) X-Received: by 10.112.29.36 with SMTP id g4mr1226105lbh.56.1432195710188; Thu, 21 May 2015 01:08:30 -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 hn6csp383901lbb; Thu, 21 May 2015 01:08:29 -0700 (PDT) X-Received: by 10.70.37.144 with SMTP id y16mr3273012pdj.86.1432195708398; Thu, 21 May 2015 01:08:28 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cg8si30499339pac.134.2015.05.21.01.07.58; Thu, 21 May 2015 01:08:28 -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 S1755380AbbEUIHQ (ORCPT + 28 others); Thu, 21 May 2015 04:07:16 -0400 Received: from mail-pa0-f54.google.com ([209.85.220.54]:34779 "EHLO mail-pa0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754100AbbEUIG4 (ORCPT ); Thu, 21 May 2015 04:06:56 -0400 Received: by pabru16 with SMTP id ru16so97328618pab.1 for ; Thu, 21 May 2015 01:06:56 -0700 (PDT) X-Received: by 10.68.165.197 with SMTP id za5mr3285453pbb.146.1432195615980; Thu, 21 May 2015 01:06:55 -0700 (PDT) Received: from localhost ([122.167.226.34]) by mx.google.com with ESMTPSA id g2sm18392096pdn.3.2015.05.21.01.06.54 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 21 May 2015 01:06:55 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Viresh Kumar Subject: [PATCH V2 1/2] clockevents: Add helpers to verify state of a clockevent device Date: Thu, 21 May 2015 13:33:45 +0530 Message-Id: <04a717d490335c688dd7af899fbcede97e1bb8ee.1432192527.git.viresh.kumar@linaro.org> 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.217.175 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, once migrated to use per-state callbacks, would need to verify 'state' of the clockevent device in their callbacks or interrupt handler. Add accessor functions clockevent_state_*() to get this information. Signed-off-by: Viresh Kumar --- include/linux/clockchips.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 271fa4c8eb29..64214ad85af9 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -149,6 +149,32 @@ struct clock_event_device { struct module *owner; } ____cacheline_aligned; +/* Helpers to verify state of a clockevent device */ +static inline bool clockevent_state_detached(struct clock_event_device *dev) +{ + return dev->state == CLOCK_EVT_STATE_DETACHED; +} + +static inline bool clockevent_state_shutdown(struct clock_event_device *dev) +{ + return dev->state == CLOCK_EVT_STATE_SHUTDOWN; +} + +static inline bool clockevent_state_periodic(struct clock_event_device *dev) +{ + return dev->state == CLOCK_EVT_STATE_PERIODIC; +} + +static inline bool clockevent_state_oneshot(struct clock_event_device *dev) +{ + return dev->state == CLOCK_EVT_STATE_ONESHOT; +} + +static inline bool clockevent_state_oneshot_stopped(struct clock_event_device *dev) +{ + return dev->state == CLOCK_EVT_STATE_ONESHOT_STOPPED; +} + /* * Calculate a multiplication factor for scaled math, which is used to convert * nanoseconds based values to clock ticks: