[media] si2165: create function si2165_write_reg_list for writing register lists
authorMatthias Schwarzott <zzam@gentoo.org>
Thu, 19 Nov 2015 20:03:55 +0000 (18:03 -0200)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Thu, 3 Dec 2015 14:03:23 +0000 (12:03 -0200)
It is common the need of writing a table of values. Add a function to provide a
helper to address such case. This will allow further code cleanups.

Signed-off-by: Matthias Schwarzott <zzam@gentoo.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/si2165.c

index a0e4600bf36f2cae81118e763f199d1cd88c9f62..222d7750f98d17e364d3ecd5b573cc15c0369fbc 100644 (file)
@@ -243,6 +243,27 @@ err:
        return ret;
 }
 
+#define REG16(reg, val) { (reg), (val) & 0xff }, { (reg)+1, (val)>>8 & 0xff }
+struct si2165_reg_value_pair {
+       u16 reg;
+       u8 val;
+};
+
+static int si2165_write_reg_list(struct si2165_state *state,
+                                const struct si2165_reg_value_pair *regs,
+                                int count)
+{
+       int i;
+       int ret;
+
+       for (i = 0; i < count; i++) {
+               ret = si2165_writereg8(state, regs[i].reg, regs[i].val);
+               if (ret < 0)
+                       return ret;
+       }
+       return 0;
+}
+
 static int si2165_get_tune_settings(struct dvb_frontend *fe,
                                    struct dvb_frontend_tune_settings *s)
 {
This page took 0.0264 seconds and 5 git commands to generate.