public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Andrew Goodbody <andrew.goodbody@linaro.org>
Cc: Jonas Karlman <jonas@kwiboo.se>, Simon Glass <sjg@chromium.org>,
	Philipp Tomsich <philipp.tomsich@vrull.eu>,
	Kever Yang <kever.yang@rock-chips.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 08/24] clk: rockchip: Remove negative error returns from clk_get_rate
Date: Mon, 20 Oct 2025 08:23:07 -0600	[thread overview]
Message-ID: <20251020142307.GU6688@bill-the-cat> (raw)
In-Reply-To: <4f84711c-8d08-419f-bef6-ff97858751f8@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 2412 bytes --]

On Mon, Oct 20, 2025 at 01:03:15PM +0100, Andrew Goodbody wrote:
> On 19/10/2025 21:28, Jonas Karlman wrote:
> > Hi Andrew,
> > 
> > On 10/15/2025 4:32 PM, Andrew Goodbody wrote:
> > > clk_get_rate() returns a ulong so do not attempt to pass negative error
> > > codes through it.
> > 
> > On Rockchip the clk drivers only implement support for a subset of all
> > clocks supported by the hardware, mostly to save space for TPL/SPL and
> > not having to implement logic for clocks not really needed by U-Boot.
> > 
> > Because support for all clocks is not implemented the existing working
> > error handling actually help us catch clock issues on the Rockchip
> > platform. E.g. when a clk is referenced by assigned-clock-rates in DT we
> > get an error and can fix the issue, or decide if we can safely ignore
> > setting the clk rate.
> > 
> > I do not understand why you need to change the way the clk ops work,
> > just check with IS_ERR_VALUE() inside the clk-uclass or similar if you
> > really must remove working error handling from the callers.
> 
> OK, so here we have a question and it is one that I wish had come up in the
> original discussion. IS_ERR_VALUE() and other related macros are from
> include/linux/err.h and are introduced with this comment
> 
> /*
>  * Kernel pointers have redundant information, so we can use a
>  * scheme where we can return either an error code or a dentry
>  * pointer with the same return value.
>  *
>  * This should be a per-architecture thing, to allow different
>  * error and pointer decisions.
>  */
> 
> So they are clearly intended to be unambiguous and used to add information
> about errors into kernel pointers. It also suggests that there may be other
> implementations of these macros for other architectures.
> 
> Much of the error checking of the return value from clk_get_rate() is done
> with IS_ERR_VALUE() despite the return value not being a kernel pointer and
> with this default implementation it does happen to work just as long as your
> clock rate does not collide with an error. OK collisions are very unlikely
> but it does still feel like an abuse of the macro to me.
> 
> Is there any official guidance on this use of IS_ERR_VALUE()?

We don't have any, really. So my question is, given the use case Jonas
outlined (thanks!), what do you see as a good way to handle this?

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2025-10-20 14:23 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-15 14:32 [PATCH 00/24] clk: Remove passing of negative errors through unsigned return Andrew Goodbody
2025-10-15 14:32 ` [PATCH 01/24] clk: meson: Remove negative error returns from clk_get_rate Andrew Goodbody
2025-10-18  8:34   ` Simon Glass
2025-10-15 14:32 ` [PATCH 02/24] clk: sifive: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 03/24] clk: armada-37xx: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 04/24] clk: thead: th1520-ap: " Andrew Goodbody
2025-10-16  4:53   ` Yao Zi
2025-10-15 14:32 ` [PATCH 05/24] clk: ccf: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 06/24] clk: at91: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 07/24] clk: renesas: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 08/24] clk: rockchip: " Andrew Goodbody
2025-10-19 20:28   ` Jonas Karlman
2025-10-20 12:03     ` Andrew Goodbody
2025-10-20 14:23       ` Tom Rini [this message]
2025-10-20 15:30         ` Andrew Goodbody
2025-10-20 15:03       ` Jonas Karlman
2025-10-20 15:57         ` Andrew Goodbody
2025-10-15 14:32 ` [PATCH 09/24] clk: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 10/24] clk: starfive: " Andrew Goodbody
2025-10-17  6:16   ` Hal Feng
2025-10-15 14:32 ` [PATCH 11/24] clk: altera: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 12/24] clk: uniphier: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 13/24] clk: aspeed: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 14/24] clk: nuvoton: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 15/24] clk: exynos: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 16/24] clk: imx: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 17/24] clk: ti: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 18/24] clk: mediatek: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 19/24] clk: owl: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 20/24] clk: tegra: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 21/24] clk: adi: " Andrew Goodbody
2025-10-17  4:02   ` Greg Malysa
2025-10-15 14:32 ` [PATCH 22/24] clk: sophgo: " Andrew Goodbody
2025-10-15 14:32 ` [PATCH 23/24] clk: stm32: " Andrew Goodbody
2025-10-16  7:37   ` Patrice CHOTARD
2025-10-15 14:32 ` [PATCH 24/24] clk: x86: " Andrew Goodbody
2025-10-18  8:34 ` [PATCH 00/24] clk: Remove passing of negative errors through unsigned return Simon Glass
2025-10-18 14:04   ` Tom Rini
2025-10-18 18:16     ` Philipp Tomsich
2025-10-19 13:05     ` Simon Glass
2025-10-19 13:45       ` Svyatoslav Ryhel
2025-10-19 16:21         ` Tom Rini
2025-10-19 18: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=20251020142307.GU6688@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=jonas@kwiboo.se \
    --cc=kever.yang@rock-chips.com \
    --cc=philipp.tomsich@vrull.eu \
    --cc=sjg@chromium.org \
    --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