diff options
author | Antti Palosaari <crope@iki.fi> | 2015-04-16 21:36:00 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2015-06-10 11:05:58 -0300 |
commit | 7978b8a1bc8ae0f2aea1e4f36ef7642a1b86b9c6 (patch) | |
tree | 637a539a29f4478b0da8397cb41dc9edf20c61c7 /drivers/media | |
parent | 80868c8e5c04bb725e411b078881b65ebbecd142 (diff) |
[media] m88ds3103: rename variables and correct logging
Rename driver state from priv to dev.
Use I2C client for correct logging.
Use adapter and address from I2C client structure where needed.
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb-frontends/Kconfig | 2 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/m88ds3103.c | 538 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/m88ds3103.h | 2 | ||||
-rw-r--r-- | drivers/media/dvb-frontends/m88ds3103_priv.h | 5 |
4 files changed, 267 insertions, 280 deletions
diff --git a/drivers/media/dvb-frontends/Kconfig b/drivers/media/dvb-frontends/Kconfig index ba65a001ba25..b7627caba1e7 100644 --- a/drivers/media/dvb-frontends/Kconfig +++ b/drivers/media/dvb-frontends/Kconfig @@ -36,7 +36,7 @@ config DVB_STV6110x A Silicon tuner that supports DVB-S and DVB-S2 modes config DVB_M88DS3103 - tristate "Montage M88DS3103" + tristate "Montage Technology M88DS3103" depends on DVB_CORE && I2C && I2C_MUX default m if !MEDIA_SUBDRV_AUTOSELECT help diff --git a/drivers/media/dvb-frontends/m88ds3103.c b/drivers/media/dvb-frontends/m88ds3103.c index c24b15238a8e..c4acf7754a74 100644 --- a/drivers/media/dvb-frontends/m88ds3103.c +++ b/drivers/media/dvb-frontends/m88ds3103.c @@ -1,5 +1,5 @@ /* - * Montage M88DS3103/M88RS6000 demodulator driver + * Montage Technology M88DS3103/M88RS6000 demodulator driver * * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> * @@ -19,16 +19,17 @@ static struct dvb_frontend_ops m88ds3103_ops; /* write multiple registers */ -static int m88ds3103_wr_regs(struct m88ds3103_priv *priv, +static int m88ds3103_wr_regs(struct m88ds3103_dev *dev, u8 reg, const u8 *val, int len) { #define MAX_WR_LEN 32 #define MAX_WR_XFER_LEN (MAX_WR_LEN + 1) + struct i2c_client *client = dev->client; int ret; u8 buf[MAX_WR_XFER_LEN]; struct i2c_msg msg[1] = { { - .addr = priv->cfg->i2c_addr, + .addr = client->addr, .flags = 0, .len = 1 + len, .buf = buf, @@ -41,15 +42,14 @@ static int m88ds3103_wr_regs(struct m88ds3103_priv *priv, buf[0] = reg; memcpy(&buf[1], val, len); - mutex_lock(&priv->i2c_mutex); - ret = i2c_transfer(priv->i2c, msg, 1); - mutex_unlock(&priv->i2c_mutex); + mutex_lock(&dev->i2c_mutex); + ret = i2c_transfer(client->adapter, msg, 1); + mutex_unlock(&dev->i2c_mutex); if (ret == 1) { ret = 0; } else { - dev_warn(&priv->i2c->dev, - "%s: i2c wr failed=%d reg=%02x len=%d\n", - KBUILD_MODNAME, ret, reg, len); + dev_warn(&client->dev, "i2c wr failed=%d reg=%02x len=%d\n", + ret, reg, len); ret = -EREMOTEIO; } @@ -57,21 +57,22 @@ static int m88ds3103_wr_regs(struct m88ds3103_priv *priv, } /* read multiple registers */ -static int m88ds3103_rd_regs(struct m88ds3103_priv *priv, +static int m88ds3103_rd_regs(struct m88ds3103_dev *dev, u8 reg, u8 *val, int len) { #define MAX_RD_LEN 3 #define MAX_RD_XFER_LEN (MAX_RD_LEN) + struct i2c_client *client = dev->client; int ret; u8 buf[MAX_RD_XFER_LEN]; struct i2c_msg msg[2] = { { - .addr = priv->cfg->i2c_addr, + .addr = client->addr, .flags = 0, .len = 1, .buf = ®, }, { - .addr = priv->cfg->i2c_addr, + .addr = client->addr, .flags = I2C_M_RD, .len = len, .buf = buf, @@ -81,16 +82,15 @@ static int m88ds3103_rd_regs(struct m88ds3103_priv *priv, if (WARN_ON(len > MAX_RD_LEN)) return -EINVAL; - mutex_lock(&priv->i2c_mutex); - ret = i2c_transfer(priv->i2c, msg, 2); - mutex_unlock(&priv->i2c_mutex); + mutex_lock(&dev->i2c_mutex); + ret = i2c_transfer(client->adapter, msg, 2); + mutex_unlock(&dev->i2c_mutex); if (ret == 2) { memcpy(val, buf, len); ret = 0; } else { - dev_warn(&priv->i2c->dev, - "%s: i2c rd failed=%d reg=%02x len=%d\n", - KBUILD_MODNAME, ret, reg, len); + dev_warn(&client->dev, "i2c rd failed=%d reg=%02x len=%d\n", + ret, reg, len); ret = -EREMOTEIO; } @@ -98,19 +98,19 @@ static int m88ds3103_rd_regs(struct m88ds3103_priv *priv, } /* write single register */ -static int m88ds3103_wr_reg(struct m88ds3103_priv *priv, u8 reg, u8 val) +static int m88ds3103_wr_reg(struct m88ds3103_dev *dev, u8 reg, u8 val) { - return m88ds3103_wr_regs(priv, reg, &val, 1); + return m88ds3103_wr_regs(dev, reg, &val, 1); } /* read single register */ -static int m88ds3103_rd_reg(struct m88ds3103_priv *priv, u8 reg, u8 *val) +static int m88ds3103_rd_reg(struct m88ds3103_dev *dev, u8 reg, u8 *val) { - return m88ds3103_rd_regs(priv, reg, val, 1); + return m88ds3103_rd_regs(dev, reg, val, 1); } /* write single register with mask */ -static int m88ds3103_wr_reg_mask(struct m88ds3103_priv *priv, +static int m88ds3103_wr_reg_mask(struct m88ds3103_dev *dev, u8 reg, u8 val, u8 mask) { int ret; @@ -118,7 +118,7 @@ static int m88ds3103_wr_reg_mask(struct m88ds3103_priv *priv, /* no need for read if whole reg is written */ if (mask != 0xff) { - ret = m88ds3103_rd_regs(priv, reg, &u8tmp, 1); + ret = m88ds3103_rd_regs(dev, reg, &u8tmp, 1); if (ret) return ret; @@ -127,17 +127,17 @@ static int m88ds3103_wr_reg_mask(struct m88ds3103_priv *priv, val |= u8tmp; } - return m88ds3103_wr_regs(priv, reg, &val, 1); + return m88ds3103_wr_regs(dev, reg, &val, 1); } /* read single register with mask */ -static int m88ds3103_rd_reg_mask(struct m88ds3103_priv *priv, +static int m88ds3103_rd_reg_mask(struct m88ds3103_dev *dev, u8 reg, u8 *val, u8 mask) { int ret, i; u8 u8tmp; - ret = m88ds3103_rd_regs(priv, reg, &u8tmp, 1); + ret = m88ds3103_rd_regs(dev, reg, &u8tmp, 1); if (ret) return ret; @@ -154,13 +154,14 @@ static int m88ds3103_rd_reg_mask(struct m88ds3103_priv *priv, } /* write reg val table using reg addr auto increment */ -static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv, +static int m88ds3103_wr_reg_val_tab(struct m88ds3103_dev *dev, const struct m88ds3103_reg_val *tab, int tab_len) { + struct i2c_client *client = dev->client; int ret, i, j; u8 buf[83]; - dev_dbg(&priv->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len); + dev_dbg(&client->dev, "tab_len=%d\n", tab_len); if (tab_len > 86) { ret = -EINVAL; @@ -171,8 +172,8 @@ static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv, 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); + !((j + 1) % (dev->cfg->i2c_wr_max - 1))) { + ret = m88ds3103_wr_regs(dev, tab[i].reg - j, buf, j + 1); if (ret) goto err; @@ -182,14 +183,15 @@ static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv, return 0; err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } static int m88ds3103_read_status(struct dvb_frontend *fe, enum fe_status *status) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; + struct i2c_client *client = dev->client; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret, i, itmp; u8 u8tmp; @@ -197,14 +199,14 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, *status = 0; - if (!priv->warm) { + if (!dev->warm) { ret = -EAGAIN; goto err; } switch (c->delivery_system) { case SYS_DVBS: - ret = m88ds3103_rd_reg_mask(priv, 0xd1, &u8tmp, 0x07); + ret = m88ds3103_rd_reg_mask(dev, 0xd1, &u8tmp, 0x07); if (ret) goto err; @@ -214,7 +216,7 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, FE_HAS_LOCK; break; case SYS_DVBS2: - ret = m88ds3103_rd_reg_mask(priv, 0x0d, &u8tmp, 0x8f); + ret = m88ds3103_rd_reg_mask(dev, 0x0d, &u8tmp, 0x8f); if (ret) goto err; @@ -224,19 +226,17 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, FE_HAS_LOCK; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", - __func__); + dev_dbg(&client->dev, "invalid delivery_system\n"); ret = -EINVAL; goto err; } - priv->fe_status = *status; + dev->fe_status = *status; - dev_dbg(&priv->i2c->dev, "%s: lock=%02x status=%02x\n", - __func__, u8tmp, *status); + dev_dbg(&client->dev, "lock=%02x status=%02x\n", u8tmp, *status); /* CNR */ - if (priv->fe_status & FE_HAS_VITERBI) { + if (dev->fe_status & FE_HAS_VITERBI) { unsigned int cnr, noise, signal, noise_tot, signal_tot; cnr = 0; @@ -248,7 +248,7 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, itmp = 0; for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { - ret = m88ds3103_rd_reg(priv, 0xff, &buf[0]); + ret = m88ds3103_rd_reg(dev, 0xff, &buf[0]); if (ret) goto err; @@ -266,7 +266,7 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, signal_tot = 0; for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { - ret = m88ds3103_rd_regs(priv, 0x8c, buf, 3); + ret = m88ds3103_rd_regs(dev, 0x8c, buf, 3); if (ret) goto err; @@ -290,8 +290,7 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, } break; default: - dev_dbg(&priv->i2c->dev, - "%s: invalid delivery_system\n", __func__); + dev_dbg(&client->dev, "invalid delivery_system\n"); ret = -EINVAL; goto err; } @@ -307,40 +306,40 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, } /* BER */ - if (priv->fe_status & FE_HAS_LOCK) { + if (dev->fe_status & FE_HAS_LOCK) { unsigned int utmp, post_bit_error, post_bit_count; switch (c->delivery_system) { case SYS_DVBS: - ret = m88ds3103_wr_reg(priv, 0xf9, 0x04); + ret = m88ds3103_wr_reg(dev, 0xf9, 0x04); if (ret) goto err; - ret = m88ds3103_rd_reg(priv, 0xf8, &u8tmp); + ret = m88ds3103_rd_reg(dev, 0xf8, &u8tmp); if (ret) goto err; /* measurement ready? */ if (!(u8tmp & 0x10)) { - ret = m88ds3103_rd_regs(priv, 0xf6, buf, 2); + ret = m88ds3103_rd_regs(dev, 0xf6, buf, 2); if (ret) goto err; post_bit_error = buf[1] << 8 | buf[0] << 0; post_bit_count = 0x800000; - priv->post_bit_error += post_bit_error; - priv->post_bit_count += post_bit_count; - priv->dvbv3_ber = post_bit_error; + dev->post_bit_error += post_bit_error; + dev->post_bit_count += post_bit_count; + dev->dvbv3_ber = post_bit_error; /* restart measurement */ u8tmp |= 0x10; - ret = m88ds3103_wr_reg(priv, 0xf8, u8tmp); + ret = m88ds3103_wr_reg(dev, 0xf8, u8tmp); if (ret) goto err; } break; case SYS_DVBS2: - ret = m88ds3103_rd_regs(priv, 0xd5, buf, 3); + ret = m88ds3103_rd_regs(dev, 0xd5, buf, 3); if (ret) goto err; @@ -348,45 +347,44 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, /* enough data? */ if (utmp > 4000) { - ret = m88ds3103_rd_regs(priv, 0xf7, buf, 2); + ret = m88ds3103_rd_regs(dev, 0xf7, buf, 2); if (ret) goto err; post_bit_error = buf[1] << 8 | buf[0] << 0; post_bit_count = 32 * utmp; /* TODO: FEC */ - priv->post_bit_error += post_bit_error; - priv->post_bit_count += post_bit_count; - priv->dvbv3_ber = post_bit_error; + dev->post_bit_error += post_bit_error; + dev->post_bit_count += post_bit_count; + dev->dvbv3_ber = post_bit_error; /* restart measurement */ - ret = m88ds3103_wr_reg(priv, 0xd1, 0x01); + ret = m88ds3103_wr_reg(dev, 0xd1, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xf9, 0x01); + ret = m88ds3103_wr_reg(dev, 0xf9, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xf9, 0x00); + ret = m88ds3103_wr_reg(dev, 0xf9, 0x00); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xd1, 0x00); + ret = m88ds3103_wr_reg(dev, 0xd1, 0x00); if (ret) goto err; } break; default: - dev_dbg(&priv->i2c->dev, - "%s: invalid delivery_system\n", __func__); + dev_dbg(&client->dev, "invalid delivery_system\n"); ret = -EINVAL; goto err; } c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; - c->post_bit_error.stat[0].uvalue = priv->post_bit_error; + c->post_bit_error.stat[0].uvalue = dev->post_bit_error; c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; - c->post_bit_count.stat[0].uvalue = priv->post_bit_count; + c->post_bit_count.stat[0].uvalue = dev->post_bit_count; } else { c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; @@ -394,13 +392,14 @@ static int m88ds3103_read_status(struct dvb_frontend *fe, return 0; err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } static int m88ds3103_set_frontend(struct dvb_frontend *fe) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; + struct i2c_client *client = dev->client; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret, len; const struct m88ds3103_reg_val *init; @@ -410,29 +409,28 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) u32 tuner_frequency, target_mclk; s32 s32tmp; - dev_dbg(&priv->i2c->dev, - "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", - __func__, c->delivery_system, - c->modulation, c->frequency, c->symbol_rate, - c->inversion, c->pilot, c->rolloff); + dev_dbg(&client->dev, + "delivery_system=%d modulation=%d frequency=%u symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", + c->delivery_system, c->modulation, c->frequency, c->symbol_rate, + c->inversion, c->pilot, c->rolloff); - if (!priv->warm) { + if (!dev->warm) { ret = -EAGAIN; goto err; } /* reset */ - ret = m88ds3103_wr_reg(priv, 0x07, 0x80); + ret = m88ds3103_wr_reg(dev, 0x07, 0x80); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0x07, 0x00); + ret = m88ds3103_wr_reg(dev, 0x07, 0x00); if (ret) goto err; /* Disable demod clock path */ - if (priv->chip_id == M88RS6000_CHIP_ID) { - ret = m88ds3103_wr_reg(priv, 0x06, 0xe0); + if (dev->chip_id == M88RS6000_CHIP_ID) { + ret = m88ds3103_wr_reg(dev, 0x06, 0xe0); if (ret) goto err; } @@ -458,11 +456,11 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) } /* select M88RS6000 demod main mclk and ts mclk from tuner die. */ - if (priv->chip_id == M88RS6000_CHIP_ID) { + if (dev->chip_id == M88RS6000_CHIP_ID) { if (c->symbol_rate > 45010000) - priv->mclk_khz = 110250; + dev->mclk_khz = 110250; else - priv->mclk_khz = 96000; + dev->mclk_khz = 96000; if (c->delivery_system == SYS_DVBS) target_mclk = 96000; @@ -470,18 +468,18 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) target_mclk = 144000; /* Enable demod clock path */ - ret = m88ds3103_wr_reg(priv, 0x06, 0x00); + ret = m88ds3103_wr_reg(dev, 0x06, 0x00); if (ret) goto err; usleep_range(10000, 20000); } else { /* set M88DS3103 mclk and ts mclk. */ - priv->mclk_khz = 96000; + dev->mclk_khz = 96000; - switch (priv->cfg->ts_mode) { + switch (dev->cfg->ts_mode) { case M88DS3103_TS_SERIAL: case M88DS3103_TS_SERIAL_D7: - target_mclk = priv->cfg->ts_clk; + target_mclk = dev->cfg->ts_clk; break; case M88DS3103_TS_PARALLEL: case M88DS3103_TS_CI: @@ -497,8 +495,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) } break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", - __func__); + dev_dbg(&client->dev, "invalid ts_mode\n"); ret = -EINVAL; goto err; } @@ -517,25 +514,25 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) u8tmp2 = 0x00; /* 0b00 */ break; } - ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); + ret = m88ds3103_wr_reg_mask(dev, 0x22, u8tmp1 << 6, 0xc0); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x24, u8tmp2 << 6, 0xc0); + ret = m88ds3103_wr_reg_mask(dev, 0x24, u8tmp2 << 6, 0xc0); if (ret) goto err; } - ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); + ret = m88ds3103_wr_reg(dev, 0xb2, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0x00, 0x01); + ret = m88ds3103_wr_reg(dev, 0x00, 0x01); if (ret) goto err; switch (c->delivery_system) { case SYS_DVBS: - if (priv->chip_id == M88RS6000_CHIP_ID) { + if (dev->chip_id == M88RS6000_CHIP_ID) { len = ARRAY_SIZE(m88rs6000_dvbs_init_reg_vals); init = m88rs6000_dvbs_init_reg_vals; } else { @@ -544,7 +541,7 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) } break; case SYS_DVBS2: - if (priv->chip_id == M88RS6000_CHIP_ID) { + if (dev->chip_id == M88RS6000_CHIP_ID) { len = ARRAY_SIZE(m88rs6000_dvbs2_init_reg_vals); init = m88rs6000_dvbs2_init_reg_vals; } else { @@ -553,44 +550,43 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) } break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", - __func__); + dev_dbg(&client->dev, "invalid delivery_system\n"); ret = -EINVAL; goto err; } /* program init table */ - if (c->delivery_system != priv->delivery_system) { - ret = m88ds3103_wr_reg_val_tab(priv, init, len); + if (c->delivery_system != dev->delivery_system) { + ret = m88ds3103_wr_reg_val_tab(dev, init, len); if (ret) goto err; } - if (priv->chip_id == M88RS6000_CHIP_ID) { + if (dev->chip_id == M88RS6000_CHIP_ID) { if ((c->delivery_system == SYS_DVBS2) && ((c->symbol_rate / 1000) <= 5000)) { - ret = m88ds3103_wr_reg(priv, 0xc0, 0x04); + ret = m88ds3103_wr_reg(dev, 0xc0, 0x04); if (ret) goto err; buf[0] = 0x09; buf[1] = 0x22; buf[2] = 0x88; - ret = m88ds3103_wr_regs(priv, 0x8a, buf, 3); + ret = m88ds3103_wr_regs(dev, 0x8a, buf, 3); if (ret) goto err; } - ret = m88ds3103_wr_reg_mask(priv, 0x9d, 0x08, 0x08); + ret = m88ds3103_wr_reg_mask(dev, 0x9d, 0x08, 0x08); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xf1, 0x01); + ret = m88ds3103_wr_reg(dev, 0xf1, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x30, 0x80, 0x80); + ret = m88ds3103_wr_reg_mask(dev, 0x30, 0x80, 0x80); if (ret) goto err; } - switch (priv->cfg->ts_mode) { + switch (dev->cfg->ts_mode) { case M88DS3103_TS_SERIAL: u8tmp1 = 0x00; u8tmp = 0x06; @@ -606,39 +602,39 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) u8tmp = 0x03; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", __func__); + dev_dbg(&client->dev, "invalid ts_mode\n"); ret = -EINVAL; goto err; } - if (priv->cfg->ts_clk_pol) + if (dev->cfg->ts_clk_pol) u8tmp |= 0x40; /* TS mode */ - ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp); + ret = m88ds3103_wr_reg(dev, 0xfd, u8tmp); if (ret) goto err; - switch (priv->cfg->ts_mode) { + switch (dev->cfg->ts_mode) { case M88DS3103_TS_SERIAL: case M88DS3103_TS_SERIAL_D7: - ret = m88ds3103_wr_reg_mask(priv, 0x29, u8tmp1, 0x20); + ret = m88ds3103_wr_reg_mask(dev, 0x29, u8tmp1, 0x20); if (ret) goto err; u8tmp1 = 0; u8tmp2 = 0; break; default: - if (priv->cfg->ts_clk) { - divide_ratio = DIV_ROUND_UP(target_mclk, priv->cfg->ts_clk); + if (dev->cfg->ts_clk) { + divide_ratio = DIV_ROUND_UP(target_mclk, dev->cfg->ts_clk); u8tmp1 = divide_ratio / 2; u8tmp2 = DIV_ROUND_UP(divide_ratio, 2); } } - dev_dbg(&priv->i2c->dev, - "%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n", - __func__, target_mclk, priv->cfg->ts_clk, divide_ratio); + dev_dbg(&client->dev, + "target_mclk=%d ts_clk=%d divide_ratio=%d\n", + target_mclk, dev->cfg->ts_clk, divide_ratio); u8tmp1--; u8tmp2--; @@ -647,17 +643,17 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) /* u8tmp2[5:0] => ea[5:0] */ u8tmp2 &= 0x3f; - ret = m88ds3103_rd_reg(priv, 0xfe, &u8tmp); + ret = m88ds3103_rd_reg(dev, 0xfe, &u8tmp); if (ret) goto err; u8tmp = ((u8tmp & 0xf0) << 0) | u8tmp1 >> 2; - ret = m88ds3103_wr_reg(priv, 0xfe, u8tmp); + ret = m88ds3103_wr_reg(dev, 0xfe, u8tmp); if (ret) goto err; u8tmp = ((u8tmp1 & 0x03) << 6) | u8tmp2 >> 0; - ret = m88ds3103_wr_reg(priv, 0xea, u8tmp); + ret = m88ds3103_wr_reg(dev, 0xea, u8tmp); if (ret) goto err; @@ -668,182 +664,181 @@ static int m88ds3103_set_frontend(struct dvb_frontend *fe) else u8tmp = 0x06; - ret = m88ds3103_wr_reg(priv, 0xc3, 0x08); + ret = m88ds3103_wr_reg(dev, 0xc3, 0x08); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xc8, u8tmp); + ret = m88ds3103_wr_reg(dev, 0xc8, u8tmp); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xc4, 0x08); + ret = m88ds3103_wr_reg(dev, 0xc4, 0x08); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xc7, 0x00); + ret = m88ds3103_wr_reg(dev, 0xc7, 0x00); if (ret) goto err; - u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, priv->mclk_khz / 2); + u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, dev->mclk_khz / 2); buf[0] = (u16tmp >> 0) & 0xff; buf[1] = (u16tmp >> 8) & 0xff; - ret = m88ds3103_wr_regs(priv, 0x61, buf, 2); + ret = m88ds3103_wr_regs(dev, 0x61, buf, 2); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x4d, priv->cfg->spec_inv << 1, 0x02); + ret = m88ds3103_wr_reg_mask(dev, 0x4d, dev->cfg->spec_inv << 1, 0x02); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x30, priv->cfg->agc_inv << 4, 0x10); + ret = m88ds3103_wr_reg_mask(dev, 0x30, dev->cfg->agc_inv << 4, 0x10); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0x33, priv->cfg->agc); + ret = m88ds3103_wr_reg(dev, 0x33, dev->cfg->agc); if (ret) goto err; - dev_dbg(&priv->i2c->dev, "%s: carrier offset=%d\n", __func__, - (tuner_frequency - c->frequency)); + dev_dbg(&client->dev, "carrier offset=%d\n", + (tuner_frequency - c->frequency)); s32tmp = 0x10000 * (tuner_frequency - c->frequency); - s32tmp = DIV_ROUND_CLOSEST(s32tmp, priv->mclk_khz); + s32tmp = DIV_ROUND_CLOSEST(s32tmp, dev->mclk_khz); if (s32tmp < 0) s32tmp += 0x10000; buf[0] = (s32tmp >> 0) & 0xff; buf[1] = (s32tmp >> 8) & 0xff; - ret = m88ds3103_wr_regs(priv, 0x5e, buf, 2); + ret = m88ds3103_wr_regs(dev, 0x5e, buf, 2); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0x00, 0x00); + ret = m88ds3103_wr_reg(dev, 0x00, 0x00); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); + ret = m88ds3103_wr_reg(dev, 0xb2, 0x00); if (ret) goto err; - priv->delivery_system = c->delivery_system; + dev->delivery_system = c->delivery_system; return 0; err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } static int m88ds3103_init(struct dvb_frontend *fe) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; + struct i2c_client *client = dev->client; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret, len, remaining; const struct firmware *fw = NULL; u8 *fw_file; u8 u8tmp; - dev_dbg(&priv->i2c->dev, "%s:\n", __func__); + dev_dbg(&client->dev, "\n"); /* set cold state by default */ - priv->warm = false; + dev->warm = false; /* wake up device from sleep */ - ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x01, 0x01); + ret = m88ds3103_wr_reg_mask(dev, 0x08, 0x01, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x00, 0x01); + ret = m88ds3103_wr_reg_mask(dev, 0x04, 0x00, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x00, 0x10); + ret = m88ds3103_wr_reg_mask(dev, 0x23, 0x00, 0x10); if (ret) goto err; /* firmware status */ - ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); + ret = m88ds3103_rd_reg(dev, 0xb9, &u8tmp); if (ret) goto err; - dev_dbg(&priv->i2c->dev, "%s: firmware=%02x\n", __func__, u8tmp); + dev_dbg(&client->dev, "firmware=%02x\n", u8tmp); if (u8tmp) goto skip_fw_download; /* global reset, global diseqc reset, golbal fec reset */ - ret = m88ds3103_wr_reg(priv, 0x07, 0xe0); + ret = m88ds3103_wr_reg(dev, 0x07, 0xe0); if (ret) goto err; - ret = m88ds3103_wr_reg(priv, 0x07, 0x00); + ret = m88ds3103_wr_reg(dev, 0x07, 0x00); if (ret) goto err; /* cold state - try to download firmware */ - dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state\n", - KBUILD_MODNAME, m88ds3103_ops.info.name); + dev_info(&client->dev, "found a '%s' in cold state\n", + m88ds3103_ops.info.name); - if (priv->chip_id == M88RS6000_CHIP_ID) + if (dev->chip_id == M88RS6000_CHIP_ID) fw_file = M88RS6000_FIRMWARE; else fw_file = M88DS3103_FIRMWARE; /* request the firmware, this will block and timeout */ - ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); + ret = request_firmware(&fw, fw_file, &client->dev); if (ret) { - dev_err(&priv->i2c->dev, "%s: firmware file '%s' not found\n", - KBUILD_MODNAME, fw_file); + dev_err(&client->dev, "firmare file '%s' not found\n", fw_file); goto err; } - dev_info(&priv->i2c->dev, "%s: downloading firmware from file '%s'\n", - KBUILD_MODNAME, fw_file); + dev_info(&client->dev, "downloading firmware from file '%s'\n", + fw_file); - ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); + ret = m88ds3103_wr_reg(dev, 0xb2, 0x01); if (ret) goto error_fw_release; for (remaining = fw->size; remaining > 0; - remaining -= (priv->cfg->i2c_wr_max - 1)) { + remaining -= (dev->cfg->i2c_wr_max - 1)) { len = remaining; - if (len > (priv->cfg->i2c_wr_max - 1)) - len = (priv->cfg->i2c_wr_max - 1); + if (len > (dev->cfg->i2c_wr_max - 1)) + len = (dev->cfg->i2c_wr_max - 1); - ret = m88ds3103_wr_regs(priv, 0xb0, + ret = m88ds3103_wr_regs(dev, 0xb0, &fw->data[fw->size - remaining], len); if (ret) { - dev_err(&priv->i2c->dev, - "%s: firmware download failed=%d\n", - KBUILD_MODNAME, ret); + dev_err(&client->dev, "firmware download failed=%d\n", + ret); goto error_fw_release; } } - ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); + ret = m88ds3103_wr_reg(dev, 0xb2, 0x00); if (ret) goto error_fw_release; release_firmware(fw); fw = NULL; - ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); + ret = m88ds3103_rd_reg(dev, 0xb9, &u8tmp); if (ret) goto err; if (!u8tmp) { - dev_info(&priv->i2c->dev, "%s: firmware did not run\n", - KBUILD_MODNAME); + dev_info(&client->dev, "firmware did not run\n"); ret = -EFAULT; goto err; } - dev_info(&priv->i2c->dev, "%s: found a '%s' in warm state\n", - KBUILD_MODNAME, m88ds3103_ops.info.name); - dev_info(&priv->i2c->dev, "%s: firmware version %X.%X\n", - KBUILD_MODNAME, (u8tmp >> 4) & 0xf, (u8tmp >> 0 & 0xf)); + dev_info(&client->dev, "found a '%s' in warm state\n", + m88ds3103_ops.info.name); + dev_info(&client->dev, "firmware version: %X.%X\n", + (u8tmp >> 4) & 0xf, (u8tmp >> 0 & 0xf)); skip_fw_download: /* warm state */ - priv->warm = true; + dev->warm = true; + /* init stats here in order signal app which stats are supported */ c->cnr.len = 1; c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; @@ -851,75 +846,77 @@ skip_fw_download: c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; c->post_bit_count.len = 1; c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; - return 0; + return 0; error_fw_release: release_firmware(fw); err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } static int m88ds3103_sleep(struct dvb_frontend *fe) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; + struct i2c_client *client = dev->client; int ret; u8 u8tmp; - dev_dbg(&priv->i2c->dev, "%s:\n", __func__); + dev_dbg(&client->dev, "\n"); - priv->fe_status = 0; - priv->delivery_system = SYS_UNDEFINED; + dev->fe_status = 0; + dev->delivery_system = SYS_UNDEFINED; /* TS Hi-Z */ - if (priv->chip_id == M88RS6000_CHIP_ID) + if (dev->chip_id == M88RS6000_CHIP_ID) u8tmp = 0x29; else u8tmp = 0x27; - ret = m88ds3103_wr_reg_mask(priv, u8tmp, 0x00, 0x01); + ret = m88ds3103_wr_reg_mask(dev, u8tmp, 0x00, 0x01); if (ret) goto err; /* sleep */ - ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x00, 0x01); + ret = m88ds3103_wr_reg_mask(dev, 0x08, 0x00, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x01, 0x01); + ret = m88ds3103_wr_reg_mask(dev, 0x04, 0x01, 0x01); if (ret) goto err; - ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x10, 0x10); + ret = m88ds3103_wr_reg_mask(dev, 0x23, 0x10, 0x10); if (ret) goto err; return 0; err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } static int m88ds3103_get_frontend(struct dvb_frontend *fe) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; + struct i2c_client *client = dev->client; struct dtv_frontend_properties *c = &fe->dtv_property_cache; int ret; u8 buf[3]; - dev_dbg(&priv->i2c->dev, "%s:\n", __func__); + dev_dbg(&client->dev, "\n"); - if (!priv->warm || !(priv->fe_status & FE_HAS_LOCK)) { + if (!dev->warm || !(dev->fe_status & FE_HAS_LOCK)) { ret = 0; goto err; } switch (c->delivery_system) { case SYS_DVBS: - ret = m88ds3103_rd_reg(priv, 0xe0, &buf[0]); + ret = m88ds3103_rd_reg(dev, 0xe0, &buf[0]); if (ret) goto err; - ret = m88ds3103_rd_reg(priv, 0xe6, &buf[1]); + ret = m88ds3103_rd_reg(dev, 0xe6, &buf[1]); if (ret) goto err; @@ -949,23 +946,22 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe) c->fec_inner = FEC_1_2; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", - __func__); + dev_dbg(&client->dev, "invalid fec_inner\n"); } c->modulation = QPSK; break; case SYS_DVBS2: - ret = m88ds3103_rd_reg(priv, 0x7e, &buf[0]); + ret = m88ds3103_rd_reg(dev, 0x7e, &buf[0]); if (ret) goto err; - ret = m88ds3103_rd_reg(priv, 0x89, &buf[1]); + ret = m88ds3103_rd_reg(dev, 0x89, &buf[1]); if (ret) goto err; - ret = m88ds3103_rd_reg(priv, 0xf2, &buf[2]); + ret = m88ds3103_rd_reg(dev, 0xf2, &buf[2]); if (ret) goto err; @@ -998,8 +994,7 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe) c->fec_inner = FEC_9_10; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", - __func__); + dev_dbg(&client->dev, "invalid fec_inner\n"); } switch ((buf[0] >> 5) & 0x01) { @@ -1025,8 +1020,7 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe) c->modulation = APSK_32; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid modulation\n", - __func__); + dev_dbg(&client->dev, "invalid modulation\n"); } switch ((buf[1] >> 7) & 0x01) { @@ -1049,27 +1043,25 @@ static int m88ds3103_get_frontend(struct dvb_frontend *fe) c->rolloff = ROLLOFF_20; break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid rolloff\n", - __func__); + dev_dbg(&client->dev, "invalid rolloff\n"); } break; default: - dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", - __func__); + dev_dbg(&client->dev, "invalid delivery_system\n"); ret = -EINVAL; goto err; } - ret = m88ds3103_rd_regs(priv, 0x6d, buf, 2); + ret = m88ds3103_rd_regs(dev, 0x6d, buf, 2); if (ret) goto err; c->symbol_rate = 1ull * ((buf[1] << 8) | (buf[0] << 0)) * - priv->mclk_khz * 1000 / 0x10000; + dev->mclk_khz * 1000 / 0x10000; return 0; err: - dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); + dev_dbg(&client->dev, "failed=%d\n", ret); return ret; } @@ -1087,9 +1079,9 @@ static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) static int m88ds3103_read_ber(struct dvb_frontend *fe, u32 *ber) { - struct m88ds3103_priv *priv = fe->demodulator_priv; + struct m88ds3103_dev *dev = fe->demodulator_priv; - *ber = priv->dvbv3 |