Re: [PATCH] pylibfdt: Add support for fdt_get_alias()

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



On Tue, Jul 02, 2019 at 04:21:28PM -0600, Simon Glass wrote:
> Hi Appana,
> 
> On Mon, 1 Jul 2019 at 04:55, Appana Durga Kedareswara rao
> <appana.durga.rao@xxxxxxxxxx> wrote:
> >
> > Add this into the class to simplify use of this function.
> >
> > Signed-off-by: Appana Durga Kedareswara rao <appana.durga.rao@xxxxxxxxxx>
> > ---
> >  pylibfdt/libfdt.i       | 12 ++++++++++++
> >  tests/pylibfdt_tests.py |  7 +++++++
> >  2 files changed, 19 insertions(+)
> >
> > diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
> > index 643f95d..afed659 100644
> > --- a/pylibfdt/libfdt.i
> > +++ b/pylibfdt/libfdt.i
> > @@ -431,6 +431,18 @@ class FdtRo(object):
> >          """
> >          return fdt_get_phandle(self._fdt, nodeoffset)
> >
> > +    def get_alias(self, name):
> > +        """Get the full path referenced by a given alias
> > +
> > +        Args:
> > +            name: name of the alias to lookup
> > +
> > +        Returns:
> > +            A pointer to the expansion of the alias named 'name', if it exists
> > +            NULL, if the given alias or the /aliases node does not exist
> 
> Should this be None?

Actually, the whole comment could do with updating to reflect things
correctly for the Python rather than the C interface (e.g. a pointer
doesn't really make sense for the Python interface).

> 
> > +        """
> > +        return fdt_get_alias(self._fdt, name)
> > +
> >      def parent_offset(self, nodeoffset, quiet=()):
> >          """Get the offset of a node's parent
> >
> > diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py
> > index c055f01..42f31ba 100644
> > --- a/tests/pylibfdt_tests.py
> > +++ b/tests/pylibfdt_tests.py
> > @@ -77,6 +77,7 @@ class PyLibfdtBasicTests(unittest.TestCase):
> >          """Read in the device tree we use for testing"""
> >          self.fdt = _ReadFdt('test_tree1.dtb')
> >          self.fdt2 = _ReadFdt('test_props.dtb')
> > +        self.fdt3 = _ReadFdt('aliases.dtb')
> >
> >      def GetPropList(self, node_path):
> >          """Read a list of properties from a node
> > @@ -340,6 +341,12 @@ class PyLibfdtBasicTests(unittest.TestCase):
> >          node2 = self.fdt.path_offset('/subnode@2')
> >          self.assertEquals(0x2000, self.fdt.get_phandle(node2))
> >
> > +    def testGetAlias(self):
> > +        """Test for the get_alias() method"""
> > +        self.assertEquals("/subnode@1", self.fdt3.get_alias('s1'))
> > +        self.assertEquals("/subnode@1/subsubnode", self.fdt3.get_alias('ss1'))
> > +        self.assertEquals("/subnode@1/subsubnode/subsubsubnode", self.fdt3.get_alias('sss1'))
> > +
> >      def testParentOffset(self):
> >          """Test for the parent_offset() method"""
> >          self.assertEquals(-libfdt.NOTFOUND,
> >
> 
> Regards,
> Simon
> 

-- 
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