All of lore.kernel.org
 help / color / mirror / Atom feed
From: Walter Lozano <walter.lozano@collabora.com>
To: u-boot@lists.denx.de
Subject: [PATCH 05/10] core: extend struct driver_info to point to device
Date: Fri, 29 May 2020 16:20:52 -0300	[thread overview]
Message-ID: <5d5b02a0-0116-9df5-0363-3e3847151aef@collabora.com> (raw)
In-Reply-To: <CAPnjgZ3WEhYwpn=k7xzy1xSi0_t8TyxVH=RMNYKe8g1FJ8f8ig@mail.gmail.com>

Hi Simon,

On 29/5/20 16:00, Simon Glass wrote:
> Hi Walter,
>
> On Fri, 29 May 2020 at 12:56, Walter Lozano <walter.lozano@collabora.com> wrote:
>>
>> On 29/5/20 15:15, Walter Lozano wrote:
>>> Currently when creating an U_BOOT_DEVICE entry a struct driver_info
>>> is declared, which contains the data needed to instantiate the device.
>>> However, the actual device is created at runtime and there is no proper
>>> way to get the device based on its struct driver_info.
>>>
>>> This patch extends struct driver_info adding a pointer to udevice which
>>> is populated during the bind process, allowing to generate a set of
>>> functions to get the device based on its struct driver_info.
>>>
>>> Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
>>> ---
>>>    drivers/core/device.c | 26 +++++++++++++++++++++++---
>>>    drivers/core/root.c   |  4 ++++
>>>    include/dm/device.h   | 14 ++++++++++++++
>>>    include/dm/platdata.h | 14 ++++++++++++++
>>>    4 files changed, 55 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/core/device.c b/drivers/core/device.c
>>> index a0ad080aaf..5adbc30849 100644
>>> --- a/drivers/core/device.c
>>> +++ b/drivers/core/device.c
>>> @@ -250,6 +250,7 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
>>>    {
>>>        struct driver *drv;
>>>        uint platdata_size = 0;
>>> +     int ret = 0;
>>>
>>>        drv = lists_driver_lookup_name(info->name);
>>>        if (!drv)
>>> @@ -260,9 +261,16 @@ int device_bind_by_name(struct udevice *parent, bool pre_reloc_only,
>>>    #if CONFIG_IS_ENABLED(OF_PLATDATA)
>>>        platdata_size = info->platdata_size;
>>>    #endif
>>> -     return device_bind_common(parent, drv, info->name,
>>> -                     (void *)info->platdata, 0, ofnode_null(), platdata_size,
>>> -                     devp);
>>> +     ret = device_bind_common(parent, drv, info->name,
>>> +                              (void *)info->platdata, 0, ofnode_null(),
>>> +                              platdata_size, devp);
>>> +     if (ret)
>>> +             return ret;
>>> +#if CONFIG_IS_ENABLED(OF_PLATDATA)
>>> +     info->dev = *devp;
>>> +#endif
>> I have tried to test this using sandbox_spl_defconfig but I've received
>> a segmentation fault when trying to update info->dev, however this code
>> works on iMX6.
>>
>> Could it be some kind of protection? Any thoughts?
> Yes, see u-boot-dm/dtoc-working - arch/sandbox/cpu/u-boot-spl.lds has
> an attempt to move some of the list stuff into the data region.

Thanks for confirmed it and also for the quick response. I'm about to 
start a deeper review to your work about tiny-dm now.

Regards,

Walter

  reply	other threads:[~2020-05-29 19:20 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-29 18:15 [PATCH 00/10] improve OF_PLATDATA support Walter Lozano
2020-05-29 18:15 ` [PATCH 01/10] dtoc: add support to scan drivers Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:49     ` Walter Lozano
2020-06-11 16:15       ` Walter Lozano
2020-06-11 16:44         ` Simon Glass
2020-06-11 16:45       ` Simon Glass
2020-06-11 17:11         ` Walter Lozano
2020-06-11 17:22           ` Simon Glass
2020-06-11 19:07             ` Walter Lozano
2020-06-12  2:22               ` Simon Glass
2020-06-12 17:38                 ` Walter Lozano
2020-06-16 13:43                   ` Simon Glass
2020-05-29 18:15 ` [PATCH 02/10] dtoc: add option to disable warnings Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:51     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 03/10] dm: doc: update of-plat with the suppor for driver aliases Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 04/10] core: drop const for struct driver_info Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 05/10] core: extend struct driver_info to point to device Walter Lozano
2020-05-29 18:56   ` Walter Lozano
2020-05-29 19:00     ` Simon Glass
2020-05-29 19:20       ` Walter Lozano [this message]
2020-05-29 20:42         ` Simon Glass
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:53     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 06/10] dtoc: extend dtoc to use struct driver_info when linking nodes Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 07/10] dm: doc: update of-plat with new phandle support Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 15:54     ` Walter Lozano
2020-05-29 18:15 ` [PATCH 08/10] dtoc: update tests to match new platdata Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:15 ` [PATCH 09/10] dtoc: update dtb_platdata to support cd-gpios Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-06-08 16:01     ` Walter Lozano
2020-06-14  2:49       ` Simon Glass
2020-05-29 18:15 ` [PATCH 10/10] dtoc add test for cd-gpios Walter Lozano
2020-06-04 15:59   ` Simon Glass
2020-05-29 18:25 ` [PATCH 00/10] improve OF_PLATDATA support Jagan Teki
2020-05-29 19:15   ` Walter Lozano

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=5d5b02a0-0116-9df5-0363-3e3847151aef@collabora.com \
    --to=walter.lozano@collabora.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 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.