Commit ad32495b authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: em28xx-dvb: simplify DVB module probing logic

The module probing logic there is a way more complex than
it should be, and requires some special magic to avoid
stack overflows when KASAN is enabled.

Solve it by creating ancillary functions to setup the
platform data and request module.

Now, the probing functions are cleaner and easier to understand.

As a side effect, the size of the module was reduced by
about 9.7% on x86_64:

Before this patch:
   text	   data	    bss	    dec	    hex	filename
  51090	  14192	     96	  65378	   ff62	drivers/media/usb/em28xx/em28xx-dvb.o

After this patch:
   text	   data	    bss	    dec	    hex	filename
  44743	  14192	     96	  59031	   e697	drivers/media/usb/em28xx/em28xx-dvb.o

Tested with a PCTV 461e device.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 8f569c0b
...@@ -1124,76 +1124,48 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb) ...@@ -1124,76 +1124,48 @@ static void em28xx_unregister_dvb(struct em28xx_dvb *dvb)
dvb_unregister_adapter(&dvb->adapter); dvb_unregister_adapter(&dvb->adapter);
} }
static noinline_for_stack int em28174_dvb_init_pctv_460e(struct em28xx *dev) static int em28174_dvb_init_pctv_460e(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_client *client;
struct i2c_board_info board_info;
struct tda10071_platform_data tda10071_pdata = {}; struct tda10071_platform_data tda10071_pdata = {};
struct a8293_platform_data a8293_pdata = {}; struct a8293_platform_data a8293_pdata = {};
int result;
/* attach demod + tuner combo */ /* attach demod + tuner combo */
tda10071_pdata.clk = 40444000, /* 40.444 MHz */ tda10071_pdata.clk = 40444000; /* 40.444 MHz */
tda10071_pdata.i2c_wr_max = 64, tda10071_pdata.i2c_wr_max = 64;
tda10071_pdata.ts_mode = TDA10071_TS_SERIAL, tda10071_pdata.ts_mode = TDA10071_TS_SERIAL;
tda10071_pdata.pll_multiplier = 20, tda10071_pdata.pll_multiplier = 20;
tda10071_pdata.tuner_i2c_addr = 0x14, tda10071_pdata.tuner_i2c_addr = 0x14;
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "tda10071_cx24118", I2C_NAME_SIZE); dvb->i2c_client_demod = dvb_module_probe("tda10071", "tda10071_cx24118",
board_info.addr = 0x55; &dev->i2c_adap[dev->def_i2c_bus],
board_info.platform_data = &tda10071_pdata; 0x55, &tda10071_pdata);
request_module("tda10071"); if (!dvb->i2c_client_demod)
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); return -ENODEV;
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV; dvb->fe[0] = tda10071_pdata.get_dvb_frontend(dvb->i2c_client_demod);
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}
dvb->fe[0] = tda10071_pdata.get_dvb_frontend(client);
dvb->i2c_client_demod = client;
/* attach SEC */ /* attach SEC */
a8293_pdata.dvb_frontend = dvb->fe[0]; a8293_pdata.dvb_frontend = dvb->fe[0];
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); dvb->i2c_client_sec = dvb_module_probe("a8293", NULL,
board_info.addr = 0x08; &dev->i2c_adap[dev->def_i2c_bus],
board_info.platform_data = &a8293_pdata; 0x08, &a8293_pdata);
request_module("a8293"); if (!dvb->i2c_client_sec) {
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); dvb_module_release(dvb->i2c_client_demod);
if (client == NULL || client->dev.driver == NULL) { return -ENODEV;
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_sec = client;
result = 0; return 0;
out_free:
return result;
} }
static noinline_for_stack int em28178_dvb_init_pctv_461e(struct em28xx *dev) static int em28178_dvb_init_pctv_461e(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_client *client;
struct i2c_adapter *i2c_adapter; struct i2c_adapter *i2c_adapter;
struct i2c_board_info board_info;
struct m88ds3103_platform_data m88ds3103_pdata = {}; struct m88ds3103_platform_data m88ds3103_pdata = {};
struct ts2020_config ts2020_config = {}; struct ts2020_config ts2020_config = {};
struct a8293_platform_data a8293_pdata = {}; struct a8293_platform_data a8293_pdata = {};
int result;
/* attach demod */ /* attach demod */
m88ds3103_pdata.clk = 27000000; m88ds3103_pdata.clk = 27000000;
...@@ -1202,184 +1174,98 @@ static noinline_for_stack int em28178_dvb_init_pctv_461e(struct em28xx *dev) ...@@ -1202,184 +1174,98 @@ static noinline_for_stack int em28178_dvb_init_pctv_461e(struct em28xx *dev)
m88ds3103_pdata.ts_clk = 16000; m88ds3103_pdata.ts_clk = 16000;
m88ds3103_pdata.ts_clk_pol = 1; m88ds3103_pdata.ts_clk_pol = 1;
m88ds3103_pdata.agc = 0x99; m88ds3103_pdata.agc = 0x99;
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "m88ds3103", I2C_NAME_SIZE); dvb->i2c_client_demod = dvb_module_probe("m88ds3103", NULL,
board_info.addr = 0x68; &dev->i2c_adap[dev->def_i2c_bus],
board_info.platform_data = &m88ds3103_pdata; 0x68, &m88ds3103_pdata);
request_module("m88ds3103"); if (!dvb->i2c_client_demod)
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); return -ENODEV;
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV; dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(dvb->i2c_client_demod);
goto out_free; i2c_adapter = m88ds3103_pdata.get_i2c_adapter(dvb->i2c_client_demod);
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}
dvb->fe[0] = m88ds3103_pdata.get_dvb_frontend(client);
i2c_adapter = m88ds3103_pdata.get_i2c_adapter(client);
dvb->i2c_client_demod = client;
/* attach tuner */ /* attach tuner */
ts2020_config.fe = dvb->fe[0]; ts2020_config.fe = dvb->fe[0];
memset(&board_info, 0, sizeof(board_info));
strlcpy(board_info.type, "ts2022", I2C_NAME_SIZE); dvb->i2c_client_tuner = dvb_module_probe("ts2020", "ts2022",
board_info.addr = 0x60; i2c_adapter,
board_info.platform_data = &ts2020_config; 0x60, &ts2020_config);
request_module("ts2020"); if (!dvb->i2c_client_tuner) {
client = i2c_new_device(i2c_adapter, &board_info); dvb_module_release(dvb->i2c_client_demod);
if (client == NULL || client->dev.driver == NULL) { return -ENODEV;
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_tuner = client;
/* delegate signal strength measurement to tuner */ /* delegate signal strength measurement to tuner */
dvb->fe[0]->ops.read_signal_strength = dvb->fe[0]->ops.read_signal_strength =
dvb->fe[0]->ops.tuner_ops.get_rf_strength; dvb->fe[0]->ops.tuner_ops.get_rf_strength;
/* attach SEC */ /* attach SEC */
a8293_pdata.dvb_frontend = dvb->fe[0]; a8293_pdata.dvb_frontend = dvb->fe[0];
memset(&board_info, 0, sizeof(board_info)); dvb->i2c_client_sec = dvb_module_probe("a8293", NULL,
strlcpy(board_info.type, "a8293", I2C_NAME_SIZE); &dev->i2c_adap[dev->def_i2c_bus],
board_info.addr = 0x08; 0x08, &a8293_pdata);
board_info.platform_data = &a8293_pdata; if (!dvb->i2c_client_sec) {
request_module("a8293"); dvb_module_release(dvb->i2c_client_tuner);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &board_info); dvb_module_release(dvb->i2c_client_demod);
if (client == NULL || client->dev.driver == NULL) { return -ENODEV;
module_put(dvb->i2c_client_tuner->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_tuner);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_tuner->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_tuner);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_sec = client;
result = 0; return 0;
out_free:
return result;
} }
static noinline_for_stack int em28178_dvb_init_pctv_292e(struct em28xx *dev) static int em28178_dvb_init_pctv_292e(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_client *client; struct si2168_config si2168_config = {};
struct i2c_board_info info; struct si2157_config si2157_config = {};
struct si2168_config si2168_config;
struct si2157_config si2157_config;
int result;
/* attach demod */ /* attach demod */
memset(&si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = &adapter; si2168_config.i2c_adapter = &adapter;
si2168_config.fe = &dvb->fe[0]; si2168_config.fe = &dvb->fe[0];
si2168_config.ts_mode = SI2168_TS_PARALLEL; si2168_config.ts_mode = SI2168_TS_PARALLEL;
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2168", I2C_NAME_SIZE);
info.addr = 0x64;
info.platform_data = &si2168_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) { dvb->i2c_client_demod = dvb_module_probe("si2168", NULL,
i2c_unregister_device(client); &dev->i2c_adap[dev->def_i2c_bus],
result = -ENODEV; 0x64, &si2168_config);
goto out_free; if (!dvb->i2c_client_demod)
} return -ENODEV;
dvb->i2c_client_demod = client;
/* attach tuner */ /* attach tuner */
memset(&si2157_config, 0, sizeof(si2157_config));
si2157_config.fe = dvb->fe[0]; si2157_config.fe = dvb->fe[0];
si2157_config.if_port = 1; si2157_config.if_port = 1;
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
si2157_config.mdev = dev->media_dev; si2157_config.mdev = dev->media_dev;
#endif #endif
memset(&info, 0, sizeof(struct i2c_board_info)); dvb->i2c_client_tuner = dvb_module_probe("si2157", NULL,
strlcpy(info.type, "si2157", I2C_NAME_SIZE); adapter,
info.addr = 0x60; 0x60, &si2157_config);
info.platform_data = &si2157_config; if (!dvb->i2c_client_tuner) {
request_module(info.type); dvb_module_release(dvb->i2c_client_demod);
client = i2c_new_device(adapter, &info); return -ENODEV;
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_tuner = client;
dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna; dvb->fe[0]->ops.set_lna = em28xx_pctv_292e_set_lna;
result = 0;
out_free: return 0;
return result;
} }
static noinline_for_stack int em28178_dvb_init_terratec_t2_stick_hd(struct em28xx *dev) static int em28178_dvb_init_terratec_t2_stick_hd(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_client *client; struct si2168_config si2168_config = {};
struct i2c_board_info info; struct si2157_config si2157_config = {};
struct si2168_config si2168_config;
struct si2157_config si2157_config;
int result;
/* attach demod */ /* attach demod */
memset(&si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = &adapter; si2168_config.i2c_adapter = &adapter;
si2168_config.fe = &dvb->fe[0]; si2168_config.fe = &dvb->fe[0];
si2168_config.ts_mode = SI2168_TS_PARALLEL; si2168_config.ts_mode = SI2168_TS_PARALLEL;
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "si2168", I2C_NAME_SIZE);
info.addr = 0x64;
info.platform_data = &si2168_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) { dvb->i2c_client_demod = dvb_module_probe("si2168", NULL,
i2c_unregister_device(client); &dev->i2c_adap[dev->def_i2c_bus],
result = -ENODEV; 0x64, &si2168_config);
goto out_free; if (!dvb->i2c_client_demod)
} return -ENODEV;
dvb->i2c_client_demod = client;
/* attach tuner */ /* attach tuner */
memset(&si2157_config, 0, sizeof(si2157_config)); memset(&si2157_config, 0, sizeof(si2157_config));
...@@ -1388,130 +1274,67 @@ static noinline_for_stack int em28178_dvb_init_terratec_t2_stick_hd(struct em28x ...@@ -1388,130 +1274,67 @@ static noinline_for_stack int em28178_dvb_init_terratec_t2_stick_hd(struct em28x
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
si2157_config.mdev = dev->media_dev; si2157_config.mdev = dev->media_dev;
#endif #endif
memset(&info, 0, sizeof(struct i2c_board_info)); dvb->i2c_client_tuner = dvb_module_probe("si2157", "si2146",
strlcpy(info.type, "si2146", I2C_NAME_SIZE); adapter,
info.addr = 0x60; 0x60, &si2157_config);
info.platform_data = &si2157_config; if (!dvb->i2c_client_tuner) {
request_module("si2157"); dvb_module_release(dvb->i2c_client_demod);
client = i2c_new_device(adapter, &info); return -ENODEV;
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_tuner = client; return 0;
result = 0;
out_free:
return result;
} }
static noinline_for_stack int em28178_dvb_init_plex_px_bcud(struct em28xx *dev) static int em28178_dvb_init_plex_px_bcud(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_client *client; struct tc90522_config tc90522_config = {};
struct i2c_board_info info; struct qm1d1c0042_config qm1d1c0042_config = {};
struct tc90522_config tc90522_config;
struct qm1d1c0042_config qm1d1c0042_config;
int result;
/* attach demod */ /* attach demod */
memset(&tc90522_config, 0, sizeof(tc90522_config)); dvb->i2c_client_demod = dvb_module_probe("tc90522", "tc90522sat",
memset(&info, 0, sizeof(struct i2c_board_info)); &dev->i2c_adap[dev->def_i2c_bus],
strlcpy(info.type, "tc90522sat", I2C_NAME_SIZE); 0x15, &tc90522_config);
info.addr = 0x15; if (!dvb->i2c_client_demod)
info.platform_data = &tc90522_config; return -ENODEV;
request_module("tc90522");
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV;
goto out_free;
}
dvb->i2c_client_demod = client;
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}
/* attach tuner */ /* attach tuner */
memset(&qm1d1c0042_config, 0,
sizeof(qm1d1c0042_config));
qm1d1c0042_config.fe = tc90522_config.fe; qm1d1c0042_config.fe = tc90522_config.fe;
qm1d1c0042_config.lpf = 1; qm1d1c0042_config.lpf = 1;
memset(&info, 0, sizeof(struct i2c_board_info));
strlcpy(info.type, "qm1d1c0042", I2C_NAME_SIZE); dvb->i2c_client_tuner = dvb_module_probe("qm1d1c0042", NULL,
info.addr = 0x61; tc90522_config.tuner_i2c,
info.platform_data = &qm1d1c0042_config; 0x61, &qm1d1c0042_config);
request_module(info.type); if (!dvb->i2c_client_tuner) {
client = i2c_new_device(tc90522_config.tuner_i2c, dvb_module_release(dvb->i2c_client_demod);
&info); return -ENODEV;
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
dvb->i2c_client_tuner = client;
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->fe[0] = tc90522_config.fe; dvb->fe[0] = tc90522_config.fe;
px_bcud_init(dev); px_bcud_init(dev);
result = 0;
out_free: return 0;
return result;
} }
static noinline_for_stack int em28174_dvb_init_hauppauge_wintv_dualhd_dvb(struct em28xx *dev) static int em28174_dvb_init_hauppauge_wintv_dualhd_dvb(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_client *client; struct si2168_config si2168_config = {};
struct i2c_board_info info; struct si2157_config si2157_config = {};
struct si2168_config si2168_config; unsigned char addr;
struct si2157_config si2157_config;
int result;
/* attach demod */ /* attach demod */
memset(&si2168_config, 0, sizeof(si2168_config));
si2168_config.i2c_adapter = &adapter; si2168_config.i2c_adapter = &adapter;
si2168_config.fe = &dvb->fe[0]; si2168_config.fe = &dvb->fe[0];
si2168_config.ts_mode = SI2168_TS_SERIAL; si2168_config.ts_mode = SI2168_TS_SERIAL;
memset(&info, 0, sizeof(struct i2c_board_info)); addr = (dev->ts == PRIMARY_TS) ? 0x64 : 0x67;
strlcpy(info.type, "si2168", I2C_NAME_SIZE);
if (dev->ts == PRIMARY_TS)
info.addr = 0x64;
else
info.addr = 0x67;
info.platform_data = &si2168_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus], &info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
result = -ENODEV;
goto out_free;
}
dvb->i2c_client_demod = client; dvb->i2c_client_demod = dvb_module_probe("si2168", NULL,
&dev->i2c_adap[dev->def_i2c_bus],
addr, &si2168_config);
if (!dvb->i2c_client_demod)
return -ENODEV;
/* attach tuner */ /* attach tuner */
memset(&si2157_config, 0, sizeof(si2157_config)); memset(&si2157_config, 0, sizeof(si2157_config));
...@@ -1520,71 +1343,38 @@ static noinline_for_stack int em28174_dvb_init_hauppauge_wintv_dualhd_dvb(struct ...@@ -1520,71 +1343,38 @@ static noinline_for_stack int em28174_dvb_init_hauppauge_wintv_dualhd_dvb(struct
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
si2157_config.mdev = dev->media_dev; si2157_config.mdev = dev->media_dev;
#endif #endif
memset(&info, 0, sizeof(struct i2c_board_info)); addr = (dev->ts == PRIMARY_TS) ? 0x60 : 0x63;
strlcpy(info.type, "si2157", I2C_NAME_SIZE);
if (dev->ts == PRIMARY_TS)
info.addr = 0x60;
else
info.addr = 0x63;
info.platform_data = &si2157_config;
request_module(info.type);
client = i2c_new_device(adapter, &info);
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) { dvb->i2c_client_tuner = dvb_module_probe("si2157", NULL,
i2c_unregister_device(client); adapter,
module_put(dvb->i2c_client_demod->dev.driver->owner); addr, &si2157_config);
i2c_unregister_device(dvb->i2c_client_demod); if (!dvb->i2c_client_tuner) {
result = -ENODEV; dvb_module_release(dvb->i2c_client_demod);
goto out_free; return -ENODEV;
} }
dvb->i2c_client_tuner = client; return 0;
result = 0;
out_free:
return result;
} }
static int em28174_dvb_init_hauppauge_wintv_dualhd_01595(struct em28xx *dev) static int em28174_dvb_init_hauppauge_wintv_dualhd_01595(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb = dev->dvb; struct em28xx_dvb *dvb = dev->dvb;
struct i2c_adapter *adapter; struct i2c_adapter *adapter;
struct i2c_client *client; struct lgdt3306a_config lgdt3306a_config = {};
struct i2c_board_info info = {};
struct lgdt3306a_config lgdt3306a_config;
struct si2157_config si2157_config = {}; struct si2157_config si2157_config = {};
int result; unsigned char addr;
/* attach demod */ /* attach demod */
lgdt3306a_config = hauppauge_01595_lgdt3306a_config; lgdt3306a_config = hauppauge_01595_lgdt3306a_config;
lgdt3306a_config.fe = &dvb->fe[0]; lgdt3306a_config.fe = &dvb->fe[0];
lgdt3306a_config.i2c_adapter = &adapter; lgdt3306a_config.i2c_adapter = &adapter;
strlcpy(info.type, "lgdt3306a", sizeof(info.type)); addr = (dev->ts == PRIMARY_TS) ? 0x59 : 0x0e;
if (dev->ts == PRIMARY_TS)
info.addr = 0x59;
else
info.addr = 0x0e;
info.platform_data = &lgdt3306a_config;
request_module(info.type);
client = i2c_new_device(&dev->i2c_adap[dev->def_i2c_bus],
&info);
if (client == NULL || client->dev.driver == NULL) {
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) { dvb->i2c_client_demod = dvb_module_probe("lgdt3306a", NULL,
i2c_unregister_device(client); &dev->i2c_adap[dev->def_i2c_bus],
result = -ENODEV; addr, &lgdt3306a_config);
goto out_free; if (!dvb->i2c_client_demod)
} return -ENODEV;
dvb->i2c_client_demod = client;
/* attach tuner */ /* attach tuner */
si2157_config.fe = dvb->fe[0]; si2157_config.fe = dvb->fe[0];
...@@ -1593,35 +1383,19 @@ static int em28174_dvb_init_hauppauge_wintv_dualhd_01595(struct em28xx *dev) ...@@ -1593,35 +1383,19 @@ static int em28174_dvb_init_hauppauge_wintv_dualhd_01595(struct em28xx *dev)
#ifdef CONFIG_MEDIA_CONTROLLER_DVB #ifdef CONFIG_MEDIA_CONTROLLER_DVB
si2157_config.mdev = dev->media_dev; si2157_config.mdev = dev->media_dev;
#endif #endif
memset(&info, 0, sizeof(struct i2c_board_info)); addr = (dev->ts == PRIMARY_TS) ? 0x60 : 0x62;
strlcpy(info.type, "si2157", sizeof(info.type));
if (dev->ts == PRIMARY_TS) dvb->i2c_client_tuner = dvb_module_probe("si2157", NULL,
info.addr = 0x60; adapter,
else 0x60, &si2157_config);
info.addr = 0x62; if (!dvb->i2c_client_tuner) {
info.platform_data = &si2157_config; dvb_module_release(dvb->i2c_client_demod);
request_module(info.type); return -ENODEV;
client = i2c_new_device(adapter, &info);
if (client == NULL || client->dev.driver == NULL) {
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) {
i2c_unregister_device(client);
module_put(dvb->i2c_client_demod->dev.driver->owner);
i2c_unregister_device(dvb->i2c_client_demod);
result = -ENODEV;
goto out_free;
} }
dvb->i2c_client_tuner = client; return 0;
result = 0;
out_free:
return result;
} }
static int em28xx_dvb_init(struct em28xx *dev) static int em28xx_dvb_init(struct em28xx *dev)
{ {
int result = 0, dvb_alt = 0; int result = 0, dvb_alt = 0;
...@@ -1857,7 +1631,7 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -1857,7 +1631,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
break; break;
case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C: case EM2884_BOARD_HAUPPAUGE_WINTV_HVR_930C:
{ {
struct xc5000_config cfg; struct xc5000_config cfg = {};
hauppauge_hvr930c_init(dev); hauppauge_hvr930c_init(dev);
...@@ -1874,7 +1648,6 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -1874,7 +1648,6 @@ static int em28xx_dvb_init(struct em28xx *dev)
dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl; dvb->fe[0]->ops.i2c_gate_ctrl = drxk_gate_ctrl;
/* Attach xc5000 */ /* Attach xc5000 */
memset(&cfg, 0, sizeof(cfg));
cfg.i2c_address = 0x61; cfg.i2c_address = 0x61;
cfg.if_khz = 4000; cfg.if_khz = 4000;
...@@ -2027,13 +1800,7 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -2027,13 +1800,7 @@ static int em28xx_dvb_init(struct em28xx *dev)
break; break;
case EM2874_BOARD_KWORLD_UB435Q_V3: case EM2874_BOARD_KWORLD_UB435Q_V3:
{ {
struct i2c_client *client;
struct i2c_adapter *adapter = &dev->i2c_adap[dev->def_i2c_bus]; struct i2c_adapter *adapter = &dev->i2c_adap[dev->def_i2c_bus];
struct i2c_board_info board_info = {
.type = "tda18212",
.addr = 0x60,
.platform_data = &kworld_ub435q_v3_config,
};
dvb->fe[0] = dvb_attach(lgdt3305_attach, dvb->fe[0] = dvb_attach(lgdt3305_attach,
&em2874_lgdt3305_nogate_dev, &em2874_lgdt3305_nogate_dev,
...@@ -2045,22 +1812,16 @@ static int em28xx_dvb_init(struct em28xx *dev) ...@@ -2045,22 +1812,16 @@ static int em28xx_dvb_init(struct em28xx *dev)
/* attach tuner */ /* attach tuner */
kworld_ub435q_v3_config.fe = dvb->fe[0]; kworld_ub435q_v3_config.fe = dvb->fe[0];
request_module("tda18212");
client = i2c_new_device(adapter, &board_info);
if (client == NULL || client->dev.driver == NULL) {
dvb_frontend_detach(dvb->fe[0]);
result = -ENODEV;
goto out_free;
}
if (!try_module_get(client->dev.driver->owner)) { dvb->i2c_client_tuner = dvb_module_probe("tda18212", NULL,
i2c_unregister_device(client); adapter,
0x60,
&kworld_ub435q_v3_config);
if (!dvb->i2c_client_tuner) {
dvb_frontend_detach(dvb->fe[0]); dvb_frontend_detach(dvb->fe[0]);
result = -ENODEV; result = -ENODEV;
goto out_free; goto out_free;
} }
dvb->i2c_client_tuner = client;
break; break;
} }
case EM2874_BOARD_PCTV_HD_MINI_80E: case EM2874_BOARD_PCTV_HD_MINI_80E:
...@@ -2159,7 +1920,6 @@ static inline void prevent_sleep(struct dvb_frontend_ops *ops) ...@@ -2159,7 +1920,6 @@ static inline void prevent_sleep(struct dvb_frontend_ops *ops)
static int em28xx_dvb_fini(struct em28xx *dev) static int em28xx_dvb_fini(struct em28xx *dev)
{ {
struct em28xx_dvb *dvb; struct em28xx_dvb *dvb;
struct i2c_client *client;
if (dev->is_audio_only) { if (dev->is_audio_only) {
/* Shouldn't initialize IR for this interface */ /* Shouldn't initialize IR for this interface */
...@@ -2195,26 +1955,10 @@ static int em28xx_dvb_fini(struct em28xx *dev) ...@@ -2195,26 +1955,10 @@ static int em28xx_dvb_fini(struct em28xx *dev)
em28xx_unregister_dvb(dvb); em28xx_unregister_dvb(dvb);
/* remove I2C SEC */ /* release I2C module bindings */
client = dvb->i2c_client_sec; dvb_module_release(dvb->i2c_client_sec);
if (client) { dvb_module_release(dvb->i2c_client_tuner);
module_put(client->dev.driver->owner); dvb_module_release(dvb->i2c_client_demod);
i2c_unregister_device(client);
}
/* remove I2C tuner */
client = dvb->i2c_client_tuner;
if (client) {
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
/* remove I2C demod */
client = dvb->i2c_client_demod;
if (client) {
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
kfree(dvb); kfree(dvb);
dev->dvb = NULL; dev->dvb = NULL;
......
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