1. 13 4月, 2010 1 次提交
  2. 02 4月, 2009 2 次提交
    • D
      libfdt: Rework/cleanup fdt_next_tag() · a22d9cfb
      David Gibson 提交于
      Currently, callers of fdt_next_tag() must usually follow the call with
      some sort of call to fdt_offset_ptr() to verify that the blob isn't
      truncated in the middle of the tag data they're going to process.
      This is a bit silly, since fdt_next_tag() generally has to call
      fdt_offset_ptr() on at least some of the data following the tag for
      its own operation.
      
      This patch alters fdt_next_tag() to always use fdt_offset_ptr() to
      verify the data between its starting offset and the offset it returns
      in nextoffset.  This simplifies fdt_get_property() which no longer has
      to verify itself that the property data is all present.
      
      At the same time, I neaten and clarify the error handling for
      fdt_next_tag().  Previously, fdt_next_tag() could return -1 instead of
      a tag value in some circumstances - which almost none of the callers
      checked for.  Also, fdt_next_tag() could return FDT_END either because
      it encountered an FDT_END tag, or because it reached the end of the
      structure block - no way was provided to tell between these cases.
      
      With this patch, fdt_next_tag() always returns FDT_END with a negative
      value in nextoffset for an error.  This means the several places which
      loop looking for FDT_END will still work correctly - they only need to
      check for errors at the end.  The errors which fdt_next_tag() can
      report are:
      	- -FDT_ERR_TRUNCATED if it reached the end of the structure
      	   block instead of finding a tag.
      
      	- -FDT_BADSTRUCTURE if a bad tag was encountered, or if the
                 tag data couldn't be verified with fdt_offset_ptr().
      
      This patch also updates the callers of fdt_next_tag(), where
      appropriate, to make use of the new error reporting.
      
      Finally, the prototype for the long gone _fdt_next_tag() is removed
      from libfdt_internal.h.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      a22d9cfb
    • D
      libfdt: Rework fdt_next_node() · 2c0b843e
      David Gibson 提交于
      Currently fdt_next_node() will find the next node in the blob
      regardless of whether it is above, below or at the same level in the
      tree as the starting node - the depth parameter is updated to indicate
      which is the case.  When a depth parameter is supplied, this patch
      makes it instead terminate immediately when it finds the END_NODE tag
      for a node at depth 0.  In this case it returns the offset immediately
      past the END_NODE tag.
      
      This has a couple of advantages.  First, this slightly simplifies
      fdt_subnode_offset(), which no longer needs to explicitly check that
      fdt_next_node()'s iteration hasn't left the starting node.  Second,
      this allows fdt_next_node() to be used to implement
      _fdt_node_end_offset() considerably simplifying the latter function.
      
      The other users of fdt_next_node() either don't need to iterate out of
      the starting node, or don't pass a depth parameter at all.  Any
      callers that really need to iterate out of the starting node, but keep
      tracking depth can do so by biasing the initial depth value.
      
      This is a semantic change, but I think it's very unlikely to break any
      existing library users.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      2c0b843e
  3. 31 10月, 2008 1 次提交
  4. 03 10月, 2008 1 次提交
  5. 02 10月, 2008 1 次提交
    • D
      libfdt: Fix bugs in fdt_get_path() · bbdbc7cb
      David Gibson 提交于
      The current implementation of fdt_get_path() has a couple of bugs,
      fixed by this patch.
      
      First, contrary to its documentation, on success it returns the length
      of the node's path, rather than 0.  The testcase is correspondingly
      wrong, and the patch fixes this as well.
      
      Second, in some circumstances, it will return -FDT_ERR_BADOFFSET
      instead of -FDT_ERR_NOSPACE when given insufficient buffer space.
      Specifically this happens when there is insufficient space even to
      hold the path's second last component.  This behaviour is corrected,
      and the testcase updated to check it.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      bbdbc7cb
  6. 25 8月, 2008 6 次提交
    • K
      libfdt: Add support for using aliases in fdt_path_offset() · feeca3f5
      Kumar Gala 提交于
      If the path doesn't start with '/' check to see if it matches some alias
      under "/aliases" and substitute the matching alias value in the path
      and retry the lookup.
      Signed-off-by: NKumar Gala <galak@kernel.crashing.org>
      Acked-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Acked-by: NGerald Van Baren <vanbaren@cideas.com>
      feeca3f5
    • D
      libfdt: Implement fdt_get_property_namelen() and fdt_getprop_namelen() · 0219399a
      David Gibson 提交于
      As well as fdt_subnode_offset(), libfdt includes an
      fdt_subnode_offset_namelen() function that takes the subnode name to
      look up not as a NUL-terminated string, but as a string with an
      explicit length.  This can be useful when the caller has the name as
      part of a longer string, such as a full path.
      
      However, we don't have corresponding 'namelen' versions for
      fdt_get_property() and fdt_getprop().  There are less obvious use
      cases for these variants on property names, but there are
      circumstances where they can be useful e.g. looking up property names
      which need to be parsed from a longer string buffer such as user input
      or a configuration file, or looking up an alias in a path with
      IEEE1275 style aliases.
      
      So, since it's very easy to implement such variants, this patch does
      so.  The original NUL-terminated variants are, of course, implemented
      in terms of the namelen versions.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      0219399a
    • D
      libfdt: Forgot one function when cleaning the namespace · f171746f
      David Gibson 提交于
      In commit b6d80a20fc293f3b995c3ce1a6744a5574192125, we renamed all
      libfdt functions to be prefixed with fdt_ or _fdt_ to minimise the
      chance of collisions with things from whatever package libfdt is
      embedded in, pulled into the libfdt build via that environment's
      libfdt_env.h.
      
      Except... I missed one.  This patch applies the same treatment to
      _stringlist_contains().  While we're at it, also make it static since
      it's only used in the same file.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      f171746f
    • D
      libfdt: Increase namespace-pollution paranoia · fc7758ee
      David Gibson 提交于
      libfdt is supposed to easy to embed in projects all and sundry.
      Often, it won't be practical to separate the embedded libfdt's
      namespace from that of the surrounding project.  Which means there can
      be namespace conflicts between even libfdt's internal/static functions
      and functions or macros coming from the surrounding project's headers
      via libfdt_env.h.
      
      This patch, therefore, renames a bunch of libfdt internal functions
      and macros and makes a few other chances to reduce the chances of
      namespace collisions with embedding projects.  Specifically:
      	- Internal functions (even static ones) are now named _fdt_*()
      
      	- The type and (static) global for the error table in
                fdt_strerror() gain an fdt_ prefix
      
      	- The unused macro PALIGN is removed
      
      	- The memeq and streq macros are removed and open-coded in the
                users (they were only used once each)
      
      	- Other macros gain an FDT_ prefix
      
      	- To save some of the bulk from the previous change, an
                FDT_TAGALIGN() macro is introduced, where FDT_TAGALIGN(x) ==
                FDT_ALIGN(x, FDT_TAGSIZE)
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      fc7758ee
    • D
      dtc: Enable and fix -Wcast-qual warnings · c6683026
      David Gibson 提交于
      Enabling -Wcast-qual warnings in dtc shows up a number of places where
      we are incorrectly discarding a const qualification.  There are also
      some places where we are intentionally discarding the 'const', and we
      need an ugly cast through uintptr_t to suppress the warning.  However,
      most of these are pretty well isolated with the *_w() functions.  So
      in the interests of maximum safety with const qualifications, this
      patch enables the warnings and fixes the existing complaints.
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Acked-by: NGerald Van Baren <vanbaren@cideas.com>
      c6683026
    • D
      dtc: Enable and fix -Wpointer-arith warnings · ef4e8ce1
      David Gibson 提交于
      This patch turns on the -Wpointer-arith option in the dtc Makefile,
      and fixes the resulting warnings due to using (void *) in pointer
      arithmetic.  While convenient, pointer arithmetic on void * is not
      portable, so it's better that we avoid it, particularly in libfdt.
      
      Also add necessary definition of uintptr_t needed by David Gibson's
      changeset "dtc: Enable and fix -Wpointer-arith warnings" (the definition
      comes from stdint.h, which u-boot doesn't have). -- gvb
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      Signed-off-by: NGerald Van Baren <vanbaren@cideas.com>
      ef4e8ce1
  7. 10 6月, 2008 1 次提交
    • D
      libfdt: Several cleanups to parameter checking · 2f08bfa9
      David Gibson 提交于
      This patch makes a couple of small cleanups to parameter checking of
      libfdt functions.
      
      	- In several functions which take a node offset, we use an
      idiom involving fdt_next_tag() first to check that we have indeed been
      given a node offset.  This patch adds a helper function
      _fdt_check_node_offset() to encapsulate this usage of fdt_next_tag().
      
      	- In fdt_rw.c in several places we have the expanded version
      of the RW_CHECK_HEADER() macro for no particular reason.  This patch
      replaces those instances with an invocation of the macro; that's what
      it's for.
      
      	- In fdt_sw.c we rename the check_header_sw() function to
      sw_check_header() to match the analgous function in fdt_rw.c, and we
      provide an SW_CHECK_HEADER() wrapper macro as RW_CHECK_HEADER()
      functions in fdt_rw.c
      Signed-off-by: NDavid Gibson <david@gibson.dropbear.id.au>
      2f08bfa9
  8. 19 3月, 2008 3 次提交
  9. 29 2月, 2008 2 次提交
  10. 22 11月, 2007 2 次提交
  11. 21 11月, 2007 1 次提交
  12. 14 8月, 2007 1 次提交
  13. 11 8月, 2007 4 次提交
  14. 18 4月, 2007 1 次提交
  15. 15 4月, 2007 1 次提交
  16. 07 4月, 2007 1 次提交
    • G
      libfdt: Make fdt_check_header() public · 6679f929
      Gerald Van Baren 提交于
      Changed _fdt_check_header() to fdt_check_header() and made it part of
      the interface - it is a useful routine.
      
      Also did some asthetics cleanup to the include files (headers).
      6679f929
  17. 04 4月, 2007 1 次提交
  18. 01 4月, 2007 3 次提交