From: Hungyu Lin <dennylin0707@gmail.com>
To: Vaibhav Agarwal <vaibhav.sr@gmail.com>,
Mark Greer <mgreer@animalcreek.com>
Cc: Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org, Hungyu Lin <dennylin0707@gmail.com>
Subject: [PATCH] greybus: audio: extract topology size retrieval into a helper
Date: Sat, 11 Apr 2026 18:20:55 +0000 [thread overview]
Message-ID: <20260411182055.24413-1-dennylin0707@gmail.com> (raw)
The topology retrieval code currently mixes the size query with
allocation and data fetch in a single function.
Extract the size query into a helper to make the control flow clearer.
No functional change.
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
drivers/staging/greybus/audio_gb.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c
index 9d8994fdb41a..d95f8b7d4ce2 100644
--- a/drivers/staging/greybus/audio_gb.c
+++ b/drivers/staging/greybus/audio_gb.c
@@ -8,21 +8,33 @@
#include <linux/greybus.h>
#include "audio_codec.h"
+static int gb_audio_gb_get_topology_size(struct gb_connection *connection,
+ u16 *size)
+{
+ struct gb_audio_get_topology_size_response size_resp;
+ int ret;
+
+ ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
+ NULL, 0, &size_resp, sizeof(size_resp));
+ if (ret)
+ return ret;
+
+ *size = le16_to_cpu(size_resp.size);
+ return 0;
+}
+
/* TODO: Split into separate calls */
int gb_audio_gb_get_topology(struct gb_connection *connection,
struct gb_audio_topology **topology)
{
- struct gb_audio_get_topology_size_response size_resp;
struct gb_audio_topology *topo;
u16 size;
int ret;
- ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
- NULL, 0, &size_resp, sizeof(size_resp));
+ ret = gb_audio_gb_get_topology_size(connection, &size);
if (ret)
return ret;
- size = le16_to_cpu(size_resp.size);
if (size < sizeof(*topo))
return -ENODATA;
--
2.34.1
reply other threads:[~2026-04-11 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260411182055.24413-1-dennylin0707@gmail.com \
--to=dennylin0707@gmail.com \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mgreer@animalcreek.com \
--cc=vaibhav.sr@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox