public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] greybus: audio: extract topology size retrieval into a helper
@ 2026-04-11 18:20 Hungyu Lin
  2026-04-13  7:04 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Hungyu Lin @ 2026-04-11 18:20 UTC (permalink / raw)
  To: Vaibhav Agarwal, Mark Greer
  Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman, greybus-dev,
	linux-staging, linux-kernel, Hungyu Lin

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] greybus: audio: extract topology size retrieval into a helper
  2026-04-11 18:20 [PATCH] greybus: audio: extract topology size retrieval into a helper Hungyu Lin
@ 2026-04-13  7:04 ` Dan Carpenter
  2026-04-13  7:16   ` Denny Lin
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2026-04-13  7:04 UTC (permalink / raw)
  To: Hungyu Lin
  Cc: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman, greybus-dev, linux-staging, linux-kernel

On Sat, Apr 11, 2026 at 06:20:55PM +0000, Hungyu Lin wrote:
> 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(-)

I don't see how this is a cleanup at all...

If you were the maintainer of the code, then you could do whatever
you want, but this is your first kernel patch.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] greybus: audio: extract topology size retrieval into a helper
  2026-04-13  7:04 ` Dan Carpenter
@ 2026-04-13  7:16   ` Denny Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Denny Lin @ 2026-04-13  7:16 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman, greybus-dev, linux-staging, linux-kernel

Hi Dan,

Thanks for the feedback. I understand and will focus on more
meaningful changes next time.

Best regards,
Hungyu

On Mon, Apr 13, 2026 at 12:04 AM Dan Carpenter <error27@gmail.com> wrote:
>
> On Sat, Apr 11, 2026 at 06:20:55PM +0000, Hungyu Lin wrote:
> > 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(-)
>
> I don't see how this is a cleanup at all...
>
> If you were the maintainer of the code, then you could do whatever
> you want, but this is your first kernel patch.
>
> regards,
> dan carpenter
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-13  7:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-11 18:20 [PATCH] greybus: audio: extract topology size retrieval into a helper Hungyu Lin
2026-04-13  7:04 ` Dan Carpenter
2026-04-13  7:16   ` Denny Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox