Message ID | 1425583534-2238-8-git-send-email-sjg@chromium.org |
---|---|
State | Accepted |
Delegated to: | Simon Glass |
Headers | show |
On Thu, Mar 05, 2015 at 12:25:19PM -0700, Simon Glass wrote: > 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>
On Fri, Mar 6, 2015 at 3:25 AM, Simon Glass <sjg@chromium.org> wrote: > 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> > --- > > Changes in v2: > - Add -ve sign before ENXIO > > include/fdtdec.h | 4 +++- > lib/fdtdec.c | 4 +++- > 2 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/include/fdtdec.h b/include/fdtdec.h > index 21bd6bb..6944048 100644 > --- a/include/fdtdec.h > +++ b/include/fdtdec.h > @@ -327,7 +327,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, > * @param type pci address type (FDT_PCI_SPACE_xxx) > * @param prop_name name of property to find > * @param addr returns pci address in the form of fdt_pci_addr > - * @return 0 if ok, negative on error > + * @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the > + * format of the property was invalid, -ENXIO if the requested > + * address type was not found > */ > int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, > const char *prop_name, struct fdt_pci_addr *addr); > diff --git a/lib/fdtdec.c b/lib/fdtdec.c > index e47fa96..9212f03 100644 > --- a/lib/fdtdec.c > +++ b/lib/fdtdec.c > @@ -160,8 +160,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, > } > } > > - if (i == num) > + if (i == num) { > + ret = -ENXIO; > goto fail; > + } > > return 0; > } else { > -- Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
On 9 March 2015 at 03:09, Bin Meng <bmeng.cn@gmail.com> wrote: > On Fri, Mar 6, 2015 at 3:25 AM, Simon Glass <sjg@chromium.org> wrote: >> 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> >> --- >> >> Changes in v2: >> - Add -ve sign before ENXIO >> >> include/fdtdec.h | 4 +++- >> lib/fdtdec.c | 4 +++- >> 2 files changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/include/fdtdec.h b/include/fdtdec.h >> index 21bd6bb..6944048 100644 >> --- a/include/fdtdec.h >> +++ b/include/fdtdec.h >> @@ -327,7 +327,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, >> * @param type pci address type (FDT_PCI_SPACE_xxx) >> * @param prop_name name of property to find >> * @param addr returns pci address in the form of fdt_pci_addr >> - * @return 0 if ok, negative on error >> + * @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the >> + * format of the property was invalid, -ENXIO if the requested >> + * address type was not found >> */ >> int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, >> const char *prop_name, struct fdt_pci_addr *addr); >> diff --git a/lib/fdtdec.c b/lib/fdtdec.c >> index e47fa96..9212f03 100644 >> --- a/lib/fdtdec.c >> +++ b/lib/fdtdec.c >> @@ -160,8 +160,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, >> } >> } >> >> - if (i == num) >> + if (i == num) { >> + ret = -ENXIO; >> goto fail; >> + } >> >> return 0; >> } else { >> -- > > Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Applied to u-boot-dm/next.
diff --git a/include/fdtdec.h b/include/fdtdec.h index 21bd6bb..6944048 100644 --- a/include/fdtdec.h +++ b/include/fdtdec.h @@ -327,7 +327,9 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node, * @param type pci address type (FDT_PCI_SPACE_xxx) * @param prop_name name of property to find * @param addr returns pci address in the form of fdt_pci_addr - * @return 0 if ok, negative on error + * @return 0 if ok, -ENOENT if the property did not exist, -EINVAL if the + * format of the property was invalid, -ENXIO if the requested + * address type was not found */ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, const char *prop_name, struct fdt_pci_addr *addr); diff --git a/lib/fdtdec.c b/lib/fdtdec.c index e47fa96..9212f03 100644 --- a/lib/fdtdec.c +++ b/lib/fdtdec.c @@ -160,8 +160,10 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type, } } - if (i == num) + if (i == num) { + ret = -ENXIO; goto fail; + } return 0; } else {
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> --- Changes in v2: - Add -ve sign before ENXIO include/fdtdec.h | 4 +++- lib/fdtdec.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-)