linux/drivers/staging/greybus
Aditya Chari da8b3221d3 greybus: audio: Split gb_audio_gb_get_topology() into size query and data fetch
`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. The topology size is now
stored as `size_t` and validated in the caller before allocation,
addressing the earlier TODO and FIXME comments.

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.

Signed-off-by: Aditya Chari S <adi25charis@gmail.com>
Reviewed-by: Dan Carpenter <error27@gmail.com>
Link: https://patch.msgid.link/20260725155108.7060-1-adi25charis@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-07-28 09:24:56 +02:00
..
Documentation staging: greybus: fix typo in sysfs-bus-greybus 2026-05-04 16:17:55 +02:00
arche-apb-ctrl.c Replace <linux/mod_devicetable.h> by more specific <linux/device-id/*.h> (c files) 2026-07-03 07:38:17 +02:00
arche-platform.c staging: greybus: arche-platform: Use sysfs_emit instead of sprintf 2026-03-09 17:02:34 +01:00
arche_platform.h staging: greybus: correct SPDX License Identifier 2018-11-09 09:49:02 -08:00
audio_apbridgea.c staging: greybus: move core include files to include/linux/greybus/ 2019-08-27 19:02:59 +02:00
audio_apbridgea.h greybus: audio: apbridgea: Remove flexible array from struct audio_apbridgea_hdr 2024-03-05 13:59:14 +00:00
audio_codec.c staging: greybus: audio_codec: remove redundant else-if check 2026-07-07 11:19:05 +02:00
audio_codec.h greybus: audio: Split gb_audio_gb_get_topology() into size query and data fetch 2026-07-28 09:24:56 +02:00
audio_gb.c greybus: audio: Split gb_audio_gb_get_topology() into size query and data fetch 2026-07-28 09:24:56 +02:00
audio_helper.c ASoC: audio_helper: convert to snd_soc_dapm_xxx() 2025-11-17 00:14:22 +00:00
audio_helper.h staging: greybus: audio: Add helper APIs for dynamic audio modules 2020-07-29 16:40:09 +02:00
audio_manager.c staging: greybus: audio: remove unused gb_audio_manager_get_module() 2026-02-25 07:04:51 -08:00
audio_manager.h staging: greybus: audio: remove unused gb_audio_manager_get_module() 2026-02-25 07:04:51 -08:00
audio_manager_module.c staging: greybus: audio: drop stale TODO comment 2026-02-25 07:05:07 -08:00
audio_manager_private.h staging: greybus: Modify lines end with a '(' 2023-10-17 15:42:27 +02:00
audio_manager_sysfs.c staging: greybus: audio: correct sscanf() return value check 2026-07-07 11:17:41 +02:00
audio_module.c greybus: audio: Split gb_audio_gb_get_topology() into size query and data fetch 2026-07-28 09:24:56 +02:00
audio_topology.c ASoC: audio_topology: convert to snd_soc_dapm_xxx() 2025-11-17 00:14:23 +00:00
authentication.c staging: greybus: remove unused macro CAP_TIMEOUT_MS 2026-07-07 11:18:41 +02:00
bootrom.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
camera.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
firmware.h staging: greybus: move core include files to include/linux/greybus/ 2019-08-27 19:02:59 +02:00
fw-core.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fw-download.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
fw-management.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
gb-camera.h staging: greybus: gb-camera: fix configure_streams indentation 2026-01-11 13:50:20 +01:00
gbphy.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
gbphy.h staging: greybus: Add identifier name to function definition argument 2020-08-18 16:07:17 +02:00
gpio.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
greybus_authentication.h staging: greybus: Replace __attribute__((packed)) by __packed in various instances 2024-03-07 21:40:52 +00:00
greybus_firmware.h staging: greybus: Replaces directive __attribute__((packed)) by __packed as suggested by checkpatch 2024-03-07 21:40:52 +00:00
hid.c staging: greybus: hid: fix SET_REPORT return value 2026-07-07 11:20:55 +02:00
i2c.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig staging: greybus: Fix spelling mistake in Kconfig 2026-02-23 14:58:24 +01:00
light.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
log.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
loopback.c staging: greybus: Remove unused macro 2026-07-07 11:19:33 +02:00
Makefile staging: greybus: audio: Enable GB codec, audio module compilation. 2020-07-29 16:40:26 +02:00
power_supply.c staging: greybus: power_supply: remove unnecessary parentheses in return 2026-07-07 11:19:57 +02:00
pwm.c staging: greybus: pwm: Fix typo in comment 2026-02-23 14:55:59 +01:00
raw.c greybus: raw: fix use-after-free if write is called after disconnect 2026-03-31 10:33:48 +02:00
sdio.c staging: greybus: sdio: Remove double whitespace 2026-02-23 14:59:02 +01:00
spi.c staging: greybus: add missing MODULE_DESCRIPTION() macros 2024-06-24 15:17:58 +02:00
spilib.c spi: fix controller registration API inconsistency 2026-05-21 12:25:55 +01:00
spilib.h staging: greybus: fix up SPDX comment in .h files 2019-08-27 19:02:18 +02:00
TODO staging: greybus: remove completed GPIO conversion task from TODO 2026-01-27 15:46:11 +01:00
uart.c staging: greybus: uart: return tty_alloc_driver() errors 2026-07-17 14:18:36 +02:00
usb.c staging: greybus: add missing MODULE_DESCRIPTION() macros 2024-06-24 15:17:58 +02:00
vibrator.c staging: greybus: vibrator: return device_create() errors 2026-07-07 11:20:00 +02:00