clk: scmi: Bulk allocate all sub-driver instance data
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Sun, 9 Nov 2025 01:35:06 +0000 (02:35 +0100)
committerPeng Fan <peng.fan@nxp.com>
Mon, 10 Nov 2025 12:57:46 +0000 (20:57 +0800)
commitef52f697f281a88f5fa63608d50838b197cc4e9d
tree7eb4396e07b0f45482d1c8dc5a20d7b637705013
parent66cb830291b78389eb995960ee5e1460aedd7447
clk: scmi: Bulk allocate all sub-driver instance data

Allocate all sub-driver instance data at once. The amount of data that
have to be allocated is known up front, so is the size of the data, so
there is no need to call malloc() in a loop, mallocate all data at once.

The upside is, less heap fragmentation and fewer malloc() calls overall,
and a faster boot time.

The downside is, if some of the clock fail to register, then the clock
driver cannot free parts of the bulk allocated sub-driver instance data.
Such a failure can only occur if clk_register() were to fail, and if that
happens, the system has more significant problems. Worse, if a core clock
driver fails to probe, the system has even bigger problem.

Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/clk/clk_scmi.c