summaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb-frontends/cxd2820r_c.c
diff options
context:
space:
mode:
authorAntti Palosaari <crope@iki.fi>2016-08-13 13:19:05 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-09-22 10:43:09 -0300
commit43e2ea63eb9781bc980cbcb954d26fec8ad108e6 (patch)
tree5cfac601c0fa6525e758cbd2459e3491e98f6fb9 /drivers/media/dvb-frontends/cxd2820r_c.c
parentd51dc917616c6c52daeeea3f93418f48f484ade5 (diff)
downloadlinux-43e2ea63eb9781bc980cbcb954d26fec8ad108e6.tar.bz2
[media] cxd2820r: convert to regmap api
Use regmap for I2C register access. Signed-off-by: Antti Palosaari <crope@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-frontends/cxd2820r_c.c')
-rw-r--r--drivers/media/dvb-frontends/cxd2820r_c.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/drivers/media/dvb-frontends/cxd2820r_c.c b/drivers/media/dvb-frontends/cxd2820r_c.c
index 0f96add3e69a..d75b0776d5b5 100644
--- a/drivers/media/dvb-frontends/cxd2820r_c.c
+++ b/drivers/media/dvb-frontends/cxd2820r_c.c
@@ -26,7 +26,7 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
struct cxd2820r_priv *priv = fe->demodulator_priv;
struct i2c_client *client = priv->client[0];
struct dtv_frontend_properties *c = &fe->dtv_property_cache;
- int ret, i;
+ int ret;
unsigned int utmp;
u8 buf[2];
u32 if_frequency;
@@ -58,12 +58,9 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
fe->ops.tuner_ops.set_params(fe);
if (priv->delivery_system != SYS_DVBC_ANNEX_A) {
- for (i = 0; i < ARRAY_SIZE(tab); i++) {
- ret = cxd2820r_wr_reg_mask(priv, tab[i].reg,
- tab[i].val, tab[i].mask);
- if (ret)
- goto error;
- }
+ ret = cxd2820r_wr_reg_val_mask_tab(priv, tab, ARRAY_SIZE(tab));
+ if (ret)
+ goto error;
}
priv->delivery_system = SYS_DVBC_ANNEX_A;
@@ -83,15 +80,15 @@ int cxd2820r_set_frontend_c(struct dvb_frontend *fe)
utmp = 0x4000 - DIV_ROUND_CLOSEST_ULL((u64)if_frequency * 0x4000, CXD2820R_CLK);
buf[0] = (utmp >> 8) & 0xff;
buf[1] = (utmp >> 0) & 0xff;
- ret = cxd2820r_wr_regs(priv, 0x10042, buf, 2);
+ ret = regmap_bulk_write(priv->regmap[1], 0x0042, buf, 2);
if (ret)
goto error;
- ret = cxd2820r_wr_reg(priv, 0x000ff, 0x08);
+ ret = regmap_write(priv->regmap[0], 0x00ff, 0x08);
if (ret)
goto error;
- ret = cxd2820r_wr_reg(priv, 0x000fe, 0x01);
+ ret = regmap_write(priv->regmap[0], 0x00fe, 0x01);
if (ret)
goto error;
@@ -107,21 +104,22 @@ int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
struct cxd2820r_priv *priv = fe->demodulator_priv;
struct i2c_client *client = priv->client[0];
int ret;
+ unsigned int utmp;
u8 buf[2];
dev_dbg(&client->dev, "\n");
- ret = cxd2820r_rd_regs(priv, 0x1001a, buf, 2);
+ ret = regmap_bulk_read(priv->regmap[1], 0x001a, buf, 2);
if (ret)
goto error;
c->symbol_rate = 2500 * ((buf[0] & 0x0f) << 8 | buf[1]);
- ret = cxd2820r_rd_reg(priv, 0x10019, &buf[0]);
+ ret = regmap_read(priv->regmap[1], 0x0019, &utmp);
if (ret)
goto error;
- switch ((buf[0] >> 0) & 0x07) {
+ switch ((utmp >> 0) & 0x07) {
case 0:
c->modulation = QAM_16;
break;
@@ -139,7 +137,7 @@ int cxd2820r_get_frontend_c(struct dvb_frontend *fe,
break;
}
- switch ((buf[0] >> 7) & 0x01) {
+ switch ((utmp >> 7) & 0x01) {
case 0:
c->inversion = INVERSION_OFF;
break;
@@ -164,10 +162,10 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
u8 buf[3];
/* Lock detection */
- ret = cxd2820r_rd_reg(priv, 0x10088, &buf[0]);
+ ret = regmap_bulk_read(priv->regmap[1], 0x0088, &buf[0], 1);
if (ret)
goto error;
- ret = cxd2820r_rd_reg(priv, 0x10073, &buf[1]);
+ ret = regmap_bulk_read(priv->regmap[1], 0x0073, &buf[1], 1);
if (ret)
goto error;
@@ -191,7 +189,7 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
if (*status & FE_HAS_SIGNAL) {
unsigned int strength;
- ret = cxd2820r_rd_regs(priv, 0x10049, buf, 2);
+ ret = regmap_bulk_read(priv->regmap[1], 0x0049, buf, 2);
if (ret)
goto error;
@@ -212,11 +210,11 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
if (*status & FE_HAS_VITERBI) {
unsigned int cnr, const_a, const_b;
- ret = cxd2820r_rd_reg(priv, 0x10019, &buf[0]);
+ ret = regmap_read(priv->regmap[1], 0x0019, &utmp);
if (ret)
goto error;
- if (((buf[0] >> 0) & 0x03) % 2) {
+ if (((utmp >> 0) & 0x03) % 2) {
const_a = 8750;
const_b = 650;
} else {
@@ -224,11 +222,10 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
const_b = 760;
}
- ret = cxd2820r_rd_reg(priv, 0x1004d, &buf[0]);
+ ret = regmap_read(priv->regmap[1], 0x004d, &utmp);
if (ret)
goto error;
- utmp = buf[0] << 0;
#define CXD2820R_LOG2_E_24 24204406 /* log2(e) << 24 */
if (utmp)
cnr = div_u64((u64)(intlog2(const_b) - intlog2(utmp))
@@ -250,7 +247,7 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
bool start_ber;
if (priv->ber_running) {
- ret = cxd2820r_rd_regs(priv, 0x10076, buf, 3);
+ ret = regmap_bulk_read(priv->regmap[1], 0x0076, buf, 3);
if (ret)
goto error;
@@ -269,7 +266,7 @@ int cxd2820r_read_status_c(struct dvb_frontend *fe, enum fe_status *status)
}
if (start_ber) {
- ret = cxd2820r_wr_reg(priv, 0x10079, 0x01);
+ ret = regmap_write(priv->regmap[1], 0x0079, 0x01);
if (ret)
goto error;
priv->ber_running = true;
@@ -299,7 +296,7 @@ int cxd2820r_init_c(struct dvb_frontend *fe)
dev_dbg(&client->dev, "\n");
- ret = cxd2820r_wr_reg(priv, 0x00085, 0x07);
+ ret = regmap_write(priv->regmap[0], 0x0085, 0x07);
if (ret)
goto error;
@@ -313,7 +310,7 @@ int cxd2820r_sleep_c(struct dvb_frontend *fe)
{
struct cxd2820r_priv *priv = fe->demodulator_priv;
struct i2c_client *client = priv->client[0];
- int ret, i;
+ int ret;
struct reg_val_mask tab[] = {
{ 0x000ff, 0x1f, 0xff },
{ 0x00085, 0x00, 0xff },
@@ -326,12 +323,9 @@ int cxd2820r_sleep_c(struct dvb_frontend *fe)
priv->delivery_system = SYS_UNDEFINED;
- for (i = 0; i < ARRAY_SIZE(tab); i++) {
- ret = cxd2820r_wr_reg_mask(priv, tab[i].reg, tab[i].val,
- tab[i].mask);
- if (ret)
- goto error;
- }
+ ret = cxd2820r_wr_reg_val_mask_tab(priv, tab, ARRAY_SIZE(tab));
+ if (ret)
+ goto error;
return ret;
error: