Re: [PATCH v2 03/10] pylibfdt: Add support for the rest of the header functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Wed, Jun 06, 2018 at 03:37:02PM -0600, Simon Glass wrote:
> Export all of these through Python.
> 
> Signed-off-by: Simon Glass <sjg@xxxxxxxxxxxx>
> ---
> 
> Changes in v2:
> - Drop use of check_err() since these functions cannot fail
> - Update existing header functions to also drop check_err()
> 
>  pylibfdt/libfdt.i       | 71 +++++++++++++++++++++++++++++++++++++++--
>  tests/pylibfdt_tests.py |  8 +++++
>  2 files changed, 76 insertions(+), 3 deletions(-)
> 
> diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> index 94c3d00..f33e2ab 100644
> --- a/pylibfdt/libfdt.i
> +++ b/pylibfdt/libfdt.i
> @@ -252,21 +252,86 @@ class Fdt:
>          """
>          return check_err(fdt_next_subnode(self._fdt, nodeoffset), quiet)
>  
> +    def magic(self):
> +        """Return the magic word from the header
> +
> +        Returns:
> +            Magic word
> +        """
> +        # Use a mask to ensure that this does not return a -ve number
> +        return fdt_magic(self._fdt) & 0xffffffff

You still have the mask here for no clear reason.

>      def totalsize(self):
>          """Return the total size of the device tree
>  
>          Returns:
>              Total tree size in bytes
>          """
> -        return check_err(fdt_totalsize(self._fdt))
> +        return fdt_totalsize(self._fdt)
>  
>      def off_dt_struct(self):
> -        """Return the start of the device tree struct area
> +        """Return the start of the device-tree struct area
> +
> +        Returns:
> +            Start offset of struct area
> +        """
> +        return fdt_off_dt_struct(self._fdt)
> +
> +    def off_dt_strings(self):
> +        """Return the start of the device-tree string area
> +
> +        Returns:
> +            Start offset of string area
> +        """
> +        return fdt_off_dt_strings(self._fdt)
> +
> +    def off_mem_rsvmap(self):
> +        """Return the start of the memory reserve map
> +
> +        Returns:
> +            Start offset of memory reserve map
> +        """
> +        return fdt_off_mem_rsvmap(self._fdt)
> +
> +    def version(self):
> +        """Return the version of the device tree
> +
> +        Returns:
> +            Version number of the device tree
> +        """
> +        return fdt_version(self._fdt)
> +
> +    def last_comp_version(self):
> +        """Return the last compatible version of the device tree
> +
> +        Returns:
> +            Last compatible version number of the device tree
> +        """
> +        return fdt_last_comp_version(self._fdt)
> +
> +    def boot_cpuid_phys(self):
> +        """Return the physical boot CPU ID
> +
> +        Returns:
> +            Physical boot CPU ID
> +        """
> +        return fdt_boot_cpuid_phys(self._fdt)
> +
> +    def size_dt_strings(self):
> +        """Return the start of the device-tree string area
> +
> +        Returns:
> +            Start offset of string area
> +        """
> +        return fdt_size_dt_strings(self._fdt)
> +
> +    def size_dt_struct(self):
> +        """Return the start of the device-tree struct area
>  
>          Returns:
>              Start offset of struct area
>          """
> -        return check_err(fdt_off_dt_struct(self._fdt))
> +        return fdt_size_dt_struct(self._fdt)
>  
>      def subnode_offset(self, parentoffset, name, quiet=()):
>          """Get the offset of a named subnode
> diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
> index cd19fa7..17bf30b 100644
> --- a/tests/pylibfdt_tests.py
> +++ b/tests/pylibfdt_tests.py
> @@ -276,8 +276,16 @@ class PyLibfdtTests(unittest.TestCase):
>  
>      def testHeader(self):
>          """Test that we can access the header values"""
> +        self.assertEquals(self.fdt.magic(), 0xd00dfeed)
>          self.assertEquals(self.fdt.totalsize(), len(self.fdt._fdt))
>          self.assertEquals(self.fdt.off_dt_struct(), 88)
> +        self.assertEquals(self.fdt.off_dt_strings(), 652)
> +        self.assertEquals(self.fdt.off_mem_rsvmap(), 40)
> +        self.assertEquals(self.fdt.version(), 17)
> +        self.assertEquals(self.fdt.last_comp_version(), 16)
> +        self.assertEquals(self.fdt.boot_cpuid_phys(), 0)
> +        self.assertEquals(self.fdt.size_dt_strings(), 105)
> +        self.assertEquals(self.fdt.size_dt_struct(), 564)
>  
>      def testPack(self):
>          """Test that we can pack the tree after deleting something"""

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux