[PATCH v2] clk: check parent_name in clk_register to avoid confusing log_error() output
Sean Anderson
seanga2 at gmail.com
Mon Nov 13 19:14:46 CET 2023
On 11/10/23 14:19, Yang Xiwen via B4 Relay wrote:
> From: Yang Xiwen <forbidden405 at outlook.com>
>
> For some gate clocks and fixed clocks without a parent, calling
> clk_register will print an useless error message indicating that parent
> is missing. Fix that by gaurding log_xxx() with an if-statement.
>
> Signed-off-by: Yang Xiwen <forbidden405 at outlook.com>
> Suggested-by: Sean Anderson <seanga2 at gmail.com>
> ---
> It's found during my development for HiSilicon clock driver.
> ---
> Changes in v2:
> - drop the commit which exports clk_mux_register.
> - drop the commit which is already merged
> - drop ccf enable_count fix as it'll be in another patchset
> - use Anderson's patch for clk_register()
> - Link to v1: https://lore.kernel.org/r/20230809-clk-fix-v1-0-808dbae54e5e@outlook.com
> ---
> drivers/clk/clk.c | 18 ++++++++++--------
> 1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index a5a3461b66..6ede1b4d4d 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -18,17 +18,19 @@
> int clk_register(struct clk *clk, const char *drv_name,
> const char *name, const char *parent_name)
> {
> - struct udevice *parent;
> + struct udevice *parent = NULL;
> struct driver *drv;
> int ret;
>
> - ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent);
> - if (ret) {
> - log_err("%s: failed to get %s device (parent of %s)\n",
> - __func__, parent_name, name);
> - } else {
> - log_debug("%s: name: %s parent: %s [0x%p]\n", __func__, name,
> - parent->name, parent);
> + if (parent_name) {
> + ret = uclass_get_device_by_name(UCLASS_CLK, parent_name, &parent);
> + if (ret) {
> + log_err("%s: failed to get %s device (parent of %s)\n",
> + __func__, parent_name, name);
> + } else {
> + log_debug("%s: name: %s parent: %s [0x%p]\n", __func__, name,
> + parent->name, parent);
> + }
> }
>
> drv = lists_driver_lookup_name(drv_name);
>
> ---
> base-commit: 580eb31199be8a822e62f20965854a242f895d03
> change-id: 20230807-clk-fix-17e895f79817
>
> Best regards,
>
Reviewed-by: Sean Anderson <seanga2 at gmail.com>
More information about the U-Boot
mailing list