From patchwork Wed May 24 11:23:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685567 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 E1B88C7EE2C for ; Wed, 24 May 2023 11:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233637AbjEXLYb (ORCPT ); Wed, 24 May 2023 07:24:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231287AbjEXLY3 (ORCPT ); Wed, 24 May 2023 07:24:29 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8BA1139 for ; Wed, 24 May 2023 04:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927468; x=1716463468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fitF0OE2reffd1zg4bv7IWDlVqhJmA9YDWbTx3hcc8M=; b=IC7S10flkXTwFLJlPr6UopU0vjwvosCj7pxDSAKSIVsJZf92hev7jsY3 G7XsJq6PuTbhVSuRO2ghPCmTDSURT9dO+IUrkLLqJJuLkUAwAul1swvyl 1enP5c7c7i4tP6LHL3awIcnnxWz6qHqkX3Ns/1PS1Rcywa6i6uHBeMI6W pA8AWXNBd+IvDmgWJ7eqFtI5Gdy0iGkW7chumfiZtNo+JtAjmG0iijZRH pboF6NcNtKODLdxc/72JYh+QzF1DJj4iXWmAG9iaQ1ls7ItJM1xUBxZ3u zAdbhJ4QRIOFr1TfTcVOCm4BLFO+FIdQVnYn7QIU616+wmCC29fHq8oov g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758115" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758115" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540546" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540546" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:23 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 2ACA1120E88; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z62-Ie; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 02/32] media: Documentation: v4l: Document missing async subdev function Date: Wed, 24 May 2023 14:23:19 +0300 Message-Id: <20230524112349.2141396-3-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Also v4l2_async_nf_add_fwnode() may be used to add an async sub-device descriptor to a notifier. Document this. Signed-off-by: Sakari Ailus --- Documentation/driver-api/media/v4l2-subdev.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Documentation/driver-api/media/v4l2-subdev.rst b/Documentation/driver-api/media/v4l2-subdev.rst index 602dadaa81d86..ce8e9d0a332bc 100644 --- a/Documentation/driver-api/media/v4l2-subdev.rst +++ b/Documentation/driver-api/media/v4l2-subdev.rst @@ -204,9 +204,9 @@ that the bridge device needs for its operation. Several functions are available to add subdevice descriptors to a notifier, depending on the type of device and the needs of the driver. -:c:func:`v4l2_async_nf_add_fwnode_remote` and -:c:func:`v4l2_async_nf_add_i2c` are for bridge and ISP drivers for -registering their async sub-devices with the notifier. +:c:func:`v4l2_async_nf_add_fwnode`, :c:func:`v4l2_async_nf_add_fwnode_remote` +:c:and func:`v4l2_async_nf_add_i2c` are for registering their async sub-devices +:c:with the notifier. :c:func:`v4l2_async_register_subdev_sensor` is a helper function for sensor drivers registering their own async sub-device, but it also registers a From patchwork Wed May 24 11:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685566 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 DE3BFC7EE2D for ; Wed, 24 May 2023 11:24:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234708AbjEXLYd (ORCPT ); Wed, 24 May 2023 07:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbjEXLYb (ORCPT ); Wed, 24 May 2023 07:24:31 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C293218E for ; Wed, 24 May 2023 04:24:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927469; x=1716463469; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yhpKYjGoEwHsGjTCPG/ehbdB8TieQ36KdaSQjZ4ez64=; b=eyAAKBwhXGc7oD7399RTggCPIWCFbZ9fVmQKuFxq2sCK7oWXN/rqENGz Mnjd7fM5SLLpseyXB8lP57tqufr89J1idmFkJsN5chrj/FfpJiD9nuLiV 1cn8ef/hMdCrsDLusMUmM3bLNpqGcb8eU/M3eLm5SppBiLle/KrIhrYI/ rbHEadzkres8Fri6A48Qc/Xg+OtU4kffLgIMHahDxNTcypcu47BmYYf+J ZBekHIzYiDbC/BNKz+Ci0OZZwbio9bcbM6qV8MAqT/YIm7fq+T5Xmv97G EU377LZfaeBkdTgd7o8hAi+a/RvdHrAvF6KbVEFRS8J4XBeZfGDJM8bMo Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758126" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758126" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540542" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540542" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:23 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 376B8121003; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z68-K2; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 04/32] media: omap3isp: Don't check for the sub-device's notifier Date: Wed, 24 May 2023 14:23:21 +0300 Message-Id: <20230524112349.2141396-5-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There's no need to check for a sub-device's notifier as we only register one notifier (and one V4L2 device). Remove this check and prepare for removing this field in struct v4l2_subdev. Signed-off-by: Sakari Ailus --- drivers/media/platform/ti/omap3isp/isp.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/media/platform/ti/omap3isp/isp.c b/drivers/media/platform/ti/omap3isp/isp.c index f3aaa9e76492e..c2b222f7df892 100644 --- a/drivers/media/platform/ti/omap3isp/isp.c +++ b/drivers/media/platform/ti/omap3isp/isp.c @@ -2039,9 +2039,6 @@ static int isp_subdev_notifier_complete(struct v4l2_async_notifier *async) } list_for_each_entry(sd, &v4l2_dev->subdevs, list) { - if (sd->notifier != &isp->notifier) - continue; - ret = isp_link_entity(isp, &sd->entity, v4l2_subdev_to_bus_cfg(sd)->interface); if (ret < 0) { From patchwork Wed May 24 11:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685565 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 B3C41C77B7A for ; Wed, 24 May 2023 11:24:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234755AbjEXLYf (ORCPT ); Wed, 24 May 2023 07:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231274AbjEXLYd (ORCPT ); Wed, 24 May 2023 07:24:33 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52C099B for ; Wed, 24 May 2023 04:24:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927472; x=1716463472; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=T37zhJKB4e66LpPhkTxLwBGgm7jXid3yGd7uYsZk+5c=; b=NyW6RIoBhXgaQdRE2UJSLBM2O9tXyKJCZWopZlxUY1OpgaiZx4MlT2Bh mi1E8TcL6C6h5BfBid0tiGG5AGs7muyedx21bOBPrvnr0tG9GH1xFLT0B F0pbIMvzBX8FOf2sid0Ed4PMiD8G2JOQZ02Erb6meanswZs4nFvrdkKtY 6HAqm93XRkzZZCDj3WTIf4UuoquQU+f40TVADgHP6V5ol5ynEZD7KqwTX ogBQs+WXwOhBODVEPUXM9fxW42xAjeNeMiwTRARuvSajiT5K6HSjmMgrD YCv7onbTuccJgFUSfnODkrLCQwm3JdI1wVeMBoaSd7rX58KHewO+uo+Y1 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758165" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758165" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540566" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540566" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:28 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 4AFE1121481; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6H-Mj; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 07/32] media: v4l: async: Drop unneeded list entry initialisation Date: Wed, 24 May 2023 14:23:24 +0300 Message-Id: <20230524112349.2141396-8-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The list entry is initialised as a head in v4l2_async_register_subdev() just before being added to the list. This isn't needed, drop the initialisation. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 320fe5cbaaf41..aef9a16e892ef 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -823,8 +823,6 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) mutex_lock(&list_lock); - INIT_LIST_HEAD(&sd->async_list); - list_for_each_entry(notifier, ¬ifier_list, list) { struct v4l2_device *v4l2_dev = v4l2_async_nf_find_v4l2_dev(notifier); From patchwork Wed May 24 11:23:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685563 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 02C23C7EE2C for ; Wed, 24 May 2023 11:24:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234242AbjEXLYj (ORCPT ); Wed, 24 May 2023 07:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbjEXLYg (ORCPT ); Wed, 24 May 2023 07:24:36 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4663119D for ; Wed, 24 May 2023 04:24:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927474; x=1716463474; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jMAS3HMI/TDbDnxXjg/fxl/vQxm8kPQ3fbao38ebTU0=; b=EUBUmi0T8ROXrRMv2OZbXeLSwpJzPwmsAp2Bn7flbHKAJWJvdTDSNB/d CMiTlASJWjU0/zcbvuSxUvazTOEVYwOZKCJ8t+eOjd0E9oOmyTWpMxQ/w jKyWl6uXvv9KAeySYr2qjb0XI8vVo5HGYJToldfCWtjjdpMysnFbVfZ6e Jv9F+oyqlzXejU/gdVVF/8l+iUwakquxjvFBJOUN1mUf5Rk+u00RLQgF1 lDEFaw+bQ35ReW71dDPI+NnYCrkFt+vnKTnZtroqdwltrgBOxsiP7ktgf nSMj29Maz2H5/iLz9jd+VAKfXlcfo84BGhNIGEtImpllgruXE7naZxu3+ A==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758208" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758208" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540578" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540578" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:28 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 5AB36122C09; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6R-P1; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 10/32] media: v4l: async: Rename V4L2_ASYNC_MATCH_ macros, add TYPE_ Date: Wed, 24 May 2023 14:23:27 +0300 Message-Id: <20230524112349.2141396-11-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The async match type is a struct field now, rename V4L2_ASYNC_MATCH_* macros as V4L2_ASYNC_MATCH_TYPE_* instead. This patch has been produced by: git grep -l V4L2_ASYNC_MATCH_ -- drivers/media/ drivers/staging/media/ \ include/ Documentation/|xargs perl -i -pe \ 's/V4L2_ASYNC_MATCH_\K/TYPE_/g' so it must be correct. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 22 +++++++++++----------- include/media/v4l2-async.h | 16 ++++++++-------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 7f56648e40c44..93234c316aa6e 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -213,10 +213,10 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, list_for_each_entry(asd, ¬ifier->waiting, list) { /* bus_type has been verified valid before */ switch (asd->match.type) { - case V4L2_ASYNC_MATCH_I2C: + case V4L2_ASYNC_MATCH_TYPE_I2C: match = match_i2c; break; - case V4L2_ASYNC_MATCH_FWNODE: + case V4L2_ASYNC_MATCH_TYPE_FWNODE: match = match_fwnode; break; default: @@ -241,12 +241,12 @@ static bool asd_equal(struct v4l2_async_subdev *asd_x, return false; switch (asd_x->match.type) { - case V4L2_ASYNC_MATCH_I2C: + case V4L2_ASYNC_MATCH_TYPE_I2C: return asd_x->match.i2c.adapter_id == asd_y->match.i2c.adapter_id && asd_x->match.i2c.address == asd_y->match.i2c.address; - case V4L2_ASYNC_MATCH_FWNODE: + case V4L2_ASYNC_MATCH_TYPE_FWNODE: return asd_x->match.fwnode == asd_y->match.fwnode; default: break; @@ -553,8 +553,8 @@ static int v4l2_async_nf_asd_valid(struct v4l2_async_notifier *notifier, struct device *dev = notifier_dev(notifier); switch (asd->match.type) { - case V4L2_ASYNC_MATCH_I2C: - case V4L2_ASYNC_MATCH_FWNODE: + case V4L2_ASYNC_MATCH_TYPE_I2C: + case V4L2_ASYNC_MATCH_TYPE_FWNODE: if (v4l2_async_nf_has_async_subdev(notifier, asd, skip_self)) { dev_dbg(dev, "v4l2-async: subdev descriptor already listed in a notifier\n"); return -EEXIST; @@ -689,7 +689,7 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) list_for_each_entry_safe(asd, tmp, ¬ifier->asd_list, asd_list) { switch (asd->match.type) { - case V4L2_ASYNC_MATCH_FWNODE: + case V4L2_ASYNC_MATCH_TYPE_FWNODE: fwnode_handle_put(asd->match.fwnode); break; default: @@ -743,7 +743,7 @@ __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, if (!asd) return ERR_PTR(-ENOMEM); - asd->match.type = V4L2_ASYNC_MATCH_FWNODE; + asd->match.type = V4L2_ASYNC_MATCH_TYPE_FWNODE; asd->match.fwnode = fwnode_handle_get(fwnode); ret = __v4l2_async_nf_add_subdev(notifier, asd); @@ -790,7 +790,7 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, int adapter_id, if (!asd) return ERR_PTR(-ENOMEM); - asd->match.type = V4L2_ASYNC_MATCH_I2C; + asd->match.type = V4L2_ASYNC_MATCH_TYPE_I2C; asd->match.i2c.adapter_id = adapter_id; asd->match.i2c.address = address; @@ -902,11 +902,11 @@ static void print_waiting_subdev(struct seq_file *s, struct v4l2_async_subdev *asd) { switch (asd->match.type) { - case V4L2_ASYNC_MATCH_I2C: + case V4L2_ASYNC_MATCH_TYPE_I2C: seq_printf(s, " [i2c] dev=%d-%04x\n", asd->match.i2c.adapter_id, asd->match.i2c.address); break; - case V4L2_ASYNC_MATCH_FWNODE: { + case V4L2_ASYNC_MATCH_TYPE_FWNODE: { struct fwnode_handle *devnode, *fwnode = asd->match.fwnode; devnode = fwnode_graph_is_endpoint(fwnode) ? diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index d347ef32f4ecb..8d1506a9755c3 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -22,15 +22,15 @@ struct v4l2_async_notifier; * enum v4l2_async_match_type - type of asynchronous subdevice logic to be used * in order to identify a match * - * @V4L2_ASYNC_MATCH_I2C: Match will check for I2C adapter ID and address - * @V4L2_ASYNC_MATCH_FWNODE: Match will use firmware node + * @V4L2_ASYNC_MATCH_TYPE_I2C: Match will check for I2C adapter ID and address + * @V4L2_ASYNC_MATCH_TYPE_FWNODE: Match will use firmware node * * This enum is used by the asynchronous sub-device logic to define the * algorithm that will be used to match an asynchronous device. */ enum v4l2_async_match_type { - V4L2_ASYNC_MATCH_I2C, - V4L2_ASYNC_MATCH_FWNODE, + V4L2_ASYNC_MATCH_TYPE_I2C, + V4L2_ASYNC_MATCH_TYPE_FWNODE, }; /** @@ -38,17 +38,17 @@ enum v4l2_async_match_type { * * @type: type of match that will be used * @fwnode: pointer to &struct fwnode_handle to be matched. - * Used if @match_type is %V4L2_ASYNC_MATCH_FWNODE. + * Used if @match_type is %V4L2_ASYNC_MATCH_TYPE_FWNODE. * @i2c: embedded struct with I2C parameters to be matched. * Both @match.i2c.adapter_id and @match.i2c.address * should be matched. - * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * Used if @match_type is %V4L2_ASYNC_MATCH_TYPE_I2C. * @i2c.adapter_id: * I2C adapter ID to be matched. - * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * Used if @match_type is %V4L2_ASYNC_MATCH_TYPE_I2C. * @i2c.address: * I2C address to be matched. - * Used if @match_type is %V4L2_ASYNC_MATCH_I2C. + * Used if @match_type is %V4L2_ASYNC_MATCH_TYPE_I2C. */ struct v4l2_async_match_desc { enum v4l2_async_match_type type; From patchwork Wed May 24 11:23:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685564 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 4CCF1C7EE2D for ; Wed, 24 May 2023 11:24:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234808AbjEXLYh (ORCPT ); Wed, 24 May 2023 07:24:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234741AbjEXLYf (ORCPT ); Wed, 24 May 2023 07:24:35 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C3CC194 for ; Wed, 24 May 2023 04:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927473; x=1716463473; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sVzSieDl8rT3JgFnzN7BqM2wqcv289dzChhcjkxIGJs=; b=EYH/2dpFn1oy/V2BqGztwUE4wCSqWVeguVFrUJtCgn5aSQY6uKJkZtOd WAyU9H1+TU62KEUWhrCyZZVT+1ejxOlw0qfHO9tPCRpbjYOCPyTvop5ZL pcuTJxCaV9wwL1gW9mKzsSH9A4oMyYBGJYt9V/pVVDLcpxJhHu6ii+IIS SWClLBsdd1Brd1w/yCqeITjqAmbUyqTkzrLAerBt9o/ktr+78sQTLOvuz eapBlHkG58pXYPg9WP8LwH+pPIpb0vDThDQDResrcqjhCZQwz2opslseM 6X0EEz39mqHJ2M4+cCQeZ3t/HWDEIzvp6BGuVMzY6tBrg7NWEzVGckOWy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758194" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758194" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540574" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540574" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:28 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 60B1E122FE3; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6U-Pg; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 11/32] media: v4l: async: Only pass match information for async subdev validation Date: Wed, 24 May 2023 14:23:28 +0300 Message-Id: <20230524112349.2141396-12-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Pass only information required for sub-device matching to functions checking whether the async sub-device already exists. Do the same for debug message printing. This makes further changes to other aspects of async sub-devices easier. Accordingly, also perform further renames: asd_equal as v4l2_async_match_equal, v4l2_async_nf_has_async_subdev as v4l2_async_nf_has_async_match, __v4l2_async_nf_has_async_subdev as v4l2_async_nf_has_async_subdev_entry and v4l2_async_nf_asd_valid as v4l2_async_nf_match_valid. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 109 ++++++++++++++------------- 1 file changed, 56 insertions(+), 53 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 93234c316aa6e..5eb9850f1c6c4 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -64,14 +64,15 @@ static void v4l2_async_nf_call_destroy(struct v4l2_async_notifier *n, } static bool match_i2c(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) + struct v4l2_subdev *sd, + struct v4l2_async_match_desc *match) { #if IS_ENABLED(CONFIG_I2C) struct i2c_client *client = i2c_verify_client(sd->dev); return client && - asd->match.i2c.adapter_id == client->adapter->nr && - asd->match.i2c.address == client->addr; + match->i2c.adapter_id == client->adapter->nr && + match->i2c.address == client->addr; #else return false; #endif @@ -91,7 +92,7 @@ static struct device *notifier_dev(struct v4l2_async_notifier *notifier) static bool match_fwnode_one(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct fwnode_handle *sd_fwnode, - struct v4l2_async_subdev *asd) + struct v4l2_async_match_desc *match) { struct fwnode_handle *other_fwnode; struct fwnode_handle *dev_fwnode; @@ -101,14 +102,14 @@ match_fwnode_one(struct v4l2_async_notifier *notifier, dev_dbg(notifier_dev(notifier), "v4l2-async: fwnode match: need %pfw, trying %pfw\n", - sd_fwnode, asd->match.fwnode); + sd_fwnode, match->fwnode); /* * Both the subdev and the async subdev can provide either an endpoint * fwnode or a device fwnode. Start with the simple case of direct * fwnode matching. */ - if (sd_fwnode == asd->match.fwnode) { + if (sd_fwnode == match->fwnode) { dev_dbg(notifier_dev(notifier), "v4l2-async: direct match found\n"); return true; @@ -123,7 +124,7 @@ match_fwnode_one(struct v4l2_async_notifier *notifier, * match unconnected endpoints. */ sd_fwnode_is_ep = fwnode_graph_is_endpoint(sd_fwnode); - asd_fwnode_is_ep = fwnode_graph_is_endpoint(asd->match.fwnode); + asd_fwnode_is_ep = fwnode_graph_is_endpoint(match->fwnode); if (sd_fwnode_is_ep == asd_fwnode_is_ep) { dev_dbg(notifier_dev(notifier), @@ -137,9 +138,9 @@ match_fwnode_one(struct v4l2_async_notifier *notifier, */ if (sd_fwnode_is_ep) { dev_fwnode = fwnode_graph_get_port_parent(sd_fwnode); - other_fwnode = asd->match.fwnode; + other_fwnode = match->fwnode; } else { - dev_fwnode = fwnode_graph_get_port_parent(asd->match.fwnode); + dev_fwnode = fwnode_graph_get_port_parent(match->fwnode); other_fwnode = sd_fwnode; } @@ -179,13 +180,14 @@ match_fwnode_one(struct v4l2_async_notifier *notifier, } static bool match_fwnode(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *sd, struct v4l2_async_subdev *asd) + struct v4l2_subdev *sd, + struct v4l2_async_match_desc *match) { dev_dbg(notifier_dev(notifier), "v4l2-async: matching for notifier %pfw, sd fwnode %pfw\n", dev_fwnode(notifier_dev(notifier)), sd->fwnode); - if (match_fwnode_one(notifier, sd, sd->fwnode, asd)) + if (match_fwnode_one(notifier, sd, sd->fwnode, match)) return true; /* Also check the secondary fwnode. */ @@ -195,7 +197,7 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier, dev_dbg(notifier_dev(notifier), "v4l2-async: trying secondary fwnode match\n"); - return match_fwnode_one(notifier, sd, sd->fwnode->secondary, asd); + return match_fwnode_one(notifier, sd, sd->fwnode->secondary, match); } static LIST_HEAD(subdev_list); @@ -207,7 +209,8 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd) { bool (*match)(struct v4l2_async_notifier *notifier, - struct v4l2_subdev *sd, struct v4l2_async_subdev *asd); + struct v4l2_subdev *sd, + struct v4l2_async_match_desc *match); struct v4l2_async_subdev *asd; list_for_each_entry(asd, ¬ifier->waiting, list) { @@ -226,7 +229,7 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, } /* match cannot be NULL here */ - if (match(notifier, sd, asd)) + if (match(notifier, sd, &asd->match)) return asd; } @@ -234,20 +237,18 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, } /* Compare two async sub-device descriptors for equivalence */ -static bool asd_equal(struct v4l2_async_subdev *asd_x, - struct v4l2_async_subdev *asd_y) +static bool v4l2_async_match_equal(struct v4l2_async_match_desc *match1, + struct v4l2_async_match_desc *match2) { - if (asd_x->match.type != asd_y->match.type) + if (match1->type != match2->type) return false; - switch (asd_x->match.type) { + switch (match1->type) { case V4L2_ASYNC_MATCH_TYPE_I2C: - return asd_x->match.i2c.adapter_id == - asd_y->match.i2c.adapter_id && - asd_x->match.i2c.address == - asd_y->match.i2c.address; + return match1->i2c.adapter_id == match2->i2c.adapter_id && + match1->i2c.address == match2->i2c.address; case V4L2_ASYNC_MATCH_TYPE_FWNODE: - return asd_x->match.fwnode == asd_y->match.fwnode; + return match1->fwnode == match2->fwnode; default: break; } @@ -497,21 +498,21 @@ v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier, /* See if an async sub-device can be found in a notifier's lists. */ static bool -__v4l2_async_nf_has_async_subdev(struct v4l2_async_notifier *notifier, - struct v4l2_async_subdev *asd) +v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier, + struct v4l2_async_match_desc *match) { - struct v4l2_async_subdev *asd_y; + struct v4l2_async_subdev *asd; struct v4l2_subdev *sd; - list_for_each_entry(asd_y, ¬ifier->waiting, list) - if (asd_equal(asd, asd_y)) + list_for_each_entry(asd, ¬ifier->waiting, list) + if (v4l2_async_match_equal(&asd->match, match)) return true; list_for_each_entry(sd, ¬ifier->done, async_list) { if (WARN_ON(!sd->asd)) continue; - if (asd_equal(asd, sd->asd)) + if (v4l2_async_match_equal(&sd->asd->match, match)) return true; } @@ -523,46 +524,48 @@ __v4l2_async_nf_has_async_subdev(struct v4l2_async_notifier *notifier, * whether it exists in a given notifier. */ static bool -v4l2_async_nf_has_async_subdev(struct v4l2_async_notifier *notifier, - struct v4l2_async_subdev *asd, bool skip_self) +v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier, + struct v4l2_async_match_desc *match, + bool skip_self) { - struct v4l2_async_subdev *asd_y; + struct v4l2_async_subdev *asd; lockdep_assert_held(&list_lock); /* Check that an asd is not being added more than once. */ - list_for_each_entry(asd_y, ¬ifier->asd_list, asd_list) { - if (skip_self && asd == asd_y) + list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { + if (skip_self && &asd->match == match) break; - if (asd_equal(asd, asd_y)) + if (v4l2_async_match_equal(&asd->match, match)) return true; } /* Check that an asd does not exist in other notifiers. */ list_for_each_entry(notifier, ¬ifier_list, list) - if (__v4l2_async_nf_has_async_subdev(notifier, asd)) + if (v4l2_async_nf_has_async_match_entry(notifier, match)) return true; return false; } -static int v4l2_async_nf_asd_valid(struct v4l2_async_notifier *notifier, - struct v4l2_async_subdev *asd, - bool skip_self) +static int v4l2_async_nf_match_valid(struct v4l2_async_notifier *notifier, + struct v4l2_async_match_desc *match, + bool skip_self) { struct device *dev = notifier_dev(notifier); - switch (asd->match.type) { + switch (match->type) { case V4L2_ASYNC_MATCH_TYPE_I2C: case V4L2_ASYNC_MATCH_TYPE_FWNODE: - if (v4l2_async_nf_has_async_subdev(notifier, asd, skip_self)) { - dev_dbg(dev, "v4l2-async: subdev descriptor already listed in a notifier\n"); + if (v4l2_async_nf_has_async_match(notifier, match, + skip_self)) { + dev_dbg(dev, "v4l2-async: match descriptor already listed in a notifier\n"); return -EEXIST; } break; default: - dev_err(dev, "v4l2-asymc: Invalid match type %u on %p\n", - asd->match.type, asd); + dev_err(dev, "v4l2-async: Invalid match type %u on %p\n", + match->type, match); return -EINVAL; } @@ -586,7 +589,7 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) mutex_lock(&list_lock); list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { - ret = v4l2_async_nf_asd_valid(notifier, asd, true); + ret = v4l2_async_nf_match_valid(notifier, &asd->match, true); if (ret) goto err_unlock; @@ -720,7 +723,7 @@ static int __v4l2_async_nf_add_subdev(struct v4l2_async_notifier *notifier, mutex_lock(&list_lock); - ret = v4l2_async_nf_asd_valid(notifier, asd, false); + ret = v4l2_async_nf_match_valid(notifier, &asd->match, false); if (ret) goto unlock; @@ -898,16 +901,16 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) } EXPORT_SYMBOL(v4l2_async_unregister_subdev); -static void print_waiting_subdev(struct seq_file *s, - struct v4l2_async_subdev *asd) +static void print_waiting_match(struct seq_file *s, + struct v4l2_async_match_desc *match) { - switch (asd->match.type) { + switch (match->type) { case V4L2_ASYNC_MATCH_TYPE_I2C: - seq_printf(s, " [i2c] dev=%d-%04x\n", asd->match.i2c.adapter_id, - asd->match.i2c.address); + seq_printf(s, " [i2c] dev=%d-%04x\n", match->i2c.adapter_id, + match->i2c.address); break; case V4L2_ASYNC_MATCH_TYPE_FWNODE: { - struct fwnode_handle *devnode, *fwnode = asd->match.fwnode; + struct fwnode_handle *devnode, *fwnode = match->fwnode; devnode = fwnode_graph_is_endpoint(fwnode) ? fwnode_graph_get_port_parent(fwnode) : @@ -944,7 +947,7 @@ static int pending_subdevs_show(struct seq_file *s, void *data) list_for_each_entry(notif, ¬ifier_list, list) { seq_printf(s, "%s:\n", v4l2_async_nf_name(notif)); list_for_each_entry(asd, ¬if->waiting, list) - print_waiting_subdev(s, asd); + print_waiting_match(s, &asd->match); } mutex_unlock(&list_lock); From patchwork Wed May 24 11:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685561 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 7C432C77B73 for ; Wed, 24 May 2023 11:24:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230160AbjEXLYz (ORCPT ); Wed, 24 May 2023 07:24:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234826AbjEXLYp (ORCPT ); Wed, 24 May 2023 07:24:45 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC9991A2 for ; Wed, 24 May 2023 04:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927479; x=1716463479; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9jgPxN6OX20jqETUAYEDVNv2TUmJX1dRWP5WHm/4Zic=; b=lqwCufFDxa2thEP+AZVcyzySEsSOKKSHZ0Dhl+0p8h9U7vIhNwqUvN01 kz7gzKjdzXfY/HYqltCgDqYOVedYwQun7LugaVngHK3O4yxa5hBoCGTkI dnuHLvdZSnXlLLzNH8mgZebfouk1KpC+nqLMmIMaZ3IZPiK8NY7/57zTJ 2d+e/4ca7GyjDdtpRqGVnv1V9kQtMyk6nLnNeswvVo/+Y3xh9DukH3dqA 1IrOPB8molUBpFJ3PBC6MVkF4Qhj4Vjw7kX+4e3rKdgSUYtvqqtNC/9/a 0vhzG/yXwehrVtn8y4aL0H/MOv6eyMnG/NPuibQDY2chBE5wZ4gxV3rte A==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758234" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758234" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540580" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540580" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:28 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6651D122FE4; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6Z-QP; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 12/32] media: v4l: async: Clean up list heads and entries Date: Wed, 24 May 2023 14:23:29 +0300 Message-Id: <20230524112349.2141396-13-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The naming of list heads and list entries is confusing as they're named similarly. Use _list for list head and _entry for list entries. Signed-off-by: Sakari Ailus --- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 6 +-- drivers/media/v4l2-core/v4l2-async.c | 54 +++++++++---------- drivers/staging/media/tegra-video/vi.c | 4 +- include/media/v4l2-async.h | 36 ++++++------- include/media/v4l2-subdev.h | 2 +- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c index 3c84cb1216320..9231d6a65f4ec 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c @@ -1420,7 +1420,7 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) unsigned int pad; int ret; - list_for_each_entry(asd, &cio2->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &cio2->notifier.asd_list, asd_entry) { s_asd = to_sensor_asd(asd); q = &cio2->queue[s_asd->csi2.port]; diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index b309af0c83749..52c5a7decf284 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -56,7 +56,7 @@ xvip_graph_find_entity(struct xvip_composite_device *xdev, struct xvip_graph_entity *entity; struct v4l2_async_subdev *asd; - list_for_each_entry(asd, &xdev->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &xdev->notifier.asd_list, asd_entry) { entity = to_xvip_entity(asd); if (entity->asd.match.fwnode == fwnode) return entity; @@ -291,7 +291,7 @@ static int xvip_graph_notify_complete(struct v4l2_async_notifier *notifier) dev_dbg(xdev->dev, "notify complete, all subdevs registered\n"); /* Create links for every entity. */ - list_for_each_entry(asd, &xdev->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &xdev->notifier.asd_list, asd_entry) { entity = to_xvip_entity(asd); ret = xvip_graph_build_one(xdev, entity); if (ret < 0) @@ -393,7 +393,7 @@ static int xvip_graph_parse(struct xvip_composite_device *xdev) if (ret < 0) return 0; - list_for_each_entry(asd, &xdev->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &xdev->notifier.asd_list, asd_entry) { entity = to_xvip_entity(asd); ret = xvip_graph_parse_one(xdev, entity->asd.match.fwnode); if (ret < 0) { diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 5eb9850f1c6c4..06b1e1a1a5f87 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -213,7 +213,7 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, struct v4l2_async_match_desc *match); struct v4l2_async_subdev *asd; - list_for_each_entry(asd, ¬ifier->waiting, list) { + list_for_each_entry(asd, ¬ifier->waiting_list, waiting_entry) { /* bus_type has been verified valid before */ switch (asd->match.type) { case V4L2_ASYNC_MATCH_TYPE_I2C: @@ -262,7 +262,7 @@ v4l2_async_find_subdev_notifier(struct v4l2_subdev *sd) { struct v4l2_async_notifier *n; - list_for_each_entry(n, ¬ifier_list, list) + list_for_each_entry(n, ¬ifier_list, notifier_entry) if (n->sd == sd) return n; @@ -287,10 +287,10 @@ v4l2_async_nf_can_complete(struct v4l2_async_notifier *notifier) { struct v4l2_subdev *sd; - if (!list_empty(¬ifier->waiting)) + if (!list_empty(¬ifier->waiting_list)) return false; - list_for_each_entry(sd, ¬ifier->done, async_list) { + list_for_each_entry(sd, ¬ifier->done_list, async_list) { struct v4l2_async_notifier *subdev_notifier = v4l2_async_find_subdev_notifier(sd); @@ -312,7 +312,7 @@ v4l2_async_nf_try_complete(struct v4l2_async_notifier *notifier) struct v4l2_async_notifier *__notifier = notifier; /* Quick check whether there are still more sub-devices here. */ - if (!list_empty(¬ifier->waiting)) + if (!list_empty(¬ifier->waiting_list)) return 0; if (notifier->sd) @@ -391,13 +391,12 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, return ret; } - /* Remove from the waiting list */ - list_del(&asd->list); + list_del(&asd->waiting_entry); sd->asd = asd; sd->notifier = notifier; /* Move from the global subdevice list to notifier's done */ - list_move(&sd->async_list, ¬ifier->done); + list_move(&sd->async_list, ¬ifier->done_list); dev_dbg(notifier_dev(notifier), "v4l2-async: %s bound (ret %d)\n", dev_name(sd->dev), ret); @@ -478,7 +477,7 @@ v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier, { struct v4l2_subdev *sd, *tmp; - list_for_each_entry_safe(sd, tmp, ¬ifier->done, async_list) { + list_for_each_entry_safe(sd, tmp, ¬ifier->done_list, async_list) { struct v4l2_async_notifier *subdev_notifier = v4l2_async_find_subdev_notifier(sd); @@ -487,7 +486,8 @@ v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier, v4l2_async_nf_call_unbind(notifier, sd, sd->asd); if (readd) - list_add_tail(&sd->asd->list, ¬ifier->waiting); + list_add_tail(&sd->asd->waiting_entry, + ¬ifier->waiting_list); v4l2_async_cleanup(sd); list_move(&sd->async_list, &subdev_list); @@ -504,11 +504,11 @@ v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier, struct v4l2_async_subdev *asd; struct v4l2_subdev *sd; - list_for_each_entry(asd, ¬ifier->waiting, list) + list_for_each_entry(asd, ¬ifier->waiting_list, waiting_entry) if (v4l2_async_match_equal(&asd->match, match)) return true; - list_for_each_entry(sd, ¬ifier->done, async_list) { + list_for_each_entry(sd, ¬ifier->done_list, async_list) { if (WARN_ON(!sd->asd)) continue; @@ -533,7 +533,7 @@ v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier, lockdep_assert_held(&list_lock); /* Check that an asd is not being added more than once. */ - list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { + list_for_each_entry(asd, ¬ifier->asd_list, asd_entry) { if (skip_self && &asd->match == match) break; if (v4l2_async_match_equal(&asd->match, match)) @@ -541,7 +541,7 @@ v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier, } /* Check that an asd does not exist in other notifiers. */ - list_for_each_entry(notifier, ¬ifier_list, list) + list_for_each_entry(notifier, ¬ifier_list, notifier_entry) if (v4l2_async_nf_has_async_match_entry(notifier, match)) return true; @@ -583,17 +583,17 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) struct v4l2_async_subdev *asd; int ret; - INIT_LIST_HEAD(¬ifier->waiting); - INIT_LIST_HEAD(¬ifier->done); + INIT_LIST_HEAD(¬ifier->waiting_list); + INIT_LIST_HEAD(¬ifier->done_list); mutex_lock(&list_lock); - list_for_each_entry(asd, ¬ifier->asd_list, asd_list) { + list_for_each_entry(asd, ¬ifier->asd_list, asd_entry) { ret = v4l2_async_nf_match_valid(notifier, &asd->match, true); if (ret) goto err_unlock; - list_add_tail(&asd->list, ¬ifier->waiting); + list_add_tail(&asd->waiting_entry, ¬ifier->waiting_list); } ret = v4l2_async_nf_try_all_subdevs(notifier); @@ -605,7 +605,7 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) goto err_unbind; /* Keep also completed notifiers on the list */ - list_add(¬ifier->list, ¬ifier_list); + list_add(¬ifier->notifier_entry, ¬ifier_list); mutex_unlock(&list_lock); @@ -670,7 +670,7 @@ __v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier) notifier->sd = NULL; notifier->v4l2_dev = NULL; - list_del(¬ifier->list); + list_del(¬ifier->notifier_entry); } void v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier) @@ -690,7 +690,7 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) if (!notifier || !notifier->asd_list.next) return; - list_for_each_entry_safe(asd, tmp, ¬ifier->asd_list, asd_list) { + list_for_each_entry_safe(asd, tmp, ¬ifier->asd_list, asd_entry) { switch (asd->match.type) { case V4L2_ASYNC_MATCH_TYPE_FWNODE: fwnode_handle_put(asd->match.fwnode); @@ -699,7 +699,7 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) break; } - list_del(&asd->asd_list); + list_del(&asd->asd_entry); v4l2_async_nf_call_destroy(notifier, asd); kfree(asd); } @@ -727,7 +727,7 @@ static int __v4l2_async_nf_add_subdev(struct v4l2_async_notifier *notifier, if (ret) goto unlock; - list_add_tail(&asd->asd_list, ¬ifier->asd_list); + list_add_tail(&asd->asd_entry, ¬ifier->asd_list); unlock: mutex_unlock(&list_lock); @@ -823,7 +823,7 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) mutex_lock(&list_lock); - list_for_each_entry(notifier, ¬ifier_list, list) { + list_for_each_entry(notifier, ¬ifier_list, notifier_entry) { struct v4l2_device *v4l2_dev = v4l2_async_nf_find_v4l2_dev(notifier); struct v4l2_async_subdev *asd; @@ -890,7 +890,7 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) if (sd->asd) { struct v4l2_async_notifier *notifier = sd->notifier; - list_add(&sd->asd->list, ¬ifier->waiting); + list_add(&sd->asd->waiting_entry, ¬ifier->waiting_list); v4l2_async_nf_call_unbind(notifier, sd, sd->asd); } @@ -944,9 +944,9 @@ static int pending_subdevs_show(struct seq_file *s, void *data) mutex_lock(&list_lock); - list_for_each_entry(notif, ¬ifier_list, list) { + list_for_each_entry(notif, ¬ifier_list, notifier_entry) { seq_printf(s, "%s:\n", v4l2_async_nf_name(notif)); - list_for_each_entry(asd, ¬if->waiting, list) + list_for_each_entry(asd, ¬if->waiting_list, waiting_entry) print_waiting_match(s, &asd->match); } diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index 2f1aff7e87170..350871f34f7cc 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1565,7 +1565,7 @@ tegra_vi_graph_find_entity(struct tegra_vi_channel *chan, struct tegra_vi_graph_entity *entity; struct v4l2_async_subdev *asd; - list_for_each_entry(asd, &chan->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &chan->notifier.asd_list, asd_entry) { entity = to_tegra_vi_graph_entity(asd); if (entity->asd.match.fwnode == fwnode) return entity; @@ -1709,7 +1709,7 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) } /* create links between the entities */ - list_for_each_entry(asd, &chan->notifier.asd_list, asd_list) { + list_for_each_entry(asd, &chan->notifier.asd_list, asd_entry) { entity = to_tegra_vi_graph_entity(asd); ret = tegra_vi_graph_build(chan, entity); if (ret < 0) diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 8d1506a9755c3..54f9f45ed3d8e 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -65,10 +65,10 @@ struct v4l2_async_match_desc { * struct v4l2_async_subdev - sub-device descriptor, as known to a bridge * * @match: struct of match type and per-bus type matching data sets - * @asd_list: used to add struct v4l2_async_subdev objects to the - * master notifier @asd_list - * @list: used to link struct v4l2_async_subdev objects, waiting to be - * probed, to a notifier->waiting list + * @asd_entry: used to add struct v4l2_async_subdev objects to the + * master notifier @asd_entry + * @waiting_entry: used to link struct v4l2_async_subdev objects, waiting to be + * probed, to a notifier->waiting_list list * * When this struct is used as a member in a driver specific struct, * the driver specific struct shall contain the &struct @@ -76,8 +76,8 @@ struct v4l2_async_match_desc { */ struct v4l2_async_subdev { struct v4l2_async_match_desc match; - struct list_head list; - struct list_head asd_list; + struct list_head asd_entry; + struct list_head waiting_entry; }; /** @@ -107,9 +107,9 @@ struct v4l2_async_notifier_operations { * @sd: sub-device that registered the notifier, NULL otherwise * @parent: parent notifier * @asd_list: master list of struct v4l2_async_subdev - * @waiting: list of struct v4l2_async_subdev, waiting for their drivers - * @done: list of struct v4l2_subdev, already probed - * @list: member in a global list of notifiers + * @waiting_list: list of struct v4l2_async_subdev, waiting for their drivers + * @done_list: list of struct v4l2_subdev, already probed + * @notifier_entry: member in a global list of notifiers */ struct v4l2_async_notifier { const struct v4l2_async_notifier_operations *ops; @@ -117,9 +117,9 @@ struct v4l2_async_notifier { struct v4l2_subdev *sd; struct v4l2_async_notifier *parent; struct list_head asd_list; - struct list_head waiting; - struct list_head done; - struct list_head list; + struct list_head waiting_list; + struct list_head done_list; + struct list_head notifier_entry; }; /** @@ -134,7 +134,7 @@ void v4l2_async_debug_init(struct dentry *debugfs_dir); * * @notifier: pointer to &struct v4l2_async_notifier * - * This function initializes the notifier @asd_list. It must be called + * This function initializes the notifier @asd_entry. It must be called * before adding a subdevice to a notifier, using one of: * v4l2_async_nf_add_fwnode_remote(), v4l2_async_nf_add_fwnode() or * v4l2_async_nf_add_i2c(). @@ -147,7 +147,7 @@ __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, unsigned int asd_struct_size); /** * v4l2_async_nf_add_fwnode - Allocate and add a fwnode async - * subdev to the notifier's master asd_list. + * subdev to the notifier's master asd_entry. * * @notifier: pointer to &struct v4l2_async_notifier * @fwnode: fwnode handle of the sub-device to be matched, pointer to @@ -157,7 +157,7 @@ __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, * sub-device struct, i.e. both begin at the same memory address. * * Allocate a fwnode-matched asd of size asd_struct_size, and add it to the - * notifiers @asd_list. The function also gets a reference of the fwnode which + * notifiers @asd_entry. The function also gets a reference of the fwnode which * is released later at notifier cleanup time. */ #define v4l2_async_nf_add_fwnode(notifier, fwnode, type) \ @@ -170,7 +170,7 @@ __v4l2_async_nf_add_fwnode_remote(struct v4l2_async_notifier *notif, /** * v4l2_async_nf_add_fwnode_remote - Allocate and add a fwnode * remote async subdev to the - * notifier's master asd_list. + * notifier's master asd_entry. * * @notifier: pointer to &struct v4l2_async_notifier * @ep: local endpoint pointing to the remote sub-device to be matched, @@ -180,7 +180,7 @@ __v4l2_async_nf_add_fwnode_remote(struct v4l2_async_notifier *notif, * sub-device struct, i.e. both begin at the same memory address. * * Gets the remote endpoint of a given local endpoint, set it up for fwnode - * matching and adds the async sub-device to the notifier's @asd_list. The + * matching and adds the async sub-device to the notifier's @asd_entry. The * function also gets a reference of the fwnode which is released later at * notifier cleanup time. * @@ -196,7 +196,7 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, unsigned int asd_struct_size); /** * v4l2_async_nf_add_i2c - Allocate and add an i2c async - * subdev to the notifier's master asd_list. + * subdev to the notifier's master asd_entry. * * @notifier: pointer to &struct v4l2_async_notifier * @adapter: I2C adapter ID to be matched diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index cfd19e72d0fc4..82e4cf3dd2e05 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1020,7 +1020,7 @@ struct v4l2_subdev_platform_data { * @dev: pointer to the physical device, if any * @fwnode: The fwnode_handle of the subdev, usually the same as * either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL). - * @async_list: Links this subdev to a global subdev_list or @notifier->done + * @async_list: Links this subdev to a global subdev_entry or @notifier->done * list. * @asd: Pointer to respective &struct v4l2_async_subdev. * @notifier: Pointer to the managing notifier. From patchwork Wed May 24 11:23:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685562 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 E3FC0C77B73 for ; Wed, 24 May 2023 11:24:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234785AbjEXLYl (ORCPT ); Wed, 24 May 2023 07:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234687AbjEXLYj (ORCPT ); Wed, 24 May 2023 07:24:39 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E431A6 for ; Wed, 24 May 2023 04:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927476; x=1716463476; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=r6OzYaHwbIBCyjYRA4K5AvsYuo/ctV0Y5RCZqQ874+0=; b=mb50O2k60vio3mmbYOhS1NNO11krDKBZYzvCAy6IZmMcUnlk2ERbpg72 hYG+lQBSUzfx/dFHNWV2vrJWUgmlJRXyxOyr779LTJjLtpZ129SN9T4Qm bmzCpkY0lK4dAravmEmlipo6NV+LATPDZsW6YgBY9+E2NhpbIKLA9I7BI D60Eyw2lUnAp6Q305itU1U6i5WTkCFfTDh/CmN/FrJE2/nYPAnghBSY87 Ul3xwayqsjjzcGMhwF4ItO1pEfySlKURikwAULa6LD0NrH/vfqdolv0Ai 3u1Rop7HantzNEtztI7tvQVArntXOYRRdw89eVkd0o6V7aJLPymE/UKHw A==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758212" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758212" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540576" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540576" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:28 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 6A33A122FE6; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6d-R9; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 13/32] media: v4l: async: Simplify async sub-device fwnode matching Date: Wed, 24 May 2023 14:23:30 +0300 Message-Id: <20230524112349.2141396-14-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org V4L2 async sub-device matching originally used the device nodes only. Endpoint nodes were taken into use instead as using the device nodes was problematic for it was in some cases ambiguous which link might have been in question. There is however no need to use endpoint nodes on both sides, as the async sub-device's fwnode can always be trivially obtained using fwnode_graph_get_remote_endpoint() when needed while what counts is whether or not the link is between two device nodes, i.e. the device nodes match. This will briefly break the adv748x driver but it will be fixed later in the set, by patch "media: adv748x: Return to endpoint matching". Signed-off-by: Sakari Ailus --- drivers/media/i2c/adv748x/adv748x-csi2.c | 5 +- drivers/media/i2c/max9286.c | 14 +--- drivers/media/i2c/rdacm20.c | 16 +--- drivers/media/i2c/rdacm21.c | 15 +--- drivers/media/i2c/tc358746.c | 5 -- drivers/media/platform/nxp/imx-mipi-csis.c | 7 -- drivers/media/v4l2-core/v4l2-async.c | 88 ++++++---------------- 7 files changed, 26 insertions(+), 124 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index bd4f3fe0e3096..b6f93c1db3d2a 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -296,13 +296,12 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) if (!is_tx_enabled(tx)) return 0; + /* FIXME: Do endpoint matching again! */ + adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops, MEDIA_ENT_F_VID_IF_BRIDGE, is_txa(tx) ? "txa" : "txb"); - /* Ensure that matching is based upon the endpoint fwnodes */ - tx->sd.fwnode = of_fwnode_handle(state->endpoints[tx->port]); - /* Register internal ops for incremental subdev registration */ tx->sd.internal_ops = &adv748x_csi2_internal_ops; diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index 13a986b885889..64f5c49cae776 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -1051,7 +1051,6 @@ static const struct v4l2_ctrl_ops max9286_ctrl_ops = { static int max9286_v4l2_register(struct max9286_priv *priv) { struct device *dev = &priv->client->dev; - struct fwnode_handle *ep; int ret; int i; @@ -1093,25 +1092,14 @@ static int max9286_v4l2_register(struct max9286_priv *priv) if (ret) goto err_async; - ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(dev), MAX9286_SRC_PAD, - 0, 0); - if (!ep) { - dev_err(dev, "Unable to retrieve endpoint on \"port@4\"\n"); - ret = -ENOENT; - goto err_async; - } - priv->sd.fwnode = ep; - ret = v4l2_async_register_subdev(&priv->sd); if (ret < 0) { dev_err(dev, "Unable to register subdevice\n"); - goto err_put_node; + goto err_async; } return 0; -err_put_node: - fwnode_handle_put(ep); err_async: v4l2_ctrl_handler_free(&priv->ctrls); max9286_v4l2_notifier_unregister(priv); diff --git a/drivers/media/i2c/rdacm20.c b/drivers/media/i2c/rdacm20.c index a2263fa825b59..9d8a8f9efd835 100644 --- a/drivers/media/i2c/rdacm20.c +++ b/drivers/media/i2c/rdacm20.c @@ -567,7 +567,6 @@ static int rdacm20_initialize(struct rdacm20_device *dev) static int rdacm20_probe(struct i2c_client *client) { struct rdacm20_device *dev; - struct fwnode_handle *ep; int ret; dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); @@ -616,24 +615,12 @@ static int rdacm20_probe(struct i2c_client *client) if (ret < 0) goto error_free_ctrls; - ep = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL); - if (!ep) { - dev_err(&client->dev, - "Unable to get endpoint in node %pOF\n", - client->dev.of_node); - ret = -ENOENT; - goto error_free_ctrls; - } - dev->sd.fwnode = ep; - ret = v4l2_async_register_subdev(&dev->sd); if (ret) - goto error_put_node; + goto error_free_ctrls; return 0; -error_put_node: - fwnode_handle_put(ep); error_free_ctrls: v4l2_ctrl_handler_free(&dev->ctrls); error: @@ -650,7 +637,6 @@ static void rdacm20_remove(struct i2c_client *client) { struct rdacm20_device *dev = i2c_to_rdacm20(client); - fwnode_handle_put(dev->sd.fwnode); v4l2_async_unregister_subdev(&dev->sd); v4l2_ctrl_handler_free(&dev->ctrls); media_entity_cleanup(&dev->sd.entity); diff --git a/drivers/media/i2c/rdacm21.c b/drivers/media/i2c/rdacm21.c index 9ccc56c30d3b0..d67cfcb2e05a4 100644 --- a/drivers/media/i2c/rdacm21.c +++ b/drivers/media/i2c/rdacm21.c @@ -543,7 +543,6 @@ static int rdacm21_initialize(struct rdacm21_device *dev) static int rdacm21_probe(struct i2c_client *client) { struct rdacm21_device *dev; - struct fwnode_handle *ep; int ret; dev = devm_kzalloc(&client->dev, sizeof(*dev), GFP_KERNEL); @@ -588,24 +587,12 @@ static int rdacm21_probe(struct i2c_client *client) if (ret < 0) goto error_free_ctrls; - ep = fwnode_graph_get_next_endpoint(dev_fwnode(&client->dev), NULL); - if (!ep) { - dev_err(&client->dev, - "Unable to get endpoint in node %pOF\n", - client->dev.of_node); - ret = -ENOENT; - goto error_free_ctrls; - } - dev->sd.fwnode = ep; - ret = v4l2_async_register_subdev(&dev->sd); if (ret) - goto error_put_node; + goto error_free_ctrls; return 0; -error_put_node: - fwnode_handle_put(dev->sd.fwnode); error_free_ctrls: v4l2_ctrl_handler_free(&dev->ctrls); error: diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c index ec1a193ba161a..b37a9ff73f6ad 100644 --- a/drivers/media/i2c/tc358746.c +++ b/drivers/media/i2c/tc358746.c @@ -1476,9 +1476,6 @@ static int tc358746_async_register(struct tc358746 *tc358746) if (err) goto err_cleanup; - tc358746->sd.fwnode = fwnode_graph_get_endpoint_by_id( - dev_fwnode(tc358746->sd.dev), TC358746_SOURCE, 0, 0); - err = v4l2_async_register_subdev(&tc358746->sd); if (err) goto err_unregister; @@ -1486,7 +1483,6 @@ static int tc358746_async_register(struct tc358746 *tc358746) return 0; err_unregister: - fwnode_handle_put(tc358746->sd.fwnode); v4l2_async_nf_unregister(&tc358746->notifier); err_cleanup: v4l2_async_nf_cleanup(&tc358746->notifier); @@ -1605,7 +1601,6 @@ static void tc358746_remove(struct i2c_client *client) v4l2_fwnode_endpoint_free(&tc358746->csi_vep); v4l2_async_nf_unregister(&tc358746->notifier); v4l2_async_nf_cleanup(&tc358746->notifier); - fwnode_handle_put(sd->fwnode); v4l2_async_unregister_subdev(sd); media_entity_cleanup(&sd->entity); diff --git a/drivers/media/platform/nxp/imx-mipi-csis.c b/drivers/media/platform/nxp/imx-mipi-csis.c index 05d52762e7926..d0dc30187775d 100644 --- a/drivers/media/platform/nxp/imx-mipi-csis.c +++ b/drivers/media/platform/nxp/imx-mipi-csis.c @@ -1365,13 +1365,6 @@ static int mipi_csis_subdev_init(struct mipi_csis_device *csis) sd->dev = csis->dev; - sd->fwnode = fwnode_graph_get_endpoint_by_id(dev_fwnode(csis->dev), - 1, 0, 0); - if (!sd->fwnode) { - dev_err(csis->dev, "Unable to retrieve endpoint for port@1\n"); - return -ENOENT; - } - csis->pads[CSIS_PAD_SINK].flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; csis->pads[CSIS_PAD_SOURCE].flags = MEDIA_PAD_FL_SOURCE diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 06b1e1a1a5f87..335597889f365 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -94,89 +94,36 @@ match_fwnode_one(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd, struct fwnode_handle *sd_fwnode, struct v4l2_async_match_desc *match) { - struct fwnode_handle *other_fwnode; - struct fwnode_handle *dev_fwnode; - bool asd_fwnode_is_ep; - bool sd_fwnode_is_ep; - struct device *dev; + struct fwnode_handle *asd_dev_fwnode; + bool ret; dev_dbg(notifier_dev(notifier), "v4l2-async: fwnode match: need %pfw, trying %pfw\n", sd_fwnode, match->fwnode); - /* - * Both the subdev and the async subdev can provide either an endpoint - * fwnode or a device fwnode. Start with the simple case of direct - * fwnode matching. - */ if (sd_fwnode == match->fwnode) { dev_dbg(notifier_dev(notifier), "v4l2-async: direct match found\n"); return true; } - /* - * Otherwise, check if the sd fwnode and the asd fwnode refer to an - * endpoint or a device. If they're of the same type, there's no match. - * Technically speaking this checks if the nodes refer to a connected - * endpoint, which is the simplest check that works for both OF and - * ACPI. This won't make a difference, as drivers should not try to - * match unconnected endpoints. - */ - sd_fwnode_is_ep = fwnode_graph_is_endpoint(sd_fwnode); - asd_fwnode_is_ep = fwnode_graph_is_endpoint(match->fwnode); - - if (sd_fwnode_is_ep == asd_fwnode_is_ep) { + if (!fwnode_graph_is_endpoint(match->fwnode)) { dev_dbg(notifier_dev(notifier), "v4l2-async: direct match not found\n"); return false; } - /* - * The sd and asd fwnodes are of different types. Get the device fwnode - * parent of the endpoint fwnode, and compare it with the other fwnode. - */ - if (sd_fwnode_is_ep) { - dev_fwnode = fwnode_graph_get_port_parent(sd_fwnode); - other_fwnode = match->fwnode; - } else { - dev_fwnode = fwnode_graph_get_port_parent(match->fwnode); - other_fwnode = sd_fwnode; - } + asd_dev_fwnode = fwnode_graph_get_port_parent(match->fwnode); - dev_dbg(notifier_dev(notifier), - "v4l2-async: fwnode compat match: need %pfw, trying %pfw\n", - dev_fwnode, other_fwnode); + ret = sd_fwnode == asd_dev_fwnode; - fwnode_handle_put(dev_fwnode); + fwnode_handle_put(asd_dev_fwnode); - if (dev_fwnode != other_fwnode) { - dev_dbg(notifier_dev(notifier), - "v4l2-async: compat match not found\n"); - return false; - } - - /* - * We have a heterogeneous match. Retrieve the struct device of the side - * that matched on a device fwnode to print its driver name. - */ - if (sd_fwnode_is_ep) - dev = notifier->v4l2_dev ? notifier->v4l2_dev->dev - : notifier->sd->dev; - else - dev = sd->dev; - - if (dev && dev->driver) { - if (sd_fwnode_is_ep) - dev_warn(dev, "Driver %s uses device fwnode, incorrect match may occur\n", - dev->driver->name); - dev_notice(dev, "Consider updating driver %s to match on endpoints\n", - dev->driver->name); - } - - dev_dbg(notifier_dev(notifier), "v4l2-async: compat match found\n"); + dev_dbg(notifier_dev(notifier), + "v4l2-async: device--endpoint match %sfound\n", + ret ? "" : "not "); - return true; + return ret; } static bool match_fwnode(struct v4l2_async_notifier *notifier, @@ -814,12 +761,19 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) int ret; /* - * No reference taken. The reference is held by the device - * (struct v4l2_subdev.dev), and async sub-device does not - * exist independently of the device at any point of time. + * No reference taken. The reference is held by the device (struct + * v4l2_subdev.dev), and async sub-device does not exist independently + * of the device at any point of time. + * + * The async sub-device shall always be registered for its device node, + * not the endpoint node. */ - if (!sd->fwnode && sd->dev) + if (!sd->fwnode && sd->dev) { sd->fwnode = dev_fwnode(sd->dev); + } else if (fwnode_graph_is_endpoint(sd->fwnode)) { + dev_warn(sd->dev, "sub-device fwnode is an endpoint!\n"); + return -EINVAL; + } mutex_lock(&list_lock); From patchwork Wed May 24 11:23:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685560 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 40429C7EE2E for ; Wed, 24 May 2023 11:24:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234741AbjEXLY6 (ORCPT ); Wed, 24 May 2023 07:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234997AbjEXLYw (ORCPT ); Wed, 24 May 2023 07:24:52 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E7641B6 for ; Wed, 24 May 2023 04:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927486; x=1716463486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6aMlAn0mXT9iOdyJQzZq5jHGx+gOFMzw/HjBF3CPNd4=; b=av2OGDGbiUUw+HvgbniiWXzDOudYT/nTejm6gxmY8Khq1sS0hK5DPG1+ zihrgw9XePGB1tkK1sYaOSDrrDCXWukV+c9wSWMhHvJCULKZe6E0Fxmfh jrjLFJkUJ17w/2kw2WNCkTsEaU5naEKnXSgwqbUD6MEE+PX1I/8aWGTpi OlTVrNLxjLW4Uo8H052ahtpp+Quc7HBLXmwHugaSh3i9U4kdyaPpMxWd3 wkUCgAR2b6h5m8VwQO06knPik1hh3jHBsY1UH6iTcbslu43PA/PElOr7C wnNOuM/1l7010xzUt9pFjA8AHwyU4/41iI+y+hInhEFQvBaMEf50oiU4E Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758284" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758284" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540606" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540606" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 84C3D122FEA; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6l-Uh; Wed, 24 May 2023 14:23:59 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 15/32] media: v4l: async: Clean up error handling in v4l2_async_match_notify Date: Wed, 24 May 2023 14:23:32 +0300 Message-Id: <20230524112349.2141396-16-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add labels for error handling instead of doing it all in individual cases. Prepare for more functionality in this function. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index b1025dfc27a92..f51f0c37210c9 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -320,10 +320,8 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, return ret; ret = v4l2_async_nf_call_bound(notifier, sd, asc); - if (ret < 0) { - v4l2_device_unregister_subdev(sd); - return ret; - } + if (ret < 0) + goto err_unregister_subdev; /* * Depending of the function of the entities involved, we may want to @@ -332,11 +330,8 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, * pad). */ ret = v4l2_async_create_ancillary_links(notifier, sd); - if (ret) { - v4l2_async_nf_call_unbind(notifier, sd, asc); - v4l2_device_unregister_subdev(sd); - return ret; - } + if (ret) + goto err_call_unbind; list_del(&asc->waiting_entry); sd->asd = asc; @@ -363,6 +358,14 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, subdev_notifier->parent = notifier; return v4l2_async_nf_try_all_subdevs(subdev_notifier); + +err_call_unbind: + v4l2_async_nf_call_unbind(notifier, sd, asc); + +err_unregister_subdev: + v4l2_device_unregister_subdev(sd); + + return ret; } /* Test all async sub-devices in a notifier for a match. */ From patchwork Wed May 24 11:23:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685553 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 C8F00C7EE2C for ; Wed, 24 May 2023 11:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232226AbjEXLZf (ORCPT ); Wed, 24 May 2023 07:25:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231701AbjEXLZe (ORCPT ); Wed, 24 May 2023 07:25:34 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC9F3195 for ; Wed, 24 May 2023 04:25:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927524; x=1716463524; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9twLKHLTKUrKTmc3bjBgibvXZG2klHxpu4DxbUTbnUU=; b=Q5n1pyWmthFSvHLhRiXK3YR+TPd/C+OFAYAmhoIkJn7jYiqzjq6P7P2K 8zoz5yZ1uNbIH4Tt33UEiW07eCFJl5hV23IDYYIE6BYwnzEmqR5KU78Sw NXqaSUM23XctgLiNYUWSDvNGCgUjg40MmX+JBSwNtzqHh1dC9fRDKxpV7 seJt61blYkYJUVXWUwBrcUEnMpY2ESGrOLNhS/LRk+FKSw9XYHqiCjoeF +QjZGEBBtTdz+uYevFs3+oIM6C6TFEo9bVXB8UrQNEM8P5AdkEKT7unM5 OtWPoFu1nMnEbEuZ4FdaBTIq7xxtIbHXyPJkg+qz9GJ1oc//7HLLA0TeD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758408" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758408" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540630" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540630" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 91CD5122FEF; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb1-008z6u-Vx; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 17/32] media: v4l: async: Rework internal lists Date: Wed, 24 May 2023 14:23:34 +0300 Message-Id: <20230524112349.2141396-18-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org This patch re-arranges internal V4L2 async lists for preparation of supporting multiple connections per sub-device as well as cleaning up used lists. The list of unbound V4L2 sub-devices is maintained for the purpose of listing those sub-devices only, not for their binding status. Also, the V4L2 async connections have a single list entry in the notifier's list, be that either waiting or done lists, while the notifier's asc_list is removed. The one-to-one relation between a sub-device and a connection is still maintained in this patch. Signed-off-by: Sakari Ailus --- drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 2 +- .../platform/renesas/rcar-vin/rcar-core.c | 2 +- .../platform/renesas/rzg2l-cru/rzg2l-core.c | 2 +- drivers/media/platform/xilinx/xilinx-vipp.c | 8 +- drivers/media/v4l2-core/v4l2-async.c | 102 +++++++++--------- .../staging/media/imx/imx-media-dev-common.c | 2 +- drivers/staging/media/tegra-video/vi.c | 6 +- include/media/v4l2-async.h | 9 +- 8 files changed, 68 insertions(+), 65 deletions(-) diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c index 1893d1ff4f169..0f43b5e10f187 100644 --- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c @@ -1420,7 +1420,7 @@ static int cio2_notifier_complete(struct v4l2_async_notifier *notifier) unsigned int pad; int ret; - list_for_each_entry(asd, &cio2->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &cio2->notifier.done_list, asc_entry) { s_asd = to_sensor_asd(asd); q = &cio2->queue[s_asd->csi2.port]; diff --git a/drivers/media/platform/renesas/rcar-vin/rcar-core.c b/drivers/media/platform/renesas/rcar-vin/rcar-core.c index b0f76477b54c7..498778eb9892b 100644 --- a/drivers/media/platform/renesas/rcar-vin/rcar-core.c +++ b/drivers/media/platform/renesas/rcar-vin/rcar-core.c @@ -396,7 +396,7 @@ static int rvin_group_notifier_init(struct rvin_dev *vin, unsigned int port, } } - if (list_empty(&vin->group->notifier.asc_list)) + if (list_empty(&vin->group->notifier.waiting_list)) return 0; vin->group->notifier.ops = &rvin_group_notify_ops; diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c index 2d1093997db52..e026ed5337513 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-core.c @@ -191,7 +191,7 @@ static int rzg2l_cru_mc_parse_of_graph(struct rzg2l_cru_dev *cru) cru->notifier.ops = &rzg2l_cru_async_ops; - if (list_empty(&cru->notifier.asc_list)) + if (list_empty(&cru->notifier.waiting_list)) return 0; ret = v4l2_async_nf_register(&cru->v4l2_dev, &cru->notifier); diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index 96fbbc55eb12c..a535a7584da0f 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -56,7 +56,7 @@ xvip_graph_find_entity(struct xvip_composite_device *xdev, struct xvip_graph_entity *entity; struct v4l2_async_connection *asd; - list_for_each_entry(asd, &xdev->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &xdev->notifier.done_list, asc_entry) { entity = to_xvip_entity(asd); if (entity->asd.match.fwnode == fwnode) return entity; @@ -291,7 +291,7 @@ static int xvip_graph_notify_complete(struct v4l2_async_notifier *notifier) dev_dbg(xdev->dev, "notify complete, all subdevs registered\n"); /* Create links for every entity. */ - list_for_each_entry(asd, &xdev->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &xdev->notifier.done_list, asc_entry) { entity = to_xvip_entity(asd); ret = xvip_graph_build_one(xdev, entity); if (ret < 0) @@ -393,7 +393,7 @@ static int xvip_graph_parse(struct xvip_composite_device *xdev) if (ret < 0) return 0; - list_for_each_entry(asd, &xdev->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &xdev->notifier.waiting_list, asc_entry) { entity = to_xvip_entity(asd); ret = xvip_graph_parse_one(xdev, entity->asd.match.fwnode); if (ret < 0) { @@ -501,7 +501,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev) goto done; } - if (list_empty(&xdev->notifier.asc_list)) { + if (list_empty(&xdev->notifier.waiting_list)) { dev_err(xdev->dev, "no subdev found in graph\n"); ret = -ENOENT; goto done; diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 5dfc6d5f6a7c3..d8de9ff3249d4 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -160,7 +160,7 @@ v4l2_async_find_match(struct v4l2_async_notifier *notifier, struct v4l2_async_match_desc *match); struct v4l2_async_connection *asc; - list_for_each_entry(asc, ¬ifier->waiting_list, waiting_entry) { + list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) { /* bus_type has been verified valid before */ switch (asc->match.type) { case V4L2_ASYNC_MATCH_TYPE_I2C: @@ -232,14 +232,14 @@ v4l2_async_nf_find_v4l2_dev(struct v4l2_async_notifier *notifier) static bool v4l2_async_nf_can_complete(struct v4l2_async_notifier *notifier) { - struct v4l2_subdev *sd; + struct v4l2_async_connection *asc; if (!list_empty(¬ifier->waiting_list)) return false; - list_for_each_entry(sd, ¬ifier->done_list, async_list) { + list_for_each_entry(asc, ¬ifier->done_list, asc_entry) { struct v4l2_async_notifier *subdev_notifier = - v4l2_async_find_subdev_notifier(sd); + v4l2_async_find_subdev_notifier(asc->sd); if (subdev_notifier && !v4l2_async_nf_can_complete(subdev_notifier)) @@ -333,12 +333,13 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, if (ret) goto err_call_unbind; - list_del(&asc->waiting_entry); sd->asd = asc; sd->notifier = notifier; - /* Move from the global subdevice list to notifier's done */ - list_move(&sd->async_list, ¬ifier->done_list); + asc->sd = sd; + + /* Move from the waiting list to notifier's done */ + list_move(&asc->asc_entry, ¬ifier->done_list); dev_dbg(notifier_dev(notifier), "v4l2-async: %s bound (ret %d)\n", dev_name(sd->dev), ret); @@ -422,25 +423,23 @@ static void v4l2_async_cleanup(struct v4l2_subdev *sd) /* Unbind all sub-devices in the notifier tree. */ static void -v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier, - bool readd) +v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier) { - struct v4l2_subdev *sd, *tmp; + struct v4l2_async_connection *asc, *asc_tmp; - list_for_each_entry_safe(sd, tmp, ¬ifier->done_list, async_list) { + list_for_each_entry_safe(asc, asc_tmp, ¬ifier->done_list, + asc_entry) { struct v4l2_async_notifier *subdev_notifier = - v4l2_async_find_subdev_notifier(sd); + v4l2_async_find_subdev_notifier(asc->sd); if (subdev_notifier) - v4l2_async_nf_unbind_all_subdevs(subdev_notifier, true); + v4l2_async_nf_unbind_all_subdevs(subdev_notifier); - v4l2_async_nf_call_unbind(notifier, sd, sd->asd); - if (readd) - list_add_tail(&sd->asd->waiting_entry, - ¬ifier->waiting_list); - v4l2_async_cleanup(sd); - - list_move(&sd->async_list, &subdev_list); + v4l2_async_nf_call_unbind(notifier, asc->sd, asc); + v4l2_async_cleanup(asc->sd); + list_move_tail(&asc->asc_entry, ¬ifier->waiting_list); + list_move(&asc->sd->async_list, &subdev_list); + asc->sd = NULL; } notifier->parent = NULL; @@ -452,17 +451,16 @@ v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier, struct v4l2_async_match_desc *match) { struct v4l2_async_connection *asc; - struct v4l2_subdev *sd; - list_for_each_entry(asc, ¬ifier->waiting_list, waiting_entry) + list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) if (v4l2_async_match_equal(&asc->match, match)) return true; - list_for_each_entry(sd, ¬ifier->done_list, async_list) { - if (WARN_ON(!sd->asd)) + list_for_each_entry(asc, ¬ifier->done_list, asc_entry) { + if (WARN_ON(!asc->sd->asd)) continue; - if (v4l2_async_match_equal(&sd->asd->match, match)) + if (v4l2_async_match_equal(&asc->match, match)) return true; } @@ -477,16 +475,24 @@ static bool v4l2_async_nf_has_async_match(struct v4l2_async_notifier *notifier, struct v4l2_async_match_desc *match) { - struct v4l2_async_connection *asc; + struct list_head *heads[] = { + ¬ifier->waiting_list, + ¬ifier->done_list, + }; + unsigned int i; lockdep_assert_held(&list_lock); /* Check that an asd is not being added more than once. */ - list_for_each_entry(asc, ¬ifier->asc_list, asc_entry) { - if (&asc->match == match) - break; - if (v4l2_async_match_equal(&asc->match, match)) - return true; + for (i = 0; i < ARRAY_SIZE(heads); i++) { + struct v4l2_async_connection *asc; + + list_for_each_entry(asc, heads[i], asc_entry) { + if (&asc->match == match) + break; + if (v4l2_async_match_equal(&asc->match, match)) + return true; + } } /* Check that an asc does not exist in other notifiers. */ @@ -521,7 +527,8 @@ static int v4l2_async_nf_match_valid(struct v4l2_async_notifier *notifier, void v4l2_async_nf_init(struct v4l2_async_notifier *notifier) { - INIT_LIST_HEAD(¬ifier->asc_list); + INIT_LIST_HEAD(¬ifier->waiting_list); + INIT_LIST_HEAD(¬ifier->done_list); } EXPORT_SYMBOL(v4l2_async_nf_init); @@ -530,17 +537,12 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) struct v4l2_async_connection *asc; int ret; - INIT_LIST_HEAD(¬ifier->waiting_list); - INIT_LIST_HEAD(¬ifier->done_list); - mutex_lock(&list_lock); - list_for_each_entry(asc, ¬ifier->asc_list, asc_entry) { + list_for_each_entry(asc, ¬ifier->waiting_list, asc_entry) { ret = v4l2_async_nf_match_valid(notifier, &asc->match); if (ret) goto err_unlock; - - list_add_tail(&asc->waiting_entry, ¬ifier->waiting_list); } ret = v4l2_async_nf_try_all_subdevs(notifier); @@ -562,7 +564,7 @@ static int __v4l2_async_nf_register(struct v4l2_async_notifier *notifier) /* * On failure, unbind all sub-devices registered through this notifier. */ - v4l2_async_nf_unbind_all_subdevs(notifier, false); + v4l2_async_nf_unbind_all_subdevs(notifier); err_unlock: mutex_unlock(&list_lock); @@ -612,7 +614,7 @@ __v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier) if (!notifier || (!notifier->v4l2_dev && !notifier->sd)) return; - v4l2_async_nf_unbind_all_subdevs(notifier, false); + v4l2_async_nf_unbind_all_subdevs(notifier); notifier->sd = NULL; notifier->v4l2_dev = NULL; @@ -634,10 +636,12 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) { struct v4l2_async_connection *asc, *tmp; - if (!notifier || !notifier->asc_list.next) + if (!notifier || !notifier->waiting_list.next) return; - list_for_each_entry_safe(asc, tmp, ¬ifier->asc_list, asc_entry) { + WARN_ON(!list_empty(¬ifier->done_list)); + + list_for_each_entry_safe(asc, tmp, ¬ifier->waiting_list, asc_entry) { switch (asc->match.type) { case V4L2_ASYNC_MATCH_TYPE_FWNODE: fwnode_handle_put(asc->match.fwnode); @@ -667,7 +671,7 @@ static int __v4l2_async_nf_add_connection(struct v4l2_async_notifier *notifier, { mutex_lock(&list_lock); - list_add_tail(&asc->asc_entry, ¬ifier->asc_list); + list_add_tail(&asc->asc_entry, ¬ifier->waiting_list); mutex_unlock(&list_lock); @@ -808,10 +812,12 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) */ subdev_notifier = v4l2_async_find_subdev_notifier(sd); if (subdev_notifier) - v4l2_async_nf_unbind_all_subdevs(subdev_notifier, false); + v4l2_async_nf_unbind_all_subdevs(subdev_notifier); - if (sd->asd) + if (sd->asd) { v4l2_async_nf_call_unbind(notifier, sd, sd->asd); + sd->asd->sd = NULL; + } v4l2_async_cleanup(sd); mutex_unlock(&list_lock); @@ -837,9 +843,9 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) if (sd->asd) { struct v4l2_async_notifier *notifier = sd->notifier; - list_add(&sd->asd->waiting_entry, ¬ifier->waiting_list); - + list_move(&sd->asd->asc_entry, ¬ifier->waiting_list); v4l2_async_nf_call_unbind(notifier, sd, sd->asd); + sd->asd->sd = NULL; } v4l2_async_cleanup(sd); @@ -893,7 +899,7 @@ static int pending_subdevs_show(struct seq_file *s, void *data) list_for_each_entry(notif, ¬ifier_list, notifier_entry) { seq_printf(s, "%s:\n", v4l2_async_nf_name(notif)); - list_for_each_entry(asc, ¬if->waiting_list, waiting_entry) + list_for_each_entry(asc, ¬if->waiting_list, asc_entry) print_waiting_match(s, &asc->match); } diff --git a/drivers/staging/media/imx/imx-media-dev-common.c b/drivers/staging/media/imx/imx-media-dev-common.c index c1216b4557b69..67c1b16db6558 100644 --- a/drivers/staging/media/imx/imx-media-dev-common.c +++ b/drivers/staging/media/imx/imx-media-dev-common.c @@ -384,7 +384,7 @@ int imx_media_dev_notifier_register(struct imx_media_dev *imxmd, int ret; /* no subdevs? just bail */ - if (list_empty(&imxmd->notifier.asc_list)) { + if (list_empty(&imxmd->notifier.waiting_list)) { v4l2_err(&imxmd->v4l2_dev, "no subdevs\n"); return -ENODEV; } diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c index c93e5ac9dbf0c..146b4fd3c8b52 100644 --- a/drivers/staging/media/tegra-video/vi.c +++ b/drivers/staging/media/tegra-video/vi.c @@ -1565,7 +1565,7 @@ tegra_vi_graph_find_entity(struct tegra_vi_channel *chan, struct tegra_vi_graph_entity *entity; struct v4l2_async_connection *asd; - list_for_each_entry(asd, &chan->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &chan->notifier.done_list, asc_entry) { entity = to_tegra_vi_graph_entity(asd); if (entity->asd.match.fwnode == fwnode) return entity; @@ -1709,7 +1709,7 @@ static int tegra_vi_graph_notify_complete(struct v4l2_async_notifier *notifier) } /* create links between the entities */ - list_for_each_entry(asd, &chan->notifier.asc_list, asc_entry) { + list_for_each_entry(asd, &chan->notifier.done_list, asc_entry) { entity = to_tegra_vi_graph_entity(asd); ret = tegra_vi_graph_build(chan, entity); if (ret < 0) @@ -1876,7 +1876,7 @@ static int tegra_vi_graph_init(struct tegra_vi *vi) ret = tegra_vi_graph_parse_one(chan, remote); fwnode_handle_put(remote); - if (ret < 0 || list_empty(&chan->notifier.asc_list)) + if (ret < 0 || list_empty(&chan->notifier.waiting_list)) continue; chan->notifier.ops = &tegra_vi_async_ops; diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 38d9d097fdb52..56b7238e2cbe2 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -66,9 +66,8 @@ struct v4l2_async_match_desc { * * @match: struct of match type and per-bus type matching data sets * @asc_entry: used to add struct v4l2_async_connection objects to the - * master notifier @asc_list - * @waiting_entry: used to link struct v4l2_async_connection objects, waiting to - * be probed, to a notifier->waiting_list list + * notifier @waiting_list or @done_list + * @sd: the related sub-device * * When this struct is used as a member in a driver specific struct, * the driver specific struct shall contain the &struct @@ -77,7 +76,7 @@ struct v4l2_async_match_desc { struct v4l2_async_connection { struct v4l2_async_match_desc match; struct list_head asc_entry; - struct list_head waiting_entry; + struct v4l2_subdev *sd; }; /** @@ -106,7 +105,6 @@ struct v4l2_async_notifier_operations { * @v4l2_dev: v4l2_device of the root notifier, NULL otherwise * @sd: sub-device that registered the notifier, NULL otherwise * @parent: parent notifier - * @asc_list: master list of struct v4l2_async_subdev * @waiting_list: list of struct v4l2_async_subdev, waiting for their drivers * @done_list: list of struct v4l2_subdev, already probed * @notifier_entry: member in a global list of notifiers @@ -116,7 +114,6 @@ struct v4l2_async_notifier { struct v4l2_device *v4l2_dev; struct v4l2_subdev *sd; struct v4l2_async_notifier *parent; - struct list_head asc_list; struct list_head waiting_list; struct list_head done_list; struct list_head notifier_entry; From patchwork Wed May 24 11:23:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685554 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 A31E8C77B7A for ; Wed, 24 May 2023 11:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231867AbjEXLZ2 (ORCPT ); Wed, 24 May 2023 07:25:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231701AbjEXLZ1 (ORCPT ); Wed, 24 May 2023 07:25:27 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0260EE42 for ; Wed, 24 May 2023 04:25:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927519; x=1716463519; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=/URpm4WDlsGLk8zP/G7udFuSFquei94ubPDSXiuWRuo=; b=MWKp9jEBjW1x2PS4I7x0xv1jNC2r2MBhwOT+75nDIwRlRTNIBcltQrc1 +bsKQFii9h6VkPY6yvWd8dHrdEvp0gORRQFfucD04nP1WQNa2SiwcZsbg PS6w7w+k01YOAUxRYyQCIZMvue8NG7RNJ7e+TNe6EuYw24wLNvjbeZ1Wv fv21MwW5OEiRp/vjVLoRDlb4yVI7vzR+76JjavE3fxhBFpiPgibacSvZN +XUTxMyuowmYxO7s2JoA48wEA8ZBg5ewMsAbO1LWVDbWrrH2wlZXOrXDc DfQhr/EE24PnVqhL1Z42a3LgMehTU17juO3rZjJErxtE97qrOZl3vFW57 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758398" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758398" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540629" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540629" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id 9E062122FF2; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z71-1P; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 19/32] media: v4l: async: Allow multiple connections between entities Date: Wed, 24 May 2023 14:23:36 +0300 Message-Id: <20230524112349.2141396-20-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org When the v4l2-async framework was introduced, the use case for it was to connect a camera sensor with a parallel receiver. Both tended to be rather simple devices with a single connection between them. The framework has been since improved in multiple ways but there are limitations that have remained, for instance the assumption an async sub-device is connected towards a single notifier and via a single link only. This patch enables connecting a sub-device to one or more notifiers simultaneously, with one or more connections per notifier. The notifier information is moved from the sub-device to the connection and the connections in sub-device are no longer a pointer but a linked list. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 149 ++++++++++++++------------- include/media/v4l2-async.h | 17 +-- include/media/v4l2-subdev.h | 6 +- 3 files changed, 90 insertions(+), 82 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index fbc98c194a92a..e6d9109049cc4 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -313,29 +313,43 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, struct v4l2_async_connection *asc) { struct v4l2_async_notifier *subdev_notifier; + bool registered = false; int ret; - ret = v4l2_device_register_subdev(v4l2_dev, sd); - if (ret < 0) - return ret; + if (list_empty(&sd->asc_list)) { + ret = v4l2_device_register_subdev(v4l2_dev, sd); + if (ret < 0) + return ret; + registered = true; + } ret = v4l2_async_nf_call_bound(notifier, sd, asc); - if (ret < 0) + if (ret < 0) { + if (asc->match.type == V4L2_ASYNC_MATCH_TYPE_FWNODE) + dev_dbg(notifier_dev(notifier), + "failed binding %pfw (%d)\n", + asc->match.fwnode, ret); goto err_unregister_subdev; + } - /* - * Depending of the function of the entities involved, we may want to - * create links between them (for example between a sensor and its lens - * or between a sensor's source pad and the connected device's sink - * pad). - */ - ret = v4l2_async_create_ancillary_links(notifier, sd); - if (ret) - goto err_call_unbind; - - sd->asd = asc; - sd->notifier = notifier; + if (registered) { + /* + * Depending of the function of the entities involved, we may + * want to create links between them (for example between a + * sensor and its lens or between a sensor's source pad and the + * connected device's sink pad). + */ + ret = v4l2_async_create_ancillary_links(notifier, sd); + if (ret) { + if (asc->match.type == V4L2_ASYNC_MATCH_TYPE_FWNODE) + dev_dbg(notifier_dev(notifier), + "failed creating links for %pfw (%d)\n", + asc->match.fwnode, ret); + goto err_call_unbind; + } + } + list_add(&asc->asc_subdev_entry, &sd->asc_list); asc->sd = sd; /* Move from the waiting list to notifier's done */ @@ -362,9 +376,11 @@ static int v4l2_async_match_notify(struct v4l2_async_notifier *notifier, err_call_unbind: v4l2_async_nf_call_unbind(notifier, sd, asc); + list_del(&asc->asc_subdev_entry); err_unregister_subdev: - v4l2_device_unregister_subdev(sd); + if (registered) + v4l2_device_unregister_subdev(sd); return ret; } @@ -410,15 +426,16 @@ v4l2_async_nf_try_all_subdevs(struct v4l2_async_notifier *notifier) return 0; } -static void v4l2_async_cleanup(struct v4l2_subdev *sd) +static void v4l2_async_unbind_subdev_one(struct v4l2_async_notifier *notifier, + struct v4l2_async_connection *asc) { - v4l2_device_unregister_subdev(sd); - /* - * Subdevice driver will reprobe and put the subdev back - * onto the list - */ - list_del_init(&sd->async_list); - sd->asd = NULL; + list_move_tail(&asc->asc_entry, ¬ifier->waiting_list); + if (list_is_singular(&asc->asc_subdev_entry)) { + v4l2_async_nf_call_unbind(notifier, asc->sd, asc); + v4l2_device_unregister_subdev(asc->sd); + asc->sd = NULL; + } + list_del(&asc->asc_subdev_entry); } /* Unbind all sub-devices in the notifier tree. */ @@ -435,11 +452,7 @@ v4l2_async_nf_unbind_all_subdevs(struct v4l2_async_notifier *notifier) if (subdev_notifier) v4l2_async_nf_unbind_all_subdevs(subdev_notifier); - v4l2_async_nf_call_unbind(notifier, asc->sd, asc); - v4l2_async_cleanup(asc->sd); - list_move_tail(&asc->asc_entry, ¬ifier->waiting_list); - list_move(&asc->sd->async_list, &subdev_list); - asc->sd = NULL; + v4l2_async_unbind_subdev_one(notifier, asc); } notifier->parent = NULL; @@ -456,13 +469,9 @@ v4l2_async_nf_has_async_match_entry(struct v4l2_async_notifier *notifier, if (v4l2_async_match_equal(&asc->match, match)) return true; - list_for_each_entry(asc, ¬ifier->done_list, asc_entry) { - if (WARN_ON(!asc->sd->asd)) - continue; - + list_for_each_entry(asc, ¬ifier->done_list, asc_entry) if (v4l2_async_match_equal(&asc->match, match)) return true; - } return false; } @@ -642,16 +651,12 @@ static void __v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) WARN_ON(!list_empty(¬ifier->done_list)); list_for_each_entry_safe(asc, tmp, ¬ifier->waiting_list, asc_entry) { - switch (asc->match.type) { - case V4L2_ASYNC_MATCH_TYPE_FWNODE: - fwnode_handle_put(asc->match.fwnode); - break; - default: - break; - } - list_del(&asc->asc_entry); v4l2_async_nf_call_destroy(notifier, asc); + + if (asc->match.type == V4L2_ASYNC_MATCH_TYPE_FWNODE) + fwnode_handle_put(asc->match.fwnode); + kfree(asc); } } @@ -666,16 +671,14 @@ void v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier) } EXPORT_SYMBOL_GPL(v4l2_async_nf_cleanup); -static int __v4l2_async_nf_add_connection(struct v4l2_async_notifier *notifier, - struct v4l2_async_connection *asc) +static void __v4l2_async_nf_add_connection(struct v4l2_async_notifier *notifier, + struct v4l2_async_connection *asc) { mutex_lock(&list_lock); list_add_tail(&asc->asc_entry, ¬ifier->waiting_list); mutex_unlock(&list_lock); - - return 0; } struct v4l2_async_connection * @@ -684,21 +687,16 @@ __v4l2_async_nf_add_fwnode(struct v4l2_async_notifier *notifier, unsigned int asc_struct_size) { struct v4l2_async_connection *asc; - int ret; asc = kzalloc(asc_struct_size, GFP_KERNEL); if (!asc) return ERR_PTR(-ENOMEM); + asc->notifier = notifier; asc->match.type = V4L2_ASYNC_MATCH_TYPE_FWNODE; asc->match.fwnode = fwnode_handle_get(fwnode); - ret = __v4l2_async_nf_add_connection(notifier, asc); - if (ret) { - fwnode_handle_put(fwnode); - kfree(asc); - return ERR_PTR(ret); - } + __v4l2_async_nf_add_connection(notifier, asc); return asc; } @@ -731,21 +729,17 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, int adapter_id, unsigned short address, unsigned int asc_struct_size) { struct v4l2_async_connection *asc; - int ret; asc = kzalloc(asc_struct_size, GFP_KERNEL); if (!asc) return ERR_PTR(-ENOMEM); + asc->notifier = notifier; asc->match.type = V4L2_ASYNC_MATCH_TYPE_I2C; asc->match.i2c.adapter_id = adapter_id; asc->match.i2c.address = address; - ret = __v4l2_async_nf_add_connection(notifier, asc); - if (ret) { - kfree(asc); - return ERR_PTR(ret); - } + __v4l2_async_nf_add_connection(notifier, asc); return asc; } @@ -754,7 +748,11 @@ EXPORT_SYMBOL_GPL(__v4l2_async_nf_add_i2c); struct v4l2_async_connection * v4l2_async_connection_unique(struct v4l2_subdev *sd) { - return sd->asd; + if (!list_is_singular(&sd->asc_list)) + return NULL; + + return list_first_entry(&sd->asc_list, + struct v4l2_async_connection, asc_subdev_entry); } EXPORT_SYMBOL_GPL(v4l2_async_connection_unique); @@ -762,8 +760,11 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) { struct v4l2_async_notifier *subdev_notifier; struct v4l2_async_notifier *notifier; + struct v4l2_async_connection *asc; int ret; + INIT_LIST_HEAD(&sd->asc_list); + /* * No reference taken. The reference is held by the device (struct * v4l2_subdev.dev), and async sub-device does not exist independently @@ -784,7 +785,6 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) list_for_each_entry(notifier, ¬ifier_list, notifier_entry) { struct v4l2_device *v4l2_dev = v4l2_async_nf_find_v4l2_dev(notifier); - struct v4l2_async_connection *asc; if (!v4l2_dev) continue; @@ -821,11 +821,8 @@ int v4l2_async_register_subdev(struct v4l2_subdev *sd) if (subdev_notifier) v4l2_async_nf_unbind_all_subdevs(subdev_notifier); - if (sd->asd) { - v4l2_async_nf_call_unbind(notifier, sd, sd->asd); - sd->asd->sd = NULL; - } - v4l2_async_cleanup(sd); + if (asc) + v4l2_async_unbind_subdev_one(notifier, asc); mutex_unlock(&list_lock); @@ -835,6 +832,8 @@ EXPORT_SYMBOL(v4l2_async_register_subdev); void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) { + struct v4l2_async_connection *asc, *asc_tmp; + if (!sd->async_list.next) return; @@ -847,15 +846,19 @@ void v4l2_async_unregister_subdev(struct v4l2_subdev *sd) kfree(sd->subdev_notifier); sd->subdev_notifier = NULL; - if (sd->asd) { - struct v4l2_async_notifier *notifier = sd->notifier; + if (sd->asc_list.next) { + list_for_each_entry_safe(asc, asc_tmp, &sd->asc_list, + asc_subdev_entry) { + list_move(&asc->asc_entry, + &asc->notifier->waiting_list); - list_move(&sd->asd->asc_entry, ¬ifier->waiting_list); - v4l2_async_nf_call_unbind(notifier, sd, sd->asd); - sd->asd->sd = NULL; + v4l2_async_unbind_subdev_one(asc->notifier, asc); + list_del(&asc->asc_subdev_entry); + } } - v4l2_async_cleanup(sd); + list_del(&sd->async_list); + sd->async_list.next = NULL; mutex_unlock(&list_lock); } diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 6e0f9a4965aa5..4c311f9b66bab 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -62,27 +62,32 @@ struct v4l2_async_match_desc { }; /** - * struct v4l2_async_connection - connection descriptor, as known to a bridge + * struct v4l2_async_connection - sub-device connection descriptor, as known to + * a bridge * * @match: struct of match type and per-bus type matching data sets + * @notifier: the async notifier the connection is related to * @asc_entry: used to add struct v4l2_async_connection objects to the * notifier @waiting_list or @done_list + * @asc_subdev_entry: entry in struct v4l2_async_subdev.asc_list list * @sd: the related sub-device * - * When this struct is used as a member in a driver specific struct, - * the driver specific struct shall contain the &struct - * v4l2_async_connection as its first member. + * When this struct is used as a member in a driver specific struct, the driver + * specific struct shall contain the &struct v4l2_async_connection as its first + * member. */ struct v4l2_async_connection { struct v4l2_async_match_desc match; + struct v4l2_async_notifier *notifier; struct list_head asc_entry; + struct list_head asc_subdev_entry; struct v4l2_subdev *sd; }; /** * struct v4l2_async_notifier_operations - Asynchronous V4L2 notifier operations - * @bound: a subdevice driver has successfully probed one of the subdevices - * @complete: All subdevices have been probed successfully. The complete + * @bound: a sub-device has been bound by the given connection + * @complete: All connections have been bound successfully. The complete * callback is only executed for the root notifier. * @unbind: a subdevice is leaving * @destroy: the asc is about to be freed diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 215fc8af87614..cc22c10540286 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1022,9 +1022,10 @@ struct v4l2_subdev_platform_data { * either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL). * @async_list: Links this subdev to a global subdev_entry or @notifier->done * list. - * @asd: Pointer to respective &struct v4l2_async_connection. * @subdev_notifier: A sub-device notifier implicitly registered for the sub- * device using v4l2_async_register_subdev_sensor(). + * @asc_list: Async connection list, of &struct + * v4l2_async_connection.subdev_entry. * @pdata: common part of subdevice platform data * @state_lock: A pointer to a lock used for all the subdev's states, set by the * driver. This is optional. If NULL, each state instance will get @@ -1064,9 +1065,8 @@ struct v4l2_subdev { struct device *dev; struct fwnode_handle *fwnode; struct list_head async_list; - struct v4l2_async_connection *asd; - struct v4l2_async_notifier *notifier; struct v4l2_async_notifier *subdev_notifier; + struct list_head asc_list; struct v4l2_subdev_platform_data *pdata; struct mutex *state_lock; From patchwork Wed May 24 11:23:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685559 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 CB4D2C77B73 for ; Wed, 24 May 2023 11:25:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232769AbjEXLY7 (ORCPT ); Wed, 24 May 2023 07:24:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235028AbjEXLYy (ORCPT ); Wed, 24 May 2023 07:24:54 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95A3D1B9 for ; Wed, 24 May 2023 04:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927486; x=1716463486; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gb9LEL4Sh5ykJGh0WcOzzxcS0x/0Ihciqe8iiAa3vzc=; b=VrN/keg+aTqSSuFnCNoEobq4OM2JBh33DzzwLpmwCHhRdlJPWiT4MqmW 5hsggqeyM7ByFQXrOXdIwrVaBFkIt7Pb5tWCdMPZF1LtjPbqg8pofMN63 SPyvr8xkWE0ItWXz20XO/CWtw/nahrFZBdxK1H8WIcn60RSk5nemzcSz9 UWfvSLtkQEN2AZmYNiaTlpQXtWUJD/XxHvS0at7gsoSGtyncqTaJ+QK10 fdnVDvzCDULz9IAtRAJBCAZ9mMZOsltIVzd4mcfTGREnkPc5ejM3RA7cP YgTx6bPa0H6IoKAA4IDQtLEHdhlTffazFweDp3/7e25aVQSUudcCQOWCO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758314" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758314" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540610" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540610" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id AAFC2122FF4; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7C-30; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 21/32] media: v4l: async: Support fwnode endpoint list matching for subdevs Date: Wed, 24 May 2023 14:23:38 +0300 Message-Id: <20230524112349.2141396-22-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Support matching V4L2 async sub-devices based on particular fwnode endpoint. This makes it possible to instantiate multiple V4L2 sub-devices based on given fwnode endpoints from a single device, based on driver needs. Signed-off-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-async.c | 41 +++++++++++++++++++++++++++ drivers/media/v4l2-core/v4l2-subdev.c | 13 +++++++++ include/media/v4l2-async.h | 29 +++++++++++++++++++ include/media/v4l2-subdev.h | 8 ++++-- 4 files changed, 89 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index 740f2a0de78ff..12b465a16ec1c 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -134,6 +134,30 @@ static bool match_fwnode(struct v4l2_async_notifier *notifier, "v4l2-async: matching for notifier %pfw, sd fwnode %pfw\n", dev_fwnode(notifier_dev(notifier)), sd->fwnode); + if (!list_empty(&sd->async_subdev_endpoint_list)) { + struct v4l2_async_subdev_endpoint *ase; + + dev_dbg(sd->dev, + "v4l2-async: endpoint fwnode list available, looking for %pfw\n", + match->fwnode); + + list_for_each_entry(ase, &sd->async_subdev_endpoint_list, + async_subdev_endpoint_entry) { + bool matched = ase->endpoint == match->fwnode; + + dev_dbg(sd->dev, + "v4l2-async: endpoint-endpoint match %sfound with %pfw\n", + matched ? "" : "not ", ase->endpoint); + + if (matched) + return true; + } + + dev_dbg(sd->dev, "async: no endpoint matched\n"); + + return false; + } + if (match_fwnode_one(notifier, sd, sd->fwnode, match)) return true; @@ -745,6 +769,23 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, int adapter_id, } EXPORT_SYMBOL_GPL(__v4l2_async_nf_add_i2c); +int v4l2_async_subdev_endpoint_add(struct v4l2_subdev *sd, + struct fwnode_handle *fwnode) +{ + struct v4l2_async_subdev_endpoint *ase; + + ase = kmalloc(sizeof(*ase), GFP_KERNEL); + if (!ase) + return -ENOMEM; + + ase->endpoint = fwnode; + list_add(&ase->async_subdev_endpoint_entry, + &sd->async_subdev_endpoint_list); + + return 0; +} +EXPORT_SYMBOL_GPL(v4l2_async_subdev_endpoint_add); + struct v4l2_async_connection * v4l2_async_connection_unique(struct v4l2_subdev *sd) { diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 2ec179cd12643..217b8019fb9b6 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1467,8 +1467,20 @@ EXPORT_SYMBOL_GPL(__v4l2_subdev_init_finalize); void v4l2_subdev_cleanup(struct v4l2_subdev *sd) { + struct v4l2_async_subdev_endpoint *ase, *ase_tmp; + __v4l2_subdev_state_free(sd->active_state); sd->active_state = NULL; + + if (list_empty(&sd->async_subdev_endpoint_list)) + return; + + list_for_each_entry_safe(ase, ase_tmp, &sd->async_subdev_endpoint_list, + async_subdev_endpoint_entry) { + list_del(&ase->async_subdev_endpoint_entry); + + kfree(ase); + } } EXPORT_SYMBOL_GPL(v4l2_subdev_cleanup); @@ -2182,6 +2194,7 @@ void v4l2_subdev_init(struct v4l2_subdev *sd, const struct v4l2_subdev_ops *ops) sd->dev_priv = NULL; sd->host_priv = NULL; sd->privacy_led = NULL; + INIT_LIST_HEAD(&sd->async_subdev_endpoint_list); #if defined(CONFIG_MEDIA_CONTROLLER) sd->entity.name = sd->name; sd->entity.obj_type = MEDIA_ENTITY_TYPE_V4L2_SUBDEV; diff --git a/include/media/v4l2-async.h b/include/media/v4l2-async.h index 4c311f9b66bab..d0bef6626e043 100644 --- a/include/media/v4l2-async.h +++ b/include/media/v4l2-async.h @@ -124,6 +124,17 @@ struct v4l2_async_notifier { struct list_head notifier_entry; }; +/** + * struct v4l2_async_subdev_endpoint - Entry in sub-device's fwnode list + * + * @entry: An entry in async_subdev_endpoint_list of &struct v4l2_subdev + * @endpoint: Endpoint fwnode agains which to match the sub-device + */ +struct v4l2_async_subdev_endpoint { + struct list_head async_subdev_endpoint_entry; + struct fwnode_handle *endpoint; +}; + /** * v4l2_async_debug_init - Initialize debugging tools. * @@ -214,6 +225,24 @@ __v4l2_async_nf_add_i2c(struct v4l2_async_notifier *notifier, ((type *)__v4l2_async_nf_add_i2c(notifier, adapter, address, \ sizeof(type))) +/** + * v4l2_async_subdev_endpoint_add - Add an endpoint fwnode to async sub-device + * matching list + * + * @sd: the sub-device + * @fwnode: the endpoint fwnode to match + * + * Add a fwnode to the async sub-device's matching list. This allows registering + * multiple async sub-devices from a single device. + * + * Note that calling v4l2_subdev_cleanup() as part of the sub-device's cleanup + * if endpoints have been added to the sub-device's fwnode matching list. + * + * Returns an error on failure, 0 on success. + */ +int v4l2_async_subdev_endpoint_add(struct v4l2_subdev *sd, + struct fwnode_handle *fwnode); + /** * v4l2_async_connection_unique - return a unique &struct v4l2_async_connection * for a sub-device diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index cc22c10540286..9b94847fb6072 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -1022,6 +1022,8 @@ struct v4l2_subdev_platform_data { * either dev->of_node->fwnode or dev->fwnode (whichever is non-NULL). * @async_list: Links this subdev to a global subdev_entry or @notifier->done * list. + * @async_subdev_endpoint_entry: List entry in async_ep_list of + * &struct v4l2_async_subdev_endpoint * @subdev_notifier: A sub-device notifier implicitly registered for the sub- * device using v4l2_async_register_subdev_sensor(). * @asc_list: Async connection list, of &struct @@ -1065,6 +1067,7 @@ struct v4l2_subdev { struct device *dev; struct fwnode_handle *fwnode; struct list_head async_list; + struct list_head async_subdev_endpoint_list; struct v4l2_async_notifier *subdev_notifier; struct list_head asc_list; struct v4l2_subdev_platform_data *pdata; @@ -1381,8 +1384,9 @@ int __v4l2_subdev_init_finalize(struct v4l2_subdev *sd, const char *name, * v4l2_subdev_cleanup() - Releases the resources allocated by the subdevice * @sd: The subdevice * - * This function will release the resources allocated in - * v4l2_subdev_init_finalize. + * Clean up a V4L2 async sub-device. Must be called for a sub-device as part of + * its release if resources have been associated with it using + * v4l2_async_subdev_endpoint_add() or v4l2_subdev_init_finalize(). */ void v4l2_subdev_cleanup(struct v4l2_subdev *sd); From patchwork Wed May 24 11:23:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685555 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 EAA74C77B7A for ; Wed, 24 May 2023 11:25:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbjEXLZ0 (ORCPT ); Wed, 24 May 2023 07:25:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232405AbjEXLZX (ORCPT ); Wed, 24 May 2023 07:25:23 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AF021BB for ; Wed, 24 May 2023 04:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927514; x=1716463514; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=X9CXNIfu7g52kWQW8CC+7Mtud54D6sd05ABI8z/1AIg=; b=Qm5iCM7bf2wXL1XM42afIr9iCtVWsaIfbA0Mm84oU1BBZiMlsopAoDKv ScVsYErT4BCvdrLIyl1250gU9uIoi6Xpb2xhhNTy92BvtxIifPjYNdeTX 3636iiuGPSur/qDF26pWQQUKyTFQFkOWvoXiIdIwJRxvzUsV+rXWXCLAN VeqWgRdtArSv6d5hMRhk2ydiCDX6DcOJ8nAtXm3F3iSATpjL+71bJr14X g4zBcq0Ju+2evm1Wk/Aob0Y9z4MaweePP9VBXR7xUnE7DF1Cggn+JZLy6 3NSYEK9MIqVunxLE+UTJKsFXfJIKnhygfiy6mQ/NabnGwGDr0XJxoEkq2 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758386" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758386" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540616" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540616" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id B19AB122FF5; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7F-3w; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 22/32] media: adv748x: Return to endpoint matching Date: Wed, 24 May 2023 14:23:39 +0300 Message-Id: <20230524112349.2141396-23-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Return the two CSI-2 transmitters of adv748x to endpoint matching. This should make the driver work again as expected. Fixes: ("media: v4l: async: Simplify async sub-device fwnode matching") Signed-off-by: Sakari Ailus --- drivers/media/i2c/adv748x/adv748x-csi2.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/adv748x/adv748x-csi2.c b/drivers/media/i2c/adv748x/adv748x-csi2.c index b6f93c1db3d2a..a5a7cb228896b 100644 --- a/drivers/media/i2c/adv748x/adv748x-csi2.c +++ b/drivers/media/i2c/adv748x/adv748x-csi2.c @@ -296,8 +296,6 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) if (!is_tx_enabled(tx)) return 0; - /* FIXME: Do endpoint matching again! */ - adv748x_subdev_init(&tx->sd, state, &adv748x_csi2_ops, MEDIA_ENT_F_VID_IF_BRIDGE, is_txa(tx) ? "txa" : "txb"); @@ -313,10 +311,15 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) if (ret) return ret; - ret = adv748x_csi2_init_controls(tx); + ret = v4l2_async_subdev_endpoint_add(&tx->sd, + of_fwnode_handle(state->endpoints[tx->port])); if (ret) goto err_free_media; + ret = adv748x_csi2_init_controls(tx); + if (ret) + goto err_cleanup_subdev; + ret = v4l2_async_register_subdev(&tx->sd); if (ret) goto err_free_ctrl; @@ -325,6 +328,8 @@ int adv748x_csi2_init(struct adv748x_state *state, struct adv748x_csi2 *tx) err_free_ctrl: v4l2_ctrl_handler_free(&tx->ctrl_hdl); +err_cleanup_subdev: + v4l2_subdev_cleanup(&tx->sd); err_free_media: media_entity_cleanup(&tx->sd.entity); @@ -339,4 +344,5 @@ void adv748x_csi2_cleanup(struct adv748x_csi2 *tx) v4l2_async_unregister_subdev(&tx->sd); media_entity_cleanup(&tx->sd.entity); v4l2_ctrl_handler_free(&tx->ctrl_hdl); + v4l2_subdev_cleanup(&tx->sd); } From patchwork Wed May 24 11:23:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685556 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 16176C77B73 for ; Wed, 24 May 2023 11:25:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231205AbjEXLZW (ORCPT ); Wed, 24 May 2023 07:25:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjEXLZS (ORCPT ); Wed, 24 May 2023 07:25:18 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C72A13E for ; Wed, 24 May 2023 04:25:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927501; x=1716463501; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GSsQkGs3JmD3/HC3WN8/S2yBpulQ9RyX3oGCHcitps8=; b=nVZRUaP0rInc6G6+Ae8gmqiL7fshkW/lNoHspsxKMY48dyzOK020/Rqt h17SVNbZIB3IikSm3ZBTqxmH/XnMF0BrB5o6jaXZaqZqNftzGvFHWTzkk DZ7KsAktJLC9y3VfIUsQ78puYO+SamCwOFgU5cGYACgxZTPTZvW8zg+tp kYqVmfNCBfOko7NLOOA8XmEmNbl/SvLu5xKfPkJjnfEhsBFrQKu4frdXi 6Dt5sT08/vwn5C8jm2kY5ebQfjMKwQ0DT11afQnXV7tGqx3pcTuWy+mcK EddRmbMlQC8tH3l1DA+86kkM40r04h5i1gQ9hzP7lqjEi8g+x8G3WzTKI A==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758378" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758378" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540620" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540620" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id C76C0122FF9; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7P-6c; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 25/32] media: marvell: cafe: Register V4L2 device earlier Date: Wed, 24 May 2023 14:23:42 +0300 Message-Id: <20230524112349.2141396-26-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-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 the async notifier so the struct device will be available for the notifier which makes it possible to use it for debug prints. Signed-off-by: Sakari Ailus --- drivers/media/platform/marvell/cafe-driver.c | 11 +++++++++-- drivers/media/platform/marvell/mcam-core.c | 6 ------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/marvell/cafe-driver.c b/drivers/media/platform/marvell/cafe-driver.c index dd1bba70bd791..fbfbb9f67ddfc 100644 --- a/drivers/media/platform/marvell/cafe-driver.c +++ b/drivers/media/platform/marvell/cafe-driver.c @@ -536,6 +536,10 @@ static int cafe_pci_probe(struct pci_dev *pdev, if (ret) goto out_pdown; + ret = v4l2_device_register(mcam->dev, &mcam->v4l2_dev); + if (ret) + goto out_smbus_shutdown; + v4l2_async_nf_init(&mcam->notifier); asd = v4l2_async_nf_add_i2c(&mcam->notifier, @@ -544,12 +548,12 @@ static int cafe_pci_probe(struct pci_dev *pdev, struct v4l2_async_connection); if (IS_ERR(asd)) { ret = PTR_ERR(asd); - goto out_smbus_shutdown; + goto out_v4l2_device_unregister; } ret = mccic_register(mcam); if (ret) - goto out_smbus_shutdown; + goto out_v4l2_device_unregister; clkdev_create(mcam->mclk, "xclk", "%d-%04x", i2c_adapter_id(cam->i2c_adapter), ov7670_info.addr); @@ -565,6 +569,8 @@ static int cafe_pci_probe(struct pci_dev *pdev, out_mccic_shutdown: mccic_shutdown(mcam); +out_v4l2_device_unregister: + v4l2_device_unregister(&mcam->v4l2_dev); out_smbus_shutdown: cafe_smbus_shutdown(cam); out_pdown: @@ -587,6 +593,7 @@ static int cafe_pci_probe(struct pci_dev *pdev, static void cafe_shutdown(struct cafe_camera *cam) { mccic_shutdown(&cam->mcam); + v4l2_device_unregister(&cam->mcam.v4l2_dev); cafe_smbus_shutdown(cam); free_irq(cam->pdev->irq, cam); pci_iounmap(cam->pdev, cam->mcam.regs); diff --git a/drivers/media/platform/marvell/mcam-core.c b/drivers/media/platform/marvell/mcam-core.c index 3cee6d6b83fa9..bcfcecdb03ea2 100644 --- a/drivers/media/platform/marvell/mcam-core.c +++ b/drivers/media/platform/marvell/mcam-core.c @@ -1866,10 +1866,6 @@ int mccic_register(struct mcam_camera *cam) /* * Register with V4L */ - ret = v4l2_device_register(cam->dev, &cam->v4l2_dev); - if (ret) - goto out; - mutex_init(&cam->s_mutex); cam->state = S_NOTREADY; mcam_set_config_needed(cam, 1); @@ -1915,7 +1911,6 @@ int mccic_register(struct mcam_camera *cam) out: v4l2_async_nf_unregister(&cam->notifier); - v4l2_device_unregister(&cam->v4l2_dev); v4l2_async_nf_cleanup(&cam->notifier); return ret; } @@ -1937,7 +1932,6 @@ void mccic_shutdown(struct mcam_camera *cam) mcam_free_dma_bufs(cam); v4l2_ctrl_handler_free(&cam->ctrl_handler); v4l2_async_nf_unregister(&cam->notifier); - v4l2_device_unregister(&cam->v4l2_dev); v4l2_async_nf_cleanup(&cam->notifier); } EXPORT_SYMBOL_GPL(mccic_shutdown); From patchwork Wed May 24 11:23:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685557 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 1C505C77B7A for ; Wed, 24 May 2023 11:25:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234790AbjEXLZD (ORCPT ); Wed, 24 May 2023 07:25:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234821AbjEXLZB (ORCPT ); Wed, 24 May 2023 07:25:01 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 705FC1B0 for ; Wed, 24 May 2023 04:24:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927494; x=1716463494; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5PTeweLPTRd1sCvqIsPZ3AJXQB1XQ71FsPOHa6uUk6Y=; b=kb+NqaFO7ucaIvGaBkSZgCLbFIt1cQsWbEbriAlLqU8uhdGP38qwskQ4 lRzg6HRZW3nSY2VhO7hjaQecuOqp1KjxRxs/tzSXw65xGGGiDhw66ZC5q zwa/6CKvh3kiCMTPHx4Eh+Ttp/LHVLZtg/GU0zyeEFEXU6dWDu9arkhPX 30pGxKXjJk3HFuOwCSmGmmZ8ZNNG+8OwNYYLlmYBdig1HMqNcesoDnslT TEH7TKE8/6daz6vgjxMocG0TCVX2CZonUBYN6Ogmu3HGxkoUiaMV4uIB7 jC84fKyw2eiEE4tOup1WXXp4pJTmtMFf7iMJ8Zv1B0IgiGiD67BLdBDqj A==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758346" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758346" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540623" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540623" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id CB5C9123002; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7T-7g; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 26/32] media: am437x-vpfe: Register V4L2 device early Date: Wed, 24 May 2023 14:23:43 +0300 Message-Id: <20230524112349.2141396-27-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-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 the async notifier so the struct device will be available for the notifier which makes it possible to use it for debug prints. Signed-off-by: Sakari Ailus --- .../media/platform/ti/am437x/am437x-vpfe.c | 27 +++++++++---------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/drivers/media/platform/ti/am437x/am437x-vpfe.c b/drivers/media/platform/ti/am437x/am437x-vpfe.c index a1e01ef5ebddb..1457a188fea12 100644 --- a/drivers/media/platform/ti/am437x/am437x-vpfe.c +++ b/drivers/media/platform/ti/am437x/am437x-vpfe.c @@ -2403,10 +2403,17 @@ static int vpfe_probe(struct platform_device *pdev) vpfe->pdev = &pdev->dev; + ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev); + if (ret) { + vpfe_err(vpfe, "Unable to register v4l2 device.\n"); + return ret; + } + vpfe_cfg = vpfe_get_pdata(vpfe); if (!vpfe_cfg) { dev_err(&pdev->dev, "No platform data\n"); - return -EINVAL; + ret = -EINVAL; + goto probe_out_cleanup; } vpfe->cfg = vpfe_cfg; @@ -2433,13 +2440,6 @@ static int vpfe_probe(struct platform_device *pdev) goto probe_out_cleanup; } - ret = v4l2_device_register(&pdev->dev, &vpfe->v4l2_dev); - if (ret) { - vpfe_err(vpfe, - "Unable to register v4l2 device.\n"); - goto probe_out_cleanup; - } - /* set the driver data in platform device */ platform_set_drvdata(pdev, vpfe); /* Enabling module functional clock */ @@ -2449,7 +2449,7 @@ static int vpfe_probe(struct platform_device *pdev) ret = pm_runtime_resume_and_get(&pdev->dev); if (ret < 0) { vpfe_err(vpfe, "Unable to resume device.\n"); - goto probe_out_v4l2_unregister; + goto probe_out_cleanup; } vpfe_ccdc_config_defaults(ccdc); @@ -2462,7 +2462,7 @@ static int vpfe_probe(struct platform_device *pdev) GFP_KERNEL); if (!vpfe->sd) { ret = -ENOMEM; - goto probe_out_v4l2_unregister; + goto probe_out_cleanup; } vpfe->notifier.ops = &vpfe_async_ops; @@ -2470,15 +2470,14 @@ static int vpfe_probe(struct platform_device *pdev) if (ret) { vpfe_err(vpfe, "Error registering async notifier\n"); ret = -EINVAL; - goto probe_out_v4l2_unregister; + goto probe_out_cleanup; } return 0; -probe_out_v4l2_unregister: - v4l2_device_unregister(&vpfe->v4l2_dev); probe_out_cleanup: v4l2_async_nf_cleanup(&vpfe->notifier); + v4l2_device_unregister(&vpfe->v4l2_dev); return ret; } @@ -2493,8 +2492,8 @@ static void vpfe_remove(struct platform_device *pdev) v4l2_async_nf_unregister(&vpfe->notifier); v4l2_async_nf_cleanup(&vpfe->notifier); - v4l2_device_unregister(&vpfe->v4l2_dev); video_unregister_device(&vpfe->video_dev); + v4l2_device_unregister(&vpfe->v4l2_dev); } #ifdef CONFIG_PM_SLEEP From patchwork Wed May 24 11:23: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: 685558 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 3AD29C7EE32 for ; Wed, 24 May 2023 11:25:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231882AbjEXLZC (ORCPT ); Wed, 24 May 2023 07:25:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234790AbjEXLZB (ORCPT ); Wed, 24 May 2023 07:25:01 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 625F3195 for ; Wed, 24 May 2023 04:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927493; x=1716463493; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OTutRpmrnvsgBz74xZsS8El+m5YwHhPnVgYvJwqT64Y=; b=Ip1qSQDk1e085WIkToGAgRnyxiwowbF43huYfxA5AYNZZq1i+jb0s5u5 N5uG9um9dDYOqwlGEKxCowO2z71wRldJoRS8ru9vb1XE3qIWr+esFGx5R lCWDX6cxPbwK6Sop76xICfbfk0J0OKZI82MRNkwUBEl9Yc09uZ+WRxk89 JptGA2pUSoXP2446KBbeBBDsxRX9m8HJxPLX3aMPSA12c8tJZwmBWgrZF VdlSc+Ky+W+ExmE3+UDavgRovvvqXLzTkZWC+7JDAXfyaVmessJeGusoM pop3/USgczuL/guml53e6272+b9E+YxnJUU0Bq1rzXabRx5N+i30FPIXH g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758334" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758334" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540626" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540626" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id D403612300F; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7c-8v; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 28/32] media: xilinx-vipp: Init async notifier after registering V4L2 device Date: Wed, 24 May 2023 14:23:45 +0300 Message-Id: <20230524112349.2141396-29-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Initialise the V4L2 async notifier after registering the V4L2 device, just before parsing DT for async sub-devices. This way struct device is available to the notifier right from the beginning which makes it possible to use it for debug prints. Signed-off-by: Sakari Ailus Reviewed-by: Laurent Pinchart --- drivers/media/platform/xilinx/xilinx-vipp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index a535a7584da0f..6bb426a25fe90 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -494,6 +494,8 @@ static int xvip_graph_init(struct xvip_composite_device *xdev) goto done; } + v4l2_async_nf_init(&xdev->notifier); + /* Parse the graph to extract a list of subdevice DT nodes. */ ret = xvip_graph_parse(xdev); if (ret < 0) { @@ -574,7 +576,6 @@ static int xvip_composite_probe(struct platform_device *pdev) xdev->dev = &pdev->dev; INIT_LIST_HEAD(&xdev->dmas); - v4l2_async_nf_init(&xdev->notifier); ret = xvip_composite_v4l2_init(xdev); if (ret < 0) From patchwork Wed May 24 11:23:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sakari Ailus X-Patchwork-Id: 685552 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 55011C77B7A for ; Wed, 24 May 2023 11:25:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231349AbjEXLZj (ORCPT ); Wed, 24 May 2023 07:25:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbjEXLZi (ORCPT ); Wed, 24 May 2023 07:25:38 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062A218E for ; Wed, 24 May 2023 04:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684927534; x=1716463534; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gd7HLGVvz+OjG/PZbl0woujGyowsfis9oXa7ZUQbEH8=; b=QoEFd1S8Jd2Xmshf6JX3pjdJbMUCJ6+gk9p2yJy/qDpF0Myxx/63JqCJ jtdEFRScH7MqN1jFTDPONdFOsYM9+ZCiqueIDllA8I67+9y2izyrR6DvN AyjPhWShtodBjpd1jX9JK7DqTqpPm4nnGEuCTPUwE+kJTgrcQuriD+oxS UF4NijP9OMFd8p3XQFld7127q3Qv5cLiwbc8dJnDpZquiNCpogYpoQMTu gtxydfxdqSMBaFCUmIRlSBu2N/3TE/QUNdocIZf/f49ZsSC13DE0ULfU1 f4xNFf2+IUWn7Wq5POlZu626ReaKodiw1gaROXlOp/yJ3JBh1tS6Axb1J g==; X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="356758438" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="356758438" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:38 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10719"; a="816540636" X-IronPort-AV: E=Sophos;i="6.00,189,1681196400"; d="scan'208";a="816540636" Received: from turnipsi.fi.intel.com (HELO kekkonen.fi.intel.com) ([10.237.72.44]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 May 2023 04:24:33 -0700 Received: from punajuuri.localdomain (punajuuri.localdomain [192.168.240.130]) by kekkonen.fi.intel.com (Postfix) with ESMTP id EF60C12302B; Wed, 24 May 2023 14:24:21 +0300 (EEST) Received: from sailus by punajuuri.localdomain with local (Exim 4.94.2) (envelope-from ) id 1q1mb2-008z7r-Cf; Wed, 24 May 2023 14:24:00 +0300 From: Sakari Ailus To: linux-media@vger.kernel.org Cc: laurent.pinchart@ideasonboard.com, Philipp Zabel , hverkuil@xs4all.nl, Francesco Dolcini , aishwarya.kothari@toradex.com, Robert Foss , Todor Tomov , Hyun Kwon , bingbu.cao@intel.com, niklas.soderlund@ragnatech.se Subject: [PATCH v3 32/32] media: Documentation: v4l: Document sub-device notifiers Date: Wed, 24 May 2023 14:23:49 +0300 Message-Id: <20230524112349.2141396-33-sakari.ailus@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> References: <20230524112349.2141396-1-sakari.ailus@linux.intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Document that sub-device notifiers are now registered using v4l2_async_subdev_nf_init(). No documentation is changed as it seems that sub-device notifiers were not documented apart from kernel-doc comments. Signed-off-by: Sakari Ailus --- Documentation/driver-api/media/v4l2-subdev.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Documentation/driver-api/media/v4l2-subdev.rst b/Documentation/driver-api/media/v4l2-subdev.rst index 83d3d29608136..d62b341642c96 100644 --- a/Documentation/driver-api/media/v4l2-subdev.rst +++ b/Documentation/driver-api/media/v4l2-subdev.rst @@ -193,9 +193,7 @@ picked up by bridge drivers. Bridge drivers in turn have to register a notifier object. This is performed using the :c:func:`v4l2_async_nf_register` call. To unregister the notifier the driver has to call -:c:func:`v4l2_async_nf_unregister`. The former of the two functions -takes two arguments: a pointer to struct :c:type:`v4l2_device` and a -pointer to struct :c:type:`v4l2_async_notifier`. +:c:func:`v4l2_async_nf_unregister`. Before registering the notifier, bridge drivers must do two things: first, the notifier must be initialized using the :c:func:`v4l2_async_nf_init`. @@ -204,6 +202,12 @@ that the bridge device needs for its operation. Several functions are available to add subdevice descriptors to a notifier, depending on the type of device and the needs of the driver. +For a sub-device driver to register a notifier, the process is otherwise similar +to that of a bridge driver, apart from that the notifier is initialised using +:c:func:`v4l2_async_subdev_nf_init` instead. A sub-device notifier may complete +only after the V4L2 device becomes available, i.e. there's a path via async +sub-devices and notifiers to that root notifier. + :c:func:`v4l2_async_nf_add_fwnode`, :c:func:`v4l2_async_nf_add_fwnode_remote` :c:and func:`v4l2_async_nf_add_i2c` are for registering their async sub-devices :c:with the notifier.