From patchwork Fri Feb 20 11:56:49 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 44860 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 100AB21554 for ; Fri, 20 Feb 2015 11:57:00 +0000 (UTC) Received: by lbvp9 with SMTP id p9sf3833608lbv.1 for ; Fri, 20 Feb 2015 03:56:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=WmCLpWtEb81NPpAh1Y4csUlfBPKzc3tU2T50qCkRHg8=; b=AI0zPdU2qKaQ/ikamBYLcQaheFTnrXreNgYdcY40ePQmkUEny9WMwXiUW4ZdefiixI 6pS36qUtpO/AVsQsPWP5HAUTm+WCcDy3egPgv0VS4GY/4PrIRa8H8kkMCxHkIH0qga4E DCUm+BwyJotPKNKo0mHyKCiuNhDGAoDCMsVIjO6cq0G1A+/ncJqI9oRIzCq8hx1jkyFs SqLs4E1OXGTDXMyXjFpeVpzEiF1jR2vUZRX68VsUDy5eEkJbvIYUl504xDx7qVP6Ub3l 1cEFvpPmUHStSomIMVG+j6Iv3p43cbDuyILSm/6c+QMCAJf7Xoon27twhq7soKtB3LWZ y1Qw== X-Gm-Message-State: ALoCoQlfVkp/d76Y1Q3VCw2Zjoc5KisRtQuGuufzgbWnidw4aby227FJWxRVlLeG1CCNOiW5xUlp X-Received: by 10.152.28.137 with SMTP id b9mr1219857lah.8.1424433418935; Fri, 20 Feb 2015 03:56:58 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.166 with SMTP id t6ls17568lat.83.gmail; Fri, 20 Feb 2015 03:56:58 -0800 (PST) X-Received: by 10.152.5.193 with SMTP id u1mr8068305lau.96.1424433418662; Fri, 20 Feb 2015 03:56:58 -0800 (PST) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id r8si5382237lbh.54.2015.02.20.03.56.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 20 Feb 2015 03:56:58 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by labgq15 with SMTP id gq15so5632134lab.3 for ; Fri, 20 Feb 2015 03:56:58 -0800 (PST) X-Received: by 10.112.14.196 with SMTP id r4mr327889lbc.86.1424433418523; Fri, 20 Feb 2015 03:56:58 -0800 (PST) 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.35.133 with SMTP id h5csp1106562lbj; Fri, 20 Feb 2015 03:56:57 -0800 (PST) X-Received: by 10.68.189.229 with SMTP id gl5mr6772426pbc.109.1424433416391; Fri, 20 Feb 2015 03:56:56 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xx4si7718085pab.33.2015.02.20.03.56.55; Fri, 20 Feb 2015 03:56:56 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754301AbbBTL4w (ORCPT + 28 others); Fri, 20 Feb 2015 06:56:52 -0500 Received: from mail-ob0-f180.google.com ([209.85.214.180]:43729 "EHLO mail-ob0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753735AbbBTL4u (ORCPT ); Fri, 20 Feb 2015 06:56:50 -0500 Received: by mail-ob0-f180.google.com with SMTP id vb8so23499332obc.11 for ; Fri, 20 Feb 2015 03:56:50 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.60.141.231 with SMTP id rr7mr6269747oeb.19.1424433410127; Fri, 20 Feb 2015 03:56:50 -0800 (PST) Received: by 10.182.33.34 with HTTP; Fri, 20 Feb 2015 03:56:49 -0800 (PST) In-Reply-To: <20150220114136.GA27483@gmail.com> References: <6291e308ab77a480c6b1732e16108c5fe6f66afa.1424412815.git.viresh.kumar@linaro.org> <20150220083842.GA20387@gmail.com> <20150220084807.GJ21418@twins.programming.kicks-ass.net> <20150220093659.GA23469@gmail.com> <20150220113753.GP5029@twins.programming.kicks-ass.net> <20150220114136.GA27483@gmail.com> Date: Fri, 20 Feb 2015 17:26:49 +0530 Message-ID: Subject: Re: [PATCH] clockevents: Add (missing) default case for switch blocks From: Viresh Kumar To: Ingo Molnar Cc: Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Linaro Kernel Mailman List , Kevin Hilman , Preeti U Murthy , Daniel Lezcano , Linux Kernel Mailing List , "linux-arm-kernel@lists.infradead.org" , Frederic Weisbecker , Linaro Networking , Steven Miao , Mark Salter , Michal Simek , Ralf Baechle , Ley Foon Tan , Jonas Bonn , "David S. Miller" , Jeff Dike , Guan Xuetao 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.42 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: , On 20 February 2015 at 17:11, Ingo Molnar wrote: > > * Peter Zijlstra wrote: >> Maybe we should break that enum into two; one for devices >> and one for the core interface and avoid the problem that >> way. > > Yeah, that would do the trick. Thanks for your suggestions. Just to confirm (before I spam lists with patches), is this somewhat similar to what you are looking for ? @@ -111,29 +115,29 @@ static int __clockevents_set_mode(struct clock_event_device *dev, /* Transition with new mode-specific callbacks */ switch (mode) { - case CLOCK_EVT_MODE_UNUSED: + case CLOCK_EVT_DEV_MODE_UNUSED: /* * This is an internal state, which is guaranteed to go from * SHUTDOWN to UNUSED. No driver interaction required. */ return 0; - case CLOCK_EVT_MODE_SHUTDOWN: + case CLOCK_EVT_DEV_MODE_SHUTDOWN: return dev->set_mode_shutdown(dev); - case CLOCK_EVT_MODE_PERIODIC: + case CLOCK_EVT_DEV_MODE_PERIODIC: /* Core internal bug */ if (!(dev->features & CLOCK_EVT_FEAT_PERIODIC)) return -ENOSYS; return dev->set_mode_periodic(dev); - case CLOCK_EVT_MODE_ONESHOT: + case CLOCK_EVT_DEV_MODE_ONESHOT: /* Core internal bug */ if (!(dev->features & CLOCK_EVT_FEAT_ONESHOT)) return -ENOSYS; return dev->set_mode_oneshot(dev); - case CLOCK_EVT_MODE_RESUME: + case CLOCK_EVT_DEV_MODE_RESUME: /* Optional callback */ if (dev->set_mode_resume) return dev->set_mode_resume(dev); Ofcourse, we also need to replace 'clock_event_mode' with 'clock_event_dev_mode' and 'CLOCK_EVT_MODE_*' with 'CLOCK_EVT_DEV_MODE_*' in all core code.. --- viresh -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/include/linux/clockchips.h b/include/linux/clockchips.h index 59af26b54d15..80b669cb836d 100644 --- a/include/linux/clockchips.h +++ b/include/linux/clockchips.h @@ -32,17 +32,24 @@ enum clock_event_nofitiers { struct clock_event_device; struct module; -/* Clock event mode commands */ +/* Clock event mode commands for legacy ->set_mode(): OBSOLETE */ enum clock_event_mode { CLOCK_EVT_MODE_UNUSED = 0, CLOCK_EVT_MODE_SHUTDOWN, CLOCK_EVT_MODE_PERIODIC, CLOCK_EVT_MODE_ONESHOT, CLOCK_EVT_MODE_RESUME, - - /* Legacy ->set_mode() callback doesn't support below modes */ }; +/* Clock event modes, only for core's internal use */ +enum clock_event_dev_mode { + CLOCK_EVT_DEV_MODE_UNUSED = 0, + CLOCK_EVT_DEV_MODE_SHUTDOWN, + CLOCK_EVT_DEV_MODE_PERIODIC, + CLOCK_EVT_DEV_MODE_ONESHOT, + CLOCK_EVT_DEV_MODE_RESUME, + CLOCK_EVT_DEV_MODE_ONESHOT_STOPPED, /* This would be the new mode which I will add later */ +}; + /* * Clock event features */ diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index 489642b08d64..16555d3db94d 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c @@ -95,14 +95,18 @@ u64 clockevent_delta2ns(unsigned long latch, struct clock_event_device *evt) EXPORT_SYMBOL_GPL(clockevent_delta2ns); static int __clockevents_set_mode(struct clock_event_device *dev, - enum clock_event_mode mode) + enum clock_event_dev_mode mode) { /* Transition with legacy set_mode() callback */ if (dev->set_mode) { /* Legacy callback doesn't support new modes */ - if (mode > CLOCK_EVT_MODE_RESUME) + if (mode > CLOCK_EVT_DEV_MODE_RESUME) return -ENOSYS; - dev->set_mode(mode, dev); + /* + * 'clock_event_dev_mode' and 'clock_event_mode' have 1-to-1 + * mapping until *_RESUME, and so a simple cast will work. + */ + dev->set_mode((enum clock_event_mode)mode, dev); return 0; }