public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Jerry Van Baren <gerald.vanbaren@ge.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 04/10] fdt: Add fdt_sizecell & fdt_addrcell helpers
Date: Thu, 23 Oct 2008 08:26:01 -0400	[thread overview]
Message-ID: <49006D59.8090302@ge.com> (raw)
In-Reply-To: <F394B3FC-0C0A-43BE-B4AF-787FCFA0CDE3@kernel.crashing.org>

Kumar Gala wrote:
> 
> On Oct 23, 2008, at 6:55 AM, Jerry Van Baren wrote:
> 
>> Kumar Gala wrote:
>>> Add helper functions to return top level #size-cell and #address-cell 
>>> info
>>> Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
>>> ---
>>> include/fdt_support.h |   18 ++++++++++++++++++
>>> 1 files changed, 18 insertions(+), 0 deletions(-)
>>> diff --git a/include/fdt_support.h b/include/fdt_support.h
>>> index ceaadc2..aa9d86b 100644
>>> --- a/include/fdt_support.h
>>> +++ b/include/fdt_support.h
>>> @@ -28,6 +28,24 @@
>>>  #include <fdt.h>
>>> +static inline int fdt_addrcell(void *blob) {
>>> +    const u32 *addrcell = fdt_getprop(blob, 0, "#address-cells", NULL);
>>> +
>>> +    if (addrcell)
>>> +        return *addrcell;
>>> +    else
>>> +        return 1;
>>> +}
>>> +
>>> +static inline int fdt_sizecell(void *blob) {
>>> +    const u32 *sizecell = fdt_getprop(blob, 0, "#size-cells", NULL);
>>> +
>>> +    if (sizecell)
>>> +        return *sizecell;
>>> +    else
>>> +        return 1;
>>> +}
>>> +
>>> int fdt_chosen(void *fdt, int force);
>>> int fdt_initrd(void *fdt, ulong initrd_start, ulong initrd_end, int 
>>> force);
>>> void do_fixup_by_path(void *fdt, const char *path, const char *prop,
>>
>> Hi Kumar,
>>
>> What about collapsing the two above into a common function?
>>
>>     fdt_addrcell(blob);
>> becomes
>>     fdt_get_prop_u32(blob, "/", "#address-cells", 1);
>> and
>>     fdt_sizecell(blob);
>> becomes
>>     fdt_get_prop_u32(blob, "/", "#size-cells", 1);
>>
>> WARNING, UNTESTED CODE:
>> /**
>> * fdt_get_prop_u32: Find a node and return it's property or a default
>> *
>> * @fdt: ptr to device tree
>> * @node: path of node
>> * @prop: property name
>> * @defalt: default value if the property isn't found
>> *
>> * Convenience function to find a node and return it's property or a
>> * default value if it doesn't exist.
>> */
>> u32 fdt_get_prop_u32(void *fdt, const char *node, const char *prop,
>>              const u32 default)
>> {
>>     const u32 *addrcell = fdt_getprop(fdt, node, prop, NULL);
>>
>>     if (addrcell)
>>         return *addrcell;
>>     else
>>         return default;
>> }
> 
> I'd prefer we call it fdt_getprop_u32_default().  If you are good with 
> the name I'll change my patchset.
> 
> - k

That was my second choice.  I figured Dennis Richie would call me up and 
complain the name was too long. ;-)

I'm find with the change.

Acked-by: Gerald Van Baren <vanbaren@cideas.com>

Thanks,
gvb

  reply	other threads:[~2008-10-23 12:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-23  6:26 [U-Boot] [PATCH 00/10] 85xx/85xx pci cleanup Kumar Gala
2008-10-23  6:26 ` [U-Boot] [PATCH 01/10] pci: Allow for PCI addresses to be 64-bit Kumar Gala
2008-10-23  6:26   ` [U-Boot] [PATCH 02/10] 85xx: Enable 64-bit PCI resources on all Freescale boards Kumar Gala
2008-10-23  6:26     ` [U-Boot] [PATCH 03/10] 86xx: " Kumar Gala
2008-10-23  6:26       ` [U-Boot] [PATCH 04/10] fdt: Add fdt_sizecell & fdt_addrcell helpers Kumar Gala
2008-10-23  6:26         ` [U-Boot] [PATCH 05/10] fdt: Added helper to set PCI dma-ranges property Kumar Gala
2008-10-23  6:26           ` [U-Boot] [PATCH 06/10] pci/fsl_pci_init: Enable larger address and setting inbound windows properly Kumar Gala
2008-10-23  6:26             ` [U-Boot] [PATCH 07/10] pci/fsl_pci_init: Add a common PCI inbound setup function Kumar Gala
2008-10-23  6:26               ` [U-Boot] [PATCH 08/10] pci/fsl_pci_init: Added fdt helper for setting up bus-ranges & dma-ranges Kumar Gala
2008-10-23  6:26                 ` [U-Boot] [PATCH 09/10] 85xx: Convert all fsl_pci_init users to new APIs Kumar Gala
2008-10-23  6:26                   ` [U-Boot] [PATCH 10/10] 86xx: " Kumar Gala
2008-10-24  0:41                     ` Jon Loeliger
2008-10-23 11:55         ` [U-Boot] [PATCH 04/10] fdt: Add fdt_sizecell & fdt_addrcell helpers Jerry Van Baren
2008-10-23 12:04           ` Kumar Gala
2008-10-23 12:26             ` Jerry Van Baren [this message]
2008-10-23 12:59               ` Kumar Gala
2008-10-24 13:12   ` [U-Boot] [PATCH 01/10] pci: Allow for PCI addresses to be 64-bit Wolfgang Denk
2008-10-23  8:35 ` [U-Boot] [PATCH 00/10] 85xx/85xx pci cleanup Wolfgang Denk
2008-10-23 11:58   ` Kumar Gala
2008-10-24 22:48     ` Andy Fleming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49006D59.8090302@ge.com \
    --to=gerald.vanbaren@ge.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox