From patchwork Tue Dec 3 14:15:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 11271387 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A94151892 for ; Tue, 3 Dec 2019 14:15:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 928F62073F for ; Tue, 3 Dec 2019 14:15:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 928F62073F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A5866E5F2; Tue, 3 Dec 2019 14:15:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id B69696E5E7 for ; Tue, 3 Dec 2019 14:15:28 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 0840B290595; Tue, 3 Dec 2019 14:15:27 +0000 (GMT) From: Boris Brezillon To: dri-devel@lists.freedesktop.org Subject: [PATCH v4 06/11] drm/bridge: Add the drm_bridge_get_prev_bridge() helper Date: Tue, 3 Dec 2019 15:15:10 +0100 Message-Id: <20191203141515.3597631-7-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191203141515.3597631-1-boris.brezillon@collabora.com> References: <20191203141515.3597631-1-boris.brezillon@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Neil Armstrong , Thierry Reding , Laurent Pinchart , kernel@collabora.com, Sam Ravnborg , Nikita Yushchenko , Andrey Smirnov , Kyungmin Park , Chris Healy , devicetree@vger.kernel.org, Jonas Karlman , Rob Herring , Jernej Skrabec , Seung-Woo Kim , Boris Brezillon Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The drm_bridge_get_prev_bridge() helper will be useful for bridge drivers that want to do bus format negotiation with their neighbours. Signed-off-by: Boris Brezillon Reviewed-by: Laurent Pinchart Reviewed-by: Neil Armstrong --- Changes in v4: * Change the helper name to be consistent with the _next_bridge() helper * Update the commit message * Add Rbs Changes in v3: * Inline drm_bridge_chain_get_prev_bridge() * Fix the doc Changes in v2: * Fix the kerneldoc * Drop the !bridge || !bridge->encoder check --- include/drm/drm_bridge.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 1eb854025a20..bfb0385163f1 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -426,6 +426,22 @@ drm_bridge_get_next_bridge(struct drm_bridge *bridge) return list_next_entry(bridge, chain_node); } +/** + * drm_bridge_get_prev_bridge() - Get the previous bridge in the chain + * @bridge: bridge object + * + * RETURNS: + * the previous bridge in the chain, or NULL if @bridge is the first. + */ +static inline struct drm_bridge * +drm_bridge_get_prev_bridge(struct drm_bridge *bridge) +{ + if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) + return NULL; + + return list_prev_entry(bridge, chain_node); +} + /** * drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain * @encoder: encoder object