[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250413073220.15931-5-ganeshkpittala@gmail.com>
Date: Sun, 13 Apr 2025 07:32:20 +0000
From: Ganesh Kumar Pittala <ganeshkpittala@...il.com>
To: johan@...nel.org,
elder@...nel.org,
gregkh@...uxfoundation.org
Cc: greybus-dev@...ts.linaro.org,
linux-staging@...ts.linux.dev,
linux-kernel@...r.kernel.org,
hvaibhav.linux@...il.com,
vaibhav.sr@...il.com,
mgreer@...malcreek.com,
rmfrfs@...il.com,
pure.logic@...us-software.ie,
ganeshkpittala@...il.com
Subject: [PATCH v2 4/4] staging: greybus: split gb_audio_gb_get_topology into helper functions
This patch addresses the TODO in gb_audio_gb_get_topology() by
splitting its logic into two smaller internal helper functions:
- gb_audio_get_topology_size()
- gb_audio_read_topology()
This improves modularity and readability while preserving the
original behavior and interface.
Signed-off-by: Ganesh Kumar Pittala <ganeshkpittala@...il.com>
---
drivers/staging/greybus/audio_gb.c | 36 +++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/greybus/audio_gb.c b/drivers/staging/greybus/audio_gb.c
index 9d8994fdb41a..92cfd1a6fc10 100644
--- a/drivers/staging/greybus/audio_gb.c
+++ b/drivers/staging/greybus/audio_gb.c
@@ -8,21 +8,28 @@
#include <linux/greybus.h>
#include "audio_codec.h"
-/* TODO: Split into separate calls */
-int gb_audio_gb_get_topology(struct gb_connection *connection,
- struct gb_audio_topology **topology)
+static int gb_audio_gb_get_topology_size(struct gb_connection *connection,
+ u16 *size)
{
- struct gb_audio_get_topology_size_response size_resp;
- struct gb_audio_topology *topo;
- u16 size;
+ struct gb_audio_get_topology_size_response resp;
int ret;
ret = gb_operation_sync(connection, GB_AUDIO_TYPE_GET_TOPOLOGY_SIZE,
- NULL, 0, &size_resp, sizeof(size_resp));
+ NULL, 0, &resp, sizeof(resp));
if (ret)
return ret;
- size = le16_to_cpu(size_resp.size);
+ *size = le16_to_cpu(resp.size);
+ return 0;
+}
+
+static int gb_audio_gb_read_topology(struct gb_connection *connection,
+ struct gb_audio_topology **topology,
+ u16 size)
+{
+ struct gb_audio_topology *topo;
+ int ret;
+
if (size < sizeof(*topo))
return -ENODATA;
@@ -41,6 +48,19 @@ int gb_audio_gb_get_topology(struct gb_connection *connection,
return 0;
}
+
+int gb_audio_gb_get_topology(struct gb_connection *connection,
+ struct gb_audio_topology **topology)
+{
+ u16 size;
+ int ret;
+
+ ret = gb_audio_gb_get_topology_size(connection, &size);
+ if (ret)
+ return ret;
+
+ return gb_audio_gb_read_topology(connection, topology, size);
+}
EXPORT_SYMBOL_GPL(gb_audio_gb_get_topology);
int gb_audio_gb_get_control(struct gb_connection *connection,
--
2.43.0
Powered by blists - more mailing lists