From patchwork Fri Sep 29 12:59:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 114517 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp798161edb; Fri, 29 Sep 2017 05:59:39 -0700 (PDT) X-Received: by 10.84.238.201 with SMTP id l9mr6705911pln.159.1506689979361; Fri, 29 Sep 2017 05:59:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506689979; cv=none; d=google.com; s=arc-20160816; b=t2G+RKZ9g/FrSjG5CL7Hz1K0XYkeHr90EUarKfbuIh4RcckmKMdot8C50iIFZJczrz 4tUc1GslplvW8S9C6bGQMvtBXKF2NlyLPkUjyrzMesLhfwb2NkMAJSzOFl3+w+ujlQed +ZpqatJwLj8wShGkrSLRszSFxq/GTdRXa9Cuez4pdf7IhSzeXCWv9Gq1DGQtpuItPcPY vp0aytX8T4smX0APEV+nhX1+sFj7JNsZsFUd+asvMMi/VtmMBCO7vB0/JaGNEgzDUogi nTQBRXdFNJYiqLLGfnhgBahXh3HLzeX5WjPH8g3TsLHiP0K4B5ACvmIma67HyzyZmccL EmFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=+6qTWk2NQHqkPJUR4egv7WzZ0oLeBPdJGWCoL/5D6Tw=; b=KuK6x2NAI1lJrdgmsRe2W3ySDzCtNQZREtYRhTRtSWQByZqqoPdXp4uVfZT28iFW3F omj+Gr/EhVhf7DJ+NDJlzdFtB/AeaohxkNhyut3nIkSUPmuSbFamZDafANjz5Dpc53No RK5oS2hXew3Q5LrqL23m2HycYPxrdaN15jRrwTIhOK3SY+KFjx59vx1IvysFh4Kdqa+N NapvyDLTGE0kW+uwfXINZqRLhVPms+UhRZHYyQL7ob8Sq77XgpR9kG5+HP2oNlwsihGl ASv989NoUfDmtnviWOLX3xYFZa94lN29WAp3jjUrZUZMZ0z7oYP5EoqXBpjYgjfz7jm7 8/Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKt5Jr7j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j185si68092pgc.543.2017.09.29.05.59.39; Fri, 29 Sep 2017 05:59:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IKt5Jr7j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752123AbdI2M7g (ORCPT + 26 others); Fri, 29 Sep 2017 08:59:36 -0400 Received: from mail-wm0-f51.google.com ([74.125.82.51]:48759 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751224AbdI2M7e (ORCPT ); Fri, 29 Sep 2017 08:59:34 -0400 Received: by mail-wm0-f51.google.com with SMTP id m127so3225850wmm.3 for ; Fri, 29 Sep 2017 05:59:33 -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=+6qTWk2NQHqkPJUR4egv7WzZ0oLeBPdJGWCoL/5D6Tw=; b=IKt5Jr7jQIVrUD4KGoRo2lDM6SCgWcMosXVwBzFx2M5p/wss/Q4OlNgZxHMQfDmhfd KiayiNOLQQ9fnkB60q9HhZUcUKL135SKMdfzteMp9yOOL1/jArPePnq35mso+WrqYp8H O7n3Y+dEISs7me+pkOZq8wWUwmLcYReovgcqE= 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=+6qTWk2NQHqkPJUR4egv7WzZ0oLeBPdJGWCoL/5D6Tw=; b=ry1HDvT3OC0bt86vHAfF6PtJkmrCtAxD08HpvfvvFV1K+PoM8H1yJ3i5Umqz8aK+zq LT70s87xPMyigHNPbr8/gjeRZUTC8TjxDtWYD6+NQh7SPJqj6oVGMpEIB3Bq9gp1OvSQ RIZCVCza/253V14zVminGe4J3GvdfVs7ix3t73Vv1eDiKbWCIasifojZci8ojCrbmMg8 uGftToAZHXqDlAgVlEDBNVqeXqJg+sSXkym9MV43lGAdZQ+s01FjSI/fr46H4RLewP4t ZDteHuMF2hOOyvyy2t4kOx+IozydSQCcytYXsnSuTo4D9DIglb1OFXPZucYx1jhBiTPf J5GA== X-Gm-Message-State: AHPjjUiQfiYlx80aDKChgt235jZyMg6vKK7nFeViG+7m8RtV37uhgzcD QB3HiKMBmM5jRJVlh5Ogwscu0A== X-Google-Smtp-Source: AOwi7QDESy5y8I6ddDl0HbbclKxo22GAEamNZ5l03A/yR94jBcOdaOZoYdxJdGipwpPbngFOJHe6wA== X-Received: by 10.28.63.145 with SMTP id m139mr4496254wma.5.1506689972620; Fri, 29 Sep 2017 05:59:32 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.91.35]) by smtp.gmail.com with ESMTPSA id k11sm3269667wrc.90.2017.09.29.05.59.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 05:59:32 -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 Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Benjamin Gaignard Subject: [PATCH 1/3] drm/bridge: make drm_panel_bridge_remove more robust Date: Fri, 29 Sep 2017 14:59:17 +0200 Message-Id: <1506689959-7858-2-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure that bridge parameter is not NULL and can be safely cast into a panel_bridge structure. Signed-off-by: Benjamin Gaignard --- drivers/gpu/drm/bridge/panel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) -- 2.7.4 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 Fri Sep 29 12:59:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Gaignard X-Patchwork-Id: 114518 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp798218edb; Fri, 29 Sep 2017 05:59:42 -0700 (PDT) X-Received: by 10.84.136.1 with SMTP id 1mr6778339plk.101.1506689982589; Fri, 29 Sep 2017 05:59:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506689982; cv=none; d=google.com; s=arc-20160816; b=Wu2zNWu7W+ipO2LiX3Pri1RR20WitTJreIIKXUgFJonm7ME296JJ/HSg7VZjm99yqn jDCE1wI4FuuPWAARuJEzR9oA4jMaDJyWZRG0wswJdcjCqdg7mCOXWh5WIydAWiQHqjZQ fFSuUrWSebysvujdAnnmwGMW0e5HkJW8UjzIJptSqvPzenZvRnjjTY7hs4uxTn5vjnA8 iE7PRe7q+sEITtBSA7E3Uk8xeXtNxMAyVLCc4jsUDPdyCh1B8uyxG2CtiMxXoc5nrfhV NHQtADTEHgPT8xsvTpnBoT4h2CBYn0jEk110zPK16O4vmO746yi2hryTNQBdWZ2vdKo0 OBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=Hj4kfz4Uzu/5sDvtj8FN2aB8mXVF81wP3HBpnWZstm8=; b=SXBcWHxruN7MqCqAugNebzOtPU7ooB3Ctf08zASXs15/xnADakidsUYFnN/tx+A8oi ucMigUdYGYxJsx73thgw7qzms2DysWHYd4tcxoOPy/51/yMiKyv+o7pRmrb/3btcZGdS r6n9p3bJXE2FXvuTzbZNKXBNghEmB46sogooUqoyJH/y5nF2mveJ4AivwHKs+Do2FFwq OQldqvlKp2yTxrYFQJH7FZZSoRmCWI3rSnFbf+6PwB11COnGtGfSPXvzbgTaPpmjA9/F I4NSmN9XtIE3neTawnZkfe5b/761S2EEBGCj3z1FOap/s/mdmkrh/ssxDggvDeX7kuXv JW1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DY0wE1vK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z18si3375077pff.620.2017.09.29.05.59.42; Fri, 29 Sep 2017 05:59:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DY0wE1vK; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752181AbdI2M7j (ORCPT + 26 others); Fri, 29 Sep 2017 08:59:39 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:56411 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752022AbdI2M7g (ORCPT ); Fri, 29 Sep 2017 08:59:36 -0400 Received: by mail-wm0-f46.google.com with SMTP id r74so3114448wme.5 for ; Fri, 29 Sep 2017 05:59:35 -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=Hj4kfz4Uzu/5sDvtj8FN2aB8mXVF81wP3HBpnWZstm8=; b=DY0wE1vKyIOBc452bJVaYDMEmkpQy9DRxipTKuYnPqYqj2eeG6rfG/ilI9iQKXHeJQ t+zKkGez0W2mZLjy7Ssrw/SEcZXrEtoQ1l01bqNYMwHYl8D3DX6JacNaRzIJEWj3laq5 pVV1NazG59mKxXc64JI6koOErcgabyL6HO5b4= 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=Hj4kfz4Uzu/5sDvtj8FN2aB8mXVF81wP3HBpnWZstm8=; b=FqR+5jGmehoCbuAIhrohfCEnvpgkSpaqYtIL6tjKqz23hhg+43c2DLNsmXPgpl/TuP pWAVMypILwR9bigts6UoINS/OM6DhpB+uKpObtCzljbtYbjqYqJ3ly5Dyrr6hbsrndn9 MGYzMXkWqPoip6yPOZwm5arNNHCh5WEQCmvd14BMp9BYQAmGvgPkeM/zwJHRa54n8XSy O02FZuAXOU4s5IZ3eSwX0RSm2G+MONALnxYyFIcSrYpE/adndMZFZUWrn6LG0S+vHZjN VvjR+rsUcsExPX9UKVrhCyNYNaf3hC252kHXwwmWZXep+9/urjiFjCDX0HPdix0hkvct E+Tg== X-Gm-Message-State: AMCzsaUhrEWoxgSuXpxL666g7L9x5c9K31S/eVWlHGYkQoSva6pTPhMU TT7CRZAhkIH30d7lmpZ0h5FFFQ== X-Google-Smtp-Source: AOwi7QDbxZA+n2FGiOED0Uu2+0/BYXDXIOuiR9HrCJYtZKp2LmeYKn2FHfQbkz8yaXn0HorqY9LGiA== X-Received: by 10.28.70.133 with SMTP id t127mr4495295wma.42.1506689975240; Fri, 29 Sep 2017 05:59:35 -0700 (PDT) Received: from lmecxl0911.lme.st.com ([80.215.91.35]) by smtp.gmail.com with ESMTPSA id k11sm3269667wrc.90.2017.09.29.05.59.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Sep 2017 05:59:34 -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 Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Benjamin Gaignard Subject: [PATCH 2/3] drm/drm_of: add drm_of_panel_bridge_remove function Date: Fri, 29 Sep 2017 14:59:18 +0200 Message-Id: <1506689959-7858-3-git-send-email-benjamin.gaignard@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> References: <1506689959-7858-1-git-send-email-benjamin.gaignard@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/gpu/drm/drm_of.c | 33 +++++++++++++++++++++++++++++++++ include/drm/drm_of.h | 8 ++++++++ 2 files changed, 41 insertions(+) -- 2.7.4 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,