From patchwork Fri Mar 4 17:19:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12769505 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 56EA8C433F5 for ; Fri, 4 Mar 2022 17:23:30 +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:References:In-Reply-To: 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: List-Owner; bh=Vucrutz/e4yRvLBcv4YCt27WB3TWhzltFWNWOghXFBw=; b=o1sm2kccninn6W dEzw/FFConnnLJn8tkUqMt1g3WCWwytg8J4uyWGQ7WaJUkFA5d1UzoMeNEsHMwrBWd9QOf2GfUEiN oZvmUwwuHfe2gLFPZNGVbALLhO3cQiruy0+5fMJdsgcpFaNNn1FEyMadytvUWKTh2x3TGgyXl6VoF 2KNUE3knYLg6Q2ekgbMdbYCUABHormxpP7sP0P5oCSuGjPh1jCQjCTQBpgnVXKKUZlErkgNn4lrRy h24LIh4Hgc7HlP7IiiNsEfnVdd0qEJIsmdFxtfMbtnEu3WUBKcYo8DtW3UD8QZSJOyLajX1wrcQ35 gpHloXWkHKgyqBjS3ZzA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQBeH-00BHzz-Qx; Fri, 04 Mar 2022 17:23:25 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nQBam-00BFdz-0M for linux-rockchip@lists.infradead.org; Fri, 04 Mar 2022 17:19:49 +0000 Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9F7F11BCB; Fri, 4 Mar 2022 18:19:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1646414385; bh=EKwBdOKXYBSAZo7eHku3+WttxLQM6TlB105HlkuT1PU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l6H2ViL+Ph9DTsTrLUeRK5MLz/hwhi6yI02lRlbyixxcByu/M2YcNzTxdjdGsXw12 9jvfjvo6DD5Nm6sQzlo/fTJFQLRkAxPYAau7q6WsNL1ypX5+VLLBoY9w78JTCb1dTK cdRxZHo++cbLIbMNbyetnPMSOHsZ+mWh9+5bwY1w= From: Laurent Pinchart To: linux-media@vger.kernel.org Cc: Dafna Hirschfeld , Heiko Stuebner , Paul Elder , Tomasz Figa , linux-rockchip@lists.infradead.org Subject: [PATCH v2 06/17] media: rkisp1: stats: Simplify (un)registration Date: Fri, 4 Mar 2022 19:19:14 +0200 Message-Id: <20220304171925.1592-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220304171925.1592-1-laurent.pinchart@ideasonboard.com> References: <20220304171925.1592-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220304_091948_240655_718A0C62 X-CRM114-Status: UNSURE ( 9.77 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org Simplify error handling at registration time as media_entity_cleanup() can be called on an uninitialized entity, and make rkisp1_stats_unregister() safe to be called on an unregistered stats node to prepare for simplification of error handling at probe time. Signed-off-by: Laurent Pinchart --- drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c index be5777c65bfb..26ef3bbe43d0 100644 --- a/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c +++ b/drivers/media/platform/rockchip/rkisp1/rkisp1-stats.c @@ -463,21 +463,21 @@ int rkisp1_stats_register(struct rkisp1_device *rkisp1) node->pad.flags = MEDIA_PAD_FL_SINK; ret = media_entity_pads_init(&vdev->entity, 1, &node->pad); if (ret) - goto err_mutex_destroy; + goto error; ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1); if (ret) { dev_err(&vdev->dev, "failed to register %s, ret=%d\n", vdev->name, ret); - goto err_cleanup_media_entity; + goto error; } return 0; -err_cleanup_media_entity: +error: media_entity_cleanup(&vdev->entity); -err_mutex_destroy: mutex_destroy(&node->vlock); + stats->rkisp1 = NULL; return ret; } @@ -487,6 +487,9 @@ void rkisp1_stats_unregister(struct rkisp1_device *rkisp1) struct rkisp1_vdev_node *node = &stats->vnode; struct video_device *vdev = &node->vdev; + if (!stats->rkisp1) + return; + vb2_video_unregister_device(vdev); media_entity_cleanup(&vdev->entity); mutex_destroy(&node->vlock);