Commit 41024743 authored by Maximilian Attems's avatar Maximilian Attems Committed by Linus Torvalds

[PATCH] saa7146_i2c.c: use msleep()

Signed-off-by: default avatarNishanth Aravamudan <nacc@us.ibm.com>
Signed-off-by: default avatarMaximilian Attems <janitor@sternwelten.at>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 6f7e10f6
#include <linux/version.h> #include <linux/version.h>
#include <media/saa7146_vv.h> #include <media/saa7146_vv.h>
/* helper function */
static void my_wait(struct saa7146_dev *dev, long ms)
{
set_current_state(TASK_INTERRUPTIBLE);
schedule_timeout((((ms+10)/10)*HZ)/1000);
}
u32 saa7146_i2c_func(struct i2c_adapter *adapter) u32 saa7146_i2c_func(struct i2c_adapter *adapter)
{ {
//fm DEB_I2C(("'%s'.\n", adapter->name)); //fm DEB_I2C(("'%s'.\n", adapter->name));
...@@ -136,12 +129,12 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev) ...@@ -136,12 +129,12 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev)
/* set "ABORT-OPERATION"-bit (bit 7)*/ /* set "ABORT-OPERATION"-bit (bit 7)*/
saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07)); saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07));
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
my_wait(dev,SAA7146_I2C_DELAY); msleep(SAA7146_I2C_DELAY);
/* clear all error-bits pending; this is needed because p.123, note 1 */ /* clear all error-bits pending; this is needed because p.123, note 1 */
saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate);
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
my_wait(dev,SAA7146_I2C_DELAY); msleep(SAA7146_I2C_DELAY);
} }
/* check if any error is (still) present. (this can be necessary because p.123, note 1) */ /* check if any error is (still) present. (this can be necessary because p.123, note 1) */
...@@ -155,18 +148,18 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev) ...@@ -155,18 +148,18 @@ static int saa7146_i2c_reset(struct saa7146_dev *dev)
after serious protocol errors caused by e.g. the SAA7740 */ after serious protocol errors caused by e.g. the SAA7740 */
saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07)); saa7146_write(dev, I2C_STATUS, (dev->i2c_bitrate | MASK_07));
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
my_wait(dev,SAA7146_I2C_DELAY); msleep(SAA7146_I2C_DELAY);
/* clear all error-bits pending */ /* clear all error-bits pending */
saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate);
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
my_wait(dev,SAA7146_I2C_DELAY); msleep(SAA7146_I2C_DELAY);
/* the data sheet says it might be necessary to clear the status /* the data sheet says it might be necessary to clear the status
twice after an abort */ twice after an abort */
saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate); saa7146_write(dev, I2C_STATUS, dev->i2c_bitrate);
saa7146_write(dev, MC2, (MASK_00 | MASK_16)); saa7146_write(dev, MC2, (MASK_00 | MASK_16));
my_wait(dev,SAA7146_I2C_DELAY); msleep(SAA7146_I2C_DELAY);
} }
/* if any error is still present, a fatal error has occured ... */ /* if any error is still present, a fatal error has occured ... */
...@@ -243,7 +236,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d ...@@ -243,7 +236,7 @@ static int saa7146_i2c_writeout(struct saa7146_dev *dev, u32* dword, int short_d
if ((++trial < 20) && short_delay) if ((++trial < 20) && short_delay)
udelay(10); udelay(10);
else else
my_wait(dev,1); msleep(1);
} }
} }
...@@ -345,7 +338,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i ...@@ -345,7 +338,7 @@ int saa7146_i2c_transfer(struct saa7146_dev *dev, const struct i2c_msg msgs[], i
} }
/* delay a bit before retrying */ /* delay a bit before retrying */
my_wait(dev, 10); msleep(10);
} while (err != num && retries--); } while (err != num && retries--);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment