Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932206AbcCUTzh (ORCPT ); Mon, 21 Mar 2016 15:55:37 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:60608 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756203AbcCUTzf (ORCPT ); Mon, 21 Mar 2016 15:55:35 -0400 From: Arnd Bergmann To: Tina Ruchandani Cc: y2038@lists.linaro.org, Stefan Richter , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH] firewire: nosy: Replace timeval with timespec64 Date: Mon, 21 Mar 2016 20:55:16 +0100 Message-ID: <3432361.tg4OvfJSmN@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: <20160321055911.GA98166@localhost> References: <20160321055911.GA98166@localhost> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:8IWxK3bmQNV2aDc1pE1RlQi0Yq7bDi0Vo1dtgUonG7DOrLIx2LD 4+prFA8objzY1P10NsS/XzKdhZO1V0ViUFxbPJ7TYTFI/c/drc88azavqxT7ZQ9vX5UiEmA 3ezmhRbFOeiYBJNmqAUIHBTy+i07mZV8n8hz+IQuHFFq3cFxRnoOHsglKJCD1/rnLfLtaXD 7PVd54zwrkVUPkKXT6SmQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:12ZP+ImPF3Q=:p649yN+jaRd4jmjFpzCWvi yIK0y7jnDMnZeXmG/zRCJ5Iwqm+Xd0MUMMgvchOmkgjwVcDKhtxTOwZWondkx3mWqhpvzILIY BNck5MgHUf+jM22z1lB6i6B5ZKBr+qaAy06Qme/wl74oIVaEpMjlmQHyj3FzhK0ztHowDLjnM TiohJv/4SC+o7JdOJXz/iag41yrNCKGUr44BFb+zlycVcu6isjrY+t0zKHu2nSHR5UrgnpRBh MN2BXAhXmA0UjC3zlsbUqVz4iCa1wJk9milpT7ztqWy6Vz2FH8ndnyPkqCACAcHzsH+hAj+8F X9wu955CUPDl5gdpoXUdHZwf1pA4PVp4tPCdnDeTQzvy1XdqjTIARMBSYk3g32dLpxxDKeTox nuUP2NWxophpADOKGqQ4D4LZScXXKYKzDHtu6VRTqxx5KePWWmWtwW0a8GoKMx8xnOhxfmBkw OjjAWSn6heNOPLHoVPxaeHqUgWs3+7N0E1VGg+4asAHcLdh3oqCRvgDLU/rE7LXfVZrjDPpkA H5MRrjF63UbSqlUFzRVqGL0bJKKEcPSJ8gC8tcQebZN2F7FYXlYFI+CSu46Mke18P6ukU1Dqg utgsNHEAwqmui1i9yFsWurU9oJCJZbt2gxAs2gqFa7XfcL6i22Sn6udiEoqfqXP/C8gOtVoik VTdB9jj1GfpsGwsY7IWJpl9jMX5uJkO6BZ3yHPCiq/3FaB2JxMiBVvOqRkv1efsI8GsVNPjXt LML97BqBQCcgf+lC Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2609 Lines: 71 On Sunday 20 March 2016 22:59:11 Tina Ruchandani wrote: > 'struct timeval' uses a 32 bit field for its 'seconds' value which > will overflow in year 2038 and beyond. This patch replaces the use > of timeval in nosy.c with timespec64 which doesn't suffer from y2038 > issue. The code is correct as is - since it is only using the > microseconds portion of timeval. However, this patch does the > replacement as part of a larger effort to remove all instances of > 'struct timeval' from the kernel (that would help identify cases > where the code is actually broken). > > Signed-off-by: Tina Ruchandani > --- > drivers/firewire/nosy.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) The patch looks correct to me, but it seems the same one has just been merged into mainline Linux on Saturday (the patch was posted back in October). commit 2ae4b6b20e2004dccf80d804ae52b073377c2f5b Author: Amitoj Kaur Chawla Date: Thu Oct 22 04:05:00 2015 +0530 firewire: nosy: Replace timeval with timespec64 32 bit systems using 'struct timeval' will break in the year 2038, so we replace the code appropriately. However, this driver is not broken in 2038 since we are using only the microseconds portion of the current time. This patch replaces timeval with timespec64. Signed-off-by: Amitoj Kaur Chawla Reviewed-by: Arnd Bergmann Signed-off-by: Stefan Richter diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c index 76b2d390f6ec..8a46077129ac 100644 --- a/drivers/firewire/nosy.c +++ b/drivers/firewire/nosy.c @@ -33,6 +33,7 @@ #include /* required for linux/wait.h */ #include #include +#include #include #include #include @@ -413,17 +414,18 @@ static void packet_irq_handler(struct pcilynx *lynx) { struct client *client; - u32 tcode_mask, tcode; + u32 tcode_mask, tcode, timestamp; size_t length; - struct timeval tv; + struct timespec64 ts64; /* FIXME: Also report rcv_speed. */ length = __le32_to_cpu(lynx->rcv_pcl->pcl_status) & 0x00001fff; tcode = __le32_to_cpu(lynx->rcv_buffer[1]) >> 4 & 0xf; - do_gettimeofday(&tv); - lynx->rcv_buffer[0] = (__force __le32)tv.tv_usec; + ktime_get_real_ts64(&ts64); + timestamp = ts64.tv_nsec / NSEC_PER_USEC; + lynx->rcv_buffer[0] = (__force __le32)timestamp; if (length == PHY_PACKET_SIZE) tcode_mask = 1 << TCODE_PHY_PACKET;