From patchwork Sun Apr 7 18:47:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Jernej_=C5=A0krabec?= X-Patchwork-Id: 10888595 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A1421708 for ; Sun, 7 Apr 2019 18:57:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 78DC82834A for ; Sun, 7 Apr 2019 18:57:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69DA228514; Sun, 7 Apr 2019 18:57:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A97EC2834A for ; Sun, 7 Apr 2019 18:57:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726372AbfDGS5s (ORCPT ); Sun, 7 Apr 2019 14:57:48 -0400 Received: from mailoutvs17.siol.net ([185.57.226.208]:58794 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726335AbfDGS5r (ORCPT ); Sun, 7 Apr 2019 14:57:47 -0400 X-Greylist: delayed 605 seconds by postgrey-1.27 at vger.kernel.org; Sun, 07 Apr 2019 14:57:46 EDT Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTP id 3EDB3521E22; Sun, 7 Apr 2019 20:47:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta10.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta10.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DdDHnUZcL_UU; Sun, 7 Apr 2019 20:47:39 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Postfix) with ESMTPS id D39355214D3; Sun, 7 Apr 2019 20:47:38 +0200 (CEST) Received: from localhost.localdomain (cpe-86-58-52-202.static.triera.net [86.58.52.202]) (Authenticated sender: 031275009) by mail.siol.net (Postfix) with ESMTPSA id E18B8521E22; Sun, 7 Apr 2019 20:47:36 +0200 (CEST) From: Jernej Skrabec To: maxime.ripard@bootlin.com, paul.kocialkowski@bootlin.com Cc: mchehab@kernel.org, gregkh@linuxfoundation.org, wens@csie.org, hverkuil-cisco@xs4all.nl, linux-media@vger.kernel.org, devel@driverdev.osuosl.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jonas Karlman Subject: [PATCH] media: cedrus: Fix initialization order Date: Sun, 7 Apr 2019 20:47:28 +0200 Message-Id: <20190407184728.16620-1-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently, MEDIA_IOC_G_TOPOLOGY ioctl on cedrus fails due to incorrect initialization order. Fix that by moving video_register_device() before v4l2_m2m_register_media_controller() and while at it, fix error path. Reported-by: Jonas Karlman Signed-off-by: Jernej Skrabec Acked-by: Paul Kocialkowski --- drivers/staging/media/sunxi/cedrus/cedrus.c | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/staging/media/sunxi/cedrus/cedrus.c b/drivers/staging/media/sunxi/cedrus/cedrus.c index b98add3cdedd..d0429c0e6b6b 100644 --- a/drivers/staging/media/sunxi/cedrus/cedrus.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus.c @@ -300,7 +300,7 @@ static int cedrus_probe(struct platform_device *pdev) "Failed to initialize V4L2 M2M device\n"); ret = PTR_ERR(dev->m2m_dev); - goto err_video; + goto err_v4l2; } dev->mdev.dev = &pdev->dev; @@ -310,23 +310,23 @@ static int cedrus_probe(struct platform_device *pdev) dev->mdev.ops = &cedrus_m2m_media_ops; dev->v4l2_dev.mdev = &dev->mdev; - ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd, - MEDIA_ENT_F_PROC_VIDEO_DECODER); - if (ret) { - v4l2_err(&dev->v4l2_dev, - "Failed to initialize V4L2 M2M media controller\n"); - goto err_m2m; - } - ret = video_register_device(vfd, VFL_TYPE_GRABBER, 0); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register video device\n"); - goto err_v4l2; + goto err_m2m; } v4l2_info(&dev->v4l2_dev, "Device registered as /dev/video%d\n", vfd->num); + ret = v4l2_m2m_register_media_controller(dev->m2m_dev, vfd, + MEDIA_ENT_F_PROC_VIDEO_DECODER); + if (ret) { + v4l2_err(&dev->v4l2_dev, + "Failed to initialize V4L2 M2M media controller\n"); + goto err_video; + } + ret = media_device_register(&dev->mdev); if (ret) { v4l2_err(&dev->v4l2_dev, "Failed to register media device\n"); @@ -339,10 +339,10 @@ static int cedrus_probe(struct platform_device *pdev) err_m2m_mc: v4l2_m2m_unregister_media_controller(dev->m2m_dev); -err_m2m: - v4l2_m2m_release(dev->m2m_dev); err_video: video_unregister_device(&dev->vfd); +err_m2m: + v4l2_m2m_release(dev->m2m_dev); err_v4l2: v4l2_device_unregister(&dev->v4l2_dev);