Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 86418f90 authored by Rob Herring's avatar Rob Herring Committed by Sean Paul
Browse files

drm: convert drivers to use of_graph_get_remote_node



Convert drivers to use the new of_graph_get_remote_node() helper
instead of parsing the endpoint node and then getting the remote device
node. Now drivers can just specify the device node and which
port/endpoint and get back the connected remote device node. The details
of the graph binding are nicely abstracted into the core OF graph code.

This changes some error messages to debug messages (in the graph core).
Graph connections are often "no connects" depending on the particular
board, so we want to avoid spurious messages. Plus the kernel is not a
DT validator.

Signed-off-by: default avatarRob Herring <robh@kernel.org>
Acked-by: default avatarNeil Armstrong <narmstrong@baylibre.com>
Tested-by: default avatarLiviu Dudau <liviu.dudau@arm.com>
Tested-by: default avatarEric Anholt <eric@anholt.net>
Tested-by: default avatarJyri Sarha <jsarha@ti.com>
Tested by: Archit Taneja <architt@codeaurora.org>
Signed-off-by: default avatarSean Paul <seanpaul@chromium.org>
parent 1f2db303
Loading
Loading
Loading
Loading
+3 −19
Original line number Diff line number Diff line
@@ -392,29 +392,13 @@ static int compare_dev(struct device *dev, void *data)

