Message ID | 3da40505e18a981c5ad626127e14ff594a826ef5.1552594551.git-series.maxime.ripard@bootlin.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ARM: dts: sunxi: Cleanup DTC warnings | expand |
On Fri, Mar 15, 2019 at 4:16 AM Maxime Ripard <maxime.ripard@bootlin.com> wrote: > > Using the new helpers introduced since we wrote that code, we can simplify > the code to retrieve the mixer 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> > --- > drivers/gpu/drm/sun4i/sun8i_mixer.c | 39 ++++++++---------------------- > 1 file changed, 11 insertions(+), 28 deletions(-) > > diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c > index 30a2eff55687..bf44a601a653 100644 > --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c > +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c > @@ -325,38 +325,21 @@ static struct regmap_config sun8i_mixer_regmap_config = { > > static int sun8i_mixer_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; > > - /* output is port 1 */ > - port = of_graph_get_port_by_id(node, 1); > - if (!port) > + /* Output port is 1, and we want the first endpoint. */ > + ep = of_graph_get_endpoint_by_regs(node, 1, -1); > + if (!ep) > return -EINVAL; > > - /* try to find downstream 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", ®); > - if (!ret) { > - of_node_put(remote); > - of_node_put(ep); > - of_node_put(port); > - > - return reg; > - } > - > - of_node_put(remote); > - } > - > - of_node_put(port); > + remote = of_graph_get_remote_endpoint(ep); Same comment as the previous patch. Reviewed-by: Chen-Yu Tsai <wens@csie.org> once fixed. > + if (!remote) > + return -EINVAL; > > - return ret; > + of_graph_parse_endpoint(remote, &of_ep); > + of_node_put(remote); > + return of_ep.id; > } > > static int sun8i_mixer_bind(struct device *dev, struct device *master, > -- > git-series 0.9.1
diff --git a/drivers/gpu/drm/sun4i/sun8i_mixer.c b/drivers/gpu/drm/sun4i/sun8i_mixer.c index 30a2eff55687..bf44a601a653 100644 --- a/drivers/gpu/drm/sun4i/sun8i_mixer.c +++ b/drivers/gpu/drm/sun4i/sun8i_mixer.c @@ -325,38 +325,21 @@ static struct regmap_config sun8i_mixer_regmap_config = { static int sun8i_mixer_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; - /* output is port 1 */ - port = of_graph_get_port_by_id(node, 1); - if (!port) + /* Output port is 1, and we want the first endpoint. */ + ep = of_graph_get_endpoint_by_regs(node, 1, -1); + if (!ep) return -EINVAL; - /* try to find downstream 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", ®); - if (!ret) { - of_node_put(remote); - of_node_put(ep); - of_node_put(port); - - return reg; - } - - of_node_put(remote); - } - - of_node_put(port); + remote = of_graph_get_remote_endpoint(ep); + if (!remote) + return -EINVAL; - return ret; + of_graph_parse_endpoint(remote, &of_ep); + of_node_put(remote); + return of_ep.id; } static int sun8i_mixer_bind(struct device *dev, struct device *master,
Using the new helpers introduced since we wrote that code, we can simplify the code to retrieve the mixer 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> --- drivers/gpu/drm/sun4i/sun8i_mixer.c | 39 ++++++++---------------------- 1 file changed, 11 insertions(+), 28 deletions(-)