]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - drivers/media/v4l2-core/v4l2-async.c
Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
[mirror_ubuntu-artful-kernel.git] / drivers / media / v4l2-core / v4l2-async.c
index 5bada202b2d38c264cbcd87022278d699e411a40..96cc733f35ef72b0f8280f8ff30e0beaedf6d222 100644 (file)
@@ -42,7 +42,8 @@ static bool match_devname(struct v4l2_subdev *sd,
 
 static bool match_of(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
 {
-       return sd->of_node == asd->match.of.node;
+       return !of_node_cmp(of_node_full_name(sd->of_node),
+                           of_node_full_name(asd->match.of.node));
 }
 
 static bool match_custom(struct v4l2_subdev *sd, struct v4l2_async_subdev *asd)
@@ -99,18 +100,11 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
 {
        int ret;
 
-       /* Remove from the waiting list */
-       list_del(&asd->list);
-       sd->asd = asd;
-       sd->notifier = notifier;
-
        if (notifier->bound) {
                ret = notifier->bound(notifier, sd, asd);
                if (ret < 0)
                        return ret;
        }
-       /* Move from the global subdevice list to notifier's done */
-       list_move(&sd->async_list, &notifier->done);
 
        ret = v4l2_device_register_subdev(notifier->v4l2_dev, sd);
        if (ret < 0) {
@@ -119,6 +113,14 @@ static int v4l2_async_test_notify(struct v4l2_async_notifier *notifier,
                return ret;
        }
 
+       /* Remove from the waiting list */
+       list_del(&asd->list);
+       sd->asd = asd;
+       sd->notifier = notifier;
+
+       /* Move from the global subdevice list to notifier's done */
+       list_move(&sd->async_list, &notifier->done);
+
        if (list_empty(&notifier->waiting) && notifier->complete)
                return notifier->complete(notifier);
 
@@ -168,9 +170,6 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
 
        mutex_lock(&list_lock);
 
-       /* Keep also completed notifiers on the list */
-       list_add(&notifier->list, &notifier_list);
-
        list_for_each_entry_safe(sd, tmp, &subdev_list, async_list) {
                int ret;
 
@@ -185,6 +184,9 @@ int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev,
                }
        }
 
+       /* Keep also completed notifiers on the list */
+       list_add(&notifier->list, &notifier_list);
+
        mutex_unlock(&list_lock);
 
        return 0;
@@ -202,7 +204,7 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier)
        if (!notifier->v4l2_dev)
                return;
 
-       dev = kmalloc(n_subdev * sizeof(*dev), GFP_KERNEL);
+       dev = kmalloc_array(n_subdev, sizeof(*dev), GFP_KERNEL);
        if (!dev) {
                dev_err(notifier->v4l2_dev->dev,
                        "Failed to allocate device cache!\n");