Commit f544f100 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[media] rtl2830: rename 'priv' to 'dev'

Use name 'dev' for device state instance as it is more common and
also one letter shorter.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent aba4e34a
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
#define MAX_XFER_SIZE 64 #define MAX_XFER_SIZE 64
/* write multiple hardware registers */ /* write multiple hardware registers */
static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len) static int rtl2830_wr(struct rtl2830_dev *dev, u8 reg, const u8 *val, int len)
{ {
int ret; int ret;
u8 buf[MAX_XFER_SIZE]; u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = { struct i2c_msg msg[1] = {
{ {
.addr = priv->cfg.i2c_addr, .addr = dev->cfg.i2c_addr,
.flags = 0, .flags = 0,
.len = 1 + len, .len = 1 + len,
.buf = buf, .buf = buf,
...@@ -45,7 +45,7 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len) ...@@ -45,7 +45,7 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len)
}; };
if (1 + len > sizeof(buf)) { if (1 + len > sizeof(buf)) {
dev_warn(&priv->i2c->dev, dev_warn(&dev->i2c->dev,
"%s: i2c wr reg=%04x: len=%d is too big!\n", "%s: i2c wr reg=%04x: len=%d is too big!\n",
KBUILD_MODNAME, reg, len); KBUILD_MODNAME, reg, len);
return -EINVAL; return -EINVAL;
...@@ -54,11 +54,11 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len) ...@@ -54,11 +54,11 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len)
buf[0] = reg; buf[0] = reg;
memcpy(&buf[1], val, len); memcpy(&buf[1], val, len);
ret = i2c_transfer(priv->i2c, msg, 1); ret = i2c_transfer(dev->i2c, msg, 1);
if (ret == 1) { if (ret == 1) {
ret = 0; ret = 0;
} else { } else {
dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \ dev_warn(&dev->i2c->dev, "%s: i2c wr failed=%d reg=%02x " \
"len=%d\n", KBUILD_MODNAME, ret, reg, len); "len=%d\n", KBUILD_MODNAME, ret, reg, len);
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
...@@ -66,28 +66,28 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len) ...@@ -66,28 +66,28 @@ static int rtl2830_wr(struct rtl2830_priv *priv, u8 reg, const u8 *val, int len)
} }
/* read multiple hardware registers */ /* read multiple hardware registers */
static int rtl2830_rd(struct rtl2830_priv *priv, u8 reg, u8 *val, int len) static int rtl2830_rd(struct rtl2830_dev *dev, u8 reg, u8 *val, int len)
{ {
int ret; int ret;
struct i2c_msg msg[2] = { struct i2c_msg msg[2] = {
{ {
.addr = priv->cfg.i2c_addr, .addr = dev->cfg.i2c_addr,
.flags = 0, .flags = 0,
.len = 1, .len = 1,
.buf = &reg, .buf = &reg,
}, { }, {
.addr = priv->cfg.i2c_addr, .addr = dev->cfg.i2c_addr,
.flags = I2C_M_RD, .flags = I2C_M_RD,
.len = len, .len = len,
.buf = val, .buf = val,
} }
}; };
ret = i2c_transfer(priv->i2c, msg, 2); ret = i2c_transfer(dev->i2c, msg, 2);
if (ret == 2) { if (ret == 2) {
ret = 0; ret = 0;
} else { } else {
dev_warn(&priv->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \ dev_warn(&dev->i2c->dev, "%s: i2c rd failed=%d reg=%02x " \
"len=%d\n", KBUILD_MODNAME, ret, reg, len); "len=%d\n", KBUILD_MODNAME, ret, reg, len);
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
...@@ -95,7 +95,7 @@ static int rtl2830_rd(struct rtl2830_priv *priv, u8 reg, u8 *val, int len) ...@@ -95,7 +95,7 @@ static int rtl2830_rd(struct rtl2830_priv *priv, u8 reg, u8 *val, int len)
} }
/* write multiple registers */ /* write multiple registers */
static int rtl2830_wr_regs(struct rtl2830_priv *priv, u16 reg, const u8 *val, static int rtl2830_wr_regs(struct rtl2830_dev *dev, u16 reg, const u8 *val,
int len) int len)
{ {
int ret; int ret;
...@@ -103,51 +103,51 @@ static int rtl2830_wr_regs(struct rtl2830_priv *priv, u16 reg, const u8 *val, ...@@ -103,51 +103,51 @@ static int rtl2830_wr_regs(struct rtl2830_priv *priv, u16 reg, const u8 *val,
u8 page = (reg >> 8) & 0xff; u8 page = (reg >> 8) & 0xff;
/* switch bank if needed */ /* switch bank if needed */
if (page != priv->page) { if (page != dev->page) {
ret = rtl2830_wr(priv, 0x00, &page, 1); ret = rtl2830_wr(dev, 0x00, &page, 1);
if (ret) if (ret)
return ret; return ret;
priv->page = page; dev->page = page;
} }
return rtl2830_wr(priv, reg2, val, len); return rtl2830_wr(dev, reg2, val, len);
} }
/* read multiple registers */ /* read multiple registers */
static int rtl2830_rd_regs(struct rtl2830_priv *priv, u16 reg, u8 *val, int len) static int rtl2830_rd_regs(struct rtl2830_dev *dev, u16 reg, u8 *val, int len)
{ {
int ret; int ret;
u8 reg2 = (reg >> 0) & 0xff; u8 reg2 = (reg >> 0) & 0xff;
u8 page = (reg >> 8) & 0xff; u8 page = (reg >> 8) & 0xff;
/* switch bank if needed */ /* switch bank if needed */
if (page != priv->page) { if (page != dev->page) {
ret = rtl2830_wr(priv, 0x00, &page, 1); ret = rtl2830_wr(dev, 0x00, &page, 1);
if (ret) if (ret)
return ret; return ret;
priv->page = page; dev->page = page;
} }
return rtl2830_rd(priv, reg2, val, len); return rtl2830_rd(dev, reg2, val, len);
} }
/* read single register */ /* read single register */
static int rtl2830_rd_reg(struct rtl2830_priv *priv, u16 reg, u8 *val) static int rtl2830_rd_reg(struct rtl2830_dev *dev, u16 reg, u8 *val)
{ {
return rtl2830_rd_regs(priv, reg, val, 1); return rtl2830_rd_regs(dev, reg, val, 1);
} }
/* write single register with mask */ /* write single register with mask */
static int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 mask) static int rtl2830_wr_reg_mask(struct rtl2830_dev *dev, u16 reg, u8 val, u8 mask)
{ {
int ret; int ret;
u8 tmp; u8 tmp;
/* no need for read if whole reg is written */ /* no need for read if whole reg is written */
if (mask != 0xff) { if (mask != 0xff) {
ret = rtl2830_rd_regs(priv, reg, &tmp, 1); ret = rtl2830_rd_regs(dev, reg, &tmp, 1);
if (ret) if (ret)
return ret; return ret;
...@@ -156,16 +156,16 @@ static int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 ma ...@@ -156,16 +156,16 @@ static int rtl2830_wr_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 val, u8 ma
val |= tmp; val |= tmp;
} }
return rtl2830_wr_regs(priv, reg, &val, 1); return rtl2830_wr_regs(dev, reg, &val, 1);
} }
/* read single register with mask */ /* read single register with mask */
static int rtl2830_rd_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 *val, u8 mask) static int rtl2830_rd_reg_mask(struct rtl2830_dev *dev, u16 reg, u8 *val, u8 mask)
{ {
int ret, i; int ret, i;
u8 tmp; u8 tmp;
ret = rtl2830_rd_regs(priv, reg, &tmp, 1); ret = rtl2830_rd_regs(dev, reg, &tmp, 1);
if (ret) if (ret)
return ret; return ret;
...@@ -183,7 +183,7 @@ static int rtl2830_rd_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 *val, u8 m ...@@ -183,7 +183,7 @@ static int rtl2830_rd_reg_mask(struct rtl2830_priv *priv, u16 reg, u8 *val, u8 m
static int rtl2830_init(struct dvb_frontend *fe) static int rtl2830_init(struct dvb_frontend *fe)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
int ret, i; int ret, i;
struct rtl2830_reg_val_mask tab[] = { struct rtl2830_reg_val_mask tab[] = {
{ 0x00d, 0x01, 0x03 }, { 0x00d, 0x01, 0x03 },
...@@ -204,10 +204,10 @@ static int rtl2830_init(struct dvb_frontend *fe) ...@@ -204,10 +204,10 @@ static int rtl2830_init(struct dvb_frontend *fe)
{ 0x2f1, 0x20, 0xf8 }, { 0x2f1, 0x20, 0xf8 },
{ 0x16d, 0x00, 0x01 }, { 0x16d, 0x00, 0x01 },
{ 0x1a6, 0x00, 0x80 }, { 0x1a6, 0x00, 0x80 },
{ 0x106, priv->cfg.vtop, 0x3f }, { 0x106, dev->cfg.vtop, 0x3f },
{ 0x107, priv->cfg.krf, 0x3f }, { 0x107, dev->cfg.krf, 0x3f },
{ 0x112, 0x28, 0xff }, { 0x112, 0x28, 0xff },
{ 0x103, priv->cfg.agc_targ_val, 0xff }, { 0x103, dev->cfg.agc_targ_val, 0xff },
{ 0x00a, 0x02, 0x07 }, { 0x00a, 0x02, 0x07 },
{ 0x140, 0x0c, 0x3c }, { 0x140, 0x0c, 0x3c },
{ 0x140, 0x40, 0xc0 }, { 0x140, 0x40, 0xc0 },
...@@ -215,7 +215,7 @@ static int rtl2830_init(struct dvb_frontend *fe) ...@@ -215,7 +215,7 @@ static int rtl2830_init(struct dvb_frontend *fe)
{ 0x15b, 0x28, 0x38 }, { 0x15b, 0x28, 0x38 },
{ 0x15c, 0x05, 0x07 }, { 0x15c, 0x05, 0x07 },
{ 0x15c, 0x28, 0x38 }, { 0x15c, 0x28, 0x38 },
{ 0x115, priv->cfg.spec_inv, 0x01 }, { 0x115, dev->cfg.spec_inv, 0x01 },
{ 0x16f, 0x01, 0x07 }, { 0x16f, 0x01, 0x07 },
{ 0x170, 0x18, 0x38 }, { 0x170, 0x18, 0x38 },
{ 0x172, 0x0f, 0x0f }, { 0x172, 0x0f, 0x0f },
...@@ -225,17 +225,17 @@ static int rtl2830_init(struct dvb_frontend *fe) ...@@ -225,17 +225,17 @@ static int rtl2830_init(struct dvb_frontend *fe)
}; };
for (i = 0; i < ARRAY_SIZE(tab); i++) { for (i = 0; i < ARRAY_SIZE(tab); i++) {
ret = rtl2830_wr_reg_mask(priv, tab[i].reg, tab[i].val, ret = rtl2830_wr_reg_mask(dev, tab[i].reg, tab[i].val,
tab[i].mask); tab[i].mask);
if (ret) if (ret)
goto err; goto err;
} }
ret = rtl2830_wr_regs(priv, 0x18f, "\x28\x00", 2); ret = rtl2830_wr_regs(dev, 0x18f, "\x28\x00", 2);
if (ret) if (ret)
goto err; goto err;
ret = rtl2830_wr_regs(priv, 0x195, ret = rtl2830_wr_regs(dev, 0x195,
"\x04\x06\x0a\x12\x0a\x12\x1e\x28", 8); "\x04\x06\x0a\x12\x0a\x12\x1e\x28", 8);
if (ret) if (ret)
goto err; goto err;
...@@ -243,26 +243,26 @@ static int rtl2830_init(struct dvb_frontend *fe) ...@@ -243,26 +243,26 @@ static int rtl2830_init(struct dvb_frontend *fe)
/* TODO: spec init */ /* TODO: spec init */
/* soft reset */ /* soft reset */
ret = rtl2830_wr_reg_mask(priv, 0x101, 0x04, 0x04); ret = rtl2830_wr_reg_mask(dev, 0x101, 0x04, 0x04);
if (ret) if (ret)
goto err; goto err;
ret = rtl2830_wr_reg_mask(priv, 0x101, 0x00, 0x04); ret = rtl2830_wr_reg_mask(dev, 0x101, 0x00, 0x04);
if (ret) if (ret)
goto err; goto err;
priv->sleeping = false; dev->sleeping = false;
return ret; return ret;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
static int rtl2830_sleep(struct dvb_frontend *fe) static int rtl2830_sleep(struct dvb_frontend *fe)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
priv->sleeping = true; dev->sleeping = true;
return 0; return 0;
} }
...@@ -278,7 +278,7 @@ static int rtl2830_get_tune_settings(struct dvb_frontend *fe, ...@@ -278,7 +278,7 @@ static int rtl2830_get_tune_settings(struct dvb_frontend *fe,
static int rtl2830_set_frontend(struct dvb_frontend *fe) static int rtl2830_set_frontend(struct dvb_frontend *fe)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret, i; int ret, i;
u64 num; u64 num;
...@@ -308,7 +308,7 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) ...@@ -308,7 +308,7 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe)
{0xae, 0xba, 0xf3, 0x26, 0x66, 0x64}, /* 8 MHz */ {0xae, 0xba, 0xf3, 0x26, 0x66, 0x64}, /* 8 MHz */
}; };
dev_dbg(&priv->i2c->dev, dev_dbg(&dev->i2c->dev,
"%s: frequency=%d bandwidth_hz=%d inversion=%d\n", "%s: frequency=%d bandwidth_hz=%d inversion=%d\n",
__func__, c->frequency, c->bandwidth_hz, c->inversion); __func__, c->frequency, c->bandwidth_hz, c->inversion);
...@@ -327,11 +327,11 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) ...@@ -327,11 +327,11 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe)
i = 2; i = 2;
break; break;
default: default:
dev_dbg(&priv->i2c->dev, "%s: invalid bandwidth\n", __func__); dev_dbg(&dev->i2c->dev, "%s: invalid bandwidth\n", __func__);
return -EINVAL; return -EINVAL;
} }
ret = rtl2830_wr_reg_mask(priv, 0x008, i << 1, 0x06); ret = rtl2830_wr_reg_mask(dev, 0x008, i << 1, 0x06);
if (ret) if (ret)
goto err; goto err;
...@@ -344,15 +344,15 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) ...@@ -344,15 +344,15 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe)
if (ret < 0) if (ret < 0)
goto err; goto err;
num = if_frequency % priv->cfg.xtal; num = if_frequency % dev->cfg.xtal;
num *= 0x400000; num *= 0x400000;
num = div_u64(num, priv->cfg.xtal); num = div_u64(num, dev->cfg.xtal);
num = -num; num = -num;
if_ctl = num & 0x3fffff; if_ctl = num & 0x3fffff;
dev_dbg(&priv->i2c->dev, "%s: if_frequency=%d if_ctl=%08x\n", dev_dbg(&dev->i2c->dev, "%s: if_frequency=%d if_ctl=%08x\n",
__func__, if_frequency, if_ctl); __func__, if_frequency, if_ctl);
ret = rtl2830_rd_reg_mask(priv, 0x119, &tmp, 0xc0); /* b[7:6] */ ret = rtl2830_rd_reg_mask(dev, 0x119, &tmp, 0xc0); /* b[7:6] */
if (ret) if (ret)
goto err; goto err;
...@@ -361,49 +361,49 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe) ...@@ -361,49 +361,49 @@ static int rtl2830_set_frontend(struct dvb_frontend *fe)
buf[1] = (if_ctl >> 8) & 0xff; buf[1] = (if_ctl >> 8) & 0xff;
buf[2] = (if_ctl >> 0) & 0xff; buf[2] = (if_ctl >> 0) & 0xff;
ret = rtl2830_wr_regs(priv, 0x119, buf, 3); ret = rtl2830_wr_regs(dev, 0x119, buf, 3);
if (ret) if (ret)
goto err; goto err;
/* 1/2 split I2C write */ /* 1/2 split I2C write */
ret = rtl2830_wr_regs(priv, 0x11c, &bw_params1[i][0], 17); ret = rtl2830_wr_regs(dev, 0x11c, &bw_params1[i][0], 17);
if (ret) if (ret)
goto err; goto err;
/* 2/2 split I2C write */ /* 2/2 split I2C write */
ret = rtl2830_wr_regs(priv, 0x12d, &bw_params1[i][17], 17); ret = rtl2830_wr_regs(dev, 0x12d, &bw_params1[i][17], 17);
if (ret) if (ret)
goto err; goto err;
ret = rtl2830_wr_regs(priv, 0x19d, bw_params2[i], 6); ret = rtl2830_wr_regs(dev, 0x19d, bw_params2[i], 6);
if (ret) if (ret)
goto err; goto err;
return ret; return ret;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
static int rtl2830_get_frontend(struct dvb_frontend *fe) static int rtl2830_get_frontend(struct dvb_frontend *fe)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
int ret; int ret;
u8 buf[3]; u8 buf[3];
if (priv->sleeping) if (dev->sleeping)
return 0; return 0;
ret = rtl2830_rd_regs(priv, 0x33c, buf, 2); ret = rtl2830_rd_regs(dev, 0x33c, buf, 2);
if (ret) if (ret)
goto err; goto err;
ret = rtl2830_rd_reg(priv, 0x351, &buf[2]); ret = rtl2830_rd_reg(dev, 0x351, &buf[2]);
if (ret) if (ret)
goto err; goto err;
dev_dbg(&priv->i2c->dev, "%s: TPS=%*ph\n", __func__, 3, buf); dev_dbg(&dev->i2c->dev, "%s: TPS=%*ph\n", __func__, 3, buf);
switch ((buf[0] >> 2) & 3) { switch ((buf[0] >> 2) & 3) {
case 0: case 0:
...@@ -493,21 +493,21 @@ static int rtl2830_get_frontend(struct dvb_frontend *fe) ...@@ -493,21 +493,21 @@ static int rtl2830_get_frontend(struct dvb_frontend *fe)
return 0; return 0;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status) static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
int ret; int ret;
u8 tmp; u8 tmp;
*status = 0; *status = 0;
if (priv->sleeping) if (dev->sleeping)
return 0; return 0;
ret = rtl2830_rd_reg_mask(priv, 0x351, &tmp, 0x78); /* [6:3] */ ret = rtl2830_rd_reg_mask(dev, 0x351, &tmp, 0x78); /* [6:3] */
if (ret) if (ret)
goto err; goto err;
...@@ -521,13 +521,13 @@ static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status) ...@@ -521,13 +521,13 @@ static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status)
return ret; return ret;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr) static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
int ret, hierarchy, constellation; int ret, hierarchy, constellation;
u8 buf[2], tmp; u8 buf[2], tmp;
u16 tmp16; u16 tmp16;
...@@ -539,12 +539,12 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -539,12 +539,12 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr)
{ 92888734, 92888734, 95487525, 99770748 }, { 92888734, 92888734, 95487525, 99770748 },
}; };
if (priv->sleeping) if (dev->sleeping)
return 0; return 0;
/* reports SNR in resolution of 0.1 dB */ /* reports SNR in resolution of 0.1 dB */
ret = rtl2830_rd_reg(priv, 0x33c, &tmp); ret = rtl2830_rd_reg(dev, 0x33c, &tmp);
if (ret) if (ret)
goto err; goto err;
...@@ -556,7 +556,7 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -556,7 +556,7 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr)
if (hierarchy > HIERARCHY_NUM - 1) if (hierarchy > HIERARCHY_NUM - 1)
goto err; goto err;
ret = rtl2830_rd_regs(priv, 0x40c, buf, 2); ret = rtl2830_rd_regs(dev, 0x40c, buf, 2);
if (ret) if (ret)
goto err; goto err;
...@@ -570,20 +570,20 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr) ...@@ -570,20 +570,20 @@ static int rtl2830_read_snr(struct dvb_frontend *fe, u16 *snr)
return 0; return 0;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
static int rtl2830_read_ber(struct dvb_frontend *fe, u32 *ber) static int rtl2830_read_ber(struct dvb_frontend *fe, u32 *ber)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
int ret; int ret;
u8 buf[2]; u8 buf[2];
if (priv->sleeping) if (dev->sleeping)
return 0; return 0;
ret = rtl2830_rd_regs(priv, 0x34e, buf, 2); ret = rtl2830_rd_regs(dev, 0x34e, buf, 2);
if (ret) if (ret)
goto err; goto err;
...@@ -591,7 +591,7 @@ static int rtl2830_read_ber(struct dvb_frontend *fe, u32 *ber) ...@@ -591,7 +591,7 @@ static int rtl2830_read_ber(struct dvb_frontend *fe, u32 *ber)
return 0; return 0;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
...@@ -603,15 +603,15 @@ static int rtl2830_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks) ...@@ -603,15 +603,15 @@ static int rtl2830_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength) static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
{ {
struct rtl2830_priv *priv = fe->demodulator_priv; struct rtl2830_dev *dev = fe->demodulator_priv;
int ret; int ret;
u8 buf[2]; u8 buf[2];
u16 if_agc_raw, if_agc; u16 if_agc_raw, if_agc;
if (priv->sleeping) if (dev->sleeping)
return 0; return 0;
ret = rtl2830_rd_regs(priv, 0x359, buf, 2); ret = rtl2830_rd_regs(dev, 0x359, buf, 2);
if (ret) if (ret)
goto err; goto err;
...@@ -627,7 +627,7 @@ static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength) ...@@ -627,7 +627,7 @@ static int rtl2830_read_signal_strength(struct dvb_frontend *fe, u16 *strength)
return 0; return 0;
err: err:
dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); dev_dbg(&dev->i2c->dev, "%s: failed=%d\n", __func__, ret);
return ret; return ret;
} }
...@@ -675,10 +675,10 @@ static struct dvb_frontend_ops rtl2830_ops = { ...@@ -675,10 +675,10 @@ static struct dvb_frontend_ops rtl2830_ops = {
static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
{ {
struct i2c_client *client = mux_priv; struct i2c_client *client = mux_priv;
struct rtl2830_priv *priv = i2c_get_clientdata(client); struct rtl2830_dev *dev = i2c_get_clientdata(client);
struct i2c_msg select_reg_page_msg[1] = { struct i2c_msg select_reg_page_msg[1] = {
{ {
.addr = priv->cfg.i2c_addr, .addr = dev->cfg.i2c_addr,
.flags = 0, .flags = 0,
.len = 2, .len = 2,
.buf = "\x00\x01", .buf = "\x00\x01",
...@@ -686,7 +686,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) ...@@ -686,7 +686,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
}; };
struct i2c_msg gate_open_msg[1] = { struct i2c_msg gate_open_msg[1] = {
{ {
.addr = priv->cfg.i2c_addr, .addr = dev->cfg.i2c_addr,
.flags = 0, .flags = 0,
.len = 2, .len = 2,
.buf = "\x01\x08", .buf = "\x01\x08",
...@@ -703,7 +703,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) ...@@ -703,7 +703,7 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
goto err; goto err;
} }
priv->page = 1; dev->page = 1;
/* open tuner I2C repeater for 1 xfer, closes automatically */ /* open tuner I2C repeater for 1 xfer, closes automatically */
ret = __i2c_transfer(adap, gate_open_msg, 1); ret = __i2c_transfer(adap, gate_open_msg, 1);
...@@ -723,20 +723,20 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id) ...@@ -723,20 +723,20 @@ static int rtl2830_select(struct i2c_adapter *adap, void *mux_priv, u32 chan_id)
static struct dvb_frontend *rtl2830_get_dvb_frontend(struct i2c_client *client) static struct dvb_frontend *rtl2830_get_dvb_frontend(struct i2c_client *client)
{ {
struct rtl2830_priv *priv = i2c_get_clientdata(client); struct rtl2830_dev *dev = i2c_get_clientdata(client);
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
return &priv->fe; return &dev->fe;
} }
static struct i2c_adapter *rtl2830_get_i2c_adapter(struct i2c_client *client) static struct i2c_adapter *rtl2830_get_i2c_adapter(struct i2c_client *client)
{ {
struct rtl2830_priv *priv = i2c_get_clientdata(client); struct rtl2830_dev *dev = i2c_get_clientdata(client);
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
return priv->adapter; return dev->adapter;
} }
static int rtl2830_probe(struct i2c_client *client, static int rtl2830_probe(struct i2c_client *client,
...@@ -744,7 +744,7 @@ static int rtl2830_probe(struct i2c_client *client, ...@@ -744,7 +744,7 @@ static int rtl2830_probe(struct i2c_client *client,
{ {
struct rtl2830_platform_data *pdata = client->dev.platform_data; struct rtl2830_platform_data *pdata = client->dev.platform_data;
struct i2c_adapter *i2c = client->adapter; struct i2c_adapter *i2c = client->adapter;
struct rtl2830_priv *priv; struct rtl2830_dev *dev;
int ret; int ret;
u8 u8tmp; u8 u8tmp;
...@@ -756,39 +756,39 @@ static int rtl2830_probe(struct i2c_client *client, ...@@ -756,39 +756,39 @@ static int rtl2830_probe(struct i2c_client *client,
} }
/* allocate memory for the internal state */ /* allocate memory for the internal state */
priv = kzalloc(sizeof(*priv), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (priv == NULL) { if (dev == NULL) {
ret = -ENOMEM; ret = -ENOMEM;
goto err; goto err;
} }
/* setup the state */ /* setup the state */
i2c_set_clientdata(client, priv); i2c_set_clientdata(client, dev);
priv->i2c = i2c; dev->i2c = i2c;
priv->sleeping = true; dev->sleeping = true;
priv->cfg.i2c_addr = client->addr; dev->cfg.i2c_addr = client->addr;
priv->cfg.xtal = pdata->clk; dev->cfg.xtal = pdata->clk;
priv->cfg.spec_inv = pdata->spec_inv; dev->cfg.spec_inv = pdata->spec_inv;
priv->cfg.vtop = pdata->vtop; dev->cfg.vtop = pdata->vtop;
priv->cfg.krf = pdata->krf; dev->cfg.krf = pdata->krf;
priv->cfg.agc_targ_val = pdata->agc_targ_val; dev->cfg.agc_targ_val = pdata->agc_targ_val;
/* check if the demod is there */ /* check if the demod is there */
ret = rtl2830_rd_reg(priv, 0x000, &u8tmp); ret = rtl2830_rd_reg(dev, 0x000, &u8tmp);
if (ret) if (ret)
goto err_kfree; goto err_kfree;
/* create muxed i2c adapter for tuner */ /* create muxed i2c adapter for tuner */
priv->adapter = i2c_add_mux_adapter(client->adapter, &client->dev, dev->adapter = i2c_add_mux_adapter(client->adapter, &client->dev,
client, 0, 0, 0, rtl2830_select, NULL); client, 0, 0, 0, rtl2830_select, NULL);
if (priv->adapter == NULL) { if (dev->adapter == NULL) {
ret = -ENODEV; ret = -ENODEV;
goto err_kfree; goto err_kfree;
} }
/* create dvb frontend */ /* create dvb frontend */
memcpy(&priv->fe.ops, &rtl2830_ops, sizeof(priv->fe.ops)); memcpy(&dev->fe.ops, &rtl2830_ops, sizeof(dev->fe.ops));
priv->fe.demodulator_priv = priv; dev->fe.demodulator_priv = dev;
/* setup callbacks */ /* setup callbacks */
pdata->get_dvb_frontend = rtl2830_get_dvb_frontend; pdata->get_dvb_frontend = rtl2830_get_dvb_frontend;
...@@ -798,7 +798,7 @@ static int rtl2830_probe(struct i2c_client *client, ...@@ -798,7 +798,7 @@ static int rtl2830_probe(struct i2c_client *client,
return 0; return 0;
err_kfree: err_kfree:
kfree(priv); kfree(dev);
err: err:
dev_dbg(&client->dev, "failed=%d\n", ret); dev_dbg(&client->dev, "failed=%d\n", ret);
return ret; return ret;
...@@ -806,12 +806,12 @@ static int rtl2830_probe(struct i2c_client *client, ...@@ -806,12 +806,12 @@ static int rtl2830_probe(struct i2c_client *client,
static int rtl2830_remove(struct i2c_client *client) static int rtl2830_remove(struct i2c_client *client)
{ {
struct rtl2830_priv *priv = i2c_get_clientdata(client); struct rtl2830_dev *dev = i2c_get_clientdata(client);
dev_dbg(&client->dev, "\n"); dev_dbg(&client->dev, "\n");
i2c_del_mux_adapter(priv->adapter); i2c_del_mux_adapter(dev->adapter);
kfree(priv); kfree(dev);
return 0; return 0;
} }
......
...@@ -35,7 +35,7 @@ struct rtl2830_config { ...@@ -35,7 +35,7 @@ struct rtl2830_config {
u8 agc_targ_val; u8 agc_targ_val;
}; };
struct rtl2830_priv { struct rtl2830_dev {
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_adapter *i2c; struct i2c_adapter *i2c;
struct dvb_frontend fe; struct dvb_frontend fe;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment