summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorShuah Khan <shuahkh@osg.samsung.com>2016-02-11 21:41:31 -0200
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2016-02-27 09:06:06 -0300
commit7b12adf6f5f8262967f83acd7c176fd617b8703a (patch)
tree2df5d6a3703f4b23cc22dda1e87eda8dfcf59348 /drivers
parent182dde7c5d4cd9fcac007c0798c9906fc5ea6889 (diff)
downloadlinux-stable-7b12adf6f5f8262967f83acd7c176fd617b8703a.tar.gz
linux-stable-7b12adf6f5f8262967f83acd7c176fd617b8703a.tar.bz2
linux-stable-7b12adf6f5f8262967f83acd7c176fd617b8703a.zip
[media] media: au0828 handle media_init and media_register window
Media device initialization and registration steps are split. There is a window between media device init and media device register during usb probe. au0828 bridge driver and snd-usb-audio could try to initialize the media device, if they simply checked, whether the device has been registered. They also need to check whether the device has been initialized. Change the au0828-core to check if media device is already initialized during initialization step and check if media device is already registered during the registration step. [mchehab@osg.samsung.com: fix a merge conflict] Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/usb/au0828/au0828-core.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/drivers/media/usb/au0828/au0828-core.c b/drivers/media/usb/au0828/au0828-core.c
index 4448399e73c5..cafe57f37e3d 100644
--- a/drivers/media/usb/au0828/au0828-core.c
+++ b/drivers/media/usb/au0828/au0828-core.c
@@ -195,13 +195,35 @@ static int au0828_media_device_init(struct au0828_dev *dev,
if (!mdev)
return -ENOMEM;
- media_device_usb_init(mdev, udev, udev->product);
+ /* check if media device is already initialized */
+ if (!mdev->dev)
+ media_device_usb_init(mdev, udev, udev->product);
dev->media_dev = mdev;
#endif
return 0;
}
+static int au0828_media_device_register(struct au0828_dev *dev,
+ struct usb_device *udev)
+{
+#ifdef CONFIG_MEDIA_CONTROLLER
+ int ret;
+
+ if (dev->media_dev &&
+ !media_devnode_is_registered(&dev->media_dev->devnode)) {
+
+ /* register media device */
+ ret = media_device_register(dev->media_dev);
+ if (ret) {
+ dev_err(&udev->dev,
+ "Media Device Register Error: %d\n", ret);
+ return ret;
+ }
+ }
+#endif
+ return 0;
+}
static int au0828_usb_probe(struct usb_interface *interface,
const struct usb_device_id *id)
@@ -305,9 +327,7 @@ static int au0828_usb_probe(struct usb_interface *interface,
mutex_unlock(&dev->lock);
-#ifdef CONFIG_MEDIA_CONTROLLER
- retval = media_device_register(dev->media_dev);
-#endif
+ retval = au0828_media_device_register(dev, usbdev);
done:
if (retval < 0)