From patchwork Fri Apr 22 01:36:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Qian X-Patchwork-Id: 12822653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 083DEC433F5 for ; Fri, 22 Apr 2022 01:53:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=GJN1b8RpJ9veeqvHcDBYGzd7uC/5tGQvvJ1DQJireW0=; b=zoY8oW8FnW6U0/ bUhlks21pEa4wvTt21PymDDcndNts7WKl9+gyR/7h7aR7bZ5iPb16YXCoy3Ta3NEkVDLbAdGHAt1+ BG934Me+QMXXN0Hf5CeMOISKyK0Yz/YB3GFtOl2KfSZ2BX+kdcfqfDVu+2qsPuqK4J48L9cRv4XsR N90CHxC2gJjFRMPnXGzn8OWUg/NcIax6Yo6DRFng87MzfhJgm+StGWeSZZWZeMmfihK1XA7ocgLYE 8eGVLC2Jx0UOi/uw/4utLC1NpV2Wz56rgRj+MJ5gHtF0fsKwmsVm5ZPUOJhkrGlly8ITyod4JSfB0 SnQxEXr+sI0MBFTMv8wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhiTZ-00FdYH-TX; Fri, 22 Apr 2022 01:52:50 +0000 Received: from mail-he1eur02on060e.outbound.protection.outlook.com ([2a01:111:f400:fe05::60e] helo=EUR02-HE1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhiTW-00FdXB-1H for linux-arm-kernel@lists.infradead.org; Fri, 22 Apr 2022 01:52:47 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yi+9ysKMFVUnAc77HNs+VT4BRhusRwyPqwi3vBD9RW+1iiNS4ID752FeDU1s+3IrDzA19BIScH/V9H0RnbQnB+E4zAnw7OCX0/CuGdneEToB3EDDE8WN0ehKXHjYqDT9vrIduZVCfxfdZWRFhOmoCIhFdb0BEANAbnfrI7U5Kf08Li6PlcO6aW4kjfZps4uUUUStc6LgArRfUyUsPTvEzswuQvN6DqUo/I0v6Lc5T1CBLjy+1DPxE48+zP1yu7VdEw3voDAnSU/+UqqqxnObFB8J1UgqO9VFqWlCUCivD1uqqAPmgwO7uq0D3Gu4v4s2cg2AC4/cU9etEOD6eFDN0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ZFMbElKFe5/Kg6HItWVWFZtWacpk+FcbeGegMGd9EK8=; b=YsI+fBvydo7F6/hfkFHw1CzjdyWJsITuqiSH7WqlACdqINXvtWopKy3T9HU5TN0asl5BRJms2PDuQ9HZjdDMI7Z577nVL0JzXBY1u0Z7HeqrL+RhcKX74Y47Z5pZaV4diUvKUQF2L0prG0maY/G2zerjxIdqfEE5MTUOdLzxo3wlfJKQ4Isqc7DyBv03SY5aEDZwDRoVfBxttPr79HKxWDRFtuqp9wQC79cuwgmeQeo1mAIyzKcjAVEEidbAnUNu2kEVGig6+LzAz6gLzpI1whAFn6vnW4+odT2Qi1rCcTxA4EUGpqgl6JjXRkSH5SdmrF0YysKeaqcbPYWm5Xwv2Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZFMbElKFe5/Kg6HItWVWFZtWacpk+FcbeGegMGd9EK8=; b=DnIiMWJzHESHcQwW3ic3PCtwvM3UQQf7fyRx9XnT1dS4R5XPzTOk7ALVD/JUNlIJ0WDyoPH1XWXtpWhIpICwg6ehZvnAPkOVGVXu2clOWxVnSel1A1uvuALC9dosH7GPCLqNoVIYzv+a8dRhRd91beGqPwO0Na3jKicYDFNEbew= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) by AM9PR04MB8145.eurprd04.prod.outlook.com (2603:10a6:20b:3e1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Fri, 22 Apr 2022 01:36:45 +0000 Received: from AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5]) by AM6PR04MB6341.eurprd04.prod.outlook.com ([fe80::d8b5:5914:5189:ffa5%6]) with mapi id 15.20.5186.014; Fri, 22 Apr 2022 01:36:44 +0000 From: Ming Qian To: mchehab@kernel.org, shawnguo@kernel.org Cc: hverkuil-cisco@xs4all.nl, robh+dt@kernel.org, s.hauer@pengutronix.de, kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, aisheng.dong@nxp.com, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] media: amphion: free ctrl handler if error is set and return error Date: Fri, 22 Apr 2022 09:36:21 +0800 Message-Id: <20220422013621.5308-1-ming.qian@nxp.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SI2P153CA0016.APCP153.PROD.OUTLOOK.COM (2603:1096:4:140::17) To AM6PR04MB6341.eurprd04.prod.outlook.com (2603:10a6:20b:d8::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2da1ebd2-0c37-484f-cfeb-08da24008efd X-MS-TrafficTypeDiagnostic: AM9PR04MB8145:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jsOPcvyBT3i2GmwGic0+O2Jm+y9IVIq5iWRVscIKr9CmYo7U6SbKjFEJ/AAiVlrEKvilqtM06CQQSCO4aLjP2D5jp07cbbBxR5PUhDbakoUhBehf7ixsed0GKRmpPt2ltn32WxBLHLAwdOn89irRhelO+lCcsdzVyjVRB+sIF448oYZmTNZPbQ3sMvoE4M69Mq/4p/TND9CUXYBtDUtzAwWSBVdxkTLVw5FbUyEibMoqNoY6VXHW7zjqH9uoNCHpR/TbfkqaULsIWuyO5tIum5qz9ftowbxlHpmQLrvCs40MytffCoSD5W8J5TEA02wXjZulwYDz6MJW4QKFmRRHwWGYeolIWpExFzBw81ThFf5qB/kR6WvBW8M2qkVMyb/cnNqV00gYGbFDvrHw050J1FGdzgjSzcMiV3q1fgvSh52GAGyeOTrrqfQd0hLybAY+oUgVBHEgIPxMOnJLbt20Xjc5TVtrGqD/dRFbSTWUNRB4SPNAbXSkAWgaUNETVBTt23zKzk45WVBdlUQWLNMtdqWfcjcb0CLYn+LC1pGrcSjnMa7juZdsF7+6VnixaXP/C+yxm2uStEFpmSJhfQH4FPn/SY97Vb7+0MkkIO5BX4VD4H4m/SW71Mdp41/re0xEnHVYQnr4XvCOQdodDSGinvG91BVdqltL51gawV5FuT+yXt+4Kj7tw9AKmY8nMepginxGuyaG0WNmDHG5nMYo8g== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6341.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(4636009)(366004)(86362001)(8936002)(4326008)(8676002)(66946007)(66556008)(66476007)(316002)(6666004)(52116002)(186003)(36756003)(2616005)(2906002)(1076003)(6506007)(44832011)(508600001)(6486002)(38100700002)(38350700002)(7416002)(6512007)(26005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hz2Zp8lpueVLp+Dv8zBtX2ebSBF6kMjZT2xVehvNx4kdV4kR29kcyOws88dkjQJLEMvWv2Ay2RQWw6/F4Dg4+TZ5CE3EciFEgajf9OWvO8FnV1U5R08xBRz3QY3CtI17VGVAgrrdpVV/pkloKAK2LtsXUrWaGtGjLvkxBeqnM4AKRsumAC+09Nb95gKpu2F4Yb+6z94EV0Gf7/TujzFLTs5ZGgc7wocTT3yGmA+xAYP2BzEnV5QULpz+APwwsVw/Lc0pQnupJnjTLVdrfywJAYDWBQA5uFhOc4UAogjTbfBR6OCIe852sledyWuheROON+d5XDsozf4fpw71A6PtyTJx9V/uep6IAXJzc4ezjrHj/Kts07xqwj6sS4ZeeO2KFN9Mu1z+dHaQowbDVI9/lUTiacMORK3wve//VsrVIhxtYo3U0lEsvxI6QaRbACpVoeRZpJqcka9GrV2dCaN3M+0zm9WJfr4Xn6rquwj94v8AM3ewc80gLtj/VD/ADWprp9vtFtb62HPnSITuqtH9Dk0iNyPSE/2iOvaIP5oUqPpLzz/9lAWPByMgKu5AI+SKl+0DqQDqxKDIqMyjL6dVnQyNiVTc2MiFzb1oHJ7T3y0R+fU4FacRDwcVVOKEIQDR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piyEyj5vrmM/HwaYV0+MzjDLhYjLkM9fdadAtGg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2da1ebd2-0c37-484f-cfeb-08da24008efd X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6341.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Apr 2022 01:36:44.5507 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ZbkV/b4yjnkdwlFjHtiQvoit1NoTx46rnc31jXxEmFNJzTn/qpYBdUDq6pET2D2kBDGpZkASktHWlIjeZyLskQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8145 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220421_185246_116795_3AA3485E X-CRM114-Status: UNSURE ( 9.89 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The typical behavior is to add all controls, then at the end check if hdl->error was set, and if so, v4l2_ctrl_handler_free is called and the error is returned. Signed-off-by: Ming Qian --- drivers/media/platform/amphion/vdec.c | 6 ++++++ drivers/media/platform/amphion/venc.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/media/platform/amphion/vdec.c b/drivers/media/platform/amphion/vdec.c index 414e5215d8d2..3c02aa2a54aa 100644 --- a/drivers/media/platform/amphion/vdec.c +++ b/drivers/media/platform/amphion/vdec.c @@ -162,6 +162,12 @@ static int vdec_ctrl_init(struct vpu_inst *inst) if (ctrl) ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE; + if (inst->ctrl_handler.error) { + ret = inst->ctrl_handler.error; + v4l2_ctrl_handler_free(&inst->ctrl_handler); + return ret; + } + ret = v4l2_ctrl_handler_setup(&inst->ctrl_handler); if (ret) { dev_err(inst->dev, "[%d] setup ctrls fail, ret = %d\n", inst->id, ret); diff --git a/drivers/media/platform/amphion/venc.c b/drivers/media/platform/amphion/venc.c index 06c873fd0031..ba9f49cca155 100644 --- a/drivers/media/platform/amphion/venc.c +++ b/drivers/media/platform/amphion/venc.c @@ -682,6 +682,12 @@ static int venc_ctrl_init(struct vpu_inst *inst) ~(1 << V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME), V4L2_MPEG_VIDEO_HEADER_MODE_JOINED_WITH_1ST_FRAME); + if (inst->ctrl_handler.error) { + ret = inst->ctrl_handler.error; + v4l2_ctrl_handler_free(&inst->ctrl_handler); + return ret; + } + ret = v4l2_ctrl_handler_setup(&inst->ctrl_handler); if (ret) { dev_err(inst->dev, "[%d] setup ctrls fail, ret = %d\n", inst->id, ret);