Commit bfa3e55b440e120739d2b4dd4cb57e6b40752113

Authored by Chin Liang See
Committed by Marek Vasut
1 parent c624d07f3f

lib, fdt: Adding fdtdec_get_uint function

Adding fdtdec_get_uint function which is the
unsigned version for fdtdec_get_int

Signed-off-by: Chin Liang See <clsee@altera.com>
Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
Cc: Dinh Nguyen <dinh.linux@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Stefan Roese <sr@denx.de>
Cc: Vikas Manocha <vikas.manocha@st.com>
Cc: Jagannadh Teki <jteki@openedev.com>
Cc: Pavel Machek <pavel@denx.de>
Cc: Heiko Schocher <hs@denx.de>

Showing 2 changed files with 31 additions and 0 deletions Side-by-side Diff

... ... @@ -490,6 +490,19 @@
490 490 s32 default_val);
491 491  
492 492 /**
  493 + * Unsigned version of fdtdec_get_int. The property must have at least
  494 + * 4 bytes of data. The value of the first cell is returned.
  495 + *
  496 + * @param blob FDT blob
  497 + * @param node node to examine
  498 + * @param prop_name name of property to find
  499 + * @param default_val default value to return if the property is not found
  500 + * @return unsigned integer value, if found, or default_val if not
  501 + */
  502 +unsigned int fdtdec_get_uint(const void *blob, int node, const char *prop_name,
  503 + unsigned int default_val);
  504 +
  505 +/**
493 506 * Get a variable-sized number from a property
494 507 *
495 508 * This reads a number from one or more cells.
... ... @@ -36,4 +36,22 @@
36 36 debug("(not found)\n");
37 37 return default_val;
38 38 }
  39 +
  40 +unsigned int fdtdec_get_uint(const void *blob, int node, const char *prop_name,
  41 + unsigned int default_val)
  42 +{
  43 + const int *cell;
  44 + int len;
  45 +
  46 + debug("%s: %s: ", __func__, prop_name);
  47 + cell = fdt_getprop(blob, node, prop_name, &len);
  48 + if (cell && len >= sizeof(unsigned int)) {
  49 + unsigned int val = fdt32_to_cpu(cell[0]);
  50 +
  51 + debug("%#x (%d)\n", val, val);
  52 + return val;
  53 + }
  54 + debug("(not found)\n");
  55 + return default_val;
  56 +}