Hi Marek,

On Tue, Oct 28, 2025 at 04:41:05AM +0100, Marek Vasut wrote:
>The clock names are retrived via SCMI_CLOCK_ATTRIBUTES, called for each
>clock ID. This may take a lot of time to complete and is not strictly
>necessary. Register each clock as "scmi-%zu" instead, and let the first
>call of SCMI_CLOCK_ATTRIBUTES fill in the actual clock name.
>
>This has a side effect, which can be considered both an upside and also
>a downside. Unused clock are never renamed and retain their placeholder
>"scmi-%zu" name, which avoids empty clock names for nameless SCMI clock,
>and avoids the name resolution and improves boot time. But for those
>SCMI clock which do have name, that name is not listed until the clock
>are used.
>
>This is a preparatory patch for deferred issue of SCMI_CLOCK_ATTRIBUTES.
>
>Signed-off-by: Marek Vasut <[email protected]>
>---
>Cc: Alice Guo <[email protected]>
>Cc: Patrice Chotard <[email protected]>
>Cc: Patrick Delaunay <[email protected]>
>Cc: Peng Fan <[email protected]>
>Cc: Sean Anderson <[email protected]>
>Cc: Tom Rini <[email protected]>
>Cc: Valentin Caron <[email protected]>
>Cc: Vinh Nguyen <[email protected]>
>Cc: [email protected]
>---
> drivers/clk/clk_scmi.c | 25 +++++++++++--------------
> 1 file changed, 11 insertions(+), 14 deletions(-)
>
>diff --git a/drivers/clk/clk_scmi.c b/drivers/clk/clk_scmi.c
>index 3ee2df0ca9b..afaeb84e65d 100644
>--- a/drivers/clk/clk_scmi.c
>+++ b/drivers/clk/clk_scmi.c
>@@ -16,6 +16,7 @@
> 
> struct clk_scmi {
>       struct clk clk;
>+      char name[SCMI_CLOCK_NAME_LENGTH_MAX];
>       u32 ctrl_flags;
> };
> 
>@@ -325,24 +326,20 @@ static int scmi_clk_probe(struct udevice *dev)
>               return -ENOMEM;
> 
>       for (i = 0; i < num_clocks; i++) {
>-              char *clock_name;
>+              clk_scmi = clk_scmi_bulk + i;
>+              char *clock_name = clk_scmi->name;
>               u32 attributes;
> 
>-              if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {
>-                      clk_scmi = clk_scmi_bulk + i;
>-                      if (!clock_name)
>-                              ret = -ENOMEM;
>-                      else
>-                              ret = clk_register(&clk_scmi->clk, 
>dev->driver->name,
>-                                                 clock_name, dev->name);
>-
>-                      if (ret) {
>-                              free(clock_name);
>-                              return ret;
>-                      }
>+              snprintf(clock_name, SCMI_CLOCK_NAME_LENGTH_MAX, "scmi-%zu", i);
>+
>+              ret = clk_register(&clk_scmi->clk, dev->driver->name,
>+                                 clock_name, dev->name);
>+              if (ret)
>+                      return ret;
> 
>-                      dev_clk_dm(dev, i, &clk_scmi->clk);
>+              dev_clk_dm(dev, i, &clk_scmi->clk);
> 
>+              if (!scmi_clk_get_attibute(dev, i, &clock_name, &attributes)) {

There is still scmi_clk_get_attibute for each clock. In commit log, 
you mentioned this takes lot time to complete. I may miss something,
what is improved in this change?

Thanks,
Peng

>                       if (CLK_HAS_RESTRICTIONS(attributes)) {
>                               u32 perm;
> 
>-- 
>2.51.0
>

Reply via email to