All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mario Six <mario.six@gdsys.cc>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/3] core: Add function to get device for ofnode
Date: Tue, 10 Apr 2018 13:34:17 +0200	[thread overview]
Message-ID: <CAN1kZoqgYzaXqS_cWqgS3Xq205sB7q82sM=k7rxH1AsMeQzCUQ@mail.gmail.com> (raw)
In-Reply-To: <CAPnjgZ2kw78m-Xa9gytUBOYw-4afK_j+NVHy3pKxUu2QFqdg2Q@mail.gmail.com>

Hi Simon,

On Fri, Mar 30, 2018 at 12:43 AM, Simon Glass <sjg@chromium.org> wrote:
> Hi Mario,
>
> On 28 March 2018 at 20:37, Mario Six <mario.six@gdsys.cc> wrote:
>> It's sometimes useful to get the device associated with a given ofnode.
>> Implement a function to implement this lookup operation.
>
> Where would you use this? Can you not use phandles to find the device?
> Or uclass_get_device_by_ofnode() ?
>

The function is used with the dev_{enable,disable}_by_path in the next patch:
If I used any of the uclass_* functions or similar, the device would be probed,
which is not what I want, since the device may not actually be physically
present.

>>
>> Signed-off-by: Mario Six <mario.six@gdsys.cc>
>> ---
>>  drivers/core/ofnode.c | 15 +++++++++++++++
>>  include/dm/ofnode.h   |  8 ++++++++
>>  2 files changed, 23 insertions(+)
>>
>> diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
>> index 4e4532651f..ca002063b3 100644
>> --- a/drivers/core/ofnode.c
>> +++ b/drivers/core/ofnode.c
>> @@ -16,6 +16,21 @@
>>  #include <linux/err.h>
>>  #include <linux/ioport.h>
>>
>> +struct udevice *ofnode_dev(ofnode node)
>
> Can you please add a test for this?
>
> This seems like an internal function since it does not probe the
> device. So how about putting it in device.h:
>
> device_get_by_ofnode() - does probe the device it returns
> device_find_by_ofnode() - doesn't probe
>
>> +{
>> +       struct uclass *uc;
>> +       struct udevice *dev;
>> +
>> +       list_for_each_entry(uc, &gd->uclass_root, sibling_node) {
>> +               list_for_each_entry(dev, &uc->dev_head, uclass_node) {
>> +                       if (ofnode_equal(dev_ofnode(dev), node))
>> +                               return dev;
>> +               }
>> +       }
>> +
>> +       return NULL;
>> +}
>> +
>>  int ofnode_read_u32(ofnode node, const char *propname, u32 *outp)
>>  {
>>         assert(ofnode_valid(node));
>> diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
>> index 0d008404f9..aec205eb80 100644
>> --- a/include/dm/ofnode.h
>> +++ b/include/dm/ofnode.h
>> @@ -193,6 +193,14 @@ static inline ofnode ofnode_null(void)
>>         return node;
>>  }
>>
>> +/**
>> + * ofnode_dev() - Get the device associated with a given ofnode
>> + *
>> + * @node:      valid node reference to get the corresponding device for
>> + * @return a pointer to the udevice if OK, NULL on error
>> + */
>> +struct udevice *ofnode_dev(ofnode node);
>> +
>>  /**
>>   * ofnode_read_u32() - Read a 32-bit integer from a property
>>   *
>> --
>> 2.16.1
>>
>
> Regards,
> Simon
>

Everything else will be addressed in v2. Thanks for reviewing!

Best regards,

Mario

  reply	other threads:[~2018-04-10 11:34 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-28 12:37 [U-Boot] [PATCH 1/3] core: Add function to get device for ofnode Mario Six
2018-03-28 12:37 ` [U-Boot] [PATCH 2/3] core: Add functions to set properties in live-tree Mario Six
2018-03-29 22:43   ` Simon Glass
2018-04-10 11:23     ` Mario Six
2018-04-12 16:42       ` Simon Glass
2018-04-18  9:10         ` Mario Six
2018-03-28 12:37 ` [U-Boot] [PATCH 3/3] core: Add dev_{disable,enable}_by_path Mario Six
2018-03-29 22:43   ` Simon Glass
2018-04-10 11:42     ` Mario Six
2018-03-29 22:43 ` [U-Boot] [PATCH 1/3] core: Add function to get device for ofnode Simon Glass
2018-04-10 11:34   ` Mario Six [this message]
2018-04-12 16:42     ` Simon Glass
2018-04-18  8:20       ` Mario Six
2018-04-22 20:13         ` Simon Glass
2018-04-26  5:59           ` Mario Six

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='CAN1kZoqgYzaXqS_cWqgS3Xq205sB7q82sM=k7rxH1AsMeQzCUQ@mail.gmail.com' \
    --to=mario.six@gdsys.cc \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.