summaryrefslogtreecommitdiff
path: root/drivers/media/platform/vivid/vivid-radio-tx.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-11-27 18:25:56 +0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-12-08 19:26:24 +0300
commitaad2fa4c8b1d99a737f97b031cc3e262f158b02e (patch)
treeb82e5566477b2c7af406f43dbe7654c4391415c5 /drivers/media/platform/vivid/vivid-radio-tx.c
parent1d88f4bccfd87b6359f11032f2018893d531d18d (diff)
downloadlinux-aad2fa4c8b1d99a737f97b031cc3e262f158b02e.tar.xz
media: vivid: use ktime_t for timestamp calculation
timespec is generally deprecated because of the y2038 overflow. In vivid, the usage is fine, since we are dealing with monotonic timestamps, but we can also simplify the code by going to ktime_t. Using ktime_divns() should be roughly as efficient as the old code, since the constant 64-bit division gets turned into a multiplication on modern platforms, and we save multiple 32-bit divisions that can be expensive e.g. on ARMv7. Tested-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/platform/vivid/vivid-radio-tx.c')
-rw-r--r--drivers/media/platform/vivid/vivid-radio-tx.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/media/platform/vivid/vivid-radio-tx.c b/drivers/media/platform/vivid/vivid-radio-tx.c
index 0e8025b7b4dd..897b56195ca7 100644
--- a/drivers/media/platform/vivid/vivid-radio-tx.c
+++ b/drivers/media/platform/vivid/vivid-radio-tx.c
@@ -37,7 +37,7 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf,
{
struct vivid_dev *dev = video_drvdata(file);
struct v4l2_rds_data *data = dev->rds_gen.data;
- struct timespec ts;
+ ktime_t timestamp;
unsigned blk;
int i;
@@ -58,10 +58,8 @@ ssize_t vivid_radio_tx_write(struct file *file, const char __user *buf,
dev->radio_tx_rds_owner = file->private_data;
retry:
- ktime_get_ts(&ts);
- ts = timespec_sub(ts, dev->radio_rds_init_ts);
- blk = ts.tv_sec * 100 + ts.tv_nsec / 10000000;
- blk = (blk * VIVID_RDS_GEN_BLOCKS) / 500;
+ timestamp = ktime_sub(ktime_get(), dev->radio_rds_init_time);
+ blk = ktime_divns(timestamp, VIVID_RDS_NSEC_PER_BLK);
if (blk - VIVID_RDS_GEN_BLOCKS >= dev->radio_tx_rds_last_block)
dev->radio_tx_rds_last_block = blk - VIVID_RDS_GEN_BLOCKS + 1;