Commit 1e251013 authored by Akihiro Tsukada's avatar Akihiro Tsukada Committed by Mauro Carvalho Chehab

media: media/dvb: earth-pt3: use the new i2c binding helper

This patch slightly simplifies the binding code by introducing commit
8f569c0b ("media: dvb-core: add helper functions for I2C binding").
Signed-off-by: default avatarAkihiro Tsukada <tskd08@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5b1a270d
...@@ -376,25 +376,22 @@ static int pt3_fe_init(struct pt3_board *pt3) ...@@ -376,25 +376,22 @@ static int pt3_fe_init(struct pt3_board *pt3)
static int pt3_attach_fe(struct pt3_board *pt3, int i) static int pt3_attach_fe(struct pt3_board *pt3, int i)
{ {
struct i2c_board_info info; const struct i2c_board_info *info;
struct tc90522_config cfg; struct tc90522_config cfg;
struct i2c_client *cl; struct i2c_client *cl;
struct dvb_adapter *dvb_adap; struct dvb_adapter *dvb_adap;
int ret; int ret;
info = adap_conf[i].demod_info; info = &adap_conf[i].demod_info;
cfg = adap_conf[i].demod_cfg; cfg = adap_conf[i].demod_cfg;
cfg.tuner_i2c = NULL; cfg.tuner_i2c = NULL;
info.platform_data = &cfg;
ret = -ENODEV; ret = -ENODEV;
request_module("tc90522"); cl = dvb_module_probe("tc90522", info->type, &pt3->i2c_adap,
cl = i2c_new_device(&pt3->i2c_adap, &info); info->addr, &cfg);
if (!cl || !cl->dev.driver) if (!cl)
return -ENODEV; return -ENODEV;
pt3->adaps[i]->i2c_demod = cl; pt3->adaps[i]->i2c_demod = cl;
if (!try_module_get(cl->dev.driver->owner))
goto err_demod_i2c_unregister_device;
if (!strncmp(cl->name, TC90522_I2C_DEV_SAT, if (!strncmp(cl->name, TC90522_I2C_DEV_SAT,
strlen(TC90522_I2C_DEV_SAT))) { strlen(TC90522_I2C_DEV_SAT))) {
...@@ -402,41 +399,33 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i) ...@@ -402,41 +399,33 @@ static int pt3_attach_fe(struct pt3_board *pt3, int i)
tcfg = adap_conf[i].tuner_cfg.qm1d1c0042; tcfg = adap_conf[i].tuner_cfg.qm1d1c0042;
tcfg.fe = cfg.fe; tcfg.fe = cfg.fe;
info = adap_conf[i].tuner_info; info = &adap_conf[i].tuner_info;
info.platform_data = &tcfg; cl = dvb_module_probe("qm1d1c0042", info->type, cfg.tuner_i2c,
request_module("qm1d1c0042"); info->addr, &tcfg);
cl = i2c_new_device(cfg.tuner_i2c, &info);
} else { } else {
struct mxl301rf_config tcfg; struct mxl301rf_config tcfg;
tcfg = adap_conf[i].tuner_cfg.mxl301rf; tcfg = adap_conf[i].tuner_cfg.mxl301rf;
tcfg.fe = cfg.fe; tcfg.fe = cfg.fe;
info = adap_conf[i].tuner_info; info = &adap_conf[i].tuner_info;
info.platform_data = &tcfg; cl = dvb_module_probe("mxl301rf", info->type, cfg.tuner_i2c,
request_module("mxl301rf"); info->addr, &tcfg);
cl = i2c_new_device(cfg.tuner_i2c, &info);
} }
if (!cl || !cl->dev.driver) if (!cl)
goto err_demod_module_put; goto err_demod_module_release;
pt3->adaps[i]->i2c_tuner = cl; pt3->adaps[i]->i2c_tuner = cl;
if (!try_module_get(cl->dev.driver->owner))
goto err_tuner_i2c_unregister_device;
dvb_adap = &pt3->adaps[one_adapter ? 0 : i]->dvb_adap; dvb_adap = &pt3->adaps[one_adapter ? 0 : i]->dvb_adap;
ret = dvb_register_frontend(dvb_adap, cfg.fe); ret = dvb_register_frontend(dvb_adap, cfg.fe);
if (ret < 0) if (ret < 0)
goto err_tuner_module_put; goto err_tuner_module_release;
pt3->adaps[i]->fe = cfg.fe; pt3->adaps[i]->fe = cfg.fe;
return 0; return 0;
err_tuner_module_put: err_tuner_module_release:
module_put(pt3->adaps[i]->i2c_tuner->dev.driver->owner); dvb_module_release(pt3->adaps[i]->i2c_tuner);
err_tuner_i2c_unregister_device: err_demod_module_release:
i2c_unregister_device(pt3->adaps[i]->i2c_tuner); dvb_module_release(pt3->adaps[i]->i2c_demod);
err_demod_module_put:
module_put(pt3->adaps[i]->i2c_demod->dev.driver->owner);
err_demod_i2c_unregister_device:
i2c_unregister_device(pt3->adaps[i]->i2c_demod);
return ret; return ret;
} }
...@@ -630,14 +619,10 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index) ...@@ -630,14 +619,10 @@ static void pt3_cleanup_adapter(struct pt3_board *pt3, int index)
adap->fe->callback = NULL; adap->fe->callback = NULL;
if (adap->fe->frontend_priv) if (adap->fe->frontend_priv)
dvb_unregister_frontend(adap->fe); dvb_unregister_frontend(adap->fe);
if (adap->i2c_tuner) { if (adap->i2c_tuner)
module_put(adap->i2c_tuner->dev.driver->owner); dvb_module_release(adap->i2c_tuner);
i2c_unregister_device(adap->i2c_tuner); if (adap->i2c_demod)
} dvb_module_release(adap->i2c_demod);
if (adap->i2c_demod) {
module_put(adap->i2c_demod->dev.driver->owner);
i2c_unregister_device(adap->i2c_demod);
}
} }
pt3_free_dmabuf(adap); pt3_free_dmabuf(adap);
dvb_dmxdev_release(&adap->dmxdev); dvb_dmxdev_release(&adap->dmxdev);
......
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