From patchwork Mon Oct 2 09:32:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 114567 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp473126qgn; Mon, 2 Oct 2017 02:32:57 -0700 (PDT) X-Received: by 10.84.218.2 with SMTP id q2mr5656958pli.111.1506936777297; Mon, 02 Oct 2017 02:32:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506936777; cv=none; d=google.com; s=arc-20160816; b=WjMHJ4zni769196R16alEOyR0Bsu1VKE2qEkpeiSHzmYpoSoqyrzxBbHft3zIezWAF 5oiXmtgMxLwhYXmhz1muO/9abFOlsWYstUUsXhcx8VYGS4RztQlLNpF5kQ86yvlLOHF1 +iXwhT6peERXY0k8H8Ctafq5wD+CEcH18nCSa+trUKgvD7tFvmrUO2H/q5b4XdgmGW0f 0mDcQUw0n6G3mimYTHWWP2KotipYQJE/IMYOV/tr3Qm/D4mn91FEXXSwcA8fwPBKO/ew xBQeoMlzmSAYc4Vfd2kkWTps9poCo4bdlETYarYJqTMIQUG/SfO+tCvWRLsRCOaNBy4a P3Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=isWHYkrtV5vknIo5Q9wbbd+fBwhKERP8BsmNlsZe1BY=; b=xT3uNHToaijEQTUvJ2r6RJXx8zcvy9/4yIclOawE1vo+qtppiol2WUX5PwtRfzlMgm 6jcI0C6nt86jjqet83cCxevgYyJJrsiFeRrwEPqSr9JryMvBniq++IvlZcnYYn7b5fP1 isbPV8BbZaKJT9schSlOBgcxythUIDxnVXzbqrcBzfyU4W60hQDjR7KHDqlSWTlJqTAw DwVla1YW1nzjYITKjWgB2cZcMg2MHJY/BkOSS2UKnXjtZwHoEs2hwoYnWdElfF2eXeaH h5X+SdKRWbOUI+2E09PAtKyh0C95ji9MYiPcKRzVOUJm01ptz83dME29Av4QI9aqLIGx yD9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=U7DQQgCX; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id h8si5208348pgp.799.2017.10.02.02.32.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 02:32:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=U7DQQgCX; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D3FAE6E2E5; Mon, 2 Oct 2017 09:32:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6E086E2E5 for ; Mon, 2 Oct 2017 09:32:53 +0000 (UTC) Received: by mail-wr0-x229.google.com with SMTP id l39so3429221wrl.12 for ; Mon, 02 Oct 2017 02:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=FGwwx0p8yLoQ/Wgw+XVB6XyVdxOVWkNkRP1/Mk0nWlw=; b=U7DQQgCXsg0eviLFaIu+XjVczHYnu8msvMibBaPaiFJslFumjNIauKaq+nwATIa83F tzrjlpF88Fozp0MTe5uuQyfX3PVGwqCOMAPXtuXjwAAm6tCF8Xn+4w9bcv9fttD0Ll+k rXe/YVbIqT+xzIxOXmPDlMNlZtelrlcPrnAAs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=FGwwx0p8yLoQ/Wgw+XVB6XyVdxOVWkNkRP1/Mk0nWlw=; b=dwV/KTXgELFJdWGR5/MlbPdIlNwbpAcrI/1KTSqIvQocJ4+7OwQqLbzMOI3tYVM5ly 6hjohVjU5ur+a30xZ9oBLtQK5IxJ2BtqFZ045Q3PnS1Gb9YSj/inHsHkq3F8dyvJ2gLY KsCFs2S2gNwQ9SMxXU1lRt2CmSRru/HwxqKj0j3o9zneaihjI4PPpvYI7VseMAsczqBO qhwjfEOaN9XirKNJDw4Dt5XMHuHYmD7SyUxNebWss7TZnvH3/NvIH712ATzKLsCMen27 9bQcYs9I+1Pq7x2D3m0xPiHPCVti5Rr8eJI6khPu2vwk5OBA9gdRiZIko2VfrHphHlii C2Rw== X-Gm-Message-State: AHPjjUjX+WNvwNqgPaz8dsnl9cMZi7yAqWmQpOE7R55V3QQph7RSKVIM bhpg0dKkxO/tC3Tj7D0ABgNKuQ== X-Google-Smtp-Source: AOwi7QAW2LUV9x42XtxV2FuOftZoQjk+zPfLShqxa9Qn06CFs4Bko2+oCKyrzQFShs3tggo0lzahyg== X-Received: by 10.223.139.212 with SMTP id w20mr13180406wra.275.1506936772338; Mon, 02 Oct 2017 02:32:52 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.199.139]) by smtp.gmail.com with ESMTPSA id 64sm4773434wma.21.2017.10.02.02.32.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 02:32:51 -0700 (PDT) From: Benjamin Gaignard To: architt@codeaurora.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, airlied@linux.ie, daniel.vetter@intel.com, jani.nikula@linux.intel.com, seanpaul@chromium.org, yannick.fertre@st.com, philippe.cornu@st.com Subject: [PATCH v2 1/5] drm/bridge: make drm_panel_bridge_remove more robust Date: Mon, 2 Oct 2017 11:32:31 +0200 Message-Id: <1506936755-23625-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506936755-23625-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506936755-23625-1-git-send-email-benjamin.gaignard@linaro.org> Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Make sure that bridge parameter is not NULL and can be safely cast into a panel_bridge structure. Signed-off-by: Benjamin Gaignard Reviewed-by: Philippe Cornu Tested-by: Philippe Cornu --- drivers/gpu/drm/bridge/panel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index e0cca19..6d99d4a 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -188,7 +188,15 @@ EXPORT_SYMBOL(drm_panel_bridge_add); */ void drm_panel_bridge_remove(struct drm_bridge *bridge) { - struct panel_bridge *panel_bridge = drm_bridge_to_panel_bridge(bridge); + struct panel_bridge *panel_bridge; + + if (!bridge) + return; + + if (bridge->funcs != &panel_bridge_bridge_funcs) + return; + + panel_bridge = drm_bridge_to_panel_bridge(bridge); drm_bridge_remove(bridge); devm_kfree(panel_bridge->panel->dev, bridge); From patchwork Mon Oct 2 09:34:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 114569 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp474784qgn; Mon, 2 Oct 2017 02:35:20 -0700 (PDT) X-Received: by 10.99.42.3 with SMTP id q3mr12419620pgq.354.1506936920446; Mon, 02 Oct 2017 02:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506936920; cv=none; d=google.com; s=arc-20160816; b=XwMos+FkKa3xZHch0Ftx7w/GDGAtfBcVMJ2vUxe+6Idx/8dXbqVlIqBT427ZLaYY/n kLNBtlhgcec0OJgEJjYPWPCO1rHXx1PPgnFQglwcoWoBYMMjxDA/IBle85Dtpre2Bi5O +l/956T0Wh11TuQPc5eufQi3UFgNsZ7woR14be/ZbhUFEs/f0m/pXOMXiRZVOG2CUdMU yTkijpYwkfJJGVEL0xzl6LUbaLqDmuFKMU7oIsmJqz/JqNf+12MOveJ9dDS2ja3mRE9W lFreMu8l3Iv9AcitANoaqreI72YbNI/h5l96QKQbyqUBP9CnZSAxv+Spy8jBYOL7fvTV rZuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:message-id:date:subject:to:from :dkim-signature:delivered-to:arc-authentication-results; bh=26HUiJu4V0L+9QchYLcH5Ut/us+THEG0X8n2WHDNZ3M=; b=z34Zmhc2Vko5+kxcnSxflTgIXPWOfPO2j51/foEYnjI25s69gifa/6uA/lomxBLAAU P4ouD+0xHSH2FvBlUWxuKYoJT7yeQ+m7S5ME1Jplg2teDcDupiJp4vcnss0A9VWgt4AH PbHXHdkZMIt12ueKgFrYNBwh1oEPsMcFyVbbbPkfdYdPXda71Yt/Vn9SAmZvEVXfNeLH 8E0K+E4EAGUrAID1SyqC7Lp7OWtyEMbVw94UNLVmJ0GQX5HmubGcccZjez3HmQc6zowq jGin5hkE3ufp86zhOtMrJhFtMeC5HFJsVVmrwYX657kQcDb78v4naoisqz9zCAxd6VbU RKbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Uooo1pZh; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id g2si7365330pgf.680.2017.10.02.02.35.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Oct 2017 02:35:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=Uooo1pZh; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1764D6E2F0; Mon, 2 Oct 2017 09:35:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) by gabe.freedesktop.org (Postfix) with ESMTPS id 64AAE6E2F0 for ; Mon, 2 Oct 2017 09:35:17 +0000 (UTC) Received: by mail-wr0-x229.google.com with SMTP id u5so3262758wrc.5 for ; Mon, 02 Oct 2017 02:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=aDoYHb9nNzhm3glJHkaoKnePiq7HmxvpjV+doWC5ujY=; b=Uooo1pZh8xEZ+F0Bjlq/YVPsZudTnWblxrK/03JAN4venlhz8UaM9Y/fhJmZYXhjUi I9aau2M//vL1HpioN1fO7DUvjCvDmjuB5MT0fN/D+SrDqcf0TXU4ADPdew6cMFyeAnnr nnxzmdv6DIx3bqGAWRPb2eMBLtqKaQlzWQeX8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=aDoYHb9nNzhm3glJHkaoKnePiq7HmxvpjV+doWC5ujY=; b=Wxav+kLJZQCVbldPkDlFugxccbeoI2YZV5F1+xyyX2Q8uyv8cL6kCejyIhvYqhjakD S5Znh2txj1QQlvTWjqXLqTBkHl9rQo3afh703HFR4ZerDoHkwBitLW3wocVBERwzDIVB sLdCLw+l7AOXD4wyYoKaA9FtmWWY3egbtaT005egIyDAW4C0DpNI2Pxi4pNFycsE1Eor KCnjLCXAuR1mn3BkOjpQNoOtNhfCI0Z6SVVgaS2fgQ3zvdh7qkkJkQLfcZ+ZnfsJsAql I1yQ81LkgrFLYmPKDq4nWlfcH97FT37UNDG1DNt7yVgCPuk8qVcFos2T1g3ZXKbVaYJN orfA== X-Gm-Message-State: AHPjjUhYH3LuMsSHWlgTtm8TukN4nRbCeKl7aha23L1Y2O9AVSA28Ew8 V8gfVaBt1A57hu6Cubc2Gmb+JLXEGPw= X-Google-Smtp-Source: AOwi7QAb6p2Xyn1pHEwXx2qHHiACRJSZ2NQApCA8CfsZ28ry5+D3yx6pWwuhA9OleAMnQE0P1Fn89Q== X-Received: by 10.223.152.132 with SMTP id w4mr13479733wrb.264.1506936915879; Mon, 02 Oct 2017 02:35:15 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.199.139]) by smtp.gmail.com with ESMTPSA id l4sm6516856wrb.74.2017.10.02.02.35.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 02 Oct 2017 02:35:15 -0700 (PDT) From: Benjamin Gaignard To: architt@codeaurora.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, airlied@linux.ie, daniel.vetter@intel.com, jani.nikula@linux.intel.com, seanpaul@chromium.org, yannick.fertre@st.com, philippe.cornu@st.com Subject: [PATCH v2 2/5] drm/drm_of: add drm_of_panel_bridge_remove function Date: Mon, 2 Oct 2017 11:34:45 +0200 Message-Id: <1506936888-23844-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This function is the pendant of drm_of_find_panel_or_bridge() to remove a previously allocated panel_bridge. Given a specific port and endpoint it remove the panel bridge. Since drm_panel_bridge_remove() will check that bridge parameter is not NULL and is a real drm_panel_bridge and no a simple bridge it is safe to call it directly. Signed-off-by: Benjamin Gaignard Reviewed-by: Philippe Cornu Tested-by: Philippe Cornu Reviewed-by: Eric Anholt --- drivers/gpu/drm/drm_of.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_of.h | 8 ++++++++ 2 files changed, 41 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index 8dafbdf..6b54f17 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -260,3 +260,36 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, return ret; } EXPORT_SYMBOL_GPL(drm_of_find_panel_or_bridge); + +#ifdef CONFIG_DRM_PANEL_BRIDGE +/* + * drm_of_panel_bridge_remove - remove panel bridge + * @np: device tree node containing panel bridge output ports + * + * Remove the panel bridge of a given DT node's port and endpoint number + * + * Returns zero if successful, or one of the standard error codes if it fails. + */ +int drm_of_panel_bridge_remove(const struct device_node *np, + int port, int endpoint) +{ + struct drm_bridge *bridge; + struct device_node *remote; + + remote = of_graph_get_remote_node(np, port, endpoint); + if (!remote) + return -ENODEV; + + bridge = of_drm_find_bridge(remote); + drm_panel_bridge_remove(bridge); + + return 0; +} +#else +int drm_of_panel_bridge_remove(const struct device_node *np, + int port, int endpoint) +{ + return -EINVAL; +} +#endif +EXPORT_SYMBOL_GPL(drm_of_panel_bridge_remove); diff --git a/include/drm/drm_of.h b/include/drm/drm_of.h index 104dd51..390966e 100644 --- a/include/drm/drm_of.h +++ b/include/drm/drm_of.h @@ -29,6 +29,8 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, int port, int endpoint, struct drm_panel **panel, struct drm_bridge **bridge); +int drm_of_panel_bridge_remove(const struct device_node *np, + int port, int endpoint); #else static inline uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, struct device_node *port) @@ -65,6 +67,12 @@ static inline int drm_of_find_panel_or_bridge(const struct device_node *np, { return -EINVAL; } + +static inline int drm_of_panel_bridge_remove(const struct device_node *np, + int port, int endpoint) +{ + return -EINVAL; +} #endif static inline int drm_of_encoder_active_endpoint_id(struct device_node *node,