summaryrefslogtreecommitdiffstats
path: root/drivers/hid/intel-ish-hid/ipc/ipc.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-05-18 22:21:42 +0200
committerJiri Kosina <jkosina@suse.cz>2017-05-30 14:11:52 +0200
commit2503f7babbc7f570d06cfa3ca6b7ceec9262ced3 (patch)
tree18102daa626df1b77b1d0f29d7db077bd4b091c4 /drivers/hid/intel-ish-hid/ipc/ipc.c
parent538be0aa8610168d7a8f4b119452056f537cff46 (diff)
downloadlinux-2503f7babbc7f570d06cfa3ca6b7ceec9262ced3.tar.bz2
HID: intel_ish-hid: convert timespec to ktime_t
The internal accounting uses 'timespec' based time stamps, which is slightly inefficient and also problematic once we get to the time_t overflow in 2038. When communicating to the firmware, we even get an open-coded 64-bit division that prevents the code from being build-tested on 32-bit architectures and is inefficient due to the double conversion from 64-bit nanoseconds to seconds+nanoseconds and then microseconds. This changes the code to use ktime_t instead. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/intel-ish-hid/ipc/ipc.c')
-rw-r--r--drivers/hid/intel-ish-hid/ipc/ipc.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/hid/intel-ish-hid/ipc/ipc.c b/drivers/hid/intel-ish-hid/ipc/ipc.c
index 842d8416a7a6..9a60ec13cb10 100644
--- a/drivers/hid/intel-ish-hid/ipc/ipc.c
+++ b/drivers/hid/intel-ish-hid/ipc/ipc.c
@@ -296,17 +296,12 @@ static int write_ipc_from_queue(struct ishtp_device *dev)
/* If sending MNG_SYNC_FW_CLOCK, update clock again */
if (IPC_HEADER_GET_PROTOCOL(doorbell_val) == IPC_PROTOCOL_MNG &&
IPC_HEADER_GET_MNG_CMD(doorbell_val) == MNG_SYNC_FW_CLOCK) {
- struct timespec ts_system;
- struct timeval tv_utc;
- uint64_t usec_system, usec_utc;
+ uint64_t usec_system, usec_utc;
struct ipc_time_update_msg time_update;
struct time_sync_format ts_format;
- get_monotonic_boottime(&ts_system);
- do_gettimeofday(&tv_utc);
- usec_system = (timespec_to_ns(&ts_system)) / NSEC_PER_USEC;
- usec_utc = (uint64_t)tv_utc.tv_sec * 1000000 +
- ((uint32_t)tv_utc.tv_usec);
+ usec_system = ktime_to_us(ktime_get_boottime());
+ usec_utc = ktime_to_us(ktime_get_real());
ts_format.ts1_source = HOST_SYSTEM_TIME_USEC;
ts_format.ts2_source = HOST_UTC_TIME_USEC;
ts_format.reserved = 0;
@@ -575,15 +570,13 @@ static void fw_reset_work_fn(struct work_struct *unused)
static void _ish_sync_fw_clock(struct ishtp_device *dev)
{
static unsigned long prev_sync;
- struct timespec ts;
uint64_t usec;
if (prev_sync && jiffies - prev_sync < 20 * HZ)
return;
prev_sync = jiffies;
- get_monotonic_boottime(&ts);
- usec = (timespec_to_ns(&ts)) / NSEC_PER_USEC;
+ usec = ktime_to_us(ktime_get_boottime());
ipc_send_mng_msg(dev, MNG_SYNC_FW_CLOCK, &usec, sizeof(uint64_t));
}