Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2623795ybt; Tue, 16 Jun 2020 10:35:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0i9gHRuoi903HH0l8K1Iq4OBY6n/0D46J+auVGBuj0t9FNumJXyhX1wFvlU5cK7g73fVX X-Received: by 2002:a17:906:1cd3:: with SMTP id i19mr3684598ejh.321.1592328918871; Tue, 16 Jun 2020 10:35:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592328918; cv=none; d=google.com; s=arc-20160816; b=D4M2sp62bLcKzQ5GBBrUTmO82rMP1bAJmnS+7w4+b69kVGIGxSgBMfvp/rJZxY248B PHzIJhQuW4o8JPOsg30rw48AMVa+2hvDjqIqTZrMAMfmZ96/B/PeRs9PHw0bxScd4umq aCkPiWekYjUCFndk4RONFWIsBnyXtQBkjEmhonNpcMKeFVefwqXFYL/vR41LAkeU7tIK n2THyXMiU+rta+M1APnpphhS038B4ZIBx8Jqc57p3SzVwOAvIiqu+AatpYGSrXzA0zih pLY6ZFXjS22yszuKxOs8jXGzSqFRNVzka+TqsPSxmvMwPPaJ5n4BBAjIkxP920E323bP vysA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=DCj9pqY7qjZgEREmJFUPlvQKClPd3GKGZPRHHv7e+jY=; b=hcWDgrot2QqBCzX7U9MdxsNGsWQ5fnuhyKU6pH4RsZoPUuvax67yolTVAFOC0mnFcK oWhWlJqfIfUUGXX1LrwNxik66npI908VMjsO5IKuhkTRAHCU643oJyk9Kd02hxS6xoGU Ap+3kCCo990IUjIJOaCuM0k8TG6fR+w/kTHrSoGYzB+KCw7o+TTSrnkNlKpm1ODDotRQ RJovvVR0U6ILvQW0NAL3a/ckvz65MZkLS5pqA92jauuS7sbn0qBTvW0mHhkY6TtmmwGT J1HuEsA5kxuq3a/9Biujl2Dx99AmZuwjjp0MP44tl7Jr1iBAMmJpDTH+CyxucIPWrugc +ipg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d6si10785439eja.468.2020.06.16.10.34.56; Tue, 16 Jun 2020 10:35:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731104AbgFPRc6 (ORCPT + 99 others); Tue, 16 Jun 2020 13:32:58 -0400 Received: from smtp1.de.adit-jv.com ([93.241.18.167]:40860 "EHLO smtp1.de.adit-jv.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730978AbgFPRc5 (ORCPT ); Tue, 16 Jun 2020 13:32:57 -0400 Received: from localhost (smtp1.de.adit-jv.com [127.0.0.1]) by smtp1.de.adit-jv.com (Postfix) with ESMTP id EE0E43C00BA; Tue, 16 Jun 2020 19:32:54 +0200 (CEST) Received: from smtp1.de.adit-jv.com ([127.0.0.1]) by localhost (smtp1.de.adit-jv.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RkBGNM8CkM4J; Tue, 16 Jun 2020 19:32:48 +0200 (CEST) Received: from HI2EXCH01.adit-jv.com (hi2exch01.adit-jv.com [10.72.92.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp1.de.adit-jv.com (Postfix) with ESMTPS id EABF03C0022; Tue, 16 Jun 2020 19:32:48 +0200 (CEST) Received: from vmlxhi-121.localdomain (10.72.92.132) by HI2EXCH01.adit-jv.com (10.72.92.24) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 16 Jun 2020 19:32:48 +0200 From: Michael Rodin To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Mauro Carvalho Chehab , , , CC: Michael Rodin , , , , Steve Longerbeam Subject: [PATCH] media: rcar-vin: Move media_device_register to async completion Date: Tue, 16 Jun 2020 19:31:36 +0200 Message-ID: <1592328696-84533-1-git-send-email-mrodin@de.adit-jv.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.72.92.132] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve Longerbeam The media_device is registered during driver probe, before async completion, so it is possible for .link_notify to be called before all devices are bound. Fix this by moving media_device_register() to rvin_group_notify_complete(). This ensures that all devices are now bound (the rcar-csi2 subdevices and and video capture devices) before .link_notify can be called. Signed-off-by: Steve Longerbeam Signed-off-by: Michael Rodin --- drivers/media/platform/rcar-vin/rcar-core.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/rcar-vin/rcar-core.c b/drivers/media/platform/rcar-vin/rcar-core.c index 7440c89..e70f83b 100644 --- a/drivers/media/platform/rcar-vin/rcar-core.c +++ b/drivers/media/platform/rcar-vin/rcar-core.c @@ -253,7 +253,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) struct media_device *mdev = &group->mdev; const struct of_device_id *match; struct device_node *np; - int ret; mutex_init(&group->lock); @@ -266,7 +265,6 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) vin_dbg(vin, "found %u enabled VIN's in DT", group->count); mdev->dev = vin->dev; - mdev->ops = &rvin_media_ops; match = of_match_node(vin->dev->driver->of_match_table, vin->dev->of_node); @@ -278,11 +276,7 @@ static int rvin_group_init(struct rvin_group *group, struct rvin_dev *vin) media_device_init(mdev); - ret = media_device_register(&group->mdev); - if (ret) - rvin_group_cleanup(group); - - return ret; + return 0; } static void rvin_group_release(struct kref *kref) @@ -688,6 +682,8 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier) return ret; } + vin->group->mdev.ops = &rvin_media_ops; + /* Register all video nodes for the group. */ for (i = 0; i < RCAR_VIN_NUM; i++) { if (vin->group->vin[i] && @@ -736,8 +732,10 @@ static int rvin_group_notify_complete(struct v4l2_async_notifier *notifier) } } mutex_unlock(&vin->group->lock); + if (ret) + return ret; - return ret; + return media_device_register(&vin->group->mdev); } static void rvin_group_notify_unbind(struct v4l2_async_notifier *notifier, -- 2.7.4