static int hdlcd_probe(struct platform_device *pdev)
{
	struct device_node *port, *ep;
	struct device_node *port;
	struct component_match *match = NULL;

	if (!pdev->dev.of_node)
		return -ENODEV;

	/* there is only one output port inside each device, find it */
	ep = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
	if (!ep)
		return -ENODEV;

	if (!of_device_is_available(ep)) {
		of_node_put(ep);
	port = of_graph_get_remote_node(pdev->dev.of_node, 0, 0);
	if (!port)
		return -ENODEV;
	}

	/* add the remote encoder port as component */
	port = of_graph_get_remote_port_parent(ep);
	of_node_put(ep);
	if (!port || !of_device_is_available(port)) {
		of_node_put(port);
		return -EAGAIN;
	}

	drm_of_component_match_add(&pdev->dev, &match, compare_dev, port);
	of_node_put(port);
+4 −24
Original line number Diff line number Diff line
@@ -283,7 +283,6 @@ static int malidp_bind(struct device *dev)
{
	struct resource *res;
	struct drm_device *drm;
	struct device_node *ep;
	struct malidp_drm *malidp;
	struct malidp_hw_device *hwdev;
	struct platform_device *pdev = to_platform_device(dev);
@@ -398,12 +397,7 @@ static int malidp_bind(struct device *dev)
		goto init_fail;

	/* Set the CRTC's port so that the encoder component can find it */
	ep = of_graph_get_next_endpoint(dev->of_node, NULL);
	if (!ep) {
		ret = -EINVAL;
		goto port_fail;
	}
	malidp->crtc.port = of_get_next_parent(ep);
	malidp->crtc.port = of_graph_get_port_by_id(dev->of_node, 0);

	ret = component_bind_all(dev, drm);
	if (ret) {
@@ -458,7 +452,6 @@ static int malidp_bind(struct device *dev)
bind_fail:
	of_node_put(malidp->crtc.port);
	malidp->crtc.port = NULL;
port_fail:
	malidp_fini(drm);
init_fail:
	drm->dev_private = NULL;
@@ -516,29 +509,16 @@ static int malidp_compare_dev(struct device *dev, void *data)

static int malidp_platform_probe(struct platform_device *pdev)
{
	struct device_node *port, *ep;
	struct device_node *port;
	struct component_match *match = NULL;

	if (!pdev->dev.of_node)
		return -ENODEV;

	/* there is only one output port inside each device, find it */
	ep = of_graph_get_next_endpoint(pdev->dev.of_node, NULL);
	if (!ep)
		return -ENODEV;

	if (!of_device_is_available(ep)) {
		of_node_put(ep);
	port = of_graph_get_remote_node(pdev->dev.of_node, 0, 0);
	if (!port)
		return -ENODEV;
	}

	/* add the remote encoder port as component */
	port = of_graph_get_remote_port_parent(ep);
	of_node_put(ep);
	if (!port || !of_device_is_available(port)) {
		of_node_put(port);
		return -EAGAIN;
	}

	drm_of_component_match_add(&pdev->dev, &match, malidp_compare_dev,
				   port);
+2 −10
Original line number Diff line number Diff line
@@ -232,7 +232,6 @@ void adv7533_detach_dsi(struct adv7511 *adv)
int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
{
	u32 num_lanes;
	struct device_node *endpoint;

	of_property_read_u32(np, "adi,dsi-lanes", &num_lanes);

@@ -241,17 +240,10 @@ int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)

	adv->num_dsi_lanes = num_lanes;

	endpoint = of_graph_get_next_endpoint(np, NULL);
	if (!endpoint)
	adv->host_node = of_graph_get_remote_node(np, 0, 0);
	if (!adv->host_node)
		return -ENODEV;

	adv->host_node = of_graph_get_remote_port_parent(endpoint);
	if (!adv->host_node) {
		of_node_put(endpoint);
		return -ENODEV;
	}

	of_node_put(endpoint);
	of_node_put(adv->host_node);

	adv->use_timing_gen = !of_property_read_bool(np,
+3 −12
Original line number Diff line number Diff line
@@ -154,21 +154,12 @@ static const struct drm_bridge_funcs dumb_vga_bridge_funcs = {

static struct i2c_adapter *dumb_vga_retrieve_ddc(struct device *dev)
{
	struct device_node *end_node, *phandle, *remote;
	struct device_node *phandle, *remote;
	struct i2c_adapter *ddc;

	end_node = of_graph_get_endpoint_by_regs(dev->of_node, 1, -1);
	if (!end_node) {
		dev_err(dev, "Missing connector endpoint\n");
		return ERR_PTR(-ENODEV);
	}

	remote = of_graph_get_remote_port_parent(end_node);
	of_node_put(end_node);
	if (!remote) {
		dev_err(dev, "Enable to parse remote node\n");
	remote = of_graph_get_remote_node(dev->of_node, 1, -1);
	if (!remote)
		return ERR_PTR(-EINVAL);
	}

	phandle = of_parse_phandle(remote, "ddc-i2c-bus", 0);
	of_node_put(remote);
+5 −10
Original line number Diff line number Diff line
@@ -165,18 +165,13 @@ static irqreturn_t tfp410_hpd_irq_thread(int irq, void *arg)

static int tfp410_get_connector_properties(struct tfp410 *dvi)
{
	struct device_node *ep = NULL, *connector_node = NULL;
	struct device_node *ddc_phandle = NULL;
	struct device_node *connector_node, *ddc_phandle;
	int ret = 0;

	/* port@1 is the connector node */
	ep = of_graph_get_endpoint_by_regs(dvi->dev->of_node, 1, -1);
	if (!ep)
		goto fail;

	connector_node = of_graph_get_remote_port_parent(ep);
	connector_node = of_graph_get_remote_node(dvi->dev->of_node, 1, -1);
	if (!connector_node)
		goto fail;
		return -ENODEV;

	dvi->hpd = fwnode_get_named_gpiod(&connector_node->fwnode,
					"hpd-gpios", 0, GPIOD_IN, "hpd");
@@ -199,10 +194,10 @@ static int tfp410_get_connector_properties(struct tfp410 *dvi)
	else
		ret = -EPROBE_DEFER;

	of_node_put(ddc_phandle);

fail:
	of_node_put(ep);
	of_node_put(connector_node);
	of_node_put(ddc_phandle);
	return ret;
}

Loading