diff options
author | Nicholas Piggin <npiggin@gmail.com> | 2023-09-06 20:10:14 +1000 |
---|---|---|
committer | Reza Arbab <arbab@linux.ibm.com> | 2023-10-11 15:07:23 -0500 |
commit | 15cc5cb569e9afd8633582b0d7ad38ecadc6cea6 (patch) | |
tree | 4335717ad366eb1ed0741feb2dc9b41e95ed7fd4 | |
parent | d368523114179996a777fe323bb0178c8d1e2388 (diff) | |
download | skiboot-15cc5cb569e9afd8633582b0d7ad38ecadc6cea6.zip skiboot-15cc5cb569e9afd8633582b0d7ad38ecadc6cea6.tar.gz skiboot-15cc5cb569e9afd8633582b0d7ad38ecadc6cea6.tar.bz2 |
hdata: split idata accessor function
Add HDIF_idata that returns the idata pointer structure, not a
pointer to the data itself.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
-rw-r--r-- | hdata/hdif.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/hdata/hdif.c b/hdata/hdif.c index aba7f36..98bd98d 100644 --- a/hdata/hdif.c +++ b/hdata/hdif.c @@ -4,10 +4,9 @@ #include "hdif.h" #include <stack.h> -const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, - unsigned int *size) +static const struct HDIF_idata_ptr * +HDIF_idata(const struct HDIF_common_hdr *hdif, unsigned int idx) { - const struct HDIF_common_hdr *hdr = hdif; const struct HDIF_idata_ptr *iptr; if (!HDIF_check(hdif, NULL)) { @@ -16,14 +15,25 @@ const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, return NULL; } - if (di >= be16_to_cpu(hdr->idptr_count)) { + if (idx >= be16_to_cpu(hdif->idptr_count)) { prlog(PR_DEBUG, "HDIF: idata %d out of range for %.6s!\n", - di, hdr->id); + idx, hdif->id); return NULL; } - iptr = (void *)hdif + be32_to_cpu(hdr->idptr_off) - + di * sizeof(struct HDIF_idata_ptr); + iptr = (void *)hdif + be32_to_cpu(hdif->idptr_off); + + return &iptr[idx]; +} + +const void *HDIF_get_idata(const struct HDIF_common_hdr *hdif, unsigned int di, + unsigned int *size) +{ + const struct HDIF_idata_ptr *iptr; + + iptr = HDIF_idata(hdif, di); + if (!iptr) + return NULL; if (size) *size = be32_to_cpu(iptr->size); |