提交 ceea5e2d 编写于 作者: M Mauro Carvalho Chehab

[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: NDevin Heitmueller <dheitmueller@kernellabs.com>
Signed-off-by: NMauro Carvalho Chehab <m.chehab@samsung.com>
上级 c4dc6f92
...@@ -4417,8 +4417,8 @@ ctrl_set_cfg_smart_ant(struct drx_demod_instance *demod, struct drxj_cfg_smart_a ...@@ -4417,8 +4417,8 @@ ctrl_set_cfg_smart_ant(struct drx_demod_instance *demod, struct drxj_cfg_smart_a
static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd) static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd)
{ {
int rc; int rc;
u32 start_time = 0;
u16 cur_cmd = 0; u16 cur_cmd = 0;
unsigned long timeout;
/* Check param */ /* Check param */
if (cmd == NULL) if (cmd == NULL)
...@@ -4478,15 +4478,17 @@ static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd ...@@ -4478,15 +4478,17 @@ static int scu_command(struct i2c_device_addr *dev_addr, struct drxjscu_cmd *cmd
} }
/* Wait until SCU has processed command */ /* Wait until SCU has processed command */
start_time = jiffies_to_msecs(jiffies); timeout = jiffies + msecs_to_jiffies(DRXJ_MAX_WAITTIME);
do { while (time_is_after_jiffies(timeout)) {
rc = DRXJ_DAP.read_reg16func(dev_addr, SCU_RAM_COMMAND__A, &cur_cmd, 0); rc = DRXJ_DAP.read_reg16func(dev_addr, SCU_RAM_COMMAND__A, &cur_cmd, 0);
if (rc != 0) { if (rc != 0) {
pr_err("error %d\n", rc); pr_err("error %d\n", rc);
goto rw_error; goto rw_error;
} }
} while (!(cur_cmd == DRX_SCU_READY) if (cur_cmd == DRX_SCU_READY)
&& ((jiffies_to_msecs(jiffies) - start_time) < DRXJ_MAX_WAITTIME)); break;
usleep_range(1000, 2000);
}
if (cur_cmd != DRX_SCU_READY) if (cur_cmd != DRX_SCU_READY)
return -EIO; return -EIO;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册