Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2815231pxb; Mon, 18 Oct 2021 02:25:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxGTluP115xGR2+D8NE6hORu0XMssov63cs4CXW1gRzEjioglNekwLl77t8f4RLSYUocdAT X-Received: by 2002:a17:906:34c3:: with SMTP id h3mr29035759ejb.10.1634549134189; Mon, 18 Oct 2021 02:25:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634549134; cv=none; d=google.com; s=arc-20160816; b=K32D3UrfZtdM5R4f5ACFmEfXg4Dcbj0bCEwbVrn2pDXG3ynnU9TmdIsB2gEwUpRfx8 rGKIsXcniLGjaobE8594iPPfNawxusybBppZV1VTYAdhr8SkvzRB1ETp9NKvMdQDOBeY oEU15naNGknMWgJWiEaWAgfk/QSbWb1XctmbLf7GAOf97drvoVDJcM/AYEY/5u71+N58 N49NfsZeJKNXIk/d6nILk3aI0ErpqMEF2VX5VmRjmo+gdqUqlCiLkbKdYRyk2Fs4nL0Y fHWD7jmglSdo0H4Ovg8cYwCuUYvSFbR5Bq/Yv/lStp1zbYqGHsTpNRyB4IyCdUOwhOKo V0gw== 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=JwpIUV5sEtm6o8nTRT7V7n3PQN13p979nQaAXJc1puWs3RNvlckdcEJGhJkKMdemr9 b7LEpQx0LU/lYOLnmhpib8B9KCJDLM+NXI2gcTCmP0xmdvgTMzwcjokAmr+7r9VPHXcd AlQKCkMJctBP3IlQU2+y3dkTjyzsMoI5Y3T4g9wphsV+fMjuer/yHdVZtHhRTvVmXvPf pKwJKx650tIATHLWnzO6Fe2Bi+ESOCy4pBDMlp7Yz/mCVPGYEigaKnep2c7/eHJO29Aw q4cQbWrIYqZGvexh2POCCeG45DjOtvARbEQDLLSKwmKUCgN8PMbvGOk6yKtjMsp8cwCC +k9g== 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 t7si23577505edd.523.2021.10.18.02.25.10; Mon, 18 Oct 2021 02:25:34 -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 S231622AbhJRJZQ (ORCPT + 99 others); Mon, 18 Oct 2021 05:25:16 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:46220 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231497AbhJRJYu (ORCPT ); Mon, 18 Oct 2021 05:24:50 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 19I90GxC071198; Mon, 18 Oct 2021 17:00:16 +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; Mon, 18 Oct 2021 17:22:10 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH v2 1/7] media: aspeed: move err-handling together to the bottom Date: Mon, 18 Oct 2021 17:22:01 +0800 Message-ID: <20211018092207.13336-2-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211018092207.13336-1-jammy_huang@aspeedtech.com> References: <20211018092207.13336-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 19I90GxC071198 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