From patchwork Thu Mar 19 05:45:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 46009 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4AB472153C for ; Thu, 19 Mar 2015 05:46:31 +0000 (UTC) Received: by wggy19 with SMTP id y19sf10588192wgg.2 for ; Wed, 18 Mar 2015 22:46:30 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=Yk1s/y4sZEkZIINBfRw4VXBB99emDWuLsTyPe/JOnZU=; b=iA/sEzHlGgDVRm9j7Q0/ILvRWhZ0/0zwTrk0uwTDsIstCcdmCm3ex4GT6MQPO8Mtbi 8xbQV1pGaT7iW0TQ9Ln3AR+ppTk4YMn0+RUTh/zYx/3Kmr119maCu93BRDIVzTFDDhcL cFj8HJ4AKpqVq4IYBQ8ugeubtNU6rpZCr6o5DMJxqeCZXNIS2TZCCd0bKZc6oVFxT62q SVgeHjJ7rciYxXoT9kApKCkMm2ZeQoyoHj7qJpgK1GOsYfraoQtX9inQB1l2gLWCXTZf MVgpYTOF66jidd4lRRWPEAgYFQD5PlB6i3+9Hcay1GAB64JI6kAhLM7tj6+H+fYsJbKB 5nGg== X-Gm-Message-State: ALoCoQmoGgA06ZlzSmZ+Tah7O6I7uQ1JssHba5qQBnSDgrzDLW7DuAVj9lmXmy5nk2dqekwZrj8j X-Received: by 10.152.3.70 with SMTP id a6mr896889laa.0.1426743990381; Wed, 18 Mar 2015 22:46:30 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.105 with SMTP id db9ls205828lad.87.gmail; Wed, 18 Mar 2015 22:46:29 -0700 (PDT) X-Received: by 10.152.5.6 with SMTP id o6mr68422978lao.59.1426743989936; Wed, 18 Mar 2015 22:46:29 -0700 (PDT) Received: from mail-lb0-f174.google.com (mail-lb0-f174.google.com. [209.85.217.174]) by mx.google.com with ESMTPS id r1si192560lbm.84.2015.03.18.22.46.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2015 22:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.174 as permitted sender) client-ip=209.85.217.174; Received: by lbblx11 with SMTP id lx11so23134157lbb.3 for ; Wed, 18 Mar 2015 22:46:29 -0700 (PDT) X-Received: by 10.112.130.195 with SMTP id og3mr66176117lbb.112.1426743989232; Wed, 18 Mar 2015 22:46:29 -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.35.133 with SMTP id h5csp171257lbj; Wed, 18 Mar 2015 22:46:28 -0700 (PDT) X-Received: by 10.70.89.8 with SMTP id bk8mr132089009pdb.139.1426743987384; Wed, 18 Mar 2015 22:46:27 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q15si577536pdl.129.2015.03.18.22.46.26; Wed, 18 Mar 2015 22:46:27 -0700 (PDT) Received-SPF: none (google.com: netdev-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 S1751945AbbCSFqY (ORCPT + 3 others); Thu, 19 Mar 2015 01:46:24 -0400 Received: from mail-pd0-f173.google.com ([209.85.192.173]:34373 "EHLO mail-pd0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751577AbbCSFqW (ORCPT ); Thu, 19 Mar 2015 01:46:22 -0400 Received: by pdbni2 with SMTP id ni2so65725277pdb.1 for ; Wed, 18 Mar 2015 22:46:22 -0700 (PDT) X-Received: by 10.70.137.72 with SMTP id qg8mr23222549pdb.8.1426743981947; Wed, 18 Mar 2015 22:46:21 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([114.30.40.58]) by mx.google.com with ESMTPSA id j4sm655258pdk.76.2015.03.18.22.46.18 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Mar 2015 22:46:20 -0700 (PDT) From: Baolin Wang To: richardcochran@gmail.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, john.stultz@linaro.com, tglx@linutronix.de, arnd@linaro.org, baolin.wang@linaro.org Subject: [PATCH 1/4] ptp/chardev:Introduce another option to get/set time in ptp_clock_info structure Date: Thu, 19 Mar 2015 13:45:06 +0800 Message-Id: <1426743909-24335-2-git-send-email-baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426743909-24335-1-git-send-email-baolin.wang@linaro.org> References: <1426743909-24335-1-git-send-email-baolin.wang@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: netdev@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: baolin.wang@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.174 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: , This patch introduces two options with "ktime_t" type to get/set time in ptp_clock_info structure that will avoid breaking in the year 2038. In ptp_chardev.c file, replace the gettime interface with getktime interface using the "ktime_t" type to get the ptp clock time. The patch's goal is to remove the original code using the "timespec" type, and I expect to be done with that in the following merge window. Signed-off-by: Baolin Wang --- drivers/ptp/ptp_chardev.c | 27 ++++++++++++++++++--------- include/linux/ptp_clock_kernel.h | 2 ++ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/ptp/ptp_chardev.c b/drivers/ptp/ptp_chardev.c index f8a7609..4e14cc6 100644 --- a/drivers/ptp/ptp_chardev.c +++ b/drivers/ptp/ptp_chardev.c @@ -125,8 +125,10 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) struct ptp_clock_info *ops = ptp->info; struct ptp_clock_time *pct; struct timespec ts; + struct timespec64 ts64; int enable, err = 0; unsigned int i, pin_index; + ktime_t kt; switch (cmd) { @@ -197,18 +199,25 @@ long ptp_ioctl(struct posix_clock *pc, unsigned int cmd, unsigned long arg) } pct = &sysoff->ts[0]; for (i = 0; i < sysoff->n_samples; i++) { - getnstimeofday(&ts); - pct->sec = ts.tv_sec; - pct->nsec = ts.tv_nsec; + ktime_get_real_ts64(&ts64); + pct->sec = ts64.tv_sec; + pct->nsec = ts64.tv_nsec; pct++; - ptp->info->gettime(ptp->info, &ts); - pct->sec = ts.tv_sec; - pct->nsec = ts.tv_nsec; + if (ptp->info->getktime) { + ptp->info->getktime(ptp->info, &kt); + ts64 = ktime_to_timespec64(kt); + pct->sec = ts64.tv_sec; + pct->nsec = ts64.tv_nsec; + } else { + ptp->info->gettime(ptp->info, &ts); + pct->sec = ts.tv_sec; + pct->nsec = ts.tv_nsec; + } pct++; } - getnstimeofday(&ts); - pct->sec = ts.tv_sec; - pct->nsec = ts.tv_nsec; + ktime_get_real_ts64(&ts64); + pct->sec = ts64.tv_sec; + pct->nsec = ts64.tv_nsec; if (copy_to_user((void __user *)arg, sysoff, sizeof(*sysoff))) err = -EFAULT; break; diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h index 0d8ff3f..86decc2 100644 --- a/include/linux/ptp_clock_kernel.h +++ b/include/linux/ptp_clock_kernel.h @@ -105,7 +105,9 @@ struct ptp_clock_info { int (*adjfreq)(struct ptp_clock_info *ptp, s32 delta); int (*adjtime)(struct ptp_clock_info *ptp, s64 delta); int (*gettime)(struct ptp_clock_info *ptp, struct timespec *ts); + int (*getktime)(struct ptp_clock_info *ptp, ktime_t *kt); int (*settime)(struct ptp_clock_info *ptp, const struct timespec *ts); + int (*setktime)(struct ptp_clock_info *ptp, ktime_t kt); int (*enable)(struct ptp_clock_info *ptp, struct ptp_clock_request *request, int on); int (*verify)(struct ptp_clock_info *ptp, unsigned int pin,