Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 330978
b: refs/heads/master
c: af3a07a
h: refs/heads/master
v: v3
  • Loading branch information
Antti Palosaari authored and Mauro Carvalho Chehab committed Sep 15, 2012
1 parent 6322de0 commit 0ef681b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 70cf058aa900394abba126d5950712e5c107768f
refs/heads/master: af3a07ac70142f3c30c4fb23c7d3ec4c0e773cce
24 changes: 11 additions & 13 deletions trunk/drivers/media/tuners/tda18218.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
/* write multiple registers */
static int tda18218_wr_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
{
int ret = 0;
u8 buf[1+len], quotient, remainder, i, msg_len, msg_len_max;
int ret = 0, len2, remaining;
u8 buf[1 + len];
struct i2c_msg msg[1] = {
{
.addr = priv->cfg->i2c_address,
Expand All @@ -38,17 +38,15 @@ static int tda18218_wr_regs(struct tda18218_priv *priv, u8 reg, u8 *val, u8 len)
}
};

msg_len_max = priv->cfg->i2c_wr_max - 1;
quotient = len / msg_len_max;
remainder = len % msg_len_max;
msg_len = msg_len_max;
for (i = 0; (i <= quotient && remainder); i++) {
if (i == quotient) /* set len of the last msg */
msg_len = remainder;

msg[0].len = msg_len + 1;
buf[0] = reg + i * msg_len_max;
memcpy(&buf[1], &val[i * msg_len_max], msg_len);
for (remaining = len; remaining > 0;
remaining -= (priv->cfg->i2c_wr_max - 1)) {
len2 = remaining;
if (len2 > (priv->cfg->i2c_wr_max - 1))
len2 = (priv->cfg->i2c_wr_max - 1);

msg[0].len = 1 + len2;
buf[0] = reg + len - remaining;
memcpy(&buf[1], &val[len - remaining], len2);

ret = i2c_transfer(priv->i2c, msg, 1);
if (ret != 1)
Expand Down

0 comments on commit 0ef681b

Please sign in to comment.