Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752691AbbKIJjj (ORCPT ); Mon, 9 Nov 2015 04:39:39 -0500 Received: from regular1.263xmail.com ([211.150.99.138]:46703 "EHLO regular1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752251AbbKIJjf (ORCPT ); Mon, 9 Nov 2015 04:39:35 -0500 X-263anti-spam: KSV:0;BIG:0;ABS:1;DNS:0;ATT:0;SPF:S; X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-KSVirus-check: 0 X-ABS-CHECKED: 1 X-SKE-CHECKED: 1 X-ADDR-CHECKED: 0 X-RL-SENDER: mark.yao@rock-chips.com X-FST-TO: linux-kernel@vger.kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: mark.yao@rock-chips.com X-UNIQUE-TAG: <77802f92f9bf5fd2c05680137f69e867> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 Message-ID: <564069CD.2070102@rock-chips.com> Date: Mon, 09 Nov 2015 17:39:25 +0800 From: Mark yao User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0 MIME-Version: 1.0 To: Liviu Dudau , David Airlie , Daniel Vetter , Philipp Zabel , Heiko Stuebner , Russell King CC: dri-devel , linux-rockchip , LAKML , LKML Subject: Re: [RFC PATCH v3 1/4] drm: Introduce generic probe function for component based masters. References: <1445267270-23126-1-git-send-email-Liviu.Dudau@arm.com> <1445267270-23126-2-git-send-email-Liviu.Dudau@arm.com> In-Reply-To: <1445267270-23126-2-git-send-email-Liviu.Dudau@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3302 Lines: 93 On 2015年10月19日 23:07, Liviu Dudau wrote: > A lot of component based DRM drivers use a variant of the same code > as the probe function. They bind the crtc ports in the first iteration > and then scan through the child nodes and bind the encoders attached > to the remote endpoints. Factor the common code into a separate > function called drm_of_component_probe() in order to increase code > reuse. > > Cc: David Airlie > Signed-off-by: Liviu Dudau > --- > drivers/gpu/drm/drm_of.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ > include/drm/drm_of.h | 13 +++++++ > 2 files changed, 101 insertions(+) > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > index be38840..493c05c 100644 > --- a/drivers/gpu/drm/drm_of.c > +++ b/drivers/gpu/drm/drm_of.c > @@ -1,3 +1,4 @@ > +#include > #include > #include > #include > @@ -61,3 +62,90 @@ uint32_t drm_of_find_possible_crtcs(struct drm_device *dev, > return possible_crtcs; > } > EXPORT_SYMBOL(drm_of_find_possible_crtcs); > + > +/** > + * drm_of_component_probe - Generic probe function for a component based master > + * @dev: master device containing the OF node > + * @compare_of: compare function used for matching components > + * @master_ops: component master ops to be used > + * > + * Parse the platform device OF node and bind all the components associated > + * with the master. Interface ports are added before the encoders in order to > + * satisfy their .bind requirements > + * See Documentation/devicetree/bindings/graph.txt for the bindings. > + * > + * Returns zero if successful, or one of the standard error codes if it fails. > + */ > +int drm_of_component_probe(struct device *dev, > + int (*compare_of)(struct device *, void *), > + const struct component_master_ops *m_ops) > +{ > + struct device_node *ep, *port, *remote; > + struct component_match *match = NULL; > + int i; > + > + if (!dev->of_node) > + return -EINVAL; > + > + /* > + * Bind the crtc's ports first, so that drm_of_find_possible_crtcs() > + * called from encoder's .bind callbacks works as expected > + */ > + for (i = 0; ; i++) { > + port = of_parse_phandle(dev->of_node, "ports", i); > + if (!port) > + break; > + > + if (!of_device_is_available(port->parent)) { > + of_node_put(port); > + continue; > + } > + > + component_match_add(dev, &match, compare_of, port); Hi Liviu Rockchip drm can't work with drm_of_component_probe function now, At drm_of_component_probe: component_match_add(dev, &match, compare_of, port); And original rockchip drm use: component_match_add(dev, &match, compare_of, port->parent); That different "port" and "port->parent" cause crtc device node always mis-match. I'm confused that rockchip use same dts node map as imx drm driver, but it works for imx drm, not work on rockchip drm. > + of_node_put(port); > + } > -- Mark Yao -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/