Browse Source

add fdt_get_symbol() and fdt_get_symbol_namelen() functions

The fdt_get_symbol_namelen() function will be used in a subsequent
patch.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
Rasmus Villemoes 2 years ago committed by David Gibson
parent
commit
a6f997bc77
  1. 11
      libfdt/fdt_ro.c
  2. 36
      libfdt/libfdt.h

11
libfdt/fdt_ro.c

@ -545,6 +545,17 @@ const char *fdt_get_alias(const void *fdt, const char *name)
return fdt_get_alias_namelen(fdt, name, strlen(name)); return fdt_get_alias_namelen(fdt, name, strlen(name));
} }


const char *fdt_get_symbol_namelen(const void *fdt,
const char *name, int namelen)
{
return fdt_path_getprop_namelen(fdt, "/__symbols__", name, namelen, NULL);
}

const char *fdt_get_symbol(const void *fdt, const char *name)
{
return fdt_get_symbol_namelen(fdt, name, strlen(name));
}

int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen) int fdt_get_path(const void *fdt, int nodeoffset, char *buf, int buflen)
{ {
int pdepth = 0, p = 0; int pdepth = 0, p = 0;

36
libfdt/libfdt.h

@ -869,6 +869,42 @@ const char *fdt_get_alias_namelen(const void *fdt,
*/ */
const char *fdt_get_alias(const void *fdt, const char *name); const char *fdt_get_alias(const void *fdt, const char *name);


/**
* fdt_get_symbol_namelen - get symbol based on substring
* @fdt: pointer to the device tree blob
* @name: name of the symbol to look up
* @namelen: number of characters of name to consider
*
* Identical to fdt_get_symbol(), but only examine the first @namelen
* characters of @name for matching the symbol name.
*
* Return: a pointer to the expansion of the symbol named @name, if it exists,
* NULL otherwise
*/
#ifndef SWIG /* Not available in Python */
const char *fdt_get_symbol_namelen(const void *fdt,
const char *name, int namelen);
#endif

/**
* fdt_get_symbol - retrieve the path referenced by a given symbol
* @fdt: pointer to the device tree blob
* @name: name of the symbol to look up
*
* fdt_get_symbol() retrieves the value of a given symbol. That is,
* the value of the property named @name in the node
* /__symbols__. Such a node exists only for a device tree blob that
* has been compiled with the -@ dtc option. Each property corresponds
* to a label appearing in the device tree source, with the name of
* the property being the label and the value being the full path of
* the node it is attached to.
*
* returns:
* a pointer to the expansion of the symbol named 'name', if it exists
* NULL, if the given symbol or the /__symbols__ node does not exist
*/
const char *fdt_get_symbol(const void *fdt, const char *name);

/** /**
* fdt_get_path - determine the full path of a node * fdt_get_path - determine the full path of a node
* @fdt: pointer to the device tree blob * @fdt: pointer to the device tree blob

Loading…
Cancel
Save