mirror of
https://github.com/mii443/qemu.git
synced 2025-12-03 11:08:25 +00:00
device_tree: qemu_fdt_getprop_cell converted to use the error API
This patch aligns the prototype with qemu_fdt_getprop. The caller can choose whether the function self-asserts on error (passing &error_fatal as Error ** argument, corresponding to the legacy behavior), or behaves differently such as simply output a message. In this later case the caller can use the new lenp parameter to interpret the error if any. Signed-off-by: Eric Auger <eric.auger@linaro.org> Reviewed-by: Peter Crosthwaite <crosthwaite.peter@gmail.com> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
committed by
Alex Williamson
parent
78e24f235e
commit
58e71097ce
@@ -350,15 +350,22 @@ const void *qemu_fdt_getprop(void *fdt, const char *node_path,
|
||||
}
|
||||
|
||||
uint32_t qemu_fdt_getprop_cell(void *fdt, const char *node_path,
|
||||
const char *property)
|
||||
const char *property, int *lenp, Error **errp)
|
||||
{
|
||||
int len;
|
||||
const uint32_t *p = qemu_fdt_getprop(fdt, node_path, property, &len,
|
||||
&error_fatal);
|
||||
if (len != 4) {
|
||||
error_report("%s: %s/%s not 4 bytes long (not a cell?)",
|
||||
__func__, node_path, property);
|
||||
exit(1);
|
||||
const uint32_t *p;
|
||||
|
||||
if (!lenp) {
|
||||
lenp = &len;
|
||||
}
|
||||
p = qemu_fdt_getprop(fdt, node_path, property, lenp, errp);
|
||||
if (!p) {
|
||||
return 0;
|
||||
} else if (*lenp != 4) {
|
||||
error_setg(errp, "%s: %s/%s not 4 bytes long (not a cell?)",
|
||||
__func__, node_path, property);
|
||||
*lenp = -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
return be32_to_cpu(*p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user