Skip to content

Commit 66a4ff3

Browse files
krzkChristophe Leroy (CS GROUP)
authored andcommitted
soc: fsl: qe: Simplify with scoped for each OF child loop
Use scoped for-each loop when iterating over device nodes to make code a bit simpler. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com> Acked-by: Herve Codina <herve.codina@bootlin.com> Link: https://lore.kernel.org/r/20260102124754.64122-2-krzysztof.kozlowski@oss.qualcomm.com Signed-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
1 parent 148891e commit 66a4ff3

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

drivers/soc/fsl/qe/qmc.c

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,31 +1284,26 @@ static unsigned int qmc_nb_chans(struct qmc *qmc)
12841284

12851285
static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)
12861286
{
1287-
struct device_node *chan_np;
12881287
struct qmc_chan *chan;
12891288
const char *mode;
12901289
u32 chan_id;
12911290
u64 ts_mask;
12921291
int ret;
12931292

1294-
for_each_available_child_of_node(np, chan_np) {
1293+
for_each_available_child_of_node_scoped(np, chan_np) {
12951294
ret = of_property_read_u32(chan_np, "reg", &chan_id);
12961295
if (ret) {
12971296
dev_err(qmc->dev, "%pOF: failed to read reg\n", chan_np);
1298-
of_node_put(chan_np);
12991297
return ret;
13001298
}
13011299
if (chan_id > 63) {
13021300
dev_err(qmc->dev, "%pOF: Invalid chan_id\n", chan_np);
1303-
of_node_put(chan_np);
13041301
return -EINVAL;
13051302
}
13061303

13071304
chan = devm_kzalloc(qmc->dev, sizeof(*chan), GFP_KERNEL);
1308-
if (!chan) {
1309-
of_node_put(chan_np);
1305+
if (!chan)
13101306
return -ENOMEM;
1311-
}
13121307

13131308
chan->id = chan_id;
13141309
spin_lock_init(&chan->ts_lock);
@@ -1319,7 +1314,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)
13191314
if (ret) {
13201315
dev_err(qmc->dev, "%pOF: failed to read fsl,tx-ts-mask\n",
13211316
chan_np);
1322-
of_node_put(chan_np);
13231317
return ret;
13241318
}
13251319
chan->tx_ts_mask_avail = ts_mask;
@@ -1329,7 +1323,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)
13291323
if (ret) {
13301324
dev_err(qmc->dev, "%pOF: failed to read fsl,rx-ts-mask\n",
13311325
chan_np);
1332-
of_node_put(chan_np);
13331326
return ret;
13341327
}
13351328
chan->rx_ts_mask_avail = ts_mask;
@@ -1340,7 +1333,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)
13401333
if (ret && ret != -EINVAL) {
13411334
dev_err(qmc->dev, "%pOF: failed to read fsl,operational-mode\n",
13421335
chan_np);
1343-
of_node_put(chan_np);
13441336
return ret;
13451337
}
13461338
if (!strcmp(mode, "transparent")) {
@@ -1350,7 +1342,6 @@ static int qmc_of_parse_chans(struct qmc *qmc, struct device_node *np)
13501342
} else {
13511343
dev_err(qmc->dev, "%pOF: Invalid fsl,operational-mode (%s)\n",
13521344
chan_np, mode);
1353-
of_node_put(chan_np);
13541345
return -EINVAL;
13551346
}
13561347

0 commit comments

Comments
 (0)