Commit e6574f2f authored by Hans Verkuil's avatar Hans Verkuil Committed by Mauro Carvalho Chehab

V4L/DVB (11373): v4l2-common: add explicit v4l2_device pointer as first arg to new_(probed)_subdev

The functions v4l2_i2c_new_subdev and v4l2_i2c_new_probed_subdev relied on
i2c_get_adapdata to return the v4l2_device. However, this is not always
possible on embedded platforms. So modify the API to pass the v4l2_device
pointer explicitly.
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 868f985c
...@@ -364,14 +364,12 @@ from the remove() callback ensures that this is always done correctly. ...@@ -364,14 +364,12 @@ from the remove() callback ensures that this is always done correctly.
The bridge driver also has some helper functions it can use: The bridge driver also has some helper functions it can use:
struct v4l2_subdev *sd = v4l2_i2c_new_subdev(adapter, "module_foo", "chipid", 0x36); struct v4l2_subdev *sd = v4l2_i2c_new_subdev(v4l2_dev, adapter,
"module_foo", "chipid", 0x36);
This loads the given module (can be NULL if no module needs to be loaded) and This loads the given module (can be NULL if no module needs to be loaded) and
calls i2c_new_device() with the given i2c_adapter and chip/address arguments. calls i2c_new_device() with the given i2c_adapter and chip/address arguments.
If all goes well, then it registers the subdev with the v4l2_device. It gets If all goes well, then it registers the subdev with the v4l2_device.
the v4l2_device by calling i2c_get_adapdata(adapter), so you should make sure
to call i2c_set_adapdata(adapter, v4l2_device) when you setup the i2c_adapter
in your driver.
You can also use v4l2_i2c_new_probed_subdev() which is very similar to You can also use v4l2_i2c_new_probed_subdev() which is very similar to
v4l2_i2c_new_subdev(), except that it has an array of possible I2C addresses v4l2_i2c_new_subdev(), except that it has an array of possible I2C addresses
......
...@@ -211,8 +211,8 @@ void au0828_card_setup(struct au0828_dev *dev) ...@@ -211,8 +211,8 @@ void au0828_card_setup(struct au0828_dev *dev)
/* Load the analog demodulator driver (note this would need to /* Load the analog demodulator driver (note this would need to
be abstracted out if we ever need to support a different be abstracted out if we ever need to support a different
demod) */ demod) */
sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "au8522", "au8522", sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
0x8e >> 1); "au8522", "au8522", 0x8e >> 1);
if (sd == NULL) if (sd == NULL)
printk(KERN_ERR "analog subdev registration failed\n"); printk(KERN_ERR "analog subdev registration failed\n");
} }
...@@ -220,8 +220,8 @@ void au0828_card_setup(struct au0828_dev *dev) ...@@ -220,8 +220,8 @@ void au0828_card_setup(struct au0828_dev *dev)
/* Setup tuners */ /* Setup tuners */
if (dev->board.tuner_type != TUNER_ABSENT) { if (dev->board.tuner_type != TUNER_ABSENT) {
/* Load the tuner module, which does the attach */ /* Load the tuner module, which does the attach */
sd = v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner", sd = v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
dev->board.tuner_addr); "tuner", "tuner", dev->board.tuner_addr);
if (sd == NULL) if (sd == NULL)
printk(KERN_ERR "tuner subdev registration fail\n"); printk(KERN_ERR "tuner subdev registration fail\n");
......
...@@ -3512,12 +3512,15 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3512,12 +3512,15 @@ void __devinit bttv_init_card2(struct bttv *btv)
/* Load tuner module before issuing tuner config call! */ /* Load tuner module before issuing tuner config call! */
if (bttv_tvcards[btv->c.type].has_radio) if (bttv_tvcards[btv->c.type].has_radio)
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO)); &btv->c.i2c_adap, "tuner", "tuner",
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner", v4l2_i2c_tuner_addrs(ADDRS_RADIO));
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, "tuner", &btv->c.i2c_adap, "tuner", "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD)); v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
&btv->c.i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_TV_WITH_DEMOD));
tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV; tun_setup.mode_mask = T_ANALOG_TV | T_DIGITAL_TV;
tun_setup.type = btv->tuner_type; tun_setup.type = btv->tuner_type;
...@@ -3570,8 +3573,8 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3570,8 +3573,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
}; };
struct v4l2_subdev *sd; struct v4l2_subdev *sd;
sd = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, sd = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"saa6588", "saa6588", addrs); &btv->c.i2c_adap, "saa6588", "saa6588", addrs);
btv->has_saa6588 = (sd != NULL); btv->has_saa6588 = (sd != NULL);
} }
...@@ -3595,8 +3598,8 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3595,8 +3598,8 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END I2C_CLIENT_END
}; };
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"msp3400", "msp3400", addrs); &btv->c.i2c_adap, "msp3400", "msp3400", addrs);
if (btv->sd_msp34xx) if (btv->sd_msp34xx)
return; return;
goto no_audio; goto no_audio;
...@@ -3609,16 +3612,16 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3609,16 +3612,16 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END I2C_CLIENT_END
}; };
if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"tda7432", "tda7432", addrs)) &btv->c.i2c_adap, "tda7432", "tda7432", addrs))
return; return;
goto no_audio; goto no_audio;
} }
case 3: { case 3: {
/* The user specified that we should probe for tvaudio */ /* The user specified that we should probe for tvaudio */
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"tvaudio", "tvaudio", tvaudio_addrs); &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs);
if (btv->sd_tvaudio) if (btv->sd_tvaudio)
return; return;
goto no_audio; goto no_audio;
...@@ -3642,16 +3645,16 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3642,16 +3645,16 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END I2C_CLIENT_END
}; };
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"msp3400", "msp3400", addrs); &btv->c.i2c_adap, "msp3400", "msp3400", addrs);
} else if (bttv_tvcards[btv->c.type].msp34xx_alt) { } else if (bttv_tvcards[btv->c.type].msp34xx_alt) {
static const unsigned short addrs[] = { static const unsigned short addrs[] = {
I2C_ADDR_MSP3400_ALT >> 1, I2C_ADDR_MSP3400_ALT >> 1,
I2C_CLIENT_END I2C_CLIENT_END
}; };
btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, btv->sd_msp34xx = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"msp3400", "msp3400", addrs); &btv->c.i2c_adap, "msp3400", "msp3400", addrs);
} }
/* If we found a msp34xx, then we're done. */ /* If we found a msp34xx, then we're done. */
...@@ -3665,14 +3668,14 @@ void __devinit bttv_init_card2(struct bttv *btv) ...@@ -3665,14 +3668,14 @@ void __devinit bttv_init_card2(struct bttv *btv)
I2C_CLIENT_END I2C_CLIENT_END
}; };
if (v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, if (v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"tda7432", "tda7432", addrs)) &btv->c.i2c_adap, "tda7432", "tda7432", addrs))
return; return;
} }
/* Now see if we can find one of the tvaudio devices. */ /* Now see if we can find one of the tvaudio devices. */
btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.i2c_adap, btv->sd_tvaudio = v4l2_i2c_new_probed_subdev(&btv->c.v4l2_dev,
"tvaudio", "tvaudio", tvaudio_addrs); &btv->c.i2c_adap, "tvaudio", "tvaudio", tvaudio_addrs);
if (btv->sd_tvaudio) if (btv->sd_tvaudio)
return; return;
......
...@@ -1954,7 +1954,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, ...@@ -1954,7 +1954,7 @@ static int cafe_pci_probe(struct pci_dev *pdev,
goto out_freeirq; goto out_freeirq;
cam->sensor_addr = 0x42; cam->sensor_addr = 0x42;
cam->sensor = v4l2_i2c_new_subdev(&cam->i2c_adapter, cam->sensor = v4l2_i2c_new_subdev(&cam->v4l2_dev, &cam->i2c_adapter,
"ov7670", "ov7670", cam->sensor_addr); "ov7670", "ov7670", cam->sensor_addr);
if (cam->sensor == NULL) { if (cam->sensor == NULL) {
ret = -ENODEV; ret = -ENODEV;
......
...@@ -100,16 +100,16 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx) ...@@ -100,16 +100,16 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
if (hw == CX18_HW_TUNER) { if (hw == CX18_HW_TUNER) {
/* special tuner group handling */ /* special tuner group handling */
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
cx->card_i2c->radio); adap, mod, type, cx->card_i2c->radio);
if (sd != NULL) if (sd != NULL)
sd->grp_id = hw; sd->grp_id = hw;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
cx->card_i2c->demod); adap, mod, type, cx->card_i2c->demod);
if (sd != NULL) if (sd != NULL)
sd->grp_id = hw; sd->grp_id = hw;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&cx->v4l2_dev,
cx->card_i2c->tv); adap, mod, type, cx->card_i2c->tv);
if (sd != NULL) if (sd != NULL)
sd->grp_id = hw; sd->grp_id = hw;
return sd != NULL ? 0 : -1; return sd != NULL ? 0 : -1;
...@@ -120,7 +120,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx) ...@@ -120,7 +120,7 @@ int cx18_i2c_register(struct cx18 *cx, unsigned idx)
return -1; return -1;
/* It's an I2C device other than an analog tuner */ /* It's an I2C device other than an analog tuner */
sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]); sd = v4l2_i2c_new_subdev(&cx->v4l2_dev, adap, mod, type, hw_addrs[idx]);
if (sd != NULL) if (sd != NULL)
sd->grp_id = hw; sd->grp_id = hw;
return sd != NULL ? 0 : -1; return sd != NULL ? 0 : -1;
......
...@@ -311,8 +311,8 @@ void cx231xx_card_setup(struct cx231xx *dev) ...@@ -311,8 +311,8 @@ void cx231xx_card_setup(struct cx231xx *dev)
/* request some modules */ /* request some modules */
if (dev->board.decoder == CX231XX_AVDECODER) { if (dev->board.decoder == CX231XX_AVDECODER) {
dev->sd_cx25840 = dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
v4l2_i2c_new_subdev(&dev->i2c_bus[0].i2c_adap, &dev->i2c_bus[0].i2c_adap,
"cx25840", "cx25840", 0x88 >> 1); "cx25840", "cx25840", 0x88 >> 1);
if (dev->sd_cx25840 == NULL) if (dev->sd_cx25840 == NULL)
cx231xx_info("cx25840 subdev registration failure\n"); cx231xx_info("cx25840 subdev registration failure\n");
...@@ -321,8 +321,8 @@ void cx231xx_card_setup(struct cx231xx *dev) ...@@ -321,8 +321,8 @@ void cx231xx_card_setup(struct cx231xx *dev)
} }
if (dev->board.tuner_type != TUNER_ABSENT) { if (dev->board.tuner_type != TUNER_ABSENT) {
dev->sd_tuner = dev->sd_tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev,
v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap, &dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", 0xc2 >> 1); "tuner", "tuner", 0xc2 >> 1);
if (dev->sd_tuner == NULL) if (dev->sd_tuner == NULL)
cx231xx_info("tuner subdev registration failure\n"); cx231xx_info("tuner subdev registration failure\n");
......
...@@ -739,7 +739,8 @@ void cx23885_card_setup(struct cx23885_dev *dev) ...@@ -739,7 +739,8 @@ void cx23885_card_setup(struct cx23885_dev *dev)
case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H: case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
case CX23885_BOARD_COMPRO_VIDEOMATE_E650F: case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->i2c_bus[2].i2c_adap, dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[2].i2c_adap,
"cx25840", "cx25840", 0x88 >> 1); "cx25840", "cx25840", 0x88 >> 1);
v4l2_subdev_call(dev->sd_cx25840, core, load_fw); v4l2_subdev_call(dev->sd_cx25840, core, load_fw);
break; break;
......
...@@ -1523,10 +1523,12 @@ int cx23885_video_register(struct cx23885_dev *dev) ...@@ -1523,10 +1523,12 @@ int cx23885_video_register(struct cx23885_dev *dev)
struct v4l2_subdev *sd = NULL; struct v4l2_subdev *sd = NULL;
if (dev->tuner_addr) if (dev->tuner_addr)
sd = v4l2_i2c_new_subdev(&dev->i2c_bus[1].i2c_adap, sd = v4l2_i2c_new_subdev(&dev->v4l2_dev,
&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", dev->tuner_addr); "tuner", "tuner", dev->tuner_addr);
else else
sd = v4l2_i2c_new_probed_subdev(&dev->i2c_bus[1].i2c_adap, sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
&dev->i2c_bus[1].i2c_adap,
"tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV)); "tuner", "tuner", v4l2_i2c_tuner_addrs(ADDRS_TV));
if (sd) { if (sd) {
struct tuner_setup tun_setup; struct tuner_setup tun_setup;
......
...@@ -3221,16 +3221,19 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr) ...@@ -3221,16 +3221,19 @@ struct cx88_core *cx88_core_create(struct pci_dev *pci, int nr)
The radio_type is sometimes missing, or set to UNSET but The radio_type is sometimes missing, or set to UNSET but
later code configures a tea5767. later code configures a tea5767.
*/ */
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", "tuner", v4l2_i2c_new_probed_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_RADIO)); v4l2_i2c_tuner_addrs(ADDRS_RADIO));
if (has_demod) if (has_demod)
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", v4l2_i2c_new_probed_subdev(&core->v4l2_dev,
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); &core->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
if (core->board.tuner_addr == ADDR_UNSET) { if (core->board.tuner_addr == ADDR_UNSET) {
v4l2_i2c_new_probed_subdev(&core->i2c_adap, "tuner", v4l2_i2c_new_probed_subdev(&core->v4l2_dev,
"tuner", has_demod ? tv_addrs + 4 : tv_addrs); &core->i2c_adap, "tuner", "tuner",
has_demod ? tv_addrs + 4 : tv_addrs);
} else { } else {
v4l2_i2c_new_subdev(&core->i2c_adap, v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"tuner", "tuner", core->board.tuner_addr); "tuner", "tuner", core->board.tuner_addr);
} }
} }
......
...@@ -1882,7 +1882,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1882,7 +1882,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
/* load and configure helper modules */ /* load and configure helper modules */
if (core->board.audio_chip == V4L2_IDENT_WM8775) if (core->board.audio_chip == V4L2_IDENT_WM8775)
v4l2_i2c_new_subdev(&core->i2c_adap, v4l2_i2c_new_subdev(&core->v4l2_dev, &core->i2c_adap,
"wm8775", "wm8775", 0x36 >> 1); "wm8775", "wm8775", 0x36 >> 1);
if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) { if (core->board.audio_chip == V4L2_IDENT_TVAUDIO) {
...@@ -1892,7 +1892,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev, ...@@ -1892,7 +1892,7 @@ static int __devinit cx8800_initdev(struct pci_dev *pci_dev,
0xb0 >> 1, I2C_CLIENT_END 0xb0 >> 1, I2C_CLIENT_END
}; };
v4l2_i2c_new_probed_subdev(&core->i2c_adap, v4l2_i2c_new_probed_subdev(&core->v4l2_dev, &core->i2c_adap,
"tvaudio", "tvaudio", i2c_addr); "tvaudio", "tvaudio", i2c_addr);
} }
......
...@@ -1958,44 +1958,46 @@ void em28xx_card_setup(struct em28xx *dev) ...@@ -1958,44 +1958,46 @@ void em28xx_card_setup(struct em28xx *dev)
/* request some modules */ /* request some modules */
if (dev->board.has_msp34xx) if (dev->board.has_msp34xx)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "msp3400", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"msp3400", msp3400_addrs); "msp3400", "msp3400", msp3400_addrs);
if (dev->board.decoder == EM28XX_SAA711X) if (dev->board.decoder == EM28XX_SAA711X)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa7115", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"saa7115_auto", saa711x_addrs); "saa7115", "saa7115_auto", saa711x_addrs);
if (dev->board.decoder == EM28XX_TVP5150) if (dev->board.decoder == EM28XX_TVP5150)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tvp5150", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tvp5150", tvp5150_addrs); "tvp5150", "tvp5150", tvp5150_addrs);
if (dev->board.adecoder == EM28XX_TVAUDIO) if (dev->board.adecoder == EM28XX_TVAUDIO)
v4l2_i2c_new_subdev(&dev->i2c_adap, "tvaudio", v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tvaudio", dev->board.tvaudio_addr); "tvaudio", "tvaudio", dev->board.tvaudio_addr);
if (dev->board.tuner_type != TUNER_ABSENT) { if (dev->board.tuner_type != TUNER_ABSENT) {
int has_demod = (dev->tda9887_conf & TDA9887_PRESENT); int has_demod = (dev->tda9887_conf & TDA9887_PRESENT);
if (dev->board.radio.type) if (dev->board.radio.type)
v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", "tuner", v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
dev->board.radio_addr); "tuner", "tuner", dev->board.radio_addr);
if (has_demod) if (has_demod)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); &dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
if (dev->tuner_addr == 0) { if (dev->tuner_addr == 0) {
enum v4l2_i2c_tuner_type type = enum v4l2_i2c_tuner_type type =
has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
struct v4l2_subdev *sd; struct v4l2_subdev *sd;
sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
"tuner", v4l2_i2c_tuner_addrs(type)); &dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(type));
if (sd) if (sd)
dev->tuner_addr = v4l2_i2c_subdev_addr(sd); dev->tuner_addr = v4l2_i2c_subdev_addr(sd);
} else { } else {
v4l2_i2c_new_subdev(&dev->i2c_adap, "tuner", v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"tuner", dev->tuner_addr); "tuner", "tuner", dev->tuner_addr);
} }
} }
......
...@@ -161,15 +161,18 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) ...@@ -161,15 +161,18 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
return -1; return -1;
if (hw == IVTV_HW_TUNER) { if (hw == IVTV_HW_TUNER) {
/* special tuner handling */ /* special tuner handling */
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->radio); itv->card_i2c->radio);
if (sd) if (sd)
sd->grp_id = 1 << idx; sd->grp_id = 1 << idx;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->demod); itv->card_i2c->demod);
if (sd) if (sd)
sd->grp_id = 1 << idx; sd->grp_id = 1 << idx;
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type,
itv->card_i2c->tv); itv->card_i2c->tv);
if (sd) if (sd)
sd->grp_id = 1 << idx; sd->grp_id = 1 << idx;
...@@ -180,9 +183,11 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx) ...@@ -180,9 +183,11 @@ int ivtv_i2c_register(struct ivtv *itv, unsigned idx)
if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) { if (hw == IVTV_HW_UPD64031A || hw == IVTV_HW_UPD6408X) {
unsigned short addrs[2] = { hw_addrs[idx], I2C_CLIENT_END }; unsigned short addrs[2] = { hw_addrs[idx], I2C_CLIENT_END };
sd = v4l2_i2c_new_probed_subdev(adap, mod, type, addrs); sd = v4l2_i2c_new_probed_subdev(&itv->v4l2_dev,
adap, mod, type, addrs);
} else { } else {
sd = v4l2_i2c_new_subdev(adap, mod, type, hw_addrs[idx]); sd = v4l2_i2c_new_subdev(&itv->v4l2_dev,
adap, mod, type, hw_addrs[idx]);
} }
if (sd) if (sd)
sd->grp_id = 1 << idx; sd->grp_id = 1 << idx;
......
...@@ -168,13 +168,20 @@ static int mxb_probe(struct saa7146_dev *dev) ...@@ -168,13 +168,20 @@ static int mxb_probe(struct saa7146_dev *dev)
return -EFAULT; return -EFAULT;
} }
mxb->saa7111a = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa7115", "saa7111", I2C_SAA7111A); mxb->saa7111a = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
mxb->tea6420_1 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_1); "saa7115", "saa7111", I2C_SAA7111A);
mxb->tea6420_2 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6420", "tea6420", I2C_TEA6420_2); mxb->tea6420_1 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
mxb->tea6415c = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tea6415c", "tea6415c", I2C_TEA6415C); "tea6420", "tea6420", I2C_TEA6420_1);
mxb->tda9840 = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tda9840", "tda9840", I2C_TDA9840); mxb->tea6420_2 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
mxb->tuner = v4l2_i2c_new_subdev(&mxb->i2c_adapter, "tuner", "tuner", I2C_TUNER); "tea6420", "tea6420", I2C_TEA6420_2);
if (v4l2_i2c_new_subdev(&mxb->i2c_adapter, "saa5246a", "saa5246a", I2C_SAA5246A)) { mxb->tea6415c = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
"tea6415c", "tea6415c", I2C_TEA6415C);
mxb->tda9840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
"tda9840", "tda9840", I2C_TDA9840);
mxb->tuner = v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
"tuner", "tuner", I2C_TUNER);
if (v4l2_i2c_new_subdev(&dev->v4l2_dev, &mxb->i2c_adapter,
"saa5246a", "saa5246a", I2C_SAA5246A)) {
printk(KERN_INFO "mxb: found teletext decoder\n"); printk(KERN_INFO "mxb: found teletext decoder\n");
} }
......
...@@ -2039,7 +2039,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, ...@@ -2039,7 +2039,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
"Module ID %u:" "Module ID %u:"
" Setting up with specified i2c address 0x%x", " Setting up with specified i2c address 0x%x",
mid, i2caddr[0]); mid, i2caddr[0]);
sd = v4l2_i2c_new_subdev(&hdw->i2c_adap, sd = v4l2_i2c_new_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
fname, fname, fname, fname,
i2caddr[0]); i2caddr[0]);
} else { } else {
...@@ -2047,7 +2047,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw, ...@@ -2047,7 +2047,7 @@ static int pvr2_hdw_load_subdev(struct pvr2_hdw *hdw,
"Module ID %u:" "Module ID %u:"
" Setting up with address probe list", " Setting up with address probe list",
mid); mid);
sd = v4l2_i2c_new_probed_subdev(&hdw->i2c_adap, sd = v4l2_i2c_new_probed_subdev(&hdw->v4l2_dev, &hdw->i2c_adap,
fname, fname, fname, fname,
i2caddr); i2caddr);
} }
......
...@@ -6599,20 +6599,24 @@ int saa7134_board_init2(struct saa7134_dev *dev) ...@@ -6599,20 +6599,24 @@ int saa7134_board_init2(struct saa7134_dev *dev)
/* Note: radio tuner address is always filled in, /* Note: radio tuner address is always filled in,
so we do not need to probe for a radio tuner device. */ so we do not need to probe for a radio tuner device. */
if (dev->radio_type != UNSET) if (dev->radio_type != UNSET)
v4l2_i2c_new_subdev(&dev->i2c_adap, v4l2_i2c_new_subdev(&dev->v4l2_dev,
"tuner", "tuner", dev->radio_addr); &dev->i2c_adap, "tuner", "tuner",
dev->radio_addr);
if (has_demod) if (has_demod)
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); &dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
if (dev->tuner_addr == ADDR_UNSET) { if (dev->tuner_addr == ADDR_UNSET) {
enum v4l2_i2c_tuner_type type = enum v4l2_i2c_tuner_type type =
has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; has_demod ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "tuner", v4l2_i2c_new_probed_subdev(&dev->v4l2_dev,
"tuner", v4l2_i2c_tuner_addrs(type)); &dev->i2c_adap, "tuner", "tuner",
v4l2_i2c_tuner_addrs(type));
} else { } else {
v4l2_i2c_new_subdev(&dev->i2c_adap, v4l2_i2c_new_subdev(&dev->v4l2_dev,
"tuner", "tuner", dev->tuner_addr); &dev->i2c_adap, "tuner", "tuner",
dev->tuner_addr);
} }
} }
......
...@@ -982,7 +982,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -982,7 +982,7 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
/* load i2c helpers */ /* load i2c helpers */
if (card_is_empress(dev)) { if (card_is_empress(dev)) {
struct v4l2_subdev *sd = struct v4l2_subdev *sd =
v4l2_i2c_new_subdev(&dev->i2c_adap, v4l2_i2c_new_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"saa6752hs", "saa6752hs", "saa6752hs", "saa6752hs",
saa7134_boards[dev->board].empress_addr); saa7134_boards[dev->board].empress_addr);
...@@ -995,8 +995,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev, ...@@ -995,8 +995,8 @@ static int __devinit saa7134_initdev(struct pci_dev *pci_dev,
struct v4l2_subdev *sd; struct v4l2_subdev *sd;
addrs[0] = saa7134_boards[dev->board].rds_addr; addrs[0] = saa7134_boards[dev->board].rds_addr;
sd = v4l2_i2c_new_probed_subdev(&dev->i2c_adap, "saa6588", sd = v4l2_i2c_new_probed_subdev(&dev->v4l2_dev, &dev->i2c_adap,
"saa6588", addrs); "saa6588", "saa6588", addrs);
if (sd) if (sd)
printk(KERN_INFO "%s: found RDS decoder\n", dev->name); printk(KERN_INFO "%s: found RDS decoder\n", dev->name);
} }
......
...@@ -247,7 +247,8 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) ...@@ -247,7 +247,8 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
switch (usbvision_device_data[usbvision->DevModel].Codec) { switch (usbvision_device_data[usbvision->DevModel].Codec) {
case CODEC_SAA7113: case CODEC_SAA7113:
case CODEC_SAA7111: case CODEC_SAA7111:
v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "saa7115", v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev,
&usbvision->i2c_adap, "saa7115",
"saa7115_auto", saa711x_addrs); "saa7115_auto", saa711x_addrs);
break; break;
} }
...@@ -256,13 +257,15 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) ...@@ -256,13 +257,15 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
enum v4l2_i2c_tuner_type type; enum v4l2_i2c_tuner_type type;
struct tuner_setup tun_setup; struct tuner_setup tun_setup;
sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner", sd = v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev,
&usbvision->i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); "tuner", v4l2_i2c_tuner_addrs(ADDRS_DEMOD));
/* depending on whether we found a demod or not, select /* depending on whether we found a demod or not, select
the tuner type. */ the tuner type. */
type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV;
sd = v4l2_i2c_new_probed_subdev(&usbvision->i2c_adap, "tuner", sd = v4l2_i2c_new_probed_subdev(&usbvision->v4l2_dev,
&usbvision->i2c_adap, "tuner",
"tuner", v4l2_i2c_tuner_addrs(type)); "tuner", v4l2_i2c_tuner_addrs(type));
if (usbvision->tuner_type != -1) { if (usbvision->tuner_type != -1) {
......
...@@ -760,18 +760,16 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init); ...@@ -760,18 +760,16 @@ EXPORT_SYMBOL_GPL(v4l2_i2c_subdev_init);
/* Load an i2c sub-device. It assumes that i2c_get_adapdata(adapter) /* Load an i2c sub-device. */
returns the v4l2_device and that i2c_get_clientdata(client) struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
returns the v4l2_subdev. */ struct i2c_adapter *adapter,
struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
const char *module_name, const char *client_type, u8 addr) const char *module_name, const char *client_type, u8 addr)
{ {
struct v4l2_device *dev = i2c_get_adapdata(adapter);
struct v4l2_subdev *sd = NULL; struct v4l2_subdev *sd = NULL;
struct i2c_client *client; struct i2c_client *client;
struct i2c_board_info info; struct i2c_board_info info;
BUG_ON(!dev); BUG_ON(!v4l2_dev);
if (module_name) if (module_name)
request_module(module_name); request_module(module_name);
...@@ -798,7 +796,7 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, ...@@ -798,7 +796,7 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
/* Register with the v4l2_device which increases the module's /* Register with the v4l2_device which increases the module's
use count as well. */ use count as well. */
if (v4l2_device_register_subdev(dev, sd)) if (v4l2_device_register_subdev(v4l2_dev, sd))
sd = NULL; sd = NULL;
/* Decrease the module use count to match the first try_module_get. */ /* Decrease the module use count to match the first try_module_get. */
module_put(client->driver->driver.owner); module_put(client->driver->driver.owner);
...@@ -812,19 +810,17 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, ...@@ -812,19 +810,17 @@ struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter,
} }
EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev); EXPORT_SYMBOL_GPL(v4l2_i2c_new_subdev);
/* Probe and load an i2c sub-device. It assumes that i2c_get_adapdata(adapter) /* Probe and load an i2c sub-device. */
returns the v4l2_device and that i2c_get_clientdata(client) struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev,
returns the v4l2_subdev. */ struct i2c_adapter *adapter,
struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
const char *module_name, const char *client_type, const char *module_name, const char *client_type,
const unsigned short *addrs) const unsigned short *addrs)
{ {
struct v4l2_device *dev = i2c_get_adapdata(adapter);
struct v4l2_subdev *sd = NULL; struct v4l2_subdev *sd = NULL;
struct i2c_client *client = NULL; struct i2c_client *client = NULL;
struct i2c_board_info info; struct i2c_board_info info;
BUG_ON(!dev); BUG_ON(!v4l2_dev);
if (module_name) if (module_name)
request_module(module_name); request_module(module_name);
...@@ -850,7 +846,7 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter, ...@@ -850,7 +846,7 @@ struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter,
/* Register with the v4l2_device which increases the module's /* Register with the v4l2_device which increases the module's
use count as well. */ use count as well. */
if (v4l2_device_register_subdev(dev, sd)) if (v4l2_device_register_subdev(v4l2_dev, sd))
sd = NULL; sd = NULL;
/* Decrease the module use count to match the first try_module_get. */ /* Decrease the module use count to match the first try_module_get. */
module_put(client->driver->driver.owner); module_put(client->driver->driver.owner);
......
...@@ -4337,11 +4337,13 @@ static int __init vino_module_init(void) ...@@ -4337,11 +4337,13 @@ static int __init vino_module_init(void)
vino_init_stage++; vino_init_stage++;
addr[0] = 0x45; addr[0] = 0x45;
vino_drvdata->decoder = v4l2_i2c_new_probed_subdev(&vino_i2c_adapter, vino_drvdata->decoder =
"saa7191", "saa7191", addr); v4l2_i2c_new_probed_subdev(&vino_drvdata->v4l2_dev,
&vino_i2c_adapter, "saa7191", "saa7191", addr);
addr[0] = 0x2b; addr[0] = 0x2b;
vino_drvdata->camera = v4l2_i2c_new_probed_subdev(&vino_i2c_adapter, vino_drvdata->camera =
"indycam", "indycam", addr); v4l2_i2c_new_probed_subdev(&vino_drvdata->v4l2_dev,
&vino_i2c_adapter, "indycam", "indycam", addr);
dprintk("init complete!\n"); dprintk("init complete!\n");
......
...@@ -3523,7 +3523,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) ...@@ -3523,7 +3523,8 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id)
w9968cf_turn_on_led(cam); w9968cf_turn_on_led(cam);
w9968cf_i2c_init(cam); w9968cf_i2c_init(cam);
cam->sensor_sd = v4l2_i2c_new_probed_subdev(&cam->i2c_adapter, cam->sensor_sd = v4l2_i2c_new_probed_subdev(&cam->v4l2_dev,
&cam->i2c_adapter,
"ovcamchip", "ovcamchip", addrs); "ovcamchip", "ovcamchip", addrs);
usb_set_intfdata(intf, cam); usb_set_intfdata(intf, cam);
......
...@@ -1360,11 +1360,13 @@ static int __devinit zoran_probe(struct pci_dev *pdev, ...@@ -1360,11 +1360,13 @@ static int __devinit zoran_probe(struct pci_dev *pdev,
goto zr_free_irq; goto zr_free_irq;
} }
zr->decoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, zr->decoder = v4l2_i2c_new_probed_subdev(&zr->v4l2_dev,
zr->card.mod_decoder, zr->card.i2c_decoder, zr->card.addrs_decoder); &zr->i2c_adapter, zr->card.mod_decoder, zr->card.i2c_decoder,
zr->card.addrs_decoder);
if (zr->card.mod_encoder) if (zr->card.mod_encoder)
zr->encoder = v4l2_i2c_new_probed_subdev(&zr->i2c_adapter, zr->encoder = v4l2_i2c_new_probed_subdev(&zr->v4l2_dev,
&zr->i2c_adapter,
zr->card.mod_encoder, zr->card.i2c_encoder, zr->card.mod_encoder, zr->card.i2c_encoder,
zr->card.addrs_encoder); zr->card.addrs_encoder);
......
...@@ -139,12 +139,14 @@ struct v4l2_subdev_ops; ...@@ -139,12 +139,14 @@ struct v4l2_subdev_ops;
/* Load an i2c module and return an initialized v4l2_subdev struct. /* Load an i2c module and return an initialized v4l2_subdev struct.
Only call request_module if module_name != NULL. Only call request_module if module_name != NULL.
The client_type argument is the name of the chip that's on the adapter. */ The client_type argument is the name of the chip that's on the adapter. */
struct v4l2_subdev *v4l2_i2c_new_subdev(struct i2c_adapter *adapter, struct v4l2_subdev *v4l2_i2c_new_subdev(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter,
const char *module_name, const char *client_type, u8 addr); const char *module_name, const char *client_type, u8 addr);
/* Probe and load an i2c module and return an initialized v4l2_subdev struct. /* Probe and load an i2c module and return an initialized v4l2_subdev struct.
Only call request_module if module_name != NULL. Only call request_module if module_name != NULL.
The client_type argument is the name of the chip that's on the adapter. */ The client_type argument is the name of the chip that's on the adapter. */
struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct i2c_adapter *adapter, struct v4l2_subdev *v4l2_i2c_new_probed_subdev(struct v4l2_device *v4l2_dev,
struct i2c_adapter *adapter,
const char *module_name, const char *client_type, const char *module_name, const char *client_type,
const unsigned short *addrs); const unsigned short *addrs);
/* Like v4l2_i2c_new_probed_subdev, except probe for a single address. */ /* Like v4l2_i2c_new_probed_subdev, except probe for a single address. */
......
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