From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756195AbbBJOPs (ORCPT ); Tue, 10 Feb 2015 09:15:48 -0500 Received: from casper.infradead.org ([85.118.1.10]:59780 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753518AbbBJOPr (ORCPT ); Tue, 10 Feb 2015 09:15:47 -0500 Date: Tue, 10 Feb 2015 15:15:41 +0100 From: Peter Zijlstra To: Viresh Kumar Cc: Thomas Gleixner , linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, Kevin Hilman , Frederic Weisbecker , Preeti U Murthy , Daniel Lezcano , linaro-networking@linaro.org Subject: Re: [PATCH] clockevents: Introduce mode specific callbacks Message-ID: <20150210141541.GB7119@twins.programming.kicks-ass.net> References: <025ca1872df9ed8a9f7b6e0400e71ed296374183.1423034839.git.viresh.kumar@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <025ca1872df9ed8a9f7b6e0400e71ed296374183.1423034839.git.viresh.kumar@linaro.org> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 04, 2015 at 01:06:23PM +0530, Viresh Kumar wrote: > + /* > + * Mode transition callback(s): Only one of the two groups should be > + * defined: > + * - set_mode(), only for modes <= CLOCK_EVT_MODE_RESUME. > + * - set_mode_{shutdown|periodic|oneshot|resume}(). > + */ > void (*set_mode)(enum clock_event_mode mode, > struct clock_event_device *); > + int (*set_mode_periodic)(struct clock_event_device *); > + int (*set_mode_oneshot)(struct clock_event_device *); > + int (*set_mode_shutdown)(struct clock_event_device *); > + int (*set_mode_resume)(struct clock_event_device *); > +/* Sanity check of mode transition callbacks */ > +static int clockevents_sanity_check(struct clock_event_device *dev) > +{ > + /* Legacy set_mode() callback */ > + if (dev->set_mode) > + return 0; > + > + if (dev->features & CLOCK_EVT_FEAT_DUMMY) > + return 0; > + > + /* New mode-specific callbacks */ > + if (!dev->set_mode_shutdown) > + return -EINVAL; > + > + if ((dev->features & CLOCK_EVT_FEAT_PERIODIC) && > + !dev->set_mode_periodic) > + return -EINVAL; > + > + if ((dev->features & CLOCK_EVT_FEAT_ONESHOT) && > + !dev->set_mode_oneshot) > + return -EINVAL; > + > + return 0; > +} It appears to me you've not actually checked that condition outlined above, a driver could set both the legacy and the new callbacks.