From patchwork Thu Jul 16 11:26:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 51152 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 B0F5222A28 for ; Thu, 16 Jul 2015 11:27:36 +0000 (UTC) Received: by lbvb1 with SMTP id b1sf17587244lbv.3 for ; Thu, 16 Jul 2015 04:27:35 -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=pxwNP96SvOg4h7wiDk5o+SAp494vzwSlhaBiAmv1IgU=; b=hJF/nTb/kwZm2DA1gdG+AxnzfRS7uTdJk1wxdMZ3dq798AfIiOp+pqr/XyYpzEdaA9 Z8T5RJhQlPnDGlhTAJTmxGcy7QCDcW7Bhxjt5woVnZ37P23AObNivQSAYKIETOZX9TJf vu/HfxcuNM+PTiuIHBVdrkcyFC6RmOYLJNlqH1EUDLEt2QOpvCv0com29Jj1pljGC6xw BYU3+cWmjgX4oqbYZBYk52WoPSbaev4eGozkkUbrLSXbSDApwhOt1vu+EmbtE6LVIXx3 Va6MLkPvpeV8G2yqmMHKwNE/SnWI4IQC8L1zDtoHEKoyqd7q1tveQQ4mocTHEwftEVXc g0/g== X-Gm-Message-State: ALoCoQl5a9T/EJT5uBwli3PFJQl2ndXv/+Fltr4v+kKZax6AXzWFpEwRuD2tWvKqaWpkmgTtttSc X-Received: by 10.152.8.110 with SMTP id q14mr4629562laa.3.1437046055671; Thu, 16 Jul 2015 04:27:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.6.101 with SMTP id z5ls330523laz.65.gmail; Thu, 16 Jul 2015 04:27:35 -0700 (PDT) X-Received: by 10.112.61.132 with SMTP id p4mr8918926lbr.48.1437046055239; Thu, 16 Jul 2015 04:27:35 -0700 (PDT) Received: from mail-lb0-f169.google.com (mail-lb0-f169.google.com. [209.85.217.169]) by mx.google.com with ESMTPS id zs5si4076629lbb.37.2015.07.16.04.27.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Jul 2015 04:27:35 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.169 as permitted sender) client-ip=209.85.217.169; Received: by lbbzr7 with SMTP id zr7so41805758lbb.1 for ; Thu, 16 Jul 2015 04:27:35 -0700 (PDT) X-Received: by 10.152.1.66 with SMTP id 2mr9144651lak.56.1437046054987; Thu, 16 Jul 2015 04:27:34 -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 hn6csp191224lbb; Thu, 16 Jul 2015 04:27:33 -0700 (PDT) X-Received: by 10.69.19.129 with SMTP id gu1mr17916253pbd.162.1437046053081; Thu, 16 Jul 2015 04:27:33 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hk2si12580539pad.95.2015.07.16.04.27.31; Thu, 16 Jul 2015 04:27:33 -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 S1754947AbbGPL1S (ORCPT + 27 others); Thu, 16 Jul 2015 07:27:18 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36385 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754612AbbGPL1N (ORCPT ); Thu, 16 Jul 2015 07:27:13 -0400 Received: by pdjr16 with SMTP id r16so43088335pdj.3 for ; Thu, 16 Jul 2015 04:27:13 -0700 (PDT) X-Received: by 10.70.42.166 with SMTP id p6mr7309275pdl.118.1437046033360; Thu, 16 Jul 2015 04:27:13 -0700 (PDT) Received: from localhost ([122.171.186.190]) by smtp.gmail.com with ESMTPSA id o7sm7703592pdi.16.2015.07.16.04.27.11 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 16 Jul 2015 04:27:12 -0700 (PDT) From: Viresh Kumar To: Thomas Gleixner , Daniel Lezcano Cc: linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Viresh Kumar , Haavard Skinnemoen , Hans-Christian Egtvedt Subject: [PATCH 03/23] AVR32/time: Migrate to new 'set-state' interface Date: Thu, 16 Jul 2015 16:56:15 +0530 Message-Id: <81008ebf47a9c63ca97c170d209c0c199f7bfb2e.1437044517.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.169 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: , Migrate avr32 driver to the new 'set-state' interface provided by clockevents core, the earlier 'set-mode' interface is marked obsolete now. This also enables us to implement callbacks for new states of clockevent devices, for example: ONESHOT_STOPPED. We want to call cpu_idle_poll_ctrl() in shutdown only if we were in oneshot or resume state earlier. Create another variable to save this information and check that in shutdown callback. Cc: Haavard Skinnemoen Cc: Hans-Christian Egtvedt Signed-off-by: Viresh Kumar --- arch/avr32/kernel/time.c | 65 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/arch/avr32/kernel/time.c b/arch/avr32/kernel/time.c index d0f771be9e96..a124c55733db 100644 --- a/arch/avr32/kernel/time.c +++ b/arch/avr32/kernel/time.c @@ -18,6 +18,7 @@ #include +static bool disable_cpu_idle_poll; static cycle_t read_cycle_count(struct clocksource *cs) { @@ -80,45 +81,45 @@ static int comparator_next_event(unsigned long delta, return 0; } -static void comparator_mode(enum clock_event_mode mode, - struct clock_event_device *evdev) +static int comparator_shutdown(struct clock_event_device *evdev) { - switch (mode) { - case CLOCK_EVT_MODE_ONESHOT: - pr_debug("%s: start\n", evdev->name); - /* FALLTHROUGH */ - case CLOCK_EVT_MODE_RESUME: + pr_debug("%s: %s\n", __func__, evdev->name); + sysreg_write(COMPARE, 0); + + if (disable_cpu_idle_poll) { + disable_cpu_idle_poll = false; /* - * If we're using the COUNT and COMPARE registers we - * need to force idle poll. + * Only disable idle poll if we have forced that + * in a previous call. */ - cpu_idle_poll_ctrl(true); - break; - case CLOCK_EVT_MODE_UNUSED: - case CLOCK_EVT_MODE_SHUTDOWN: - sysreg_write(COMPARE, 0); - pr_debug("%s: stop\n", evdev->name); - if (evdev->mode == CLOCK_EVT_MODE_ONESHOT || - evdev->mode == CLOCK_EVT_MODE_RESUME) { - /* - * Only disable idle poll if we have forced that - * in a previous call. - */ - cpu_idle_poll_ctrl(false); - } - break; - default: - BUG(); + cpu_idle_poll_ctrl(false); } + return 0; +} + +static int comparator_set_oneshot(struct clock_event_device *evdev) +{ + pr_debug("%s: %s\n", __func__, evdev->name); + + disable_cpu_idle_poll = true; + /* + * If we're using the COUNT and COMPARE registers we + * need to force idle poll. + */ + cpu_idle_poll_ctrl(true); + + return 0; } static struct clock_event_device comparator = { - .name = "avr32_comparator", - .features = CLOCK_EVT_FEAT_ONESHOT, - .shift = 16, - .rating = 50, - .set_next_event = comparator_next_event, - .set_mode = comparator_mode, + .name = "avr32_comparator", + .features = CLOCK_EVT_FEAT_ONESHOT, + .shift = 16, + .rating = 50, + .set_next_event = comparator_next_event, + .set_state_shutdown = comparator_shutdown, + .set_state_oneshot = comparator_set_oneshot, + .tick_resume = comparator_set_oneshot, }; void read_persistent_clock(struct timespec *ts)