From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Fri, 22 Mar 2019 15:53:00 +0800 Subject: [U-Boot] [PATCH v3 03/13] fdtdec: Add fdt_{addr, size}_unpack() helpers In-Reply-To: <20190321181010.27005-4-thierry.reding@gmail.com> References: <20190321181010.27005-1-thierry.reding@gmail.com> <20190321181010.27005-4-thierry.reding@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Thierry, On Fri, 22 Mar 2019 at 02:10, Thierry Reding wrote: > > From: Thierry Reding > > These helpers can be used to unpack variables of type fdt_addr_t and > fdt_size_t into a pair of 32-bit variables. This is useful in cases > where such variables need to be written to properties (such as "reg") > of a device tree node where they need to be split into cells. > > Signed-off-by: Thierry Reding > --- > Changes in v2: > - new patch > > include/fdtdec.h | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/include/fdtdec.h b/include/fdtdec.h > index a965c33157c9..a0ba57c6318b 100644 > --- a/include/fdtdec.h > +++ b/include/fdtdec.h > @@ -23,6 +23,31 @@ > */ > typedef phys_addr_t fdt_addr_t; > typedef phys_size_t fdt_size_t; > + > +static inline fdt32_t fdt_addr_unpack(fdt_addr_t addr, fdt32_t *upper) > +{ > + if (upper) > +#ifdef CONFIG_PHYS_64BIT Could we use 'if IS_ENABLED()' instead? > + *upper = addr >> 32; > +#else > + *upper = 0; > +#endif > + > + return addr; > +} > + > +static inline fdt32_t fdt_size_unpack(fdt_size_t size, fdt32_t *upper) > +{ > + if (upper) > +#ifdef CONFIG_PHYS_64BIT > + *upper = size >> 32; > +#else > + *upper = 0; > +#endif > + > + return size; > +} > + > #ifdef CONFIG_PHYS_64BIT > #define FDT_ADDR_T_NONE (-1U) > #define fdt_addr_to_cpu(reg) be64_to_cpu(reg) > -- > 2.21.0 > Regards, Simon