From: Sean Anderson <seanga2@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH 1/5] dm: core: Fix devfdt_get_addr_ptr return value
Date: Thu, 28 May 2020 15:29:45 -0400 [thread overview]
Message-ID: <431d293c-682c-5375-9fb2-05f0af478333@gmail.com> (raw)
In-Reply-To: <CAPnjgZ13OrjiKjcbfha5VZSDoBjVffO65T6ET4aFnvmnhHz61A@mail.gmail.com>
On 5/28/20 10:32 AM, Simon Glass wrote:
> On Wed, 27 May 2020 at 00:45, Ovidiu Panait <ovidiu.panait@windriver.com> wrote:
>>
>> According to the description of devfdt_get_addr_ptr, this function should
>> return NULL on failure, but currently it returns (void *)FDT_ADDR_T_NONE.
>>
>> This is also a problem because there are two definitions for
>> dev_read_addr_ptr, depending on CONFIG_DM_DEV_READ_INLINE:
>>
>> 1. one returning NULL on failure (drivers/core/read.c):
>> void *dev_read_addr_ptr(const struct udevice *dev)
>> {
>> fdt_addr_t addr = dev_read_addr(dev);
>>
>> return (addr == FDT_ADDR_T_NONE) ? NULL : map_sysmem(addr, 0);
>> }
>>
>> 2. another one, which is a wrapper over devfdt_get_addr_ptr, returning
>> (void *)FDT_ADDR_T_NONE (include/dm/read.h)
>>
>> static inline void *dev_read_addr_ptr(const struct udevice *dev)
>> {
>> return devfdt_get_addr_ptr(dev);
>> }
>>
>> Currently, some drivers which make use of devfdt_get_addr_ptr check the
>> return value for NULL:
>> drivers/i2c/mvtwsi.c
>> drivers/i2c/designware_i2c.c
>> drivers/usb/host/ehci-zynq.c
>>
>> while others check the return value for (void *)FDT_ADDR_T_NONE:
>> drivers/pinctrl/mvebu/pinctrl-mvebu.c
>> drivers/timer/ast_timer.c
>> drivers/watchdog/ast_wdt.c
>>
>> Fix this by making devfdt_get_addr_ptr return NULL on failure, as
>> described in the function comments. Also, update the drivers currently
>> checking (void *)FDT_ADDR_T_NONE to check for NULL.
>>
>> Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
>> ---
>>
>> drivers/clk/aspeed/clk_ast2500.c | 4 ++--
>> drivers/core/fdtaddr.c | 5 ++++-
>> drivers/i2c/ast_i2c.c | 4 ++--
>> drivers/pinctrl/mvebu/pinctrl-mvebu.c | 2 +-
>> drivers/timer/ast_timer.c | 4 ++--
>> drivers/watchdog/ast_wdt.c | 4 ++--
>> 6 files changed, 13 insertions(+), 10 deletions(-)
>>
>
> +Sean Anderson
It looks like I never actually got CC'd
>
> I did already review another patch on this topic[1]. I'm not sure
> when that is going to land though. Perhaps this one should be rebased
> on that? Or Matthias can check with the other custodian to see what is
> happening with that series.
Hopefully soon; I believe the last holdup was passing CI.
>
> I've sent a patch for a test which detects the inconsistency[2]. It is
> very easy to write a new test so I encourage people to do that
> whenever there is a fix like this. So with that:
I think that's a good idea. However, from what I can see, that patch
tests dev_read_addr_ptr, not devfdt_get_addr_ptr. You may also want to
check the error case, to make sure FDT_ADDR_T_NONE gets returned.
>
> Tested on sandbox
> Tested-by: Simon Glass <sjg@chromium.org>
>
> [1] http://patchwork.ozlabs.org/project/uboot/patch/20200521161503.384823-10-seanga2 at gmail.com/
> [2] http://patchwork.ozlabs.org/project/uboot/patch/20200528082045.1.Ibd999a0382164a37d1e59c00c8c7a9ff92b8f53a at changeid/
>
--Sean
next prev parent reply other threads:[~2020-05-28 19:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-27 6:41 [PATCH 1/5] dm: core: Fix devfdt_get_addr_ptr return value Ovidiu Panait
2020-05-27 6:41 ` [PATCH 2/5] pinctrl: bcm283x: DM_FLAG_PRE_RELOC: Remove OF_CONTROL check Ovidiu Panait
2020-05-27 6:41 ` [PATCH 3/5] pinctrl: bcm283x: Read address from DT in ofdata_to_platdata Ovidiu Panait
2020-05-27 6:41 ` [PATCH 4/5] pinctrl: bcm283x: Fix return value check for dev_read_addr_ptr Ovidiu Panait
2020-05-27 6:41 ` [PATCH 5/5] pinctrl: bcm283x: Store the return value of dev_read_u32_default to int Ovidiu Panait
2020-05-27 12:05 ` [PATCH 1/5] dm: core: Fix devfdt_get_addr_ptr return value Matthias Brugger
2020-06-11 9:07 ` Ovidiu Panait
2020-05-28 9:22 ` Cédric Le Goater
2020-05-28 14:32 ` Simon Glass
2020-05-28 19:29 ` Sean Anderson [this message]
2020-05-29 0:28 ` Simon Glass
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=431d293c-682c-5375-9fb2-05f0af478333@gmail.com \
--to=seanga2@gmail.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