From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934251AbdBQPEl (ORCPT ); Fri, 17 Feb 2017 10:04:41 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:59017 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934072AbdBQPEj (ORCPT ); Fri, 17 Feb 2017 10:04:39 -0500 From: Arnd Bergmann To: Don Brace , "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , kevin Barnett , Johannes Thumshirn , Scott Benesh , esc.storagedev@microsemi.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] smartpqi: fix time handling Date: Fri, 17 Feb 2017 16:03:52 +0100 Message-Id: <20170217150417.2458237-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:mFWXo+ebOYnTiht5VKgyk7Uo4q4QTsGFcKm2ocWD2x0SYOuJNi3 sO768cK0SLmujCl6jm1Kb4sWNq2Qewm4bq3OjmpYGENNqVie14yj2/K/RSX2noB0LFq7MKI bua8w6kZ+2LajR8gyuD568OTMS+YiMZ9QL1VM3ZmJGKbvdTMG911LX+5HvpjP4U87EoJ9/U dtXQNqL7dV7wmGOrQ2C0A== X-UI-Out-Filterresults: notjunk:1;V01:K0:i4ov/huHN8k=:6aH/9p91cIvXJdx9cACL8D k1sJCtdMPQJWy4yHQeyahe1OrIcz57mer6OwnuVppR9zcdSIqSFzWYZtYs887UP+RSNVNcXeL e/3+Zv2V2DxUcBnyX7w4qfZfaO0GeUmCSsxhxEsXkt8sv9x4iy/ydSsIhRyXAg6/NjaVI2/Jb k4cgIDg1/SEkJmmX58U2IRPSLwBAkhzAkimzlRlIlAsmhz/OEtNv88e/QVAq6IhGzqYtN66s1 29QsZGUfRDaKaHDZxlEbCWE9z8r4fVljx1TqDwwMqyYUU1ILBpDVps3Z2GRyAsyysbg1FeFsb sY/4vxtr3DyWduuTNWpiu0mDKTWw4WHXhD9v7IIWd7pecJm0JvtPayVtPPGJZi1SmRFbGyHDY yO1SUG72ubA3L/ABXQDoYz9T9OkivvOkVUKbjMYsBrjgPoxGPmUWvyMBJIqZSkZ8Zq4Axr/K5 U8cTN9fGunLuW786wsy4V+cH6bvyu6H7C71phAgrzxMeyLSKmPrpMP1PvOTK72OTOlIob3lTA JVK8nUHn6TvdfIPE6i9W+2Cz0L7Rb32QV2Vif1HlbM5nq/foXEp/rnvA8Vx0lNFa2mGDnGWrg ZIxb9/z0j+ZGcAR/YUP8MwnD2+MGKkYC4eL07O1nW/kMWuKXHRiH4fJ1VirP6FkXg8FIX/6cO jdg/ZnPpWddXlO2exnmq2o51lNfvogVu7+K1yQ/o9OXpOYRr32VexHBVRxhrgXjhEHmI= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When we have turned off RTC support, the smartpqi driver fails to build: ERROR: "rtc_time64_to_tm" [drivers/scsi/smartpqi/smartpqi.ko] undefined! This is easily avoided by using the generic 'struct tm' based helper rather than the RTC specific one. While fixing this, I noticed that even though the driver uses time64_t for storing seconds, it gets them from the old 32-bit struct timeval. To address this, we can simplify the code by calling ktime_get_real_seconds() directly. Fixes: 6c223761eb54 ("smartpqi: initial commit of Microsemi smartpqi driver") Signed-off-by: Arnd Bergmann --- drivers/scsi/smartpqi/smartpqi_init.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 11c0dfb3dfa3..657ad15682a3 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -534,8 +534,7 @@ static int pqi_write_current_time_to_host_wellness( size_t buffer_length; time64_t local_time; unsigned int year; - struct timeval time; - struct rtc_time tm; + struct tm tm; buffer_length = sizeof(*buffer); @@ -552,9 +551,8 @@ static int pqi_write_current_time_to_host_wellness( put_unaligned_le16(sizeof(buffer->time), &buffer->time_length); - do_gettimeofday(&time); - local_time = time.tv_sec - (sys_tz.tz_minuteswest * 60); - rtc_time64_to_tm(local_time, &tm); + local_time = ktime_get_real_seconds(); + time64_to_tm(local_time, -sys_tz.tz_minuteswest * 60, &tm); year = tm.tm_year + 1900; buffer->time[0] = bin2bcd(tm.tm_hour); -- 2.9.0