mirror of
https://github.com/torvalds/linux.git
synced 2026-05-29 17:43:52 +02:00
media: staging: media: zoran: introduce zoran_i2c_init
Reduces the size of the probe function by adding zoran_i2c_init and zoran_i2c_exit functions. Signed-off-by: Corentin Labbe <clabbe@baylibre.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
This commit is contained in:
parent
3b70b0ecd7
commit
8f7cc5c0b0
|
|
@ -931,6 +931,53 @@ static int zoran_init_video_devices(struct zoran *zr)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* v4l2_device_unregister() will care about removing zr->encoder/zr->decoder
|
||||||
|
* via v4l2_i2c_subdev_unregister()
|
||||||
|
*/
|
||||||
|
static int zoran_i2c_init(struct zoran *zr)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
pci_info(zr->pci_dev, "Initializing i2c bus...\n");
|
||||||
|
|
||||||
|
err = zoran_register_i2c(zr);
|
||||||
|
if (err) {
|
||||||
|
pci_err(zr->pci_dev, "%s - cannot initialize i2c bus\n", __func__);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
|
||||||
|
zr->card.i2c_decoder, 0,
|
||||||
|
zr->card.addrs_decoder);
|
||||||
|
if (!zr->decoder) {
|
||||||
|
pci_err(zr->pci_dev, "Fail to get decoder %s\n", zr->card.i2c_decoder);
|
||||||
|
err = -EINVAL;
|
||||||
|
goto error_decoder;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zr->card.i2c_encoder) {
|
||||||
|
zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
|
||||||
|
zr->card.i2c_encoder, 0,
|
||||||
|
zr->card.addrs_encoder);
|
||||||
|
if (!zr->encoder) {
|
||||||
|
pci_err(zr->pci_dev, "Fail to get encoder %s\n", zr->card.i2c_encoder);
|
||||||
|
err = -EINVAL;
|
||||||
|
goto error_decoder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
error_decoder:
|
||||||
|
zoran_unregister_i2c(zr);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void zoran_i2c_exit(struct zoran *zr)
|
||||||
|
{
|
||||||
|
zoran_unregister_i2c(zr);
|
||||||
|
}
|
||||||
|
|
||||||
void zoran_open_init_params(struct zoran *zr)
|
void zoran_open_init_params(struct zoran *zr)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
@ -1059,7 +1106,7 @@ static void zoran_remove(struct pci_dev *pdev)
|
||||||
videocodec_exit(zr);
|
videocodec_exit(zr);
|
||||||
|
|
||||||
/* unregister i2c bus */
|
/* unregister i2c bus */
|
||||||
zoran_unregister_i2c(zr);
|
zoran_i2c_exit(zr);
|
||||||
/* disable PCI bus-mastering */
|
/* disable PCI bus-mastering */
|
||||||
zoran_set_pci_master(zr, 0);
|
zoran_set_pci_master(zr, 0);
|
||||||
/* put chip into reset */
|
/* put chip into reset */
|
||||||
|
|
@ -1340,22 +1387,10 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
}
|
}
|
||||||
|
|
||||||
zr36057_restart(zr);
|
zr36057_restart(zr);
|
||||||
/* i2c */
|
|
||||||
pci_info(zr->pci_dev, "Initializing i2c bus...\n");
|
|
||||||
|
|
||||||
if (zoran_register_i2c(zr) < 0) {
|
err = zoran_i2c_init(zr);
|
||||||
pci_err(pdev, "%s - can't initialize i2c bus\n", __func__);
|
if (err)
|
||||||
goto zr_free_irq;
|
goto zr_free_irq;
|
||||||
}
|
|
||||||
|
|
||||||
zr->decoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
|
|
||||||
zr->card.i2c_decoder, 0,
|
|
||||||
zr->card.addrs_decoder);
|
|
||||||
|
|
||||||
if (zr->card.i2c_encoder)
|
|
||||||
zr->encoder = v4l2_i2c_new_subdev(&zr->v4l2_dev, &zr->i2c_adapter,
|
|
||||||
zr->card.i2c_encoder, 0,
|
|
||||||
zr->card.addrs_encoder);
|
|
||||||
|
|
||||||
pci_info(zr->pci_dev, "Initializing videocodec bus...\n");
|
pci_info(zr->pci_dev, "Initializing videocodec bus...\n");
|
||||||
err = videocodec_init(zr);
|
err = videocodec_init(zr);
|
||||||
|
|
@ -1370,15 +1405,15 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
if (zr->card.video_codec != 0) {
|
if (zr->card.video_codec != 0) {
|
||||||
master_codec = zoran_setup_videocodec(zr, zr->card.video_codec);
|
master_codec = zoran_setup_videocodec(zr, zr->card.video_codec);
|
||||||
if (!master_codec)
|
if (!master_codec)
|
||||||
goto zr_unreg_i2c;
|
goto zr_unreg_videocodec;
|
||||||
zr->codec = videocodec_attach(master_codec);
|
zr->codec = videocodec_attach(master_codec);
|
||||||
if (!zr->codec) {
|
if (!zr->codec) {
|
||||||
pci_err(pdev, "%s - no codec found\n", __func__);
|
pci_err(pdev, "%s - no codec found\n", __func__);
|
||||||
goto zr_unreg_i2c;
|
goto zr_unreg_videocodec;
|
||||||
}
|
}
|
||||||
if (zr->codec->type != zr->card.video_codec) {
|
if (zr->codec->type != zr->card.video_codec) {
|
||||||
pci_err(pdev, "%s - wrong codec\n", __func__);
|
pci_err(pdev, "%s - wrong codec\n", __func__);
|
||||||
goto zr_detach_codec;
|
goto zr_unreg_videocodec;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (zr->card.video_vfe != 0) {
|
if (zr->card.video_vfe != 0) {
|
||||||
|
|
@ -1417,7 +1452,7 @@ static int zoran_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
|
||||||
zr_unreg_videocodec:
|
zr_unreg_videocodec:
|
||||||
videocodec_exit(zr);
|
videocodec_exit(zr);
|
||||||
zr_unreg_i2c:
|
zr_unreg_i2c:
|
||||||
zoran_unregister_i2c(zr);
|
zoran_i2c_exit(zr);
|
||||||
zr_free_irq:
|
zr_free_irq:
|
||||||
btwrite(0, ZR36057_SPGPPCR);
|
btwrite(0, ZR36057_SPGPPCR);
|
||||||
pci_free_irq(zr->pci_dev, 0, zr);
|
pci_free_irq(zr->pci_dev, 0, zr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user