From patchwork Mon Nov 27 13:19:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10076909 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6C8D602BC for ; Mon, 27 Nov 2017 13:24:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C690F26E3D for ; Mon, 27 Nov 2017 13:24:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB46828E54; Mon, 27 Nov 2017 13:24:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 369CC26E3D for ; Mon, 27 Nov 2017 13:24:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbdK0NY4 (ORCPT ); Mon, 27 Nov 2017 08:24:56 -0500 Received: from mout.kundenserver.de ([217.72.192.73]:64621 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751311AbdK0NYz (ORCPT ); Mon, 27 Nov 2017 08:24:55 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0LlnLU-1eseDb3rNo-00ZPSD; Mon, 27 Nov 2017 14:24:44 +0100 From: Arnd Bergmann To: Alan Cox , Sakari Ailus , Mauro Carvalho Chehab , Greg Kroah-Hartman Cc: y2038@lists.linaro.org, Arnd Bergmann , Andy Shevchenko , linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/8] [media] staging: atomisp: convert timestamps to ktime_t Date: Mon, 27 Nov 2017 14:19:59 +0100 Message-Id: <20171127132027.1734806-7-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20171127132027.1734806-1-arnd@arndb.de> References: <20171127132027.1734806-1-arnd@arndb.de> X-Provags-ID: V03:K0:/+7j1r9EDm5UfyVnGclpfGsQKRTPgB0y2Hku+zqqUO4dHUdmLnv eAQcEbN4tEqMbst/3wuokUI803TngqtSxoXrdF07q/ftQv7grLf4L5b5amKxP+PM+djRk40 cqg4IwcMD0ZZ4aS17DRkGOylJWxHPfyOK/MvSpS9lwVCMSM+5hHL87PJ1vVYcWc+rbuOWxu tnsffaTs+eiRB7OrQziFw== X-UI-Out-Filterresults: notjunk:1; V01:K0:wyQtjaMmdJ4=:ysE8tUvkAKMr2/eei/LXcC boABwV0Dg0jBFj3Qhj+yzLT9GZ3EOAqPMHML3t+8Opi+nQcrTTylvsqReD5E67PcumbMYXJbr nYj8kDEXS3YZ/9L4JzKkleR4rb4Qg1hk5zRx1KwyL9ryH3n10VSIo6BwDHwTSiS1kezLVFWRj wsuY1xm2p+WaB4r7tqy+xv4xkR1LCsfjcyDCdCsAOl0MzfRwfznXJF+GBfTDJlFdygnuEiHdT qW13KbhWQlTjxBy0DOJKFdn5V76+T8ObVKq7d8cet+mXfzBISudjM7RIDROdsDR4IH+y14PuL ZsXssbuCLALKrxMUbgWUAjS3aMRlzozHT86PXGcr9QuekUS8QpqmI0PCPDv1KiS+7C5hk5mB7 fnvq9kNdsh0nJEiO2Za2meOwsJ4HM5Yt/XulUldaTemwok0KFTR7EgVO6YJ8SE8GpB/27NA9G SK1jQIhpa17vU1SqvvsuAbPLH01lLiZniSpt0RTb0T7eoxT1CK0/oAajxUgbxHcgt+XDGDS5a oc8OjaIGjEdG2xg57LjjBZoqh+zvY0vuD5gSFKDiS3lk+0O3MO0KYeFGjgXSB2izSYX1F9pU1 On45Z31rq50iGt0OLBICw2y4jS43oP0cy64hXdFjHp3pYdYGuqObI5JiTtDIHHj1rMT1xWLnm 1/stEXBrjBjnq/CsBEFehTDFvBdCev1RyvZPqJSQmaJCYNNFagWZweTVIRXOfko/eOn0peV6Y F4RF1GJxcQIU1vnBBHcNfvfbXNxSYiNyW6BqHQ== Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP timespec overflows in 2038 on 32-bit architectures, and the getnstimeofday() suffers from possible time jumps, so the timestamps here are better done using ktime_get(), which has neither of those problems. In case of ov2680, we don't seem to use the timestamp at all, so I just remove it. Signed-off-by: Arnd Bergmann --- drivers/staging/media/atomisp/i2c/ov2680.h | 1 - drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c | 15 ++++++--------- drivers/staging/media/atomisp/i2c/ov5693/ov5693.h | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/atomisp/i2c/ov2680.h b/drivers/staging/media/atomisp/i2c/ov2680.h index bf4897347df7..03f75dd80f87 100644 --- a/drivers/staging/media/atomisp/i2c/ov2680.h +++ b/drivers/staging/media/atomisp/i2c/ov2680.h @@ -174,7 +174,6 @@ struct ov2680_format { struct mutex input_lock; struct v4l2_ctrl_handler ctrl_handler; struct camera_sensor_platform_data *platform_data; - struct timespec timestamp_t_focus_abs; int vt_pix_clk_freq_mhz; int fmt_idx; int run_mode; diff --git a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c index 3e7c3851280f..a715ea0e4230 100644 --- a/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c +++ b/drivers/staging/media/atomisp/i2c/ov5693/atomisp-ov5693.c @@ -973,7 +973,7 @@ static int ov5693_t_focus_abs(struct v4l2_subdev *sd, s32 value) if (ret == 0) { dev->number_of_steps = value - dev->focus; dev->focus = value; - getnstimeofday(&(dev->timestamp_t_focus_abs)); + dev->timestamp_t_focus_abs = ktime_get(); } else dev_err(&client->dev, "%s: i2c failed. ret %d\n", __func__, ret); @@ -993,16 +993,13 @@ static int ov5693_q_focus_status(struct v4l2_subdev *sd, s32 *value) { u32 status = 0; struct ov5693_device *dev = to_ov5693_sensor(sd); - struct timespec temptime; - const struct timespec timedelay = { - 0, + ktime_t temptime; + ktime_t timedelay = ns_to_ktime( min((u32)abs(dev->number_of_steps) * DELAY_PER_STEP_NS, - (u32)DELAY_MAX_PER_STEP_NS), - }; + (u32)DELAY_MAX_PER_STEP_NS)); - getnstimeofday(&temptime); - temptime = timespec_sub(temptime, (dev->timestamp_t_focus_abs)); - if (timespec_compare(&temptime, &timedelay) <= 0) { + temptime = ktime_sub(ktime_get(), (dev->timestamp_t_focus_abs)); + if (ktime_compare(temptime, timedelay) <= 0) { status |= ATOMISP_FOCUS_STATUS_MOVING; status |= ATOMISP_FOCUS_HP_IN_PROGRESS; } else { diff --git a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h index 2ea63807c56d..68cfcb4a6c3c 100644 --- a/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h +++ b/drivers/staging/media/atomisp/i2c/ov5693/ov5693.h @@ -221,7 +221,7 @@ struct ov5693_device { struct v4l2_ctrl_handler ctrl_handler; struct camera_sensor_platform_data *platform_data; - struct timespec timestamp_t_focus_abs; + ktime_t timestamp_t_focus_abs; int vt_pix_clk_freq_mhz; int fmt_idx; int run_mode;