summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2019-03-14 21:16:22 +0100
committerMaxime Ripard <maxime.ripard@bootlin.com>2019-03-15 09:36:45 +0100
commiteb40baefb64063b585740ecf0b1be6c859166ad4 (patch)
treea42e4df68b47339201a5eb412fb9250e20f1adef /drivers/gpu/drm
parent40609d4820b21ff0bb0a58e196601a6747fd55b7 (diff)
downloadlinux-stable-eb40baefb64063b585740ecf0b1be6c859166ad4.tar.gz
linux-stable-eb40baefb64063b585740ecf0b1be6c859166ad4.tar.bz2
linux-stable-eb40baefb64063b585740ecf0b1be6c859166ad4.zip
drm/sun4i: backend: Simplify the get_id logic
Using the new helpers introduced since we wrote that code, we can simplify the code to retrieve the backend ID significantly. The new code will also allow us to deal nicely with endpoints that don't have a reg property, as expected in the case where there's a single endpoint for a given port. Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Link: https://patchwork.freedesktop.org/patch/msgid/1a9bf911b0a40475da8025859032514131d5397b.1552594551.git-series.maxime.ripard@bootlin.com
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_backend.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index 4c0d51f73237..ee59da4a0172 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -720,33 +720,22 @@ static int sun4i_backend_free_sat(struct device *dev) {
*/
static int sun4i_backend_of_get_id(struct device_node *node)
{
- struct device_node *port, *ep;
- int ret = -EINVAL;
+ struct device_node *ep, *remote;
+ struct of_endpoint of_ep;
- /* input is port 0 */
- port = of_graph_get_port_by_id(node, 0);
- if (!port)
+ /* Input port is 0, and we want the first endpoint. */
+ ep = of_graph_get_endpoint_by_regs(node, 0, -1);
+ if (!ep)
return -EINVAL;
- /* try finding an upstream endpoint */
- for_each_available_child_of_node(port, ep) {
- struct device_node *remote;
- u32 reg;
-
- remote = of_graph_get_remote_endpoint(ep);
- if (!remote)
- continue;
-
- ret = of_property_read_u32(remote, "reg", &reg);
- if (ret)
- continue;
-
- ret = reg;
- }
-
- of_node_put(port);
+ remote = of_graph_get_remote_endpoint(ep);
+ of_node_put(ep);
+ if (!remote)
+ return -EINVAL;
- return ret;
+ of_graph_parse_endpoint(remote, &of_ep);
+ of_node_put(remote);
+ return of_ep.id;
}
/* TODO: This needs to take multiple pipelines into account */