Re: [PATCH v2] staging: greybus: move topology allocation to codec probe

From: Greg KH

Date: Tue Feb 24 2026 - 13:10:01 EST


On Tue, Feb 24, 2026 at 09:44:23AM +0100, Jose A. Perez de Azpillaga wrote:
> The FIXME in gb_audio_probe noted that memory allocation for the
> topology should happen within the codec driver rather than the
> greybus helper.
>
> Move the size-check and kzalloc from audio_gb.c to audio_module.c
> and update the function signature of gb_audio_gb_get_topology to
> accept the pointer. This clarifies ownership of the allocated memory.
>
> Reported-by: kernel test robot <lkp@xxxxxxxxx>

The kernel test robot did not ask for this patch, it reported a problem
with your v1 patch.

> Closes: https://lore.kernel.org/oe-kbuild-all/202602240844.4eT24iVh-lkp@xxxxxxxxx/

Nor does this change fix anything.


> Signed-off-by: Jose A. Perez de Azpillaga <azpijr@xxxxxxxxx>
> ---
> v2:
> - Fixed build error by updating function prototype in audio_codec.h.
> - Fixed 'struct gb_audio_topology has no member named size' by passing
> size as an explicit argument to gb_audio_gb_get_topology().

Did you test this version as well? But step back, why is this change
needed at all?

> ---
> drivers/staging/greybus/audio_codec.h | 2 +-
> drivers/staging/greybus/audio_gb.c | 33 +++-----------------------
> drivers/staging/greybus/audio_module.c | 27 +++++++++++++++++----
> 3 files changed, 26 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/staging/greybus/audio_codec.h b/drivers/staging/greybus/audio_codec.h
> index f3f7a7ec6be4..2d7c3f928b1d 100644
> --- a/drivers/staging/greybus/audio_codec.h
> +++ b/drivers/staging/greybus/audio_codec.h
> @@ -179,7 +179,7 @@ void gbaudio_unregister_module(struct gbaudio_module_info *module);
>
> /* protocol related */
> int gb_audio_gb_get_topology(struct gb_connection *connection,
> - struct gb_audio_topology **topology);
> + struct gb_audio_topology *topology, u16 size);

Adding a random new field to a function means that we need to look up
what that value is to try to figure out what is going on. That makes
things much harder overall. So did this make the code harder to
understand?

Why can't the size be determined automatically by this function?

thanks,

greg k-h