From: Antti Palosaari Date: Mon, 2 Dec 2013 17:08:53 +0000 (-0300) Subject: [media] m88ds3103: I/O optimize inittab write X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=06487dee53ae1574fb9637a4c243287ea92ab69d;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [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 Signed-off-by: Mauro Carvalho Chehab --- 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 */