Commit 106cce9604306743c86addd4d27426cce498c9d1

Authored by Simon Glass
1 parent cc5e196e03

fdt: Tighten up error handling in fdtdec_get_pci_addr()

This function returns -ENOENT when the property is missing (which the caller
might forgive) and also when the property is present but incorrectly
formatted (which many callers would like to report).

Update the error return value to allow these different situations to be
distinguished.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Showing 2 changed files with 6 additions and 2 deletions Side-by-side Diff

... ... @@ -327,7 +327,9 @@
327 327 * @param type pci address type (FDT_PCI_SPACE_xxx)
328 328 * @param prop_name name of property to find
329 329 * @param addr returns pci address in the form of fdt_pci_addr
330   - * @return 0 if ok, negative on error
  330 + * @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the
  331 + * format of the property was invalid, -ENXIO if the requested
  332 + * address type was not found
331 333 */
332 334 int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
333 335 const char *prop_name, struct fdt_pci_addr *addr);
... ... @@ -160,8 +160,10 @@
160 160 }
161 161 }
162 162  
163   - if (i == num)
  163 + if (i == num) {
  164 + ret = -ENXIO;
164 165 goto fail;
  166 + }
165 167  
166 168 return 0;
167 169 } else {