Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1415419pxb; Thu, 21 Oct 2021 23:57:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwV0CD2FLOunlJ6xNCOn1WHP146jXTZKYxaoWePgc0QUT57HL8x/tkWEcehO977jjuCFx9J X-Received: by 2002:a62:6411:0:b0:44c:bf9f:f584 with SMTP id y17-20020a626411000000b0044cbf9ff584mr10872040pfb.29.1634885829327; Thu, 21 Oct 2021 23:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634885829; cv=none; d=google.com; s=arc-20160816; b=KSTRj/LtDsd2ibqNzffAoFZyO1spUnZDE/JS9g1BkizeHQmLhBYipNqFPoGA6dnUyE j7p2QqEpbcw3T1CjMIVHObqHN9pW6gXYgRY8D/3FW3dtoxx8YVhmP5JhMAMeiS7PDGKH FtgDZlmbjpCBfoAAZxpXAzKVKdHB51daM62ly6crU0xSFPbY6iXj4QDUl0oKMit8RLL1 U1nrURjJ6RdJejEC/wjSwjJRrg2vnyZlDBaoXePzm6gXccsZ+EAyQEtXSyC4wxHkIZ6n nKiFPToLcdSJ15suwtp4/N9GWxAoZ7V+s7UEAJrSxLilQAH/CmzBlnCOq3xoLNxOm156 /3/Q== 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=YMaCEmybQguR/T10vvqP0XTKJE/qndFzZGYBTDnVMF9I3x+eq/zqm1aUPyBNIi5B4d xNnFsZIqU/anrkdzhs2MFLdV1noDAgGWapKDVeOH6tNsRbTKhwjJQ8nVImxiwlRswghK 5eMW24Nyv/n58jmQQBjeKWuxkadghU0VFWp9+f2HdRA+eu3tXZ0zvArVM/HTTKUvwP/o sxbWIqIaqLHjl7+JHCPNlwpxpMAaAIAaGR6Vfw0jKrJx2KuRGqHyghP9vV4RZkTL5B4Q lwG8FUl3e5bg5clM6EAXhUUrgsesSTGARnuwRoVHLfSRy6GyXAKBNGR151ustAX+pgM6 CkIw== 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 w63si9498629pgd.388.2021.10.21.23.56.57; Thu, 21 Oct 2021 23:57:09 -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 S232201AbhJVG6D (ORCPT + 99 others); Fri, 22 Oct 2021 02:58:03 -0400 Received: from twspam01.aspeedtech.com ([211.20.114.71]:52701 "EHLO twspam01.aspeedtech.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232002AbhJVG55 (ORCPT ); Fri, 22 Oct 2021 02:57:57 -0400 Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 19M6XF6A087033; Fri, 22 Oct 2021 14:33:15 +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; Fri, 22 Oct 2021 14:55:22 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH v3 1/7] media: aspeed: move err-handling together to the bottom Date: Fri, 22 Oct 2021 14:55:33 +0800 Message-ID: <20211022065539.12392-2-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211022065539.12392-1-jammy_huang@aspeedtech.com> References: <20211022065539.12392-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 19M6XF6A087033 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