]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
soc: fsl: cpm1: qmc: Introduce qmc_chan_count_phandles()
authorHerve Codina <herve.codina@bootlin.com>
Mon, 1 Jul 2024 11:30:35 +0000 (13:30 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 4 Jul 2024 11:24:59 +0000 (12:24 +0100)
No function in the QMC API is available to get the number of phandles
present in a phandle list.

Fill this lack introducing qmc_chan_count_phandles().

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
Link: https://patch.msgid.link/20240701113038.55144-9-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/soc/fsl/qe/qmc.c
include/soc/fsl/qe/qmc.h

index e23d600184006bbc5a6ca144bc2476fafdede616..76bb496305a0e0a241c3f2acf088b94478128b4f 100644 (file)
@@ -1777,6 +1777,19 @@ static struct qmc_chan *qmc_chan_get_from_qmc(struct device_node *qmc_np, unsign
        return qmc_chan;
 }
 
+int qmc_chan_count_phandles(struct device_node *np, const char *phandles_name)
+{
+       int count;
+
+       /* phandles are fixed args phandles with one arg */
+       count = of_count_phandle_with_args(np, phandles_name, NULL);
+       if (count < 0)
+               return count;
+
+       return count / 2;
+}
+EXPORT_SYMBOL(qmc_chan_count_phandles);
+
 struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
                                               const char *phandles_name,
                                               int index)
index 0fa7205145cec11615d2532beb3aee8c518c53f9..294e42ea8d4c5088f4d1ee6b568ab6568182ac44 100644 (file)
@@ -16,6 +16,8 @@ struct device_node;
 struct device;
 struct qmc_chan;
 
+int qmc_chan_count_phandles(struct device_node *np, const char *phandles_name);
+
 struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
                                               const char *phandles_name,
                                               int index);