Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 246C4C33CA0 for ; Tue, 3 Dec 2019 14:15:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0B8C2146E for ; Tue, 3 Dec 2019 14:15:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726086AbfLCOP3 (ORCPT ); Tue, 3 Dec 2019 09:15:29 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:59046 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726505AbfLCOP3 (ORCPT ); Tue, 3 Dec 2019 09:15:29 -0500 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 Cc: Lucas Stach , Chris Healy , Andrey Smirnov , Nikita Yushchenko , kernel@collabora.com, Daniel Vetter , Inki Dae , Joonyoung Shim , Seung-Woo Kim , Kyungmin Park , Thierry Reding , Sam Ravnborg , Philipp Zabel , Rob Clark , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Rob Herring , Mark Rutland , devicetree@vger.kernel.org, Eric Anholt , Boris Brezillon , Laurent Pinchart 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 Content-Transfer-Encoding: 8bit Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org 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 -- 2.23.0