[U-Boot] [RESEND PATCH v2 1/4] core: ofnode: Fix style violations

There are some style violations in ofnode.c; fix those.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc ---
v1 -> v2: None
--- drivers/core/ofnode.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0030ab962e..ebcf64d867 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -296,7 +296,8 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, int ret;
ret = of_parse_phandle_with_args(ofnode_to_np(node), - list_name, cells_name, index, &args); + list_name, cells_name, index, + &args); if (ret) return ret; ofnode_from_of_phandle_args(&args, out_args); @@ -305,8 +306,9 @@ int ofnode_parse_phandle_with_args(ofnode node, const char *list_name, int ret;
ret = fdtdec_parse_phandle_with_args(gd->fdt_blob, - ofnode_to_offset(node), list_name, cells_name, - cell_count, index, &args); + ofnode_to_offset(node), + list_name, cells_name, + cell_count, index, &args); if (ret) return ret; ofnode_from_fdtdec_phandle_args(&args, out_args); @@ -534,10 +536,10 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, addr->phys_mid = fdt32_to_cpu(cell[1]); addr->phys_lo = fdt32_to_cpu(cell[1]); break; - } else { - cell += (FDT_PCI_ADDR_CELLS + - FDT_PCI_SIZE_CELLS); } + + cell += (FDT_PCI_ADDR_CELLS + + FDT_PCI_SIZE_CELLS); }
if (i == num) { @@ -546,10 +548,10 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type, }
return 0; - } else { - ret = -EINVAL; }
+ ret = -EINVAL; + fail: debug("(not found)\n"); return ret; -- 2.11.0

