Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4093889pxb; Wed, 13 Oct 2021 20:51:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuRfYFKzSX3LRqhvIgU2Vy+9BbeW4m860fwxr6GXpFG4awPx12wakTT6vkiHlnw9mrugne X-Received: by 2002:a05:6a00:1c42:b0:44d:2e14:74b7 with SMTP id s2-20020a056a001c4200b0044d2e1474b7mr3274921pfw.25.1634183497605; Wed, 13 Oct 2021 20:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634183497; cv=none; d=google.com; s=arc-20160816; b=CudphJBc6+bkobBdQrTgGqfejeyz2zQezkmFzoEJl13eOXhXwJImxr1nDKdtqnz7Wv VGckN9DaCofIkLTUveBkr+7nz/zv79pX4/P/c5m0rSfCHq3sy5EZ6tRr/OyWBo5hFFoJ 0Ej8X+V6qwD5SpMg9Wm25myrsXYnNqWrDMFV+JMTrp+UE+WOa4jboi5kbdp58IipMskp w604I1vHa88kbXgC8qLHye4VDUv/gkMubhe61eWGT8+RbG4VQpl53nW8uYH0EwSqc8el rjhBvpp04fdyoHvZaXWqGmT945eJkDPdkIhC8ouFra8dlamHRm1qLas2AxeNNECcILlS 4vbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=2gqqP+g+1NqtLW+fElROM8cdtzRSvIMZKX5osBhesY4=; b=o81Fkcg8UWSDECmwsiVLTfiCdPlvTjND6SN4Na+5efsPF1ivsHopfzUu85M5uF12tq qtFqePhm35BFjrjl1YBsTE95wbVVVE6bfIkDP+1DdueTmHH+MM2KR2g9kHDBqPA9mCcU l44Mo5Krru7+dHlExvcoqmSDO0BnTF0b8UfiG4ke6Le9tQJ1gQScMBCqGc8822ot4uBy lspT/ZEt4/OI/Jznkg22d/f7feXEmfuoNORIKgpw1/6mp4tsmR+oFydhuRmg765ndmHn 84ju4b3nq4FvENGWFhPhqwAEYwKscLkSPl9PS9tFPb6JKLsdTWzey9jET4qASkv/Tmzm Qb5g== 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 c9si1817076pgl.600.2021.10.13.20.51.25; Wed, 13 Oct 2021 20:51:37 -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 S229948AbhJNDvS (ORCPT + 99 others); Wed, 13 Oct 2021 23:51:18 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:34976 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230109AbhJNDus (ORCPT ); Wed, 13 Oct 2021 23:50:48 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 19E3QbPu006361; Thu, 14 Oct 2021 11:26:38 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from JammyHuang-PC.aspeed.com (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 14 Oct 2021 11:48:16 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH 1/6] media: aspeed: move err-handling together to the bottom Date: Thu, 14 Oct 2021 11:48:14 +0800 Message-ID: <20211014034819.2283-2-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211014034819.2283-1-jammy_huang@aspeedtech.com> References: <20211014034819.2283-1-jammy_huang@aspeedtech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 19E3QbPu006361 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org refine aspeed_video_setup_video() flow. Signed-off-by: Jammy Huang --- drivers/media/platform/aspeed-video.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c index 491447bf5186..6259cf17a7cc 100644 --- a/drivers/media/platform/aspeed-video.c +++ b/drivers/media/platform/aspeed-video.c @@ -1644,11 +1644,8 @@ static int aspeed_video_setup_video(struct aspeed_video *video) rc = video->ctrl_handler.error; if (rc) { - v4l2_ctrl_handler_free(&video->ctrl_handler); - v4l2_device_unregister(v4l2_dev); - dev_err(video->dev, "Failed to init controls: %d\n", rc); - return rc; + goto err_ctrl_init; } v4l2_dev->ctrl_handler = &video->ctrl_handler; @@ -1666,11 +1663,8 @@ static int aspeed_video_setup_video(struct aspeed_video *video) rc = vb2_queue_init(vbq); if (rc) { - v4l2_ctrl_handler_free(&video->ctrl_handler); - v4l2_device_unregister(v4l2_dev); - dev_err(video->dev, "Failed to init vb2 queue\n"); - return rc; + goto err_vb2_init; } vdev->queue = vbq; @@ -1688,15 +1682,19 @@ static int aspeed_video_setup_video(struct aspeed_video *video) video_set_drvdata(vdev, video); rc = video_register_device(vdev, VFL_TYPE_GRABBER, 0); if (rc) { - vb2_queue_release(vbq); - v4l2_ctrl_handler_free(&video->ctrl_handler); - v4l2_device_unregister(v4l2_dev); - dev_err(video->dev, "Failed to register video device\n"); - return rc; + goto err_video_reg; } return 0; + +err_video_reg: + vb2_queue_release(vbq); +err_vb2_init: +err_ctrl_init: + v4l2_ctrl_handler_free(&video->ctrl_handler); + v4l2_device_unregister(v4l2_dev); + return rc; } static int aspeed_video_init(struct aspeed_video *video) -- 2.25.1