Re: sound/pci/ctxfi/ctdaio.c: duplicate function removal question

From: Takashi Iwai
Date: Sun Dec 29 2024 - 03:32:33 EST


On Wed, 25 Dec 2024 00:16:17 +0100,
Ethan Carter Edwards wrote:
>
> Hello all,
>
> First of all, happy holidays.
>
> I was browsing the ctdaio.c code and I noticed a lot of
> duplicate code and functions, specifically:
>
> dao_set_{right,left}_input and
> dao_clear_{right,left}_input functions.
>
> The functions are pretty much identical. They only
> differ in the side (left, right). What was the original
> idea in doing this? Wouldn't it make more since to just
> have an ENUM (left, right) as an argument that would
> determine the side and just reduce the function to
> dao_set_input and dao_clear_input.
>
> I would be more than happy to send in a patch doing
> these changes, but before I did I wanted to ask if
> there was a reason the code was written in this way.
> I am pretty new to kernel development.

Yes, the code simplification would be appreciated.
You can create a common function and call with the left/right
argument from each callback or change the call pattern from ctatc.c.


thanks,

Takashi