[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH 3/8] lib/fdt: Remove redundant code for fdt_address/size_cells
We use fdt_get_cells to reduce the redundant code. Change-Id: I7a5e91fe20640c3cbc1a784ade0e84e04d573527 Signed-off-by: Wei Chen <wei.chen@xxxxxxx> Signed-off-by: Jianyong Wu <jianyong.wu@xxxxxxx> --- lib/fdt/fdt_addresses.c | 34 ++-------------------------------- lib/fdt/include/libfdt.h | 2 -- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/lib/fdt/fdt_addresses.c b/lib/fdt/fdt_addresses.c index eff4dbc..bccb11c 100644 --- a/lib/fdt/fdt_addresses.c +++ b/lib/fdt/fdt_addresses.c @@ -57,40 +57,10 @@ int fdt_address_cells(const void *fdt, int nodeoffset) { - const fdt32_t *ac; - int val; - int len; - - ac = fdt_getprop(fdt, nodeoffset, "#address-cells", &len); - if (!ac) - return 2; - - if (len != sizeof(*ac)) - return -FDT_ERR_BADNCELLS; - - val = fdt32_to_cpu(*ac); - if ((val <= 0) || (val > FDT_MAX_NCELLS)) - return -FDT_ERR_BADNCELLS; - - return val; + return fdt_get_cells(fdt, "#address-cells", nodeoffset); } int fdt_size_cells(const void *fdt, int nodeoffset) { - const fdt32_t *sc; - int val; - int len; - - sc = fdt_getprop(fdt, nodeoffset, "#size-cells", &len); - if (!sc) - return 2; - - if (len != sizeof(*sc)) - return -FDT_ERR_BADNCELLS; - - val = fdt32_to_cpu(*sc); - if ((val < 0) || (val > FDT_MAX_NCELLS)) - return -FDT_ERR_BADNCELLS; - - return val; + return fdt_get_cells(fdt, "#size-cells", nodeoffset); } diff --git a/lib/fdt/include/libfdt.h b/lib/fdt/include/libfdt.h index bda6456..798a57a 100644 --- a/lib/fdt/include/libfdt.h +++ b/lib/fdt/include/libfdt.h @@ -1111,7 +1111,6 @@ int fdt_get_cells(const void *fdt, const char *prop, int nodeoffset); * * returns: * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #address-cells property * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid * #address-cells property * -FDT_ERR_BADMAGIC, @@ -1132,7 +1131,6 @@ int fdt_address_cells(const void *fdt, int nodeoffset); * * returns: * 0 <= n < FDT_MAX_NCELLS, on success - * 2, if the node has no #address-cells property * -FDT_ERR_BADNCELLS, if the node has a badly formatted or invalid * #size-cells property * -FDT_ERR_BADMAGIC, -- 2.17.1 _______________________________________________ Minios-devel mailing list Minios-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/minios-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |