aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-26 22:28:57 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-10 03:06:20 -0500
commit5022a2088687baeda87b03889d0791b1b908266b (patch)
tree82c9f3366c55aee1bd5e29b88c84d2132489199e /drivers/media
parent2276bf70a7433c2afec541257eab28a43ed6c9cf (diff)
[media] em28xx: properly implement AC97 wait code
Instead of assuming that msleep() is precise, use a jiffies based code to wait for AC97 to be available. Reviewed-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/em28xx/em28xx-core.c7
-rw-r--r--drivers/media/usb/em28xx/em28xx.h3
2 files changed, 8 insertions, 2 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c
index b5f49703f7ce..b6dc3327c51c 100644
--- a/drivers/media/usb/em28xx/em28xx-core.c
+++ b/drivers/media/usb/em28xx/em28xx-core.c
@@ -23,6 +23,7 @@
23 */ 23 */
24 24
25#include <linux/init.h> 25#include <linux/init.h>
26#include <linux/jiffies.h>
26#include <linux/list.h> 27#include <linux/list.h>
27#include <linux/module.h> 28#include <linux/module.h>
28#include <linux/slab.h> 29#include <linux/slab.h>
@@ -252,16 +253,18 @@ EXPORT_SYMBOL_GPL(em28xx_toggle_reg_bits);
252 */ 253 */
253static int em28xx_is_ac97_ready(struct em28xx *dev) 254static int em28xx_is_ac97_ready(struct em28xx *dev)
254{ 255{
255 int ret, i; 256 unsigned long timeout = jiffies + msecs_to_jiffies(EM28XX_AC97_XFER_TIMEOUT);
257 int ret;
256 258
257 /* Wait up to 50 ms for AC97 command to complete */ 259 /* Wait up to 50 ms for AC97 command to complete */
258 for (i = 0; i < 10; i++, msleep(5)) { 260 while (time_is_after_jiffies(timeout)) {
259 ret = em28xx_read_reg(dev, EM28XX_R43_AC97BUSY); 261 ret = em28xx_read_reg(dev, EM28XX_R43_AC97BUSY);
260 if (ret < 0) 262 if (ret < 0)
261 return ret; 263 return ret;
262 264
263 if (!(ret & 0x01)) 265 if (!(ret & 0x01))
264 return 0; 266 return 0;
267 msleep(5);
265 } 268 }
266 269
267 em28xx_warn("AC97 command still being executed: not handled properly!\n"); 270 em28xx_warn("AC97 command still being executed: not handled properly!\n");
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index b792f2225abd..b0aa8497c1a9 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -186,6 +186,9 @@
186/* time in msecs to wait for i2c writes to finish */ 186/* time in msecs to wait for i2c writes to finish */
187#define EM2800_I2C_XFER_TIMEOUT 20 187#define EM2800_I2C_XFER_TIMEOUT 20
188 188
189/* time in msecs to wait for AC97 xfers to finish */
190#define EM28XX_AC97_XFER_TIMEOUT 100
191
189/* max. number of button state polling addresses */ 192/* max. number of button state polling addresses */
190#define EM28XX_NUM_BUTTON_ADDRESSES_MAX 5 193#define EM28XX_NUM_BUTTON_ADDRESSES_MAX 5
191 194