From patchwork Tue May 10 11:51:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15846 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 0EE00C326D for ; Tue, 10 May 2022 11:52:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AB116565A; Tue, 10 May 2022 13:52:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1652183525; bh=g1HSzGVKOFmiTz3acZlXrvGDr9k5S9lpIAwIEIkpp9E=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=o8fyufMT51Hy+4R4NINI8E5lVOnNqHkRrFltefxA/GcWWhLuqj+QDw4+PN3vOPB4k F8a7VaDxbwaH1qSQkoCtebkFOpnfHjefQKlSWj3+BKPVCHql/7elZRXtP/NSRXV8e4 bUscnxIY2dLCGiKhTzr8nWeKaTtUODtwmsUt6MmBPgJyqBe+j/8sEzVPctx9eV6T4N nt8/g/0XGn7+qVNEcedp1yAYr5qiWn0hM+o44W7UXMsIKAxEsWv0wQhPX58M9czGip UzEfhVlF9+FhKs60UxMMPGsjc+TX4YmvVrTiyeckmjwTDa2bXau1RKDd2x6VYJzpYU qIQvEJkeCMt0Q== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 157446564D for ; Tue, 10 May 2022 13:52:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eEPBhNTv"; dkim-atps=neutral Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 122E4824; Tue, 10 May 2022 13:52:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1652183521; bh=g1HSzGVKOFmiTz3acZlXrvGDr9k5S9lpIAwIEIkpp9E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEPBhNTvBK+STHKodI7N+UoAIQx2E542gSGao25WdDtAXYia5YOG7z69wH2PaIXJw vvV2Qi34nkU4/IEtvQDTBUP0YGEJFHGIcVrJ53N1sSjFRG1fu8hcNzigFBP3nD83sb U2ZbXcuLbQvIqsYn1+a3ArWsFWA/Gw/FQbcem5nc= To: libcamera-devel@lists.libcamera.org Date: Tue, 10 May 2022 14:51:03 +0300 Message-Id: <20220510115147.19360-7-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> References: <20220510115147.19360-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/50] staging: media: imx: imx7-media-csi: Move misc init out of probe() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Laurent Pinchart via libcamera-devel From: Laurent Pinchart Reply-To: Laurent Pinchart Cc: Martin Kepplinger , kernel@pengutronix.de, Dorota Czaplejewicz , Alexander Stein , Rui Miguel Silva , Philipp Zabel , Steve Longerbeam Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Paul Elder There is a chunk of miscellaneous initializations related to the CSI subdev and media pads directly in the probe function. Move them into the imx7_csi_media_init() function to clean up the probe function. Signed-off-by: Paul Elder --- drivers/staging/media/imx/imx7-media-csi.c | 49 +++++++++++----------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/drivers/staging/media/imx/imx7-media-csi.c b/drivers/staging/media/imx/imx7-media-csi.c index 984f7bec15af..042dd4c0cb4d 100644 --- a/drivers/staging/media/imx/imx7-media-csi.c +++ b/drivers/staging/media/imx/imx7-media-csi.c @@ -1342,7 +1342,7 @@ static void imx7_csi_media_cleanup(struct imx7_csi *csi) static int imx7_csi_media_init(struct imx7_csi *csi) { struct imx_media_dev *imxmd; - int ret; + int i, ret; /* add media device */ imxmd = imx_media_dev_init(csi->dev, NULL); @@ -1357,14 +1357,33 @@ static int imx7_csi_media_init(struct imx7_csi *csi) csi->imxmd = imxmd; - return 0; + v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); + v4l2_set_subdevdata(&csi->sd, csi); + csi->sd.internal_ops = &imx7_csi_internal_ops; + csi->sd.entity.ops = &imx7_csi_entity_ops; + csi->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; + csi->sd.dev = csi->dev; + csi->sd.owner = THIS_MODULE; + csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; + snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); + + for (i = 0; i < IMX7_CSI_PADS_NUM; i++) + csi->pad[i].flags = (i == IMX7_CSI_PAD_SINK) ? + MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; + + ret = media_entity_pads_init(&csi->sd.entity, IMX7_CSI_PADS_NUM, + csi->pad); + if (ret < 0) + return ret; + + return v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); } static int imx7_csi_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; struct imx7_csi *csi; - int i, ret; + int ret; csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); if (!csi) @@ -1410,28 +1429,9 @@ static int imx7_csi_probe(struct platform_device *pdev) if (ret) goto destroy_mutex; - v4l2_subdev_init(&csi->sd, &imx7_csi_subdev_ops); - v4l2_set_subdevdata(&csi->sd, csi); - csi->sd.internal_ops = &imx7_csi_internal_ops; - csi->sd.entity.ops = &imx7_csi_entity_ops; - csi->sd.entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; - csi->sd.dev = &pdev->dev; - csi->sd.owner = THIS_MODULE; - csi->sd.flags = V4L2_SUBDEV_FL_HAS_DEVNODE; - snprintf(csi->sd.name, sizeof(csi->sd.name), "csi"); - - for (i = 0; i < IMX7_CSI_PADS_NUM; i++) - csi->pad[i].flags = (i == IMX7_CSI_PAD_SINK) ? - MEDIA_PAD_FL_SINK : MEDIA_PAD_FL_SOURCE; - - ret = media_entity_pads_init(&csi->sd.entity, IMX7_CSI_PADS_NUM, - csi->pad); - if (ret < 0) - goto cleanup; - ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd); if (ret) - goto cleanup; + goto media_cleanup; ret = imx7_csi_async_register(csi); if (ret) @@ -1442,8 +1442,7 @@ static int imx7_csi_probe(struct platform_device *pdev) subdev_notifier_cleanup: v4l2_async_nf_unregister(&csi->notifier); v4l2_async_nf_cleanup(&csi->notifier); - -cleanup: +media_cleanup: imx7_csi_media_cleanup(csi); destroy_mutex: