[PATCH 5/8] of: Add of_graph_get_port_by_id function

Philipp Zabel p.zabel at pengutronix.de
Fri Aug 22 12:09:58 UTC 2014


Hi Laurent,

Thank you for the comments.

Am Mittwoch, den 20.08.2014, 22:13 +0200 schrieb Laurent Pinchart:
[...]
> > +	struct device_node *port = NULL;
> > +	int port_id;
> > +
> > +	while (true) {
> > +		port = of_get_next_child(node, port);
> > +		if (!port)
> > +			return NULL;
> > +		if (of_node_cmp(port->name, "port") != 0)
> > +			continue;
> > +		if (of_property_read_u32(port, "reg", &port_id)) {
> > +			if (!id)
> > +				return port;
> > +		} else {
> > +			if (id == port_id)
> > +				return port;
> > +		}
> 
> Nitpicking here, I would have written this
> 
> 		int port_id = 0;
> 
> 		port = of_get_next_child(node, port);
> 		if (!port)
> 			return NULL;
> 		if (of_node_cmp(port->name, "port") != 0)
> 			continue;
> 		of_property_read_u32(port, "reg", &port_id);
> 		if (id == port_id)
> 			return port;
> 
> That saves 8 bytes with my ARM cross-compiler (at the expense of using two 
> extra local registers).
> 
> Please free to ignore this is you find your code layout easier to read.

No, that does look sensible to me. I'll follow your suggestions and
resend the series.

regards
Philipp



More information about the devel mailing list