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

[media] cx231xx: enforce check for graph creation

If the graph creation fails, don't register the device.
Acked-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 5e5387df
...@@ -1185,8 +1185,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev) ...@@ -1185,8 +1185,6 @@ static void cx231xx_unregister_media_device(struct cx231xx *dev)
*/ */
void cx231xx_release_resources(struct cx231xx *dev) void cx231xx_release_resources(struct cx231xx *dev)
{ {
cx231xx_unregister_media_device(dev);
cx231xx_release_analog_resources(dev); cx231xx_release_analog_resources(dev);
cx231xx_remove_from_devlist(dev); cx231xx_remove_from_devlist(dev);
...@@ -1199,6 +1197,8 @@ void cx231xx_release_resources(struct cx231xx *dev) ...@@ -1199,6 +1197,8 @@ void cx231xx_release_resources(struct cx231xx *dev)
/* delete v4l2 device */ /* delete v4l2 device */
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
cx231xx_unregister_media_device(dev);
usb_put_dev(dev->udev); usb_put_dev(dev->udev);
/* Mark device as unused */ /* Mark device as unused */
...@@ -1237,15 +1237,16 @@ static void cx231xx_media_device_register(struct cx231xx *dev, ...@@ -1237,15 +1237,16 @@ static void cx231xx_media_device_register(struct cx231xx *dev,
#endif #endif
} }
static void cx231xx_create_media_graph(struct cx231xx *dev) static int cx231xx_create_media_graph(struct cx231xx *dev)
{ {
#ifdef CONFIG_MEDIA_CONTROLLER #ifdef CONFIG_MEDIA_CONTROLLER
struct media_device *mdev = dev->media_dev; struct media_device *mdev = dev->media_dev;
struct media_entity *entity; struct media_entity *entity;
struct media_entity *tuner = NULL, *decoder = NULL; struct media_entity *tuner = NULL, *decoder = NULL;
int ret;
if (!mdev) if (!mdev)
return; return 0;
media_device_for_each_entity(entity, mdev) { media_device_for_each_entity(entity, mdev) {
switch (entity->type) { switch (entity->type) {
...@@ -1261,16 +1262,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev) ...@@ -1261,16 +1262,24 @@ static void cx231xx_create_media_graph(struct cx231xx *dev)
/* Analog setup, using tuner as a link */ /* Analog setup, using tuner as a link */
if (!decoder) if (!decoder)
return; return 0;
if (tuner) if (tuner) {
media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0, ret = media_create_pad_link(tuner, TUNER_PAD_IF_OUTPUT, decoder, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
media_create_pad_link(decoder, 1, &dev->vdev.entity, 0, if (ret < 0)
MEDIA_LNK_FL_ENABLED); return ret;
media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, }
MEDIA_LNK_FL_ENABLED); ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret < 0)
return ret;
ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED);
if (ret < 0)
return ret;
#endif #endif
return 0;
} }
/* /*
...@@ -1732,9 +1741,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface, ...@@ -1732,9 +1741,12 @@ static int cx231xx_usb_probe(struct usb_interface *interface,
/* load other modules required */ /* load other modules required */
request_modules(dev); request_modules(dev);
cx231xx_create_media_graph(dev); retval = cx231xx_create_media_graph(dev);
if (retval < 0) {
cx231xx_release_resources(dev);
}
return 0; return retval;
err_video_alt: err_video_alt:
/* cx231xx_uninit_dev: */ /* cx231xx_uninit_dev: */
cx231xx_close_extension(dev); cx231xx_close_extension(dev);
......
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