From patchwork Thu Mar 30 11:58:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 668748 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4CD1C761A6 for ; Thu, 30 Mar 2023 11:59:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231572AbjC3L7U (ORCPT ); Thu, 30 Mar 2023 07:59:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231578AbjC3L7S (ORCPT ); Thu, 30 Mar 2023 07:59:18 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB88CA24B for ; Thu, 30 Mar 2023 04:59:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680177557; x=1711713557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/IZJ23BqUrVQR8XLBbfJMcyYu1OfY0V9V/AWPGGpC1k=; b=ghUxrjh2vRb0sBFtsfQpLTR+B4wP9TUuLFv2LzP5wpJ++Xbk9Q816/GZ Figm9cGhrip5wnN0vHGLWTNZrN0iAet3L9oT4G/GE/EsKdFd5N9rshNcI XIATetsQnCtkyYDBSv703Zd605RmsqLIaDXg+PcuCQ3cSMDdEcKGlQlh6 byp2PWecb5kx8DtCtCw4P7htJnk9UNqUvoI1abBHBKIUAjEZ+cRZkiFvV 1rXNX/zwfqjpeHyuMQrC6neMC+MCusKbuzYdCkQ4UK0RSU+FFlQWWBqHU fPur3mm4nbidGP0ei1jop6husniyHgl+237OfPxxcnN/0wbkogSxGAket w==; X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="406111442" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="406111442" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 04:59:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10664"; a="714952926" X-IronPort-AV: E=Sophos;i="5.98,303,1673942400"; d="scan'208";a="714952926" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Mar 2023 04:59:10 -0700 Received: from svinhufvud.ger.corp.intel.com (localhost [IPv6:::1]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2C574122457; Thu, 30 Mar 2023 14:59:08 +0300 (EEST) From: Sakari Ailus To: linux-media@vger.kernel.org Cc: Philipp Zabel , Laurent Pinchart , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon Subject: [PATCH 10/18] media: pxa_camera: Register V4L2 device early, fix probe error handling Date: Thu, 30 Mar 2023 14:58:45 +0300 Message-Id: <20230330115853.1628216-11-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230330115853.1628216-1-sakari.ailus@linux.intel.com> References: <20230330115853.1628216-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Register V4L2 device before initialising the notifier. This way the device is available to the notifier from the beginning. Also fix error handling in probe. Signed-off-by: Sakari Ailus --- drivers/media/platform/intel/pxa_camera.c | 30 +++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/intel/pxa_camera.c b/drivers/media/platform/intel/pxa_camera.c index b848a2a9032f..31ae220ee4f3 100644 --- a/drivers/media/platform/intel/pxa_camera.c +++ b/drivers/media/platform/intel/pxa_camera.c @@ -2289,6 +2289,10 @@ static int pxa_camera_probe(struct platform_device *pdev) if (IS_ERR(pcdev->clk)) return PTR_ERR(pcdev->clk); + err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev); + if (err) + return err; + v4l2_async_nf_init(&pcdev->notifier); pcdev->res = res; pcdev->pdata = pdev->dev.platform_data; @@ -2306,10 +2310,10 @@ static int pxa_camera_probe(struct platform_device *pdev) } else if (pdev->dev.of_node) { err = pxa_camera_pdata_from_dt(&pdev->dev, pcdev); } else { - return -ENODEV; + err = -ENODEV; } if (err < 0) - return err; + goto exit_notifier_cleanup; if (!(pcdev->platform_flags & (PXA_CAMERA_DATAWIDTH_8 | PXA_CAMERA_DATAWIDTH_9 | PXA_CAMERA_DATAWIDTH_10))) { @@ -2342,8 +2346,10 @@ static int pxa_camera_probe(struct platform_device *pdev) * Request the regions. */ base = devm_ioremap_resource(&pdev->dev, res); - if (IS_ERR(base)) - return PTR_ERR(base); + if (IS_ERR(base)) { + err = PTR_ERR(base); + goto exit_notifier_cleanup; + } pcdev->irq = irq; pcdev->base = base; @@ -2352,7 +2358,8 @@ static int pxa_camera_probe(struct platform_device *pdev) pcdev->dma_chans[0] = dma_request_chan(&pdev->dev, "CI_Y"); if (IS_ERR(pcdev->dma_chans[0])) { dev_err(&pdev->dev, "Can't request DMA for Y\n"); - return PTR_ERR(pcdev->dma_chans[0]); + err = PTR_ERR(pcdev->dma_chans[0]); + goto exit_notifier_cleanup; } pcdev->dma_chans[1] = dma_request_chan(&pdev->dev, "CI_U"); @@ -2392,23 +2399,17 @@ static int pxa_camera_probe(struct platform_device *pdev) pxa_camera_activate(pcdev); platform_set_drvdata(pdev, pcdev); - err = v4l2_device_register(&pdev->dev, &pcdev->v4l2_dev); - if (err) - goto exit_deactivate; err = pxa_camera_init_videobuf2(pcdev); if (err) - goto exit_notifier_cleanup; + goto exit_deactivate; pcdev->notifier.ops = &pxa_camera_sensor_ops; err = v4l2_async_nf_register(&pcdev->v4l2_dev, &pcdev->notifier); if (err) - goto exit_notifier_cleanup; + goto exit_deactivate; return 0; -exit_notifier_cleanup: - v4l2_async_nf_cleanup(&pcdev->notifier); - v4l2_device_unregister(&pcdev->v4l2_dev); exit_deactivate: pxa_camera_deactivate(pcdev); tasklet_kill(&pcdev->task_eof); @@ -2418,6 +2419,9 @@ static int pxa_camera_probe(struct platform_device *pdev) dma_release_channel(pcdev->dma_chans[1]); exit_free_dma_y: dma_release_channel(pcdev->dma_chans[0]); +exit_notifier_cleanup: + v4l2_async_nf_cleanup(&pcdev->notifier); + v4l2_device_unregister(&pcdev->v4l2_dev); return err; }