aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-11-06 15:04:39 +0100
committerDavid S. Miller <davem@davemloft.net>2017-11-08 13:33:40 +0900
commit7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c (patch)
treec957c9e22e6370243956f0fa9016f9cf748b97e1 /drivers
parentof: add of_property_read_variable_* dummy helpers (diff)
downloadlinux-dev-7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c.tar.xz
linux-dev-7dfaa7bc99498da1c6c4a48bee8d2d5265161a8c.zip
bnxt: fix bnxt_hwrm_fw_set_time for y2038
On 32-bit architectures, rtc_time_to_tm() returns incorrect results in 2038 or later, and do_gettimeofday() is broken for the same reason. This changes the code to use ktime_get_real_seconds() and time64_to_tm() instead, both of them are 2038-safe, and we can also get rid of the CONFIG_RTC_LIB dependency that way. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/broadcom/bnxt/bnxt.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index e5472e5ae7b2..33c49ad697e4 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4915,16 +4915,14 @@ hwrm_ver_get_exit:
int bnxt_hwrm_fw_set_time(struct bnxt *bp)
{
-#if IS_ENABLED(CONFIG_RTC_LIB)
struct hwrm_fw_set_time_input req = {0};
- struct rtc_time tm;
- struct timeval tv;
+ struct tm tm;
+ time64_t now = ktime_get_real_seconds();
if (bp->hwrm_spec_code < 0x10400)
return -EOPNOTSUPP;
- do_gettimeofday(&tv);
- rtc_time_to_tm(tv.tv_sec, &tm);
+ time64_to_tm(now, 0, &tm);
bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FW_SET_TIME, -1, -1);
req.year = cpu_to_le16(1900 + tm.tm_year);
req.month = 1 + tm.tm_mon;
@@ -4933,9 +4931,6 @@ int bnxt_hwrm_fw_set_time(struct bnxt *bp)
req.minute = tm.tm_min;
req.second = tm.tm_sec;
return hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT);
-#else
- return -EOPNOTSUPP;
-#endif
}
static int bnxt_hwrm_port_qstats(struct bnxt *bp)