aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Regel <andreas.regel@gmx.de>2010-01-05 17:22:45 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-02-26 13:10:36 -0500
commit0c3f9fd807d9ef842fcc7e47e447ed2c68d63e49 (patch)
tree3ad1ed4d7eddf1c9a4ebdd849307f2908c296d12
parentf91e59cb5e6add13d4e45c5cc8d45a614e1dc8e4 (diff)
V4L/DVB (13980): [STV6110x] Added function stv6110x_write_regs
The function stv6110x_write_regs is used to write several registers at once. Signed-off-by: Andreas Regel <andreas.regel@gmx.de> Signed-off-by: Manu Abraham <manu@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/dvb/frontends/stv6110x.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/drivers/media/dvb/frontends/stv6110x.c b/drivers/media/dvb/frontends/stv6110x.c
index bcfcb652464c..09e3aef8073b 100644
--- a/drivers/media/dvb/frontends/stv6110x.c
+++ b/drivers/media/dvb/frontends/stv6110x.c
@@ -58,12 +58,23 @@ static int stv6110x_read_reg(struct stv6110x_state *stv6110x, u8 reg, u8 *data)
58 return 0; 58 return 0;
59} 59}
60 60
61static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data) 61static int stv6110x_write_regs(struct stv6110x_state *stv6110x, int start, u8 data[], int len)
62{ 62{
63 int ret; 63 int ret;
64 const struct stv6110x_config *config = stv6110x->config; 64 const struct stv6110x_config *config = stv6110x->config;
65 u8 buf[] = { reg, data }; 65 u8 buf[len + 1];
66 struct i2c_msg msg = { .addr = config->addr, .flags = 0, . buf = buf, .len = 2 }; 66 struct i2c_msg msg = {
67 .addr = config->addr,
68 .flags = 0,
69 .buf = buf,
70 .len = len + 1
71 };
72
73 if (start + len > 8)
74 return -EINVAL;
75
76 buf[0] = start;
77 memcpy(&buf[1], data, len);
67 78
68 ret = i2c_transfer(stv6110x->i2c, &msg, 1); 79 ret = i2c_transfer(stv6110x->i2c, &msg, 1);
69 if (ret != 1) { 80 if (ret != 1) {
@@ -74,18 +85,21 @@ static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data)
74 return 0; 85 return 0;
75} 86}
76 87
88static int stv6110x_write_reg(struct stv6110x_state *stv6110x, u8 reg, u8 data)
89{
90 return stv6110x_write_regs(stv6110x, reg, &data, 1);
91}
92
77static int stv6110x_init(struct dvb_frontend *fe) 93static int stv6110x_init(struct dvb_frontend *fe)
78{ 94{
79 struct stv6110x_state *stv6110x = fe->tuner_priv; 95 struct stv6110x_state *stv6110x = fe->tuner_priv;
80 int ret; 96 int ret;
81 u8 i;
82 97
83 for (i = 0; i < ARRAY_SIZE(stv6110x_regs); i++) { 98 ret = stv6110x_write_regs(stv6110x, 0, stv6110x_regs,
84 ret = stv6110x_write_reg(stv6110x, i, stv6110x_regs[i]); 99 ARRAY_SIZE(stv6110x_regs));
85 if (ret < 0) { 100 if (ret < 0) {
86 dprintk(FE_ERROR, 1, "Initialization failed"); 101 dprintk(FE_ERROR, 1, "Initialization failed");
87 return -1; 102 return -1;
88 }
89 } 103 }
90 104
91 return 0; 105 return 0;