Re: [PATCH v2] staging: greybus: audio: split topology get into size and data calls

From: Dan Carpenter

Date: Wed Jul 01 2026 - 01:05:00 EST


On Wed, Jul 01, 2026 at 02:19:08AM +0530, adi25charis@xxxxxxxxx wrote:
> From: Aditya Chari S <adi25charis@xxxxxxxxx>
>
> gb_audio_gb_get_topology() combined three separate responsibilities
> into a single call: querying the topology size, allocating a buffer
> for it, and fetching the topology data into that buffer. This left
> callers with no way to perform any of these steps independently, and
> forced the kzalloc() allocation to live inside the protocol-layer
> driver rather than the caller, as already flagged by a FIXME comment
> at the call site in audio_module.c.
>
> Split the function into two:
>
> gb_audio_gb_get_topology_size() - queries only the topology size
> gb_audio_gb_get_topology() - fetches topology data into a
> caller-supplied buffer of a
> given size
>
> Update the only caller, gb_audio_probe() in audio_module.c, to query
> the size first, allocate the topology buffer itself, then fetch the
> data into it, freeing the buffer via the existing free_topology error
> path on failure.
>
> This resolves both the "TODO: Split into separate calls" comment
> above the original function in audio_gb.c and the FIXME comment at
> the call site in audio_module.c, both of which are removed as part
> of this change.
>
> No functional change in behavior for the existing probe path.
>
> Compile-tested with W=1, sparse (C=2), and checkpatch.pl; all clean
> on the three changed files (audio_gb.c, audio_module.c, audio_codec.h).
>
> Signed-off-by: Aditya Chari S <adi25charis@xxxxxxxxx>
>
> ----------
> v2:
> - Fold in review feedback from Dan Carpenter.
> - Store topology size as size_t instead of u16.
> - Move topology size validation into gb_audio_probe() before kzalloc().
> - Use -EINVAL for invalid topology size.
> - Drop unrelated dev_err() formatting cleanup.
> - Compile-tested with `make M=drivers/staging/greybus`.
> - Run checkpatch.pl on the updated patch; no issues reported.
> ---

Thanks!

Reviewed-by: Dan Carpenter <error27@xxxxxxxxx>

regards,
dan carpenter