]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: codecs: wsa881x: Use designator array initializers for Soundwire ports
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Thu, 25 Jul 2024 11:23:43 +0000 (13:23 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 29 Jul 2024 00:41:16 +0000 (01:41 +0100)
Two arrays (with 'struct sdw_dpn_prop' and 'struct sdw_port_config')
store configuration of Soundwire ports, thus each of their element is
indexed according to the port number (enum wsa_port_ids, e.g.
WSA881X_PORT_DAC).  Except the indexing, they also store port number
offset by one in member 'num'.

Entire code depends on that correlation between array index and port
number, thus make it explicit by using designators.  The code is
functionally the same, but more obvious for reading.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://patch.msgid.link/20240725-asoc-wsa88xx-port-arrays-v1-1-80a03f440c72@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wsa881x.c

index 0478599d0f359f2fbd64bc353e7b179b90adafd2..a5e05c05fd3dc144e02b7cf79e7903fc7d25c92d 100644 (file)
@@ -386,33 +386,32 @@ enum wsa_port_ids {
 
 /* 4 ports */
 static struct sdw_dpn_prop wsa_sink_dpn_prop[WSA881X_MAX_SWR_PORTS] = {
-       {
-               /* DAC */
-               .num = 1,
+       [WSA881X_PORT_DAC] = {
+               .num = WSA881X_PORT_DAC + 1,
                .type = SDW_DPN_SIMPLE,
                .min_ch = 1,
                .max_ch = 1,
                .simple_ch_prep_sm = true,
                .read_only_wordlength = true,
-       }, {
-               /* COMP */
-               .num = 2,
+       },
+       [WSA881X_PORT_COMP] = {
+               .num = WSA881X_PORT_COMP + 1,
                .type = SDW_DPN_SIMPLE,
                .min_ch = 1,
                .max_ch = 1,
                .simple_ch_prep_sm = true,
                .read_only_wordlength = true,
-       }, {
-               /* BOOST */
-               .num = 3,
+       },
+       [WSA881X_PORT_BOOST] = {
+               .num = WSA881X_PORT_BOOST + 1,
                .type = SDW_DPN_SIMPLE,
                .min_ch = 1,
                .max_ch = 1,
                .simple_ch_prep_sm = true,
                .read_only_wordlength = true,
-       }, {
-               /* VISENSE */
-               .num = 4,
+       },
+       [WSA881X_PORT_VISENSE] = {
+               .num = WSA881X_PORT_VISENSE + 1,
                .type = SDW_DPN_SIMPLE,
                .min_ch = 1,
                .max_ch = 1,
@@ -422,17 +421,20 @@ static struct sdw_dpn_prop wsa_sink_dpn_prop[WSA881X_MAX_SWR_PORTS] = {
 };
 
 static const struct sdw_port_config wsa881x_pconfig[WSA881X_MAX_SWR_PORTS] = {
-       {
-               .num = 1,
+       [WSA881X_PORT_DAC] = {
+               .num = WSA881X_PORT_DAC + 1,
                .ch_mask = 0x1,
-       }, {
-               .num = 2,
+       },
+       [WSA881X_PORT_COMP] = {
+               .num = WSA881X_PORT_COMP + 1,
                .ch_mask = 0xf,
-       }, {
-               .num = 3,
+       },
+       [WSA881X_PORT_BOOST] = {
+               .num = WSA881X_PORT_BOOST + 1,
                .ch_mask = 0x3,
-       }, {    /* IV feedback */
-               .num = 4,
+       },
+       [WSA881X_PORT_VISENSE] = {
+               .num = WSA881X_PORT_VISENSE + 1,
                .ch_mask = 0x3,
        },
 };