From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbbCSHyX (ORCPT ); Thu, 19 Mar 2015 03:54:23 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:35115 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbbCSHyV (ORCPT ); Thu, 19 Mar 2015 03:54:21 -0400 Date: Thu, 19 Mar 2015 08:54:16 +0100 From: Richard Cochran To: Baolin Wang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, john.stultz@linaro.com, tglx@linutronix.de, arnd@linaro.org Subject: Re: [PATCH 2/4] ptp/clcok:Introduce the setktime/getktime interfaces with "ktime_t" type Message-ID: <20150319075416.GB4568@localhost.localdomain> References: <1426743909-24335-1-git-send-email-baolin.wang@linaro.org> <1426743909-24335-3-git-send-email-baolin.wang@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426743909-24335-3-git-send-email-baolin.wang@linaro.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 19, 2015 at 01:45:07PM +0800, Baolin Wang wrote: > diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c > index 296b0ec..46425ad 100644 > --- a/drivers/ptp/ptp_clock.c > +++ b/drivers/ptp/ptp_clock.c > @@ -106,14 +106,30 @@ static int ptp_clock_getres(struct posix_clock *pc, struct timespec *tp) > > static int ptp_clock_settime(struct posix_clock *pc, const struct timespec *tp) > { > + ktime_t kt; > struct ptp_clock *ptp = container_of(pc, struct ptp_clock, clock); > - return ptp->info->settime(ptp->info, tp); > + > + if (ptp->info->setktime) { > + kt = timespec_to_ktime(*tp); > + return ptp->info->setktime(ptp->info, kt); > + } else { > + return ptp->info->settime(ptp->info, tp); > + } This conditional is just the kind of thing I *don't* want to see. In Documentation/ptp/ptp.txt we read: ** Writing clock drivers Clock drivers include include/linux/ptp_clock_kernel.h and register themselves by presenting a 'struct ptp_clock_info' to the registration method. Clock drivers must implement all of the functions in the interface. If a clock does not offer a particular ancillary feature, then the driver should just return -EOPNOTSUPP from those functions. Please don't litter the code with tests for NULL methods everywhere. Thanks, Richard