Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ASoC: rsnd: Refactor port handling with helper for endpoint node selection

Refactor the code responsible for selecting the correct device node for
audio endpoint parsing in the rsnd driver. A new helper function
`rsnd_pick_endpoint_node_for_ports()` is introduced to handle the
selection of the endpoint node by checking whether the port is named
'port' or 'ports'.

This change simplifies the logic in both `rsnd_dai_of_node()` and
`rsnd_dai_probe()` functions by replacing repetitive condition checks
with the new helper.

Suggested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://patch.msgid.link/20241011175346.1093649-1-prabhakar.mahadev-lad.rj@bp.renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Lad Prabhakar and committed by
Mark Brown
daf5e3c6 43916d92

+21 -9
+21 -9
sound/soc/sh/rcar/core.c
··· 1233 1233 return i; 1234 1234 } 1235 1235 1236 + static struct device_node* 1237 + rsnd_pick_endpoint_node_for_ports(struct device_node *e_ports, 1238 + struct device_node *e_port) 1239 + { 1240 + if (of_node_name_eq(e_ports, "ports")) 1241 + return e_ports; 1242 + 1243 + if (of_node_name_eq(e_ports, "port")) 1244 + return e_port; 1245 + 1246 + return NULL; 1247 + } 1248 + 1236 1249 static int rsnd_dai_of_node(struct rsnd_priv *priv, int *is_graph) 1237 1250 { 1238 1251 struct device *dev = rsnd_priv_to_dev(priv); ··· 1291 1278 * Audio-Graph-Card 1292 1279 */ 1293 1280 for_each_child_of_node(np, ports) { 1294 - if (!of_node_name_eq(ports, "ports") && 1295 - !of_node_name_eq(ports, "port")) 1281 + node = rsnd_pick_endpoint_node_for_ports(ports, np); 1282 + if (!node) 1296 1283 continue; 1297 - priv->component_dais[i] = 1298 - of_graph_get_endpoint_count(of_node_name_eq(ports, "ports") ? 1299 - ports : np); 1284 + priv->component_dais[i] = of_graph_get_endpoint_count(node); 1300 1285 nr += priv->component_dais[i]; 1301 1286 i++; 1302 1287 if (i >= RSND_MAX_COMPONENT) { ··· 1499 1488 */ 1500 1489 dai_i = 0; 1501 1490 if (is_graph) { 1491 + struct device_node *dai_np_port; 1502 1492 struct device_node *ports; 1503 1493 struct device_node *dai_np; 1504 1494 1505 1495 for_each_child_of_node(np, ports) { 1506 - if (!of_node_name_eq(ports, "ports") && 1507 - !of_node_name_eq(ports, "port")) 1496 + dai_np_port = rsnd_pick_endpoint_node_for_ports(ports, np); 1497 + if (!dai_np_port) 1508 1498 continue; 1509 - for_each_endpoint_of_node(of_node_name_eq(ports, "ports") ? 1510 - ports : np, dai_np) { 1499 + 1500 + for_each_endpoint_of_node(dai_np_port, dai_np) { 1511 1501 __rsnd_dai_probe(priv, dai_np, dai_np, 0, dai_i); 1512 1502 if (!rsnd_is_gen1(priv) && !rsnd_is_gen2(priv)) { 1513 1503 rdai = rsnd_rdai_get(priv, dai_i);