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

[media] tua9001: use regmap for I2C register access

Use regmap for I2C register access.
Signed-off-by: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 465433fa
...@@ -236,6 +236,7 @@ config MEDIA_TUNER_M88RS6000T ...@@ -236,6 +236,7 @@ config MEDIA_TUNER_M88RS6000T
config MEDIA_TUNER_TUA9001 config MEDIA_TUNER_TUA9001
tristate "Infineon TUA9001 silicon tuner" tristate "Infineon TUA9001 silicon tuner"
depends on MEDIA_SUPPORT && I2C depends on MEDIA_SUPPORT && I2C
select REGMAP_I2C
default m if !MEDIA_SUBDRV_AUTOSELECT default m if !MEDIA_SUBDRV_AUTOSELECT
help help
Infineon TUA 9001 silicon tuner driver. Infineon TUA 9001 silicon tuner driver.
......
...@@ -16,32 +16,6 @@ ...@@ -16,32 +16,6 @@
#include "tua9001_priv.h" #include "tua9001_priv.h"
/* write register */
static int tua9001_wr_reg(struct tua9001_dev *dev, u8 reg, u16 val)
{
struct i2c_client *client = dev->client;
int ret;
u8 buf[3] = { reg, (val >> 8) & 0xff, (val >> 0) & 0xff };
struct i2c_msg msg[1] = {
{
.addr = client->addr,
.flags = 0,
.len = sizeof(buf),
.buf = buf,
}
};
ret = i2c_transfer(client->adapter, msg, 1);
if (ret == 1) {
ret = 0;
} else {
dev_warn(&client->dev, "i2c wr failed=%d reg=%02x\n", ret, reg);
ret = -EREMOTEIO;
}
return ret;
}
static int tua9001_init(struct dvb_frontend *fe) static int tua9001_init(struct dvb_frontend *fe)
{ {
struct tua9001_dev *dev = fe->tuner_priv; struct tua9001_dev *dev = fe->tuner_priv;
...@@ -76,7 +50,7 @@ static int tua9001_init(struct dvb_frontend *fe) ...@@ -76,7 +50,7 @@ static int tua9001_init(struct dvb_frontend *fe)
} }
for (i = 0; i < ARRAY_SIZE(data); i++) { for (i = 0; i < ARRAY_SIZE(data); i++) {
ret = tua9001_wr_reg(dev, data[i].reg, data[i].val); ret = regmap_write(dev->regmap, data[i].reg, data[i].val);
if (ret) if (ret)
goto err; goto err;
} }
...@@ -166,7 +140,7 @@ static int tua9001_set_params(struct dvb_frontend *fe) ...@@ -166,7 +140,7 @@ static int tua9001_set_params(struct dvb_frontend *fe)
} }
for (i = 0; i < ARRAY_SIZE(data); i++) { for (i = 0; i < ARRAY_SIZE(data); i++) {
ret = tua9001_wr_reg(dev, data[i].reg, data[i].val); ret = regmap_write(dev->regmap, data[i].reg, data[i].val);
if (ret) if (ret)
goto err; goto err;
} }
...@@ -216,6 +190,10 @@ static int tua9001_probe(struct i2c_client *client, ...@@ -216,6 +190,10 @@ static int tua9001_probe(struct i2c_client *client,
struct tua9001_platform_data *pdata = client->dev.platform_data; struct tua9001_platform_data *pdata = client->dev.platform_data;
struct dvb_frontend *fe = pdata->dvb_frontend; struct dvb_frontend *fe = pdata->dvb_frontend;
int ret; int ret;
static const struct regmap_config regmap_config = {
.reg_bits = 8,
.val_bits = 16,
};
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev) {
...@@ -223,8 +201,13 @@ static int tua9001_probe(struct i2c_client *client, ...@@ -223,8 +201,13 @@ static int tua9001_probe(struct i2c_client *client,
goto err; goto err;
} }
dev->client = client;
dev->fe = pdata->dvb_frontend; dev->fe = pdata->dvb_frontend;
dev->client = client;
dev->regmap = devm_regmap_init_i2c(client, &regmap_config);
if (IS_ERR(dev->regmap)) {
ret = PTR_ERR(dev->regmap);
goto err_kfree;
}
if (fe->callback) { if (fe->callback) {
ret = fe->callback(client->adapter, ret = fe->callback(client->adapter,
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#define TUA9001_PRIV_H #define TUA9001_PRIV_H
#include "tua9001.h" #include "tua9001.h"
#include <linux/regmap.h>
struct tua9001_reg_val { struct tua9001_reg_val {
u8 reg; u8 reg;
...@@ -27,6 +28,7 @@ struct tua9001_reg_val { ...@@ -27,6 +28,7 @@ struct tua9001_reg_val {
struct tua9001_dev { struct tua9001_dev {
struct dvb_frontend *fe; struct dvb_frontend *fe;
struct i2c_client *client; struct i2c_client *client;
struct regmap *regmap;
}; };
#endif #endif
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