diff options
author | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-26 19:55:57 +0100 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-04 18:37:41 +0100 |
commit | ceea5e2d9dc2334c6a4b167b6134f5cd740b8e0b (patch) | |
tree | bed5ffda60ddcbc5b35627603720b343ce7c5cf3 | |
parent | [media] drx-j: call ctrl_set_standard even if a standard is powered (diff) | |
download | linux-ceea5e2d9dc2334c6a4b167b6134f5cd740b8e0b.tar.xz linux-ceea5e2d9dc2334c6a4b167b6134f5cd740b8e0b.zip |
[media] drx-j: use the proper timeout code on scu_command
Checking if a time is after another one can have issues, as
times are generally u32 wide.
Use the proper macros for that at scu_command().
It should be noticed that other places also use jiffies
calculus on an improper way. This should be fixed too,
but the logic there is more complex. So, let's do it in
separate patches.
Acked-by: Devin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/dvb-frontends/drx39xyj/drxj.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c index b1a7dfeec489..c843d8f4a96a 100644 --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c @@ -4417,8 +4417,8 @@ rw_error: static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd) { int rc; - u32 start_time = 0; u16 cur_cmd = 0; + unsigned long timeout; /* Check param */ if (cmd == NULL) @@ -4478,15 +4478,17 @@ static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd } /* Wait until SCU has processed command */ - start_time = jiffies_to_msecs(jiffies); - do { + timeout = jiffies + msecs_to_jiffies(DRXJ_MAX_WAITTIME); + while (time_is_after_jiffies(timeout)) { rc = DRXJ_DAP.read_reg16func(dev_addr, SCU_RAM_COMMAND__A, &cur_cmd, 0); if (rc != 0) { pr_err("error %d\n", rc); goto rw_error; } - } while (!(cur_cmd == DRX_SCU_READY) - && ((jiffies_to_msecs(jiffies) - start_time) < DRXJ_MAX_WAITTIME)); + if (cur_cmd == DRX_SCU_READY) + break; + usleep_range(1000, 2000); + } if (cur_cmd != DRX_SCU_READY) return -EIO; |