From: David Lechner <dlechner@baylibre.com>
To: Julien Stephan <jstephan@baylibre.com>
Cc: Ryder Lee <ryder.lee@mediatek.com>,
Weijie Gao <weijie.gao@mediatek.com>,
Chunfeng Yun <chunfeng.yun@mediatek.com>,
Igor Belwon <igor.belwon@mentallysanemainliners.org>,
Carlo Caione <ccaione@baylibre.com>,
GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>,
Tom Rini <trini@konsulko.com>, Simon Glass <sjg@chromium.org>,
u-boot@lists.u-boot-project.org,
Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
Subject: Re: [PATCH 1/2] serial: mtk: use ulong for clk_rate
Date: Tue, 28 Jul 2026 11:04:42 -0500 [thread overview]
Message-ID: <97226293-adb8-4b89-98aa-e4909bef9fff@baylibre.com> (raw)
In-Reply-To: <CAEHHSvayHDYp9+4SKOhYKk0j5ya2gmXbJSP7zVQBx344P1jS-g@mail.gmail.com>
On 7/28/26 10:57 AM, Julien Stephan wrote:
> Le mar. 28 juil. 2026 à 01:25, David Lechner <dlechner@baylibre.com> a écrit :
>>
>> From: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
>>
>> Use ulong for return value of clk_get_rate() in the MediaTek serial
>> driver.
>>
>> IS_ERR_VALUE() does a signed 64-bit comparison against the range of
>> possible error codes. If clk_get_rate() returns an error, assigning this
>> to a u32 truncates the top 32 bits making the value smaller, defeating
>> IS_ERR_VALUE() and producing a garbage divisor that hangs the UART.
>>
>> Fixes: 3b17f2e2c2a9 ("serial: mtk: add support for using dynamic baud clock souce")
>> Signed-off-by: Suhrid Subramaniam <suhrid.subramaniam@mediatek.com>
>> Signed-off-by: David Lechner <dlechner@baylibre.com>
>> ---
>> drivers/serial/serial_mtk.c | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/serial/serial_mtk.c b/drivers/serial/serial_mtk.c
>> index 01cc415efdd..64b3287f8eb 100644
>> --- a/drivers/serial/serial_mtk.c
>> +++ b/drivers/serial/serial_mtk.c
>> @@ -213,7 +213,7 @@ static int _mtk_serial_pending(struct mtk_serial_priv *priv, bool input)
>> static int mtk_serial_setbrg(struct udevice *dev, int baudrate)
>> {
>> struct mtk_serial_priv *priv = dev_get_priv(dev);
>> - u32 clk_rate;
>> + ulong clk_rate;
>>
>> clk_rate = clk_get_rate(&priv->clk);
>> if (IS_ERR_VALUE(clk_rate) || clk_rate == 0)
>> @@ -266,6 +266,7 @@ static int mtk_serial_of_to_plat(struct udevice *dev)
>> {
>> struct mtk_serial_priv *priv = dev_get_priv(dev);
>> fdt_addr_t addr;
>> + ulong clk_rate;
>> int err;
>>
>> addr = dev_read_addr(dev);
>> @@ -282,10 +283,10 @@ static int mtk_serial_of_to_plat(struct udevice *dev)
>> return -EINVAL;
>> }
>> } else {
>> - err = clk_get_rate(&priv->clk);
>> - if (IS_ERR_VALUE(err)) {
>> + clk_rate = clk_get_rate(&priv->clk);
>> + if (IS_ERR_VALUE(clk_rate)) {
>> dev_err(dev, "invalid baud clock\n");
>> - return -EINVAL;
>> + return (int)clk_rate;
>
> Hello David,
>
> This is a functional changes, maybe deserves a separate patch?
I checked all users and nothing check for specific return values.
Everything just logs the error or only cares about pass/fail. So
I don't consider it that significant of a change. Maybe I should
have mentioned it in the commit message though.
>
> Cheers
> Julien
>
>> }
>> }
>>
>>
>> --
>> 2.43.0
>>
next prev parent reply other threads:[~2026-07-28 16:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-27 23:24 [PATCH 0/2] serial: mtk: clock rate fixes David Lechner
2026-07-27 23:24 ` [PATCH 1/2] serial: mtk: use ulong for clk_rate David Lechner
2026-07-28 15:57 ` Julien Stephan
2026-07-28 16:04 ` David Lechner [this message]
2026-07-27 23:24 ` [PATCH 2/2] serial: mtk: guard clk ops on clk.dev David Lechner
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=97226293-adb8-4b89-98aa-e4909bef9fff@baylibre.com \
--to=dlechner@baylibre.com \
--cc=GSS_MTK_Uboot_upstream@mediatek.com \
--cc=ccaione@baylibre.com \
--cc=chunfeng.yun@mediatek.com \
--cc=igor.belwon@mentallysanemainliners.org \
--cc=jstephan@baylibre.com \
--cc=ryder.lee@mediatek.com \
--cc=sjg@chromium.org \
--cc=suhrid.subramaniam@mediatek.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=weijie.gao@mediatek.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 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.