From patchwork Tue Sep 17 14:09:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13806184 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72EB519BBA; Tue, 17 Sep 2024 14:10:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582210; cv=none; b=ddxar7NizKEO7lDe029ka4j9OzTLOx/PeGtFWoJJzx1XNYoprNgo8jkKcrRoccyzib3E0qx88s8V0IfuCIldL/LpB7xuuMzRSjFCWsuPdgwT2EWXsB0wzizpziZ2XQp5TLBq4Xd6tbsNOmc8sGNZUL6x77PycBSgJoWoh9tFO04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582210; c=relaxed/simple; bh=dJi12s2uuOavLgRJd+8G/40diMcWbmgczahPyVn/RCI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jakKC+mtUxj/X0QW51Omiw3JbuK6t+pfa+/KkVaGtwZBeBlQBMPlIx5xIS7bztbyw1sAiprGA8wiVYmK4j5ySK3nKrMiRMikmVuDPPvTF02igI1Qdavlb1aJThpjFYnPdHQQqX8eM9rGYsut2yIIRMZg8bcCRzGX99kfkvXoFHQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=aQzhEj40; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="aQzhEj40" Received: from [127.0.1.1] (91-156-87-48.elisa-laajakaista.fi [91.156.87.48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE7466B5; Tue, 17 Sep 2024 16:08:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726582124; bh=dJi12s2uuOavLgRJd+8G/40diMcWbmgczahPyVn/RCI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aQzhEj40fqqXhL4kwCu2fy8doPaf0e39W8BFTMw0uAQZUEfRrNM/HcZTYenEcNcuX GwoNZ1kFcjfcvhCS41GdMDevsu419mU1Eh7AT4mFiEt+IsRs7MubNsGjXYYO0qceQ/ W3IrHcqgTc77VzFbOU6RBSRcxBb1K5xO0IgsPJlY= From: Tomi Valkeinen Date: Tue, 17 Sep 2024 17:09:29 +0300 Subject: [PATCH 1/4] media: v4l2-subdev: Add cleanup macros for active state Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240917-scoped-state-v1-1-b8ba3fbe5952@ideasonboard.com> References: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> In-Reply-To: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , Hans Verkuil , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1639; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=h+utgyyppaqOqSvoQJ+8vFfC8hzW6qWNmGY5TYaanVw=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBm6Y27dHyTQ+/AekiRMk2DsfelvLw8zpOyIuR05 FcVQj9J5qqJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZumNuwAKCRD6PaqMvJYe 9d/hD/9HgsqpkJr4FALWv264jckzXVna2IvdhY9BWKXoLMRo60ts1PA9TZfoQyPZS7LM23Mxfbu tDC1PaiZTS1ThXWgtpR5c7j/Bm5lRowe9p8CBHLwTuHxfDWueMdfUPaxM9HK44mVi6wmRSC8TfX AafPEwkXUzHd5CG8nugCUvWEG83UYCsP+p0WZYy92gydPvzdo+COqDjTL+PZ/7VOKaJtNOntJM4 BGNElZKdKpyvx+avumgcGq4eIg5ejIDpciQPTatI3wjek2E27n910JsbaJcquq1aoeoWzhUDzyJ A6VEe/j4TcVQ/ZNKoVCArQQVePNDT4UKKzf/o1wQ0bUxUEW4mEK2rSrBo3nf0VFdQVukU+X6Dbr E01A/qRLUYFKK/5GBMa49FKojhyaJxpnX6IXA64EQI8+0nfoat4G/15FipW9OXKwhI3vpi4lXgy Yj4SB2h2G97OqVgktWCpkzV3FLTYwD55RNaIwzUjDRa7CQP71SpWPorl+bFLpezlefvfnwLdQuy V4r74oy54cj447iQcNWpte/qPIlYTtLo4gzYHcQvhXTT/x4XEu+ZfdsaHb4v4pD2eYq4JoBRkew sZ8Ag8Lug1PKLWlpLWnpYEuYASdFStieBzMxcmE0Kw/76e2O1/omeK7akCAyJPPWEey0Bazgz1J zg4xSbFqfW6olyA== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 From: Tomi Valkeinen Add cleanup macros for active state. These can be used to call v4l2_subdev_lock_and_get_active_state() and manage the unlocking either in unscoped or scoped fashion: This locks the state, gets it to the 'state' variable, and unlocks when exiting the surrounding scope: CLASS(v4l2_subdev_lock_and_get_active_state, state)(subdev); This does the same, but inside the given scope: scoped_v4l2_subdev_lock_and_get_active_state(subdev) { } Signed-off-by: Tomi Valkeinen --- include/media/v4l2-subdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index bd235d325ff9..699007cfffd7 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h @@ -8,6 +8,7 @@ #ifndef _V4L2_SUBDEV_H #define _V4L2_SUBDEV_H +#include #include #include #include @@ -1854,6 +1855,15 @@ v4l2_subdev_lock_and_get_active_state(struct v4l2_subdev *sd) return sd->active_state; } +DEFINE_CLASS(v4l2_subdev_lock_and_get_active_state, struct v4l2_subdev_state *, + v4l2_subdev_unlock_state(_T), + v4l2_subdev_lock_and_get_active_state(sd), struct v4l2_subdev *sd); + +#define scoped_v4l2_subdev_lock_and_get_active_state(sd) \ + for (CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd), \ + *done = NULL; \ + !done; done = (void *)1) + /** * v4l2_subdev_init - initializes the sub-device struct * From patchwork Tue Sep 17 14:09:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13806186 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9AC1A17BB3C; Tue, 17 Sep 2024 14:10:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582213; cv=none; b=FjEeQywEVGuGJnnZqserVFfThoq5RXiMnWV4XeUvBxiUgRvDJSKOhLbuLsqOtMJbYiaTVXtZtp7M19jKyl0M3UsE01lFEnCu5FI3M8l1u5Ibz5yCOUYEocZE2Ex4f6Yezlij7Qg3HomWd1bxCM64bjV3kr3dBD1YR9QbnA34wWQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582213; c=relaxed/simple; bh=56c7Mc469V5jQOz9OsJXi7Ra1pifB6dbDmhheU41ITM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SpFFpFPYLY6W2OHQt6BOLRh4QYKeH4NVL2uV6/R5wzEwGmgcmZqqgQ4BjvMnxqXzFGj6Wxeeh4qLCmzMaf2Lf9a2Zr5Im63bOB4yaTjlzqYbOMUCKuvTvT+28Cz0nNBmlBMWPIhIFFCfSFc1jcUMF6RHUKpPIli2SRjHJ6hYykE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=wH5CcbYU; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="wH5CcbYU" Received: from [127.0.1.1] (91-156-87-48.elisa-laajakaista.fi [91.156.87.48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 72B7582A; Tue, 17 Sep 2024 16:08:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726582124; bh=56c7Mc469V5jQOz9OsJXi7Ra1pifB6dbDmhheU41ITM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=wH5CcbYUC8GoDHS7UIXyRPvxycUUNcN0X3py8gzdZMnFQVuCeXolKNqhlhtTa0SGi Sy/R4avQA7SkhfR0hGOAadJ8zTn3XSkWq6KmiOc2fEHNFq1Gg08P6Dw68pftC/+2Wl wJCiQASMwS1ge8LUCFYRgQlla6NaajrKuqJ5kZuQ= From: Tomi Valkeinen Date: Tue, 17 Sep 2024 17:09:30 +0300 Subject: [PATCH 2/4] media: v4l2-subdev: Use state cleanup macros Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240917-scoped-state-v1-2-b8ba3fbe5952@ideasonboard.com> References: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> In-Reply-To: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , Hans Verkuil , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2162; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=EbcgQL+tX2nYvMWczFyWQYM06jA72gwsCC48WpBYQKs=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBm6Y27pkJc8Q46tX+GK8fM6O57muJhhE2Ryndck /pwyPuFJP2JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZumNuwAKCRD6PaqMvJYe 9c4rD/45X/i21ZbCtXfd1aOxfLlsvz4l7A+rYU51ao+MhkcUCRDzJKLEY6tdJoa8h9VLubI7fsA 9atbJWbsYe2znvk049Ko8GPQL4R1pG3eRfg96ugFrBs4U0mvdskrURwTcbKtMFxSw+XjFXXslrO R4z8nkA0QPbWS5iuEZDzxB9ViNErImV4BUB67VL6ZPMjrOe5bu97yggMv8MmlZ0X/h65aIvUq1a bH10ntLyrzjx/71X1p+U/BD/gEF3/X9Y5QDUUv9QqwY9GRlE/+9Jqsn+8c0VgitTTeQGXDLVnPd O+jeuBKpgv2GhNJUmQL3BaD8mw9a62ylPCnr7qg08PEU7Gy7747XB319IjA20Sx84PrCYycYnQa uyV45oIO6zET2aAeXn76HAU0cAP3i2NkclpfTTQgw1swrxWRRpe7DkCIFNnZb8hGiE/xhzMilvp 6WD4CuXsl7Rvydtdd5dxR1+bpMjWpdNY8kHyw4069SVJumFX9mHGu2c/b8XuwYccgWcoIQQH6fs gHyZXv4fKFz6p3Ab2OoYeGFb8F5jLrH9oD4epvAYer4/p7xDvUKb85v7ozS5aIEWO5364B4kWXE 4KP6yLYyf/7ZbnTD4A37JpWJvVdm+Z56KWuFDNZGGF2J117G326p/vJXQZw5ZTSKfdsTqhORYMI 2kCT4oX0A8T4fBw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 From: Tomi Valkeinen Use the new subdev state cleanup macros. Signed-off-by: Tomi Valkeinen --- drivers/media/v4l2-core/v4l2-subdev.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c index 7c5812d55315..1e701c340d0b 100644 --- a/drivers/media/v4l2-core/v4l2-subdev.c +++ b/drivers/media/v4l2-core/v4l2-subdev.c @@ -1478,10 +1478,9 @@ bool v4l2_subdev_has_pad_interdep(struct media_entity *entity, { struct v4l2_subdev *sd = media_entity_to_v4l2_subdev(entity); struct v4l2_subdev_krouting *routing; - struct v4l2_subdev_state *state; unsigned int i; - state = v4l2_subdev_lock_and_get_active_state(sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd); routing = &state->routing; @@ -1492,14 +1491,10 @@ bool v4l2_subdev_has_pad_interdep(struct media_entity *entity, continue; if ((route->sink_pad == pad0 && route->source_pad == pad1) || - (route->source_pad == pad0 && route->sink_pad == pad1)) { - v4l2_subdev_unlock_state(state); + (route->source_pad == pad0 && route->sink_pad == pad1)) return true; - } } - v4l2_subdev_unlock_state(state); - return false; } EXPORT_SYMBOL_GPL(v4l2_subdev_has_pad_interdep); @@ -2393,7 +2388,6 @@ EXPORT_SYMBOL_GPL(v4l2_subdev_disable_streams); int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable) { - struct v4l2_subdev_state *state; struct v4l2_subdev_route *route; struct media_pad *pad; u64 source_mask = 0; @@ -2419,12 +2413,10 @@ int v4l2_subdev_s_stream_helper(struct v4l2_subdev *sd, int enable) * As there's a single source pad, just collect all the source * streams. */ - state = v4l2_subdev_lock_and_get_active_state(sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd); for_each_active_route(&state->routing, route) source_mask |= BIT_ULL(route->source_stream); - - v4l2_subdev_unlock_state(state); } else { /* * For non-streams subdevices, there's a single implicit stream From patchwork Tue Sep 17 14:09:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13806187 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 553BD17BEDB; Tue, 17 Sep 2024 14:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582213; cv=none; b=KovPu7CmWGOgTO4f28sArGQTuU8pS7O8DbGFYGJpcKlEhHgZGdymjFwucrnbCx8kc2Vf4KdVEbeqgpNcgdosvwztcXPWWsXuJ9BvlQlPraBSFQqVNq88z9LFhnx57qIYQalCOU6dqFeaVflVyG9if4FjkzJvLzlb+XZrtNFnFi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582213; c=relaxed/simple; bh=yuqsL2W74eA6/mxkQ/xEXQAbG/42LNjT3uMhh5obiIA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AfGCrQBSnaP/JQ/vGMueUGh034r5tKzJynJlk81Azws24CK/OrYpOcDj7dYfOyZ2kssbjazUOPIsbJL+pmF1Y8QqauTbACQpgwV/1xYycKBHXN5fA4VZl0zkWjYkiyHBA2cJpkoS9VU6SI67Zz1+GoZGtKFY6IWqPJut7EEjXlU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=TLkcCTri; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="TLkcCTri" Received: from [127.0.1.1] (91-156-87-48.elisa-laajakaista.fi [91.156.87.48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 16E758BE; Tue, 17 Sep 2024 16:08:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726582125; bh=yuqsL2W74eA6/mxkQ/xEXQAbG/42LNjT3uMhh5obiIA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TLkcCTriu7A+FeQO7Zd2W+fvIvW8ouNV56VcCHZBbXBgQrrx/As6WE1qe7lNueAP7 yrD3PPmcrtVs+uaes4fVWkKjIBT9bCq1+fWYGHIiJTvU4C6BmLTWAM9jgkUIpUXLpC 56BsmEJj04ViPrehMON0YzTFexoXgjSm9UtdXTUw= From: Tomi Valkeinen Date: Tue, 17 Sep 2024 17:09:31 +0300 Subject: [PATCH 3/4] media: renesas: Use state cleanup macros Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240917-scoped-state-v1-3-b8ba3fbe5952@ideasonboard.com> References: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> In-Reply-To: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , Hans Verkuil , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4070; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=NCiPAqhXCcuK34hin2VFlGsCD4jIoCLs1SmrFqCLKyo=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBm6Y27GmYXeGPZjUyQjwAN/NDMSO7Lhoi6AK4sN cu6ZPSBXfeJAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZumNuwAKCRD6PaqMvJYe 9cCwD/4ox6YtzI9LJMGx6A8RpQRD5zRJBFu24xaKUVmv2t/TMXT8QTtstzYHTp2dMBAkxXqCDLG WuXTtZYEmbtXJvkz9UyBAtquj+8BOXuF/p6pxkLZ5EgZLttbB5ZH9pcD6W/GxVj2JFpJQW/QI9Q uTu/li5fyUsa+wWnLlLWWLQmGQIQp+/HX3gbjn+3Wj8feaZQg7cfm6/zYs9/aytAUDIFd/9JcfI BT9N/MFJpIS3oKLukpaOnRLXRGENio57TkTsrTRXZMTE5BxUjEeZ8NG4tIagTuRhCwPW3oxqprL dkMwwhCElk/0aIpq+j3xs3cFXOsmfnENslikDGMdrD5UArn0D6Xj8cAZqveDxtX56AUPNfNGcYY /HhRAvMmyW5b1WHZD9kpMQ1Xz0SOqxkJzeMYEm7CcJ0j8US/taCA+z9hXouQfZxoc//kZ7qkQmG Xo0xjfOcnj1Ngw6x7Mk9VDIcW5tPMa0WvmgV5Y+OqqEp8ncmEhp0BBEGHdUOr10p5uz8iT+yBgr Or5X3vdx3VAusmFNlBULcZTTLJo5NHgt95BVG+xKYvlodymI8RsCKdFTdjpo+0GjWieiYgkuVho AlF79V3ARu76qy94u8ns9hetvwzyeXVvIkX1PHVkoDbRHSPmXdPrM45IUVVBysectUAVL0y2dSh dXrOCYL8DoXcnJw== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 From: Tomi Valkeinen Use the new subdev state cleanup macros. Signed-off-by: Tomi Valkeinen Reviewed-by: Niklas Söderlund --- drivers/media/platform/renesas/rcar-csi2.c | 14 ++++---------- drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c | 9 ++++----- drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c | 9 ++------- 3 files changed, 10 insertions(+), 22 deletions(-) diff --git a/drivers/media/platform/renesas/rcar-csi2.c b/drivers/media/platform/renesas/rcar-csi2.c index c419ddb4c5a2..03ef6566271f 100644 --- a/drivers/media/platform/renesas/rcar-csi2.c +++ b/drivers/media/platform/renesas/rcar-csi2.c @@ -1163,27 +1163,24 @@ static void rcsi2_stop(struct rcar_csi2 *priv) static int rcsi2_s_stream(struct v4l2_subdev *sd, int enable) { struct rcar_csi2 *priv = sd_to_csi2(sd); - struct v4l2_subdev_state *state; int ret = 0; if (!priv->remote) return -ENODEV; - state = v4l2_subdev_lock_and_get_active_state(&priv->subdev); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(&priv->subdev); if (enable && priv->stream_count == 0) { ret = rcsi2_start(priv, state); if (ret) - goto out; + return ret; } else if (!enable && priv->stream_count == 1) { rcsi2_stop(priv); } priv->stream_count += enable ? 1 : -1; -out: - v4l2_subdev_unlock_state(state); - return ret; + return 0; } static int rcsi2_set_pad_format(struct v4l2_subdev *sd, @@ -1274,18 +1271,15 @@ static irqreturn_t rcsi2_irq(int irq, void *data) static irqreturn_t rcsi2_irq_thread(int irq, void *data) { - struct v4l2_subdev_state *state; struct rcar_csi2 *priv = data; - state = v4l2_subdev_lock_and_get_active_state(&priv->subdev); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(&priv->subdev); rcsi2_stop(priv); usleep_range(1000, 2000); if (rcsi2_start(priv, state)) dev_warn(priv->dev, "Failed to restart CSI-2 receiver\n"); - v4l2_subdev_unlock_state(state); - return IRQ_HANDLED; } diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c index e68fcdaea207..63b846f3e468 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-csi2.c @@ -238,7 +238,6 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2 *csi2) struct v4l2_subdev *source = csi2->remote_source; const struct rzg2l_csi2_format *format; const struct v4l2_mbus_framefmt *fmt; - struct v4l2_subdev_state *state; struct v4l2_ctrl *ctrl; u64 mbps; @@ -250,10 +249,10 @@ static int rzg2l_csi2_calc_mbps(struct rzg2l_csi2 *csi2) return -EINVAL; } - state = v4l2_subdev_lock_and_get_active_state(&csi2->subdev); - fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK); - format = rzg2l_csi2_code_to_fmt(fmt->code); - v4l2_subdev_unlock_state(state); + scoped_v4l2_subdev_lock_and_get_active_state(&csi2->subdev) { + fmt = v4l2_subdev_state_get_format(state, RZG2L_CSI2_SINK); + format = rzg2l_csi2_code_to_fmt(fmt->code); + } /* * Calculate hsfreq in Mbps diff --git a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c index ac8ebae4ed07..0b9e8a7cf22a 100644 --- a/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c +++ b/drivers/media/platform/renesas/rzg2l-cru/rzg2l-ip.c @@ -36,14 +36,9 @@ static const struct rzg2l_cru_ip_format *rzg2l_cru_ip_code_to_fmt(unsigned int c struct v4l2_mbus_framefmt *rzg2l_cru_ip_get_src_fmt(struct rzg2l_cru_dev *cru) { - struct v4l2_subdev_state *state; - struct v4l2_mbus_framefmt *fmt; + CLASS(v4l2_subdev_lock_and_get_active_state, state)(&cru->ip.subdev); - state = v4l2_subdev_lock_and_get_active_state(&cru->ip.subdev); - fmt = v4l2_subdev_state_get_format(state, 1); - v4l2_subdev_unlock_state(state); - - return fmt; + return v4l2_subdev_state_get_format(state, 1); } static int rzg2l_cru_ip_s_stream(struct v4l2_subdev *sd, int enable) From patchwork Tue Sep 17 14:09:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 13806188 X-Patchwork-Delegate: kieran@bingham.xyz Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F5AC1865FB; Tue, 17 Sep 2024 14:10:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.167.242.64 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582216; cv=none; b=kwVfsxAZZblgYRTGXwhfFLiPeu6bGBZX/e8B0Kcw7K1rWZmb5z6ArNfRd9lm3FiIPc1mceen1GyuE+MX8qdCRoV1jFFOBAaDHrRM4R+Zl+OK4MXQ2aDL16Tiv5ttfCNHWw2xiR3GHzgtIXRDdDoRLXN7d+YjdcBVJ/fkNoPdMvs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726582216; c=relaxed/simple; bh=MQejPUhA+YLEWckuXq06Okd8VmXhHdkXVmMWosZvBuA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZTsZZTTYhFXCEjnrpCJAZN355SsMcCYRLjBBqD4bVNQ2TnhY5onts2QN5KKEMDYtgcZXtJ1+HEGErhOtw63Kx2rpYUEv6IETLCQ0bwUWhu5Y4WZz5HNTehmtOmFd401+IfuB08AMvunemb8J1dp6I+yp8gPc2m3IbhEHMXRKbFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com; spf=pass smtp.mailfrom=ideasonboard.com; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b=lOShdXFy; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ideasonboard.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lOShdXFy" Received: from [127.0.1.1] (91-156-87-48.elisa-laajakaista.fi [91.156.87.48]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B0A3AF86; Tue, 17 Sep 2024 16:08:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1726582126; bh=MQejPUhA+YLEWckuXq06Okd8VmXhHdkXVmMWosZvBuA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lOShdXFyeyghnksDq3BUEuaAHxnMrKyuEQgc5wKLPICFYn0EVRTnbJOSlpZ5AETlK qz0hiKaD8bx4l+bA6Yr69EQOo2Ru/F0zbWgdz20Ug2aIJStfwB363kv3M6TYsyKqNJ ltBKkzppKTd/O3ACPDMsT3FRT5j6fKwD4hZ6wi6U= From: Tomi Valkeinen Date: Tue, 17 Sep 2024 17:09:32 +0300 Subject: [PATCH 4/4] media: i2c: ds90ub9xx: Use state cleanup macros Precedence: bulk X-Mailing-List: linux-renesas-soc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240917-scoped-state-v1-4-b8ba3fbe5952@ideasonboard.com> References: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> In-Reply-To: <20240917-scoped-state-v1-0-b8ba3fbe5952@ideasonboard.com> To: Mauro Carvalho Chehab , =?utf-8?q?Niklas_S=C3=B6derl?= =?utf-8?q?und?= , Hans Verkuil , Sakari Ailus , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Tomi Valkeinen X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6178; i=tomi.valkeinen@ideasonboard.com; h=from:subject:message-id; bh=jLqnCfsN8nWchZxolR03Bfc5Bu6MqE3ssrg54dj55Ws=; b=owEBbQKS/ZANAwAIAfo9qoy8lh71AcsmYgBm6Y28wB6Ai7xXG80tcbePYq2sntO19C9gE02uH /PaWbLMZL6JAjMEAAEIAB0WIQTEOAw+ll79gQef86f6PaqMvJYe9QUCZumNvAAKCRD6PaqMvJYe 9SjYD/90l4x4d+2tL/hXEM8LzacA4AJAFJD7izawzpBX7JaoQdz/Ixk4yITPnA2mobPeajwrgWm KDs1DDVmmvJ2mV5T2lo8rRdA7t6mHuuhyEw8BYEb1LX1UUJQMCTLf9fInREGC2rikDFn/U4c2Ob 7LUa7btVgJpWwDjtxT2N8HmbrseqX7OCQEZgAzsX/qywGU/8qAL/mMoaZTC0ftazkqb9T4cTvQT iqUR1K11wv8SiKvXyEnzDFDYfMQUOGaMkEKukrzzR6pQRQ4hn5sjk2+xd6/o6y7x3KMVwBouYfC 5CGCd7sZyQ+EbxwnUDITLJHNAqJun365W0KZhciXHVfAjP0hThDBhbp4aJDextQh1U7ArUQLQFc LxU2z4hSSEst8hZfrhJGpAX+zaD1umPTikraTgkIsnmJEIR8ecqKpP5iqfgXLtGorhb8HT006Cz +6xBzoxi/7dSouWql8xIYzvOraIVCiKwACoYQV2uOAXovz0947WBcFkNcykBo0yuoHzU8o/O9Dq hQ9kuDt7BunsnM/U7vSBktDXlPhmEdk+PVHzgQRcDaXbrQC/lYvRRi7UrxR0Xl9ywzznVzunbc/ 4sOpdeM3oqSAoRSez8lDAkO06bcwkxxXcVuAzF+L4mGC1j5W/6IO3JFwCWMTcBla9DS+wX50DOw Ct3S0oZ3RdGwZyQ== X-Developer-Key: i=tomi.valkeinen@ideasonboard.com; a=openpgp; fpr=C4380C3E965EFD81079FF3A7FA3DAA8CBC961EF5 From: Tomi Valkeinen Use the new subdev state cleanup macros. Signed-off-by: Tomi Valkeinen --- drivers/media/i2c/ds90ub913.c | 11 +++-------- drivers/media/i2c/ds90ub953.c | 11 +++-------- drivers/media/i2c/ds90ub960.c | 27 ++++++++------------------- 3 files changed, 14 insertions(+), 35 deletions(-) diff --git a/drivers/media/i2c/ds90ub913.c b/drivers/media/i2c/ds90ub913.c index ca9bb29dab89..7a53b68db1b4 100644 --- a/drivers/media/i2c/ds90ub913.c +++ b/drivers/media/i2c/ds90ub913.c @@ -351,7 +351,6 @@ static int ub913_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, const struct v4l2_subdev_krouting *routing; struct v4l2_mbus_frame_desc source_fd; struct v4l2_subdev_route *route; - struct v4l2_subdev_state *state; int ret; if (pad != UB913_PAD_SOURCE) @@ -364,7 +363,7 @@ static int ub913_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->type = V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL; - state = v4l2_subdev_lock_and_get_active_state(sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd); routing = &state->routing; @@ -382,8 +381,7 @@ static int ub913_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, if (i == source_fd.num_entries) { dev_err(&priv->client->dev, "Failed to find stream from source frame desc\n"); - ret = -EPIPE; - goto out_unlock; + return -EPIPE; } fd->entry[fd->num_entries].stream = route->source_stream; @@ -395,10 +393,7 @@ static int ub913_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->num_entries++; } -out_unlock: - v4l2_subdev_unlock_state(state); - - return ret; + return 0; } static int ub913_set_fmt(struct v4l2_subdev *sd, diff --git a/drivers/media/i2c/ds90ub953.c b/drivers/media/i2c/ds90ub953.c index 16f88db14981..131b1523c3a5 100644 --- a/drivers/media/i2c/ds90ub953.c +++ b/drivers/media/i2c/ds90ub953.c @@ -488,7 +488,6 @@ static int ub953_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, struct ub953_data *priv = sd_to_ub953(sd); struct v4l2_mbus_frame_desc source_fd; struct v4l2_subdev_route *route; - struct v4l2_subdev_state *state; int ret; if (pad != UB953_PAD_SOURCE) @@ -501,7 +500,7 @@ static int ub953_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; - state = v4l2_subdev_lock_and_get_active_state(sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd); for_each_active_route(&state->routing, route) { struct v4l2_mbus_frame_desc_entry *source_entry = NULL; @@ -520,8 +519,7 @@ static int ub953_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, if (!source_entry) { dev_err(&priv->client->dev, "Failed to find stream from source frame desc\n"); - ret = -EPIPE; - goto out_unlock; + return -EPIPE; } fd->entry[fd->num_entries].stream = route->source_stream; @@ -536,10 +534,7 @@ static int ub953_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->num_entries++; } -out_unlock: - v4l2_subdev_unlock_state(state); - - return ret; + return 0; } static int ub953_set_fmt(struct v4l2_subdev *sd, diff --git a/drivers/media/i2c/ds90ub960.c b/drivers/media/i2c/ds90ub960.c index ffe5f25f8647..e873611bf5c7 100644 --- a/drivers/media/i2c/ds90ub960.c +++ b/drivers/media/i2c/ds90ub960.c @@ -2777,7 +2777,6 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, { struct ub960_data *priv = sd_to_ub960(sd); struct v4l2_subdev_route *route; - struct v4l2_subdev_state *state; int ret = 0; struct device *dev = &priv->client->dev; u8 vc_map[UB960_MAX_RX_NPORTS] = {}; @@ -2787,7 +2786,7 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->type = V4L2_MBUS_FRAME_DESC_TYPE_CSI2; - state = v4l2_subdev_lock_and_get_active_state(&priv->sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(&priv->sd); ub960_get_vc_maps(priv, state, vc_map); @@ -2810,7 +2809,7 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, dev_err(dev, "Failed to get source frame desc for pad %u\n", route->sink_pad); - goto out_unlock; + return ret; } for (i = 0; i < source_fd.num_entries; i++) { @@ -2823,8 +2822,7 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, if (!source_entry) { dev_err(dev, "Failed to find stream from source frame desc\n"); - ret = -EPIPE; - goto out_unlock; + return -EPIPE; } fd->entry[fd->num_entries].stream = route->source_stream; @@ -2844,16 +2842,13 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fmt = v4l2_subdev_state_get_format(state, pad, route->source_stream); - if (!fmt) { - ret = -EINVAL; - goto out_unlock; - } + if (!fmt) + return -EINVAL; ub960_fmt = ub960_find_format(fmt->code); if (!ub960_fmt) { dev_err(dev, "Unable to find format\n"); - ret = -EINVAL; - goto out_unlock; + return -EINVAL; } fd->entry[fd->num_entries].bus.csi2.dt = @@ -2863,10 +2858,7 @@ static int ub960_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad, fd->num_entries++; } -out_unlock: - v4l2_subdev_unlock_state(state); - - return ret; + return 0; } static int ub960_set_fmt(struct v4l2_subdev *sd, @@ -2944,14 +2936,13 @@ static int ub960_log_status(struct v4l2_subdev *sd) { struct ub960_data *priv = sd_to_ub960(sd); struct device *dev = &priv->client->dev; - struct v4l2_subdev_state *state; unsigned int nport; unsigned int i; u16 v16 = 0; u8 v = 0; u8 id[UB960_SR_FPD3_RX_ID_LEN]; - state = v4l2_subdev_lock_and_get_active_state(sd); + CLASS(v4l2_subdev_lock_and_get_active_state, state)(sd); for (i = 0; i < sizeof(id); i++) ub960_read(priv, UB960_SR_FPD3_RX_ID(i), &id[i]); @@ -3078,8 +3069,6 @@ static int ub960_log_status(struct v4l2_subdev *sd) } } - v4l2_subdev_unlock_state(state); - return 0; }