From: Quentin Schulz <quentin.schulz@cherry.de>
To: Tom Rini <trini@konsulko.com>
Cc: u-boot@lists.denx.de, Lukasz Majewski <lukma@denx.de>,
Sean Anderson <seanga2@gmail.com>
Subject: Re: [PATCH 2/3] clk: clk-cdce9xx.c: Change from u32 to ulong for addresses
Date: Thu, 17 Jul 2025 17:19:39 +0200 [thread overview]
Message-ID: <3eb8df7f-632f-464b-bf44-b05678bd22e2@cherry.de> (raw)
In-Reply-To: <20250717150827.GN193579@bill-the-cat>
Hi Tom,
On 7/17/25 5:08 PM, Tom Rini wrote:
> On Mon, Jul 14, 2025 at 12:35:14PM +0200, Quentin Schulz wrote:
>> Hi Tom,
>>
>> On 7/2/25 3:05 AM, Tom Rini wrote:
>>> For 32/64bit correctness, we need to use ulong and not u32 for casting
>>> for addresses.
>>>
>>> Signed-off-by: Tom Rini <trini@konsulko.com>
>>> ---
>>> Cc: Lukasz Majewski <lukma@denx.de>
>>> Cc: Sean Anderson <seanga2@gmail.com>
>>> ---
>>> drivers/clk/clk-cdce9xx.c | 10 +++++-----
>>> 1 file changed, 5 insertions(+), 5 deletions(-)
>>>
>>> diff --git a/drivers/clk/clk-cdce9xx.c b/drivers/clk/clk-cdce9xx.c
>>> index e5f74e714d54..afb997c06be5 100644
>>> --- a/drivers/clk/clk-cdce9xx.c
>>> +++ b/drivers/clk/clk-cdce9xx.c
>>> @@ -103,7 +103,7 @@ static int cdce9xx_clk_probe(struct udevice *dev)
>>> u32 val;
>>> struct clk clk;
>>> - val = (u32)dev_read_addr_ptr(dev);
>>> + val = (ulong)dev_read_addr_ptr(dev);
>>
>> The output would be stored in a u32 anyway so not sure this actually helps
>> (see type of val in the git context above).
>
> Yeah. It's funny. The other example of a driver doing these games is
> drivers/clk/clk_versaclock.c which uses u64 since it's a 64bit system I
> believe.
>
>>> ret = i2c_get_chip(dev->parent, val, 1, &data->i2c);
>>> if (ret) {
>>> @@ -226,10 +226,10 @@ static ulong cdce9xx_clk_set_rate(struct clk *clk, ulong rate)
>>> }
>>> static const struct udevice_id cdce9xx_clk_of_match[] = {
>>> - { .compatible = "ti,cdce913", .data = (u32)&cdce913_chip_info },
>>> - { .compatible = "ti,cdce925", .data = (u32)&cdce925_chip_info },
>>> - { .compatible = "ti,cdce937", .data = (u32)&cdce937_chip_info },
>>> - { .compatible = "ti,cdce949", .data = (u32)&cdce949_chip_info },
>>> + { .compatible = "ti,cdce913", .data = (ulong)&cdce913_chip_info },
>>> + { .compatible = "ti,cdce925", .data = (ulong)&cdce925_chip_info },
>>> + { .compatible = "ti,cdce937", .data = (ulong)&cdce937_chip_info },
>>> + { .compatible = "ti,cdce949", .data = (ulong)&cdce949_chip_info },
>>
>> Just get rid of the cast I guess? udevice_id.data being a ulong already the
>> compiler should perform the cast in any case and this improves readability?
>
> Without some cast we get:
> error: initialization of ‘long unsigned int’ from ‘const struct
> cdce9xx_chip_info *’ makes integer from pointer without a cast
> [-Werror=int-conversion]
>
My apologies for the mislead.
It seems like places where it's not needed are where the member is of
type void*. The kernel uses this type for of_device_id struct which I'm
the most familiar with, but U-Boot's udevice_id actually uses a ulong
instead, which thus requires the cast I guess.
> That said, I'm just going to drop this patch and make the driver depend
> on ARCH_OMAP2PLUS. My gut feeling is this is another one of the cases
> where we run in to problems because we don't use phys_addr_t for
> physical addresses consistently.
>
Considering it could be anything, should the type be void* like in the
kernel for udevice_id.data maybe? Up to the driver to perform the proper
cast when accessing/dereferencing it?
Cheers,
Quentin
next prev parent reply other threads:[~2025-07-17 15:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 1:05 [PATCH 1/3] clk: Add missing <dm/device.h> to include/clk.h Tom Rini
2025-07-02 1:05 ` [PATCH 2/3] clk: clk-cdce9xx.c: Change from u32 to ulong for addresses Tom Rini
2025-07-14 10:35 ` Quentin Schulz
2025-07-14 14:03 ` Tom Rini
2025-07-17 15:08 ` Tom Rini
2025-07-17 15:19 ` Quentin Schulz [this message]
2025-07-17 18:05 ` Tom Rini
2025-07-02 1:05 ` [PATCH 3/3] clk: Tighten some clock driver dependencies Tom Rini
2025-10-28 23:57 ` (subset) [PATCH 1/3] clk: Add missing <dm/device.h> to include/clk.h Tom Rini
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=3eb8df7f-632f-464b-bf44-b05678bd22e2@cherry.de \
--to=quentin.schulz@cherry.de \
--cc=lukma@denx.de \
--cc=seanga2@gmail.com \
--cc=trini@konsulko.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