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: 5855781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2123F9F269 for ; Fri, 20 Feb 2015 11:59:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AAB8A20340 for ; Fri, 20 Feb 2015 11:59:30 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE77D202DD for ; Fri, 20 Feb 2015 11:59:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YOmCq-0003IC-F4; Fri, 20 Feb 2015 11:57:16 +0000 Received: from mail-ob0-f175.google.com ([209.85.214.175]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YOmCn-0003EF-1u for linux-arm-kernel@lists.infradead.org; Fri, 20 Feb 2015 11:57:13 +0000 Received: by mail-ob0-f175.google.com with SMTP id va2so23657943obc.6 for ; Fri, 20 Feb 2015 03:56:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=UcITbfDLeFxN+8mguHfUNaOG2QkfaJ0Mdr4hG+SwVdA=; b=O+6gU9SQPkA2f8yXdadDvf0DuGLZkwq8DzAvYHxedwvnEHA1IZICDpXSV9HHhASB+Q tH6+SopDUsTsIDB1D3EHww0+Mwg/YR5B4MduNW6nhC+ZT6eGNflKxZX9+uEUEoeVStsr +JMAMiJWdnLdsVIaVWb/ChLl0JUfRdrGrAPWWjrmTV3NwIn0I7RkzAUeTylvxma+L/Z/ g5UdzJlh+fmZIrsHuK9WbMtBLsfrzuORi4GpHdAAG9nCJlvIAuMWcpX/8a8771w67m3+ xaoC+pwO0cPX/qlRgjvJabzZtB6jGFDxbKwYwdMkmy+dSl5XXt67VdbB8a25DUX5xiiG KQ1g== X-Gm-Message-State: ALoCoQm8Q6fFrv3JdY+qvtQePIT6wCoSCJnzzlQUbP1KfCZ/shf1TSKaxcr67jFUonKE9rPBrgyl 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150220_035713_171422_5A17049B X-CRM114-Status: GOOD ( 16.37 ) X-Spam-Score: -0.7 (/) Cc: Jonas Bonn , Michal Simek , Kevin Hilman , Steven Miao , Peter Zijlstra , Frederic Weisbecker , Jeff Dike , Daniel Lezcano , Linux Kernel Mailing List , Ralf Baechle , Ley Foon Tan , Ingo Molnar , "linux-arm-kernel@lists.infradead.org" , Mark Salter , Preeti U Murthy , Linaro Networking , Thomas Gleixner , Guan Xuetao , "David S. Miller" , Linaro Kernel Mailman List X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 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; }