summaryrefslogtreecommitdiff
path: root/drivers/media/dvb-frontends/m88ds3103.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2013-12-02 21:08:53 +0400
committerMauro Carvalho Chehab <m.chehab@samsung.com>2013-12-19 15:23:04 +0400
commit06487dee53ae1574fb9637a4c243287ea92ab69d (patch)
tree48f9136de25e89329966fe7cd805f67736c3c1ea /drivers/media/dvb-frontends/m88ds3103.c
parentdcaf0fbfd2fa5a36e6e1150576f7a8c3efc43f92 (diff)
downloadlinux-06487dee53ae1574fb9637a4c243287ea92ab69d.tar.xz
[media] m88ds3103: I/O optimize inittab write
Write inittab using reg address auto-increment in order to reduce I/O a little bit. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/dvb-frontends/m88ds3103.c')
-rw-r--r--drivers/media/dvb-frontends/m88ds3103.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c
index f9d896767887..76bd85aa8f4e 100644
--- a/drivers/media/dvb-frontends/m88ds3103.c
+++ b/drivers/media/dvb-frontends/m88ds3103.c
@@ -157,6 +157,38 @@ static int m88ds3103_rd_reg_mask(struct m88ds3103_priv *priv,
return 0;
}
+/* write reg val table using reg addr auto increment */
+static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv,
+ const struct m88ds3103_reg_val *tab, int tab_len)
+{
+ int ret, i, j;
+ u8 buf[83];
+ dev_dbg(&priv->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len);
+
+ if (tab_len > 83) {
+ ret = -EINVAL;
+ goto err;
+ }
+
+ for (i = 0, j = 0; i < tab_len; i++, j++) {
+ buf[j] = tab[i].val;
+
+ if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1 ||
+ !((j + 1) % (priv->cfg->i2c_wr_max - 1))) {
+ ret = m88ds3103_wr_regs(priv, tab[i].reg - j, buf, j + 1);
+ if (ret)
+ goto err;
+
+ j = -1;
+ }
+ }
+
+ return 0;
+err:
+ dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret);
+ return ret;
+}
+
static int m88ds3103_read_status(struct dvb_frontend *fe, fe_status_t *status)
{
struct m88ds3103_priv *priv = fe->demodulator_priv;
@@ -214,7 +246,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
{
struct m88ds3103_priv *priv = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
- int ret, i, len;
+ int ret, len;
const struct m88ds3103_reg_val *init;
u8 u8tmp, u8tmp1, u8tmp2;
u8 buf[2];
@@ -308,12 +340,9 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe)
/* program init table */
if (c->delivery_system != priv->delivery_system) {
- dev_dbg(&priv->i2c->dev, "%s: program init\n", __func__);
- for (i = 0; i < len; i++) {
- ret = m88ds3103_wr_reg(priv, init[i].reg, init[i].val);
- if (ret)
- goto err;
- }
+ ret = m88ds3103_wr_reg_val_tab(priv, init, len);
+ if (ret)
+ goto err;
}
u8tmp1 = 0; /* silence compiler warning */