* Fix up overlay according to a property in /__fixup__. If the fixed property * is a /fragment@X:target, also update /__symbols__ references to fragment. * * @params overlay Overlay to fix up. * @params fixup /__fixup__ property. * @params phandle phandle value to insert where the fixup points to. * @params base_path Path to the base DT node that the fixup points to. * @params overlay_symbo
| 1841 | * @return 0 on success, -1 on error. |
| 1842 | */ |
| 1843 | static int dt_fixup_external(struct device_tree *overlay, |
| 1844 | struct device_tree_property *fixup, |
| 1845 | uint32_t phandle, const char *base_path, |
| 1846 | struct device_tree_node *overlay_symbols) |
| 1847 | { |
| 1848 | struct device_tree_property *prop; |
| 1849 | |
| 1850 | /* External fixup properties are encoded as "<path>:<prop>:<offset>". */ |
| 1851 | char *entry = fixup->prop.data; |
| 1852 | while ((void *)entry < fixup->prop.data + fixup->prop.size) { |
| 1853 | /* okay to destroy fixup property value, won't need it again */ |
| 1854 | char *node_path = entry; |
| 1855 | entry = strchr(node_path, ':'); |
| 1856 | if (!entry) |
| 1857 | return -1; |
| 1858 | *entry++ = '\0'; |
| 1859 | |
| 1860 | char *prop_name = entry; |
| 1861 | entry = strchr(prop_name, ':'); |
| 1862 | if (!entry) |
| 1863 | return -1; |
| 1864 | *entry++ = '\0'; |
| 1865 | |
| 1866 | struct device_tree_node *ovl_node = dt_find_node_by_path( |
| 1867 | overlay, node_path, NULL, NULL, 0); |
| 1868 | if (!ovl_node || !isdigit(*entry)) |
| 1869 | return -1; |
| 1870 | |
| 1871 | struct device_tree_property *ovl_prop = NULL; |
| 1872 | list_for_each(prop, ovl_node->properties, list_node) |
| 1873 | if (!strcmp(prop->prop.name, prop_name)) { |
| 1874 | ovl_prop = prop; |
| 1875 | break; |
| 1876 | } |
| 1877 | |
| 1878 | /* Move entry to first char after number, must be a '\0'. */ |
| 1879 | uint32_t offset = skip_atoi(&entry); |
| 1880 | if (!ovl_prop || offset + 4 > ovl_prop->prop.size || entry[0]) |
| 1881 | return -1; |
| 1882 | entry++; /* jump over '\0' to potential next fixup */ |
| 1883 | |
| 1884 | be32enc(ovl_prop->prop.data + offset, phandle); |
| 1885 | |
| 1886 | /* If this is a /fragment@X:target property, update references |
| 1887 | to this fragment in the overlay __symbols__ now. */ |
| 1888 | if (offset == 0 && !strcmp(prop_name, "target") && |
| 1889 | !strchr(node_path + 1, '/')) /* only toplevel nodes */ |
| 1890 | dt_fix_symbols(overlay_symbols, ovl_node, base_path); |
| 1891 | } |
| 1892 | |
| 1893 | return 0; |
| 1894 | } |
| 1895 | |
| 1896 | /* |
| 1897 | * Apply all /__fixup__ properties in the overlay. This will destroy the |
no test coverage detected