From mboxrd@z Thu Jan 1 00:00:00 1970 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 C48153E0240; Mon, 4 May 2026 15:27:40 +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=1777908462; cv=none; b=LcXqz/7mqfIjmRVUcefF/6+YZjt0e9g9DNYoSodDsYS3XBQMmEsKnhuRiIfvWhGpDoPCtvLCBBfyR9qPdTRIsfhQthZlbpCSaGqpK+kWHqZh+kBzQ3JCHUkYsBczxX5kgTx0WRNhRsrdEj6R6yz5zSet4xp6w9kUsiDacDOP3uE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777908462; c=relaxed/simple; bh=FTSgfFPCnzQLTG4eJxZAem+3dcr6wPJ3+G1sIL7RpM0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FW1Yvsm8AQ7p7Iu8NbmpQBGF+3udXSpQujFviT3u/g0PfVMxgLDRZNK5jydab7BW1KgNu4PeyACyn4bBJOfqBYf3pGwMo50ETndtGbKEAqlVsN85kCwMSMYnlfoRqyi4+KYD8IYgWHCaTlu5sqScVDa46LSg9z5YodULL2GjhFA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (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=m1jZ0a3C; arc=none smtp.client-ip=213.167.242.64 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (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="m1jZ0a3C" Received: from killaraus.ideasonboard.com (2001-14ba-703d-e500--2a1.rev.dnainternet.fi [IPv6:2001:14ba:703d:e500::2a1]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6426C175; Mon, 4 May 2026 17:27:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1777908456; bh=FTSgfFPCnzQLTG4eJxZAem+3dcr6wPJ3+G1sIL7RpM0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=m1jZ0a3C6WrgBNNrmOhhF+xER7PP8ksCg7WfK+EHHpWugmOHtchtHIxqSgVOeFwh+ sl/1vOAKOQevSZvLEr3Q3UzV8EjOpdDxhKMrBJnYB/M5ORdHZOb1fyoZTCnOhfAHiC JhgXEXNRhvND9Klnic6IkEjVExvb7u8s7nVGBVRk= Date: Mon, 4 May 2026 18:27:37 +0300 From: Laurent Pinchart To: Luca Ceresoli Cc: Andrzej Hajda , Neil Armstrong , Robert Foss , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , Sumit Semwal , John Stultz , Tomi Valkeinen , Michal Simek , Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Dmitry Baryshkov Subject: Re: [PATCH v4 11/11] drm: of: forbid bridge-only calls to drm_of_find_panel_or_bridge() Message-ID: <20260504152737.GD1455860@killaraus.ideasonboard.com> References: <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-0-b578c3daaf10@bootlin.com> <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-11-b578c3daaf10@bootlin.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260504-drm-bridge-alloc-getput-panel_or_bridge-v4-11-b578c3daaf10@bootlin.com> On Mon, May 04, 2026 at 12:45:14PM +0200, Luca Ceresoli wrote: > Up to now drm_of_find_panel_or_bridge() can be called with a bridge pointer > only, a panel pointer only, or both a bridge and a panel pointers. The > logic to handle all the three cases is somewhat complex to read however. > > Now all bridge-only callers have been converted to > of_drm_get_bridge_by_endpoint(), which is simpler and handles bridge > refcounting. So forbid new bridge-only users by mandating a non-NULL panel > pointer in the docs and in the sanity checks along with a warning. > > Reviewed-by: Dmitry Baryshkov > Signed-off-by: Luca Ceresoli Reviewed-by: Laurent Pinchart > --- > drivers/gpu/drm/drm_of.c | 26 ++++++++++++-------------- > 1 file changed, 12 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > index ef6b09316963..d03ada82eac9 100644 > --- a/drivers/gpu/drm/drm_of.c > +++ b/drivers/gpu/drm/drm_of.c > @@ -225,15 +225,15 @@ EXPORT_SYMBOL_GPL(drm_of_encoder_active_endpoint); > * @np: device tree node containing encoder output ports > * @port: port in the device tree node > * @endpoint: endpoint in the device tree node > - * @panel: pointer to hold returned drm_panel > + * @panel: pointer to hold returned drm_panel, must not be NULL > * @bridge: pointer to hold returned drm_bridge > * > * Given a DT node's port and endpoint number, find the connected node and > - * return either the associated struct drm_panel or drm_bridge device. Either > - * @panel or @bridge must not be NULL. > + * return either the associated struct drm_panel or drm_bridge device. > * > * This function is deprecated and should not be used in new drivers. Use > - * devm_drm_of_get_bridge() instead. > + * of_drm_get_bridge_by_endpoint() instead when not looking for a panel, or > + * devm_drm_of_get_bridge() otherwise. > * > * Returns zero if successful, or one of the standard error codes if it fails. > */ > @@ -245,10 +245,10 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, > int ret = -EPROBE_DEFER; > struct device_node *remote; > > - if (!panel && !bridge) > + if (WARN_ON(!panel)) > return -EINVAL; > - if (panel) > - *panel = NULL; > + > + *panel = NULL; > > /* > * of_graph_get_remote_node() produces a noisy error message if port > @@ -263,13 +263,11 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, > if (!remote) > return -ENODEV; > > - if (panel) { > - *panel = of_drm_find_panel(remote); > - if (!IS_ERR(*panel)) > - ret = 0; > - else > - *panel = NULL; > - } > + *panel = of_drm_find_panel(remote); > + if (!IS_ERR(*panel)) > + ret = 0; > + else > + *panel = NULL; > > if (bridge) { > if (ret) { > -- Regards, Laurent Pinchart