There are some whitespace-related style violations in read.c; fix those.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc ---
v1 -> v2: None
--- drivers/core/read.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/core/read.c b/drivers/core/read.c index 5d440cee72..08955f81fc 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -66,7 +66,7 @@ void *dev_read_addr_ptr(struct udevice *dev) }
fdt_addr_t dev_read_addr_size(struct udevice *dev, const char *property, - fdt_size_t *sizep) + fdt_size_t *sizep) { return ofnode_get_addr_size(dev_ofnode(dev), property, sizep); } @@ -77,7 +77,7 @@ const char *dev_read_name(struct udevice *dev) }
int dev_read_stringlist_search(struct udevice *dev, const char *property, - const char *string) + const char *string) { return ofnode_stringlist_search(dev_ofnode(dev), property, string); } @@ -94,9 +94,8 @@ int dev_read_string_count(struct udevice *dev, const char *propname) }
int dev_read_phandle_with_args(struct udevice *dev, const char *list_name, - const char *cells_name, int cell_count, - int index, - struct ofnode_phandle_args *out_args) + const char *cells_name, int cell_count, + int index, struct ofnode_phandle_args *out_args) { return ofnode_parse_phandle_with_args(dev_ofnode(dev), list_name, cells_name, cell_count, index, -- 2.11.0

On 15 January 2018 at 03:07, Mario Six mario.six@gdsys.cc wrote:
There are some whitespace-related style violations in read.c; fix those.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc
v1 -> v2: None
drivers/core/read.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
Applied to u-boot-dm, thanks!

Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc ---
v1 -> v2: None
--- drivers/core/ofnode.c | 8 ++++++++ drivers/core/read.c | 5 +++++ include/dm/ofnode.h | 13 +++++++++++++ include/dm/read.h | 17 +++++++++++++++++ 4 files changed, 43 insertions(+)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index ebcf64d867..0b32f9b085 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -644,3 +644,11 @@ int ofnode_read_resource_byname(ofnode node, const char *name,
return ofnode_read_resource(node, index, res); } + +u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr) +{ + if (ofnode_is_np(node)) + return of_translate_address(ofnode_to_np(node), in_addr); + else + return fdt_translate_address(gd->fdt_blob, ofnode_to_offset(node), in_addr); +} diff --git a/drivers/core/read.c b/drivers/core/read.c index 08955f81fc..19207a3906 100644 --- a/drivers/core/read.c +++ b/drivers/core/read.c @@ -188,3 +188,8 @@ int dev_read_resource_byname(struct udevice *dev, const char *name, { return ofnode_read_resource_byname(dev_ofnode(dev), name, res); } + +u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr) +{ + return ofnode_translate_address(dev_ofnode(dev), in_addr); +} diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 8b9932a569..c359a60f95 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -652,4 +652,17 @@ int ofnode_read_resource_byname(ofnode node, const char *name, ofnode_valid(node); \ node = ofnode_next_subnode(node))
+/** + * ofnode_translate_address() - Tranlate a device-tree address + * + * Translate an address from the device-tree into a CPU physical address. This + * function walks up the tree and applies the various bus mappings along the + * way. + * + * @ofnode: Device tree node giving the context in which to translate the + * address + * @in_addr: pointer to the address to translate + * @return the translated address; OF_BAD_ADDR on error + */ +u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr); #endif diff --git a/include/dm/read.h b/include/dm/read.h index 8114037e97..2551e5f0dc 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -410,6 +410,18 @@ int dev_read_resource(struct udevice *dev, uint index, struct resource *res); int dev_read_resource_byname(struct udevice *dev, const char *name, struct resource *res);
+/** + * dev_translate_address() - Tranlate a device-tree address + * + * Translate an address from the device-tree into a CPU physical address. This + * function walks up the tree and applies the various bus mappings along the + * way. + * + * @dev: device giving the context in which to translate the address + * @in_addr: pointer to the address to translate + * @return the translated address; OF_BAD_ADDR on error + */ +u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr); #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
static inline int dev_read_u32_default(struct udevice *dev, @@ -582,6 +594,11 @@ static inline int dev_read_resource_byname(struct udevice *dev, return ofnode_read_resource_byname(dev_ofnode(dev), name, res); }
+static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr) +{ + return ofnode_translate_address(dev_ofnode(dev), in_addr); +} + #endif /* CONFIG_DM_DEV_READ_INLINE */
/** -- 2.11.0

On 15 January 2018 at 03:07, Mario Six mario.six@gdsys.cc wrote:
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc
v1 -> v2: None
drivers/core/ofnode.c | 8 ++++++++ drivers/core/read.c | 5 +++++ include/dm/ofnode.h | 13 +++++++++++++ include/dm/read.h | 17 +++++++++++++++++ 4 files changed, 43 insertions(+)
Applied to u-boot-dm, thanks!

Judging from its name and parameters, device_is_compatible looks like it is compatible with a live device tree, but it actually isn't.
Make it compatible with a live device tree.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc ---
v1 -> v2: None
--- drivers/core/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c index 9a46a7bbe5..144ac2a991 100644 --- a/drivers/core/device.c +++ b/drivers/core/device.c @@ -17,6 +17,7 @@ #include <dm/device.h> #include <dm/device-internal.h> #include <dm/lists.h> +#include <dm/of_access.h> #include <dm/pinctrl.h> #include <dm/platdata.h> #include <dm/read.h> @@ -703,8 +704,12 @@ int device_set_name(struct udevice *dev, const char *name) bool device_is_compatible(struct udevice *dev, const char *compat) { const void *fdt = gd->fdt_blob; + ofnode node = dev_ofnode(dev);
- return !fdt_node_check_compatible(fdt, dev_of_offset(dev), compat); + if (ofnode_is_np(node)) + return of_device_is_compatible(ofnode_to_np(node), compat, NULL, NULL); + else + return !fdt_node_check_compatible(fdt, ofnode_to_offset(node), compat); }
bool of_machine_is_compatible(const char *compat) -- 2.11.0

On 15 January 2018 at 03:07, Mario Six mario.six@gdsys.cc wrote:
Judging from its name and parameters, device_is_compatible looks like it is compatible with a live device tree, but it actually isn't.
Make it compatible with a live device tree.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc
v1 -> v2: None
drivers/core/device.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!

On 15 January 2018 at 03:07, Mario Six mario.six@gdsys.cc wrote:
There are some style violations in ofnode.c; fix those.
Reviewed-by: Simon Glass sjg@chromium.org Signed-off-by: Mario Six mario.six@gdsys.cc
v1 -> v2: None
drivers/core/ofnode.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
participants (2)
-
Mario Six
-
Simon Glass