From patchwork Fri Nov 10 15:39:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10053383 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 30E5560631 for ; Fri, 10 Nov 2017 15:40:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1F45E2AF01 for ; Fri, 10 Nov 2017 15:40:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 146742AF16; Fri, 10 Nov 2017 15:40:15 +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=unavailable 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 CBABD2AF01 for ; Fri, 10 Nov 2017 15:40:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752302AbdKJPkF (ORCPT ); Fri, 10 Nov 2017 10:40:05 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:59072 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbdKJPkD (ORCPT ); Fri, 10 Nov 2017 10:40:03 -0500 Received: from wuerfel.lan ([109.193.157.232]) by mrelayeu.kundenserver.de (mreue007 [212.227.15.129]) with ESMTPA (Nemesis) id 0LgBIO-1eyOno3QtI-00nkWU; Fri, 10 Nov 2017 16:39:48 +0100 From: Arnd Bergmann To: Bradley Grove , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: esas2r: use ktime_get_real_seconds() Date: Fri, 10 Nov 2017 16:39:34 +0100 Message-Id: <20171110153947.1932747-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:7l+XteiW/Bh5HNjtLLS2nMDGEJx2l3HvMFwMfXjuGjkjjRjE7Y3 VoqL4IjeulCDXInTq1FWzUARL+DvN5bJKUodPyXDotc39c4sv6JfYyXLEOZvFVSr37M7/Q5 UYAwqOjna+Aib9f/xKNL76e7nFuppdOINH9f/EnCrrd1KHgT2lYdrXGoO3wIx1dCE2DFA4C HsCYmrwhwwWITq/rsOy+Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:k3yTW+fQIWQ=:xPBUIoYhD7QK+WzkHaa8io ZHpUTGyocp+zAGtcmYV6K2ahsWnhUIqsmuX/h4WcylnEdiE1J1qjprlrFeHtWclBsx5TW5RvD KIxjmaIsuYMgOLYutv5kTII6HvicvnON954aQXYCELOe49LvI24sFe0bTPkOWMac0VxUrQORf jC0iYeVlG0NXQKP9zv1+IYH9yzRPZFa9tu4MvZogFU7oDSNpXkH9NfWPKef0/P3zrzbxBEICc lbx3gS0jak+4WV1seNIiIBqRP4o6PV0WRVDtSmyYFlqeXCiI8TBPgN6HFlzClBjYEHcQmisSH up35yvBeKWNlR4CldrWhL7wsdbwFbmoGWz2LlOT5lPwZ20VbDOYFju42lYp5jiS9CeO0af2ur F1wKPs5ITSERO77tc8uOLYlZdRmALxv+lFuPneUshBVYAdXhqbsdsr0xLrcI1QXgrNvQdheRl zs+T3FQf5biK1arxGO/pXL1lRST0w+ug3Izc+tV9W+XTdpGwfqRAN0wwB+wDU4AsF8Sq+pM8G gB6Z6g1giKIA1/mMMExL2o4dg3izvGsP8IowwHqV0jDNSJ2g2V9Sv6n4u1Lr71k3zu2Uqopvy Erk4482/rtAg3UNvBnesr1IPHBgqjcm/ry92CSG3JCgpc8ZWgas8OJ/T5Rkxk+IBasu+0p+94 v+9Y9lcC4K891T7Zzbkv8zo5Md8sGSwn494h2kVtq/UVwGG/LtzPraYleOpNRS+bU8pZQWP1U A5JUnpGmnUYZn5sEXcAhsS/76wSUy1OKFJBQUA== Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do_gettimeofday() is deprecated because of the y2038 overflow. Here, we use the result to pass into a 32-bit field in the firmware, which still risks an overflow, but if the firmware is written to expect unsigned values, it can at least last until y2106, and there is not much we can do about it. This changes do_gettimeofday() to ktime_get_real_seconds(), which at least simplifies the code a bit, and avoids the deprecated interface. I'm adding a comment about the overflow to document what happens. Signed-off-by: Arnd Bergmann --- drivers/scsi/esas2r/esas2r_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index 5b14dd29b764..67b3e3354e3c 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c @@ -1223,8 +1223,6 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a, case ESAS2R_INIT_MSG_START: case ESAS2R_INIT_MSG_REINIT: { - struct timeval now; - do_gettimeofday(&now); esas2r_hdebug("CFG init"); esas2r_build_cfg_req(a, rq, @@ -1233,7 +1231,8 @@ static bool esas2r_format_init_msg(struct esas2r_adapter *a, NULL); ci = (struct atto_vda_cfg_init *)&rq->vrq->cfg.data.init; ci->sgl_page_size = cpu_to_le32(sgl_page_size); - ci->epoch_time = cpu_to_le32(now.tv_sec); + /* firmware interface overflows in y2106 */ + ci->epoch_time = cpu_to_le32(ktime_get_real_seconds()); rq->flags |= RF_FAILURE_OK; a->init_msg = ESAS2R_INIT_MSG_INIT; break;