fdt: Fix handling of paths with options in them
After syncing the sunxi dts files with the upstream kernel dm/fdt sunxi builds would no longer boot. The problem is that stdout-path is now set like this in the upstream dts files: stdout-path = "serial0:115200n8". The use of options in of-paths, either after an alias name, or after a full path, e.g. stdout-path = "/soc@01c00000/serial@01c28000:115200", is standard of usage, but something which the u-boot dts code so far did not handle. This commit fixes this, adding support for both path formats. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
		
							parent
							
								
									d8c1d5d5fb
								
							
						
					
					
						commit
						77d7fff8ce
					
				|  | @ -113,6 +113,25 @@ int fdt_subnode_offset(const void *fdt, int parentoffset, | ||||||
| 	return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); | 	return fdt_subnode_offset_namelen(fdt, parentoffset, name, strlen(name)); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | /*
 | ||||||
|  |  * Find the next of path seperator, note we need to search for both '/' and ':' | ||||||
|  |  * and then take the first one so that we do the rigth thing for e.g. | ||||||
|  |  * "foo/bar:option" and "bar:option/otheroption", both of which happen, so | ||||||
|  |  * first searching for either ':' or '/' does not work. | ||||||
|  |  */ | ||||||
|  | static const char *fdt_path_next_seperator(const char *path) | ||||||
|  | { | ||||||
|  | 	const char *sep1 = strchr(path, '/'); | ||||||
|  | 	const char *sep2 = strchr(path, ':'); | ||||||
|  | 
 | ||||||
|  | 	if (sep1 && sep2) | ||||||
|  | 		return (sep1 < sep2) ? sep1 : sep2; | ||||||
|  | 	else if (sep1) | ||||||
|  | 		return sep1; | ||||||
|  | 	else | ||||||
|  | 		return sep2; | ||||||
|  | } | ||||||
|  | 
 | ||||||
| int fdt_path_offset(const void *fdt, const char *path) | int fdt_path_offset(const void *fdt, const char *path) | ||||||
| { | { | ||||||
| 	const char *end = path + strlen(path); | 	const char *end = path + strlen(path); | ||||||
|  | @ -123,7 +142,7 @@ int fdt_path_offset(const void *fdt, const char *path) | ||||||
| 
 | 
 | ||||||
| 	/* see if we have an alias */ | 	/* see if we have an alias */ | ||||||
| 	if (*path != '/') { | 	if (*path != '/') { | ||||||
| 		const char *q = strchr(path, '/'); | 		const char *q = fdt_path_next_seperator(path); | ||||||
| 
 | 
 | ||||||
| 		if (!q) | 		if (!q) | ||||||
| 			q = end; | 			q = end; | ||||||
|  | @ -141,9 +160,9 @@ int fdt_path_offset(const void *fdt, const char *path) | ||||||
| 
 | 
 | ||||||
| 		while (*p == '/') | 		while (*p == '/') | ||||||
| 			p++; | 			p++; | ||||||
| 		if (! *p) | 		if (*p == '\0' || *p == ':') | ||||||
| 			return offset; | 			return offset; | ||||||
| 		q = strchr(p, '/'); | 		q = fdt_path_next_seperator(p); | ||||||
| 		if (! q) | 		if (! q) | ||||||
| 			q = end; | 			q = end; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue