/* write multiple hardware registers */
static int rtl2830_wr(struct i2c_client *client, u8 reg, const u8 *val, int len)
{
- struct rtl2830_dev *dev = i2c_get_clientdata(client);
int ret;
u8 buf[MAX_XFER_SIZE];
struct i2c_msg msg[1] = {
{
- .addr = dev->cfg.i2c_addr,
+ .addr = client->addr,
.flags = 0,
.len = 1 + len,
.buf = buf,
buf[0] = reg;
memcpy(&buf[1], val, len);
- ret = i2c_transfer(dev->i2c, msg, 1);
+ ret = i2c_transfer(client->adapter, msg, 1);
if (ret == 1) {
ret = 0;
} else {
/* read multiple hardware registers */
static int rtl2830_rd(struct i2c_client *client, u8 reg, u8 *val, int len)
{
- struct rtl2830_dev *dev = i2c_get_clientdata(client);
int ret;
struct i2c_msg msg[2] = {
{
- .addr = dev->cfg.i2c_addr,
+ .addr = client->addr,
.flags = 0,
.len = 1,
.buf = ®,
}, {
- .addr = dev->cfg.i2c_addr,
+ .addr = client->addr,
.flags = I2C_M_RD,
.len = len,
.buf = val,
}
};
- ret = i2c_transfer(dev->i2c, msg, 2);
+ ret = i2c_transfer(client->adapter, msg, 2);
if (ret == 2) {
ret = 0;
} else {
{ 0x2f1, 0x20, 0xf8 },
{ 0x16d, 0x00, 0x01 },
{ 0x1a6, 0x00, 0x80 },
- { 0x106, dev->cfg.vtop, 0x3f },
- { 0x107, dev->cfg.krf, 0x3f },
+ { 0x106, dev->pdata->vtop, 0x3f },
+ { 0x107, dev->pdata->krf, 0x3f },
{ 0x112, 0x28, 0xff },
- { 0x103, dev->cfg.agc_targ_val, 0xff },
+ { 0x103, dev->pdata->agc_targ_val, 0xff },
{ 0x00a, 0x02, 0x07 },
{ 0x140, 0x0c, 0x3c },
{ 0x140, 0x40, 0xc0 },
{ 0x15b, 0x28, 0x38 },
{ 0x15c, 0x05, 0x07 },
{ 0x15c, 0x28, 0x38 },
- { 0x115, dev->cfg.spec_inv, 0x01 },
+ { 0x115, dev->pdata->spec_inv, 0x01 },
{ 0x16f, 0x01, 0x07 },
{ 0x170, 0x18, 0x38 },
{ 0x172, 0x0f, 0x0f },
if (ret < 0)
goto err;
- num = if_frequency % dev->cfg.xtal;
+ num = if_frequency % dev->pdata->clk;
num *= 0x400000;
- num = div_u64(num, dev->cfg.xtal);
+ num = div_u64(num, dev->pdata->clk);
num = -num;
if_ctl = num & 0x3fffff;
dev_dbg(&client->dev, "if_frequency=%d if_ctl=%08x\n",
static int rtl2830_read_status(struct dvb_frontend *fe, fe_status_t *status)
{
struct i2c_client *client = fe->demodulator_priv;
- struct rtl2830_dev *dev = fe->demodulator_priv;
+ struct rtl2830_dev *dev = i2c_get_clientdata(client);
int ret;
u8 tmp;
*status = 0;
struct rtl2830_dev *dev = i2c_get_clientdata(client);
struct i2c_msg select_reg_page_msg[1] = {
{
- .addr = dev->cfg.i2c_addr,
+ .addr = client->addr,
.flags = 0,
.len = 2,
.buf = "\x00\x01",
};
struct i2c_msg gate_open_msg[1] = {
{
- .addr = dev->cfg.i2c_addr,
+ .addr = client->addr,
.flags = 0,
.len = 2,
.buf = "\x01\x08",
int ret;
/* select register page */
- ret = __i2c_transfer(adap, select_reg_page_msg, 1);
+ ret = __i2c_transfer(client->adapter, select_reg_page_msg, 1);
if (ret != 1) {
dev_warn(&client->dev, "i2c write failed %d\n", ret);
if (ret >= 0)
dev->page = 1;
/* open tuner I2C repeater for 1 xfer, closes automatically */
- ret = __i2c_transfer(adap, gate_open_msg, 1);
+ ret = __i2c_transfer(client->adapter, gate_open_msg, 1);
if (ret != 1) {
dev_warn(&client->dev, "i2c write failed %d\n", ret);
if (ret >= 0)
const struct i2c_device_id *id)
{
struct rtl2830_platform_data *pdata = client->dev.platform_data;
- struct i2c_adapter *i2c = client->adapter;
struct rtl2830_dev *dev;
int ret;
u8 u8tmp;
/* setup the state */
i2c_set_clientdata(client, dev);
- dev->i2c = i2c;
+ dev->pdata = client->dev.platform_data;
dev->sleeping = true;
- dev->cfg.i2c_addr = client->addr;
- dev->cfg.xtal = pdata->clk;
- dev->cfg.spec_inv = pdata->spec_inv;
- dev->cfg.vtop = pdata->vtop;
- dev->cfg.krf = pdata->krf;
- dev->cfg.agc_targ_val = pdata->agc_targ_val;
/* check if the demod is there */
ret = rtl2830_rd_reg(client, 0x000, &u8tmp);