diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2014-03-28 22:27:32 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-05-23 19:02:57 +0400 |
commit | 05b1b986b540fe48f98a09b087b054754d67ef41 (patch) | |
tree | dcd07a9d12a358ec4982235f5d5b2cf5d248c754 /drivers/staging/media/omap4iss/iss.c | |
parent | 47a963f1025690824a3f00e27d1d161a0f01cd88 (diff) | |
download | linux-05b1b986b540fe48f98a09b087b054754d67ef41.tar.xz |
[media] omap4iss: Use a common macro for all sleep-based poll loops
Instead of implementing usleep_range-based poll loops manually (and
slightly differently), create a generic iss_poll_wait_timeout() macro
and use it through the driver.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/staging/media/omap4iss/iss.c')
-rw-r--r-- | drivers/staging/media/omap4iss/iss.c | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/drivers/staging/media/omap4iss/iss.c b/drivers/staging/media/omap4iss/iss.c index 219519d0f029..217d719625ce 100644 --- a/drivers/staging/media/omap4iss/iss.c +++ b/drivers/staging/media/omap4iss/iss.c @@ -734,18 +734,17 @@ static int iss_pipeline_is_last(struct media_entity *me) static int iss_reset(struct iss_device *iss) { - unsigned long timeout = 0; + unsigned int timeout; iss_reg_set(iss, OMAP4_ISS_MEM_TOP, ISS_HL_SYSCONFIG, ISS_HL_SYSCONFIG_SOFTRESET); - while (iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_SYSCONFIG) & - ISS_HL_SYSCONFIG_SOFTRESET) { - if (timeout++ > 100) { - dev_alert(iss->dev, "cannot reset ISS\n"); - return -ETIMEDOUT; - } - usleep_range(10, 10); + timeout = iss_poll_condition_timeout( + !(iss_reg_read(iss, OMAP4_ISS_MEM_TOP, ISS_HL_SYSCONFIG) & + ISS_HL_SYSCONFIG_SOFTRESET), 1000, 10, 10); + if (timeout) { + dev_err(iss->dev, "ISS reset timeout\n"); + return -ETIMEDOUT; } iss->crashed = 0; @@ -754,7 +753,7 @@ static int iss_reset(struct iss_device *iss) static int iss_isp_reset(struct iss_device *iss) { - unsigned long timeout = 0; + unsigned int timeout; /* Fist, ensure that the ISP is IDLE (no transactions happening) */ iss_reg_update(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_SYSCONFIG, @@ -763,29 +762,24 @@ static int iss_isp_reset(struct iss_device *iss) iss_reg_set(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_CTRL, ISP5_CTRL_MSTANDBY); - for (;;) { - if (iss_reg_read(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_CTRL) & - ISP5_CTRL_MSTANDBY_WAIT) - break; - if (timeout++ > 1000) { - dev_alert(iss->dev, "cannot set ISP5 to standby\n"); - return -ETIMEDOUT; - } - usleep_range(1000, 1500); + timeout = iss_poll_condition_timeout( + iss_reg_read(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_CTRL) & + ISP5_CTRL_MSTANDBY_WAIT, 1000000, 1000, 1500); + if (timeout) { + dev_err(iss->dev, "ISP5 standby timeout\n"); + return -ETIMEDOUT; } /* Now finally, do the reset */ iss_reg_set(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_SYSCONFIG, ISP5_SYSCONFIG_SOFTRESET); - timeout = 0; - while (iss_reg_read(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_SYSCONFIG) & - ISP5_SYSCONFIG_SOFTRESET) { - if (timeout++ > 1000) { - dev_alert(iss->dev, "cannot reset ISP5\n"); - return -ETIMEDOUT; - } - usleep_range(1000, 1500); + timeout = iss_poll_condition_timeout( + !(iss_reg_read(iss, OMAP4_ISS_MEM_ISP_SYS1, ISP5_SYSCONFIG) & + ISP5_SYSCONFIG_SOFTRESET), 1000000, 1000, 1500); + if (timeout) { + dev_err(iss->dev, "ISP5 reset timeout\n"); + return -ETIMEDOUT; } return 0; |