Commit 4e26f3ab authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] au0828: 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 ab232e46
...@@ -172,9 +172,9 @@ static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev) ...@@ -172,9 +172,9 @@ static void au0828_usb_v4l2_release(struct v4l2_device *v4l2_dev)
struct au0828_dev *dev = struct au0828_dev *dev =
container_of(v4l2_dev, struct au0828_dev, v4l2_dev); container_of(v4l2_dev, struct au0828_dev, v4l2_dev);
au0828_usb_v4l2_media_release(dev);
v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl); v4l2_ctrl_handler_free(&dev->v4l2_ctrl_hdl);
v4l2_device_unregister(&dev->v4l2_dev); v4l2_device_unregister(&dev->v4l2_dev);
au0828_usb_v4l2_media_release(dev);
au0828_usb_release(dev); au0828_usb_release(dev);
} }
#endif #endif
...@@ -253,16 +253,16 @@ static void au0828_media_device_register(struct au0828_dev *dev, ...@@ -253,16 +253,16 @@ static void au0828_media_device_register(struct au0828_dev *dev,
} }
static void au0828_create_media_graph(struct au0828_dev *dev) static int au0828_create_media_graph(struct au0828_dev *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 i; int i, 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) {
...@@ -279,15 +279,23 @@ static void au0828_create_media_graph(struct au0828_dev *dev) ...@@ -279,15 +279,23 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
/* Something bad happened! */ /* Something bad happened! */
if (!decoder) if (!decoder)
return; return -EINVAL;
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)
return ret;
}
ret = media_create_pad_link(decoder, 1, &dev->vdev.entity, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0, if (ret)
return ret;
ret = media_create_pad_link(decoder, 2, &dev->vbi_dev.entity, 0,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
for (i = 0; i < AU0828_MAX_INPUT; i++) { for (i = 0; i < AU0828_MAX_INPUT; i++) {
struct media_entity *ent = &dev->input_ent[i]; struct media_entity *ent = &dev->input_ent[i];
...@@ -299,20 +307,27 @@ static void au0828_create_media_graph(struct au0828_dev *dev) ...@@ -299,20 +307,27 @@ static void au0828_create_media_graph(struct au0828_dev *dev)
case AU0828_VMUX_CABLE: case AU0828_VMUX_CABLE:
case AU0828_VMUX_TELEVISION: case AU0828_VMUX_TELEVISION:
case AU0828_VMUX_DVB: case AU0828_VMUX_DVB:
if (tuner) if (!tuner)
media_create_pad_link(ent, 0, tuner, break;
ret = media_create_pad_link(ent, 0, tuner,
TUNER_PAD_RF_INPUT, TUNER_PAD_RF_INPUT,
MEDIA_LNK_FL_ENABLED); MEDIA_LNK_FL_ENABLED);
if (ret)
return ret;
break; break;
case AU0828_VMUX_COMPOSITE: case AU0828_VMUX_COMPOSITE:
case AU0828_VMUX_SVIDEO: case AU0828_VMUX_SVIDEO:
default: /* AU0828_VMUX_DEBUG */ default: /* AU0828_VMUX_DEBUG */
/* FIXME: fix the decoder PAD */ /* FIXME: fix the decoder PAD */
media_create_pad_link(ent, 0, decoder, 0, 0); ret = media_create_pad_link(ent, 0, decoder, 0, 0);
if (ret)
return ret;
break; break;
} }
} }
#endif #endif
return 0;
} }
static int au0828_usb_probe(struct usb_interface *interface, static int au0828_usb_probe(struct usb_interface *interface,
...@@ -427,7 +442,12 @@ static int au0828_usb_probe(struct usb_interface *interface, ...@@ -427,7 +442,12 @@ static int au0828_usb_probe(struct usb_interface *interface,
mutex_unlock(&dev->lock); mutex_unlock(&dev->lock);
au0828_create_media_graph(dev); retval = au0828_create_media_graph(dev);
if (retval) {
pr_err("%s() au0282_dev_register failed to create graph\n",
__func__);
au0828_usb_disconnect(interface);
}
return retval; return retval;
} }
......
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