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: 119708 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp263326qgn; Mon, 27 Nov 2017 05:24:57 -0800 (PST) X-Google-Smtp-Source: AGs4zMbzPhEby4UUVX9ryXfc5UfPcvQE9pA5lATP2vSu97ZTaO1xZjYPUJfVGt74XQVy36nUMCfl X-Received: by 10.101.70.11 with SMTP id v11mr36484985pgq.306.1511789097427; Mon, 27 Nov 2017 05:24:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511789097; cv=none; d=google.com; s=arc-20160816; b=RCnN2Uh5jMdPyIUgh3YM1yR37M7ORv50RLzoi67auV3hCdcc5QdLO1H9zYg/iUeY4b X9sqUge08AYQoL61pUnV+Ky/PG6KzjkksePiBgHt9wvfn0ecRCso/QVWRiro+BS0YrFv x0v1k8mStOKvO+CiWGBsgbmemw9NayN/pL5Lg9ezD7sTehNX+j+tbCnE4J5KB3Bz2RTO OQiWbpudsaqyvwsoUG42OgtqYVc+K6Ma2P1QGUbUUnCFW6B5eU+Kz0tqtIgXXJheEDrt dTfxUqkjfRaa8nKfDvuutzk4mSUko1h6wcOQkHCZvLDYgqcobjOKYBT4ocyrxzqdPv6m Hh1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=KoyzF7Ry3Ys+VTKVzHk552hzK7Wl/EBgiS+wr7LsYf4=; b=FBlr7FpK1PFCbyi1Duj/AgW0IPwuBc9ZGfwi2/0u3YrKBzLoFx2FCbTqHaPAppReMH DzGdtltg5PnfHZiUS2DOEjPkyJkHRx6/YcLsCn/px15cxqvGplY0+J4oz2XkEtnfose2 ppx4fVsNsNqx7gglCe60By1Rz3gne5uMKwP/cv9A3oP1QGYJbBYkwiEFsXbHOdMRiL9B biAtvtfQfh7HwQZUZ0DRxoyq/E/S4sjRILrCBZbikvinhXh3rz2Sc5l/pJNe3FnVSLOK acpA9ufyV5EDGze9rWHVcmAMqfVHMAC8qFYT1fl2CbPyyPJV65CYDJKo0wXZTy674SBM xZNg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y21si15412116pgc.766.2017.11.27.05.24.57; Mon, 27 Nov 2017 05:24:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752182AbdK0NY4 (ORCPT + 4 others); 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 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(-) -- 2.9.0 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;