From: Sean Anderson <seanga2@gmail.com>
To: Michael Walle <michael@walle.cc>
Cc: Heiko Thiery <heiko.thiery@gmail.com>,
u-boot@lists.denx.de, Marek Vasut <marex@denx.de>,
Angus Ainslie <angus@akkea.ca>,
Angus Ainslie <angus.ainslie@puri.sm>,
lukma@denx.de, sbabic@denx.de, festevam@gmail.com,
uboot-imx@nxp.com, peng.fan@nxp.com
Subject: Re: [RFC] serial: mxc: get the clock frequency from the used clock for the device
Date: Thu, 17 Mar 2022 22:15:09 -0400 [thread overview]
Message-ID: <112363c5-d7b7-80ec-17eb-4b5d91729c34@gmail.com> (raw)
In-Reply-To: <25046b02eb285f3f281cd003961e4900@walle.cc>
On 3/17/22 10:47 AM, Michael Walle wrote:
>
>>> + struct clk clk;
>>> + if(!clk_get_by_name(dev, "ipg", &clk))
>>> + rate = clk_get_rate(&clk);
>>> + }
>>> +
>>> + /* as fallback we try to get the clk rate that way */
>>> + if (rate == 0)
>>
>> !rate || IS_ERR_VALUE(rate)
>
> This looked so weird I had to actually look at clk_get_rate()
> in u-boot.
>
> /**
> * clk_get_rate() - Get current clock rate.
> * @clk: A clock struct that was previously successfully requested by
> * clk_request/get_by_*().
> *
> * Return: clock rate in Hz on success, 0 for invalid clock, or -ve error code
> * for other errors.
> */
> ulong clk_get_rate(struct clk *clk);
>
> How can an ulong return a negative error value?
It can't. Which is why we need IS_ERR_VALUE and not < 0.
> What if the clock speed happens to be the same as -errno?
Due to physical constraints, this isn't an issue on 64 bit systems. And you
could run into trouble if you have a 32-bit system with a 4GHz processor.
I don't think it's the best interface. In e.g. Linux clk_get_rate returns 0 on
failure, which I think is reasonable. If you are interested, please send a patch series :)
--Sean
next prev parent reply other threads:[~2022-03-18 2:15 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 12:41 [RFC] serial: mxc: get the clock frequency from the used clock for the device Heiko Thiery
2022-03-17 13:19 ` Angus Ainslie
2022-03-18 19:06 ` Heiko Thiery
2022-03-19 14:32 ` Angus Ainslie
2022-03-21 13:50 ` Heiko Thiery
2022-03-22 12:47 ` Angus Ainslie
2022-03-24 2:08 ` Adam Ford
2022-03-24 9:58 ` Heiko Thiery
2022-03-24 10:57 ` Adam Ford
2022-03-17 14:38 ` Sean Anderson
2022-03-17 14:47 ` Michael Walle
2022-03-18 2:15 ` Sean Anderson [this message]
2022-03-17 16:31 ` Lukasz Majewski
2022-03-17 19:14 ` Heiko Thiery
2022-03-18 2:19 ` Sean Anderson
2022-03-18 8:05 ` Heiko Thiery
2022-03-18 13:26 ` Sean Anderson
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=112363c5-d7b7-80ec-17eb-4b5d91729c34@gmail.com \
--to=seanga2@gmail.com \
--cc=angus.ainslie@puri.sm \
--cc=angus@akkea.ca \
--cc=festevam@gmail.com \
--cc=heiko.thiery@gmail.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=michael@walle.cc \
--cc=peng.fan@nxp.com \
--cc=sbabic@denx.de \
--cc=u-boot@lists.denx.de \
--cc=uboot-imx@nxp.com \
/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