[PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list

Herve Codina posted 10 patches 1 year, 5 months ago
[PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
Posted by Herve Codina 1 year, 5 months ago
qmc_chan_get_byphandle() and the resource managed version retrieve a
channel from a simple phandle.

Extend the API and introduce qmc_chan_get_byphandles_index() and the
resource managed version in order to retrieve a channel from a phandle
list using the provided index to identify the phandle in the list.

Also update qmc_chan_get_byphandle() and the resource managed version to
use qmc_chan_get_byphandles_index() and so avoid code duplication.

Signed-off-by: Herve Codina <herve.codina@bootlin.com>
---
 drivers/soc/fsl/qe/qmc.c | 19 +++++++++++--------
 include/soc/fsl/qe/qmc.h | 25 ++++++++++++++++++++++---
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/fsl/qe/qmc.c b/drivers/soc/fsl/qe/qmc.c
index f498db9abe35..e23d60018400 100644
--- a/drivers/soc/fsl/qe/qmc.c
+++ b/drivers/soc/fsl/qe/qmc.c
@@ -1777,13 +1777,15 @@ static struct qmc_chan *qmc_chan_get_from_qmc(struct device_node *qmc_np, unsign
 	return qmc_chan;
 }
 
-struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phandle_name)
+struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
+					       const char *phandles_name,
+					       int index)
 {
 	struct of_phandle_args out_args;
 	struct qmc_chan *qmc_chan;
 	int ret;
 
-	ret = of_parse_phandle_with_fixed_args(np, phandle_name, 1, 0,
+	ret = of_parse_phandle_with_fixed_args(np, phandles_name, 1, index,
 					       &out_args);
 	if (ret < 0)
 		return ERR_PTR(ret);
@@ -1797,7 +1799,7 @@ struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phan
 	of_node_put(out_args.np);
 	return qmc_chan;
 }
-EXPORT_SYMBOL(qmc_chan_get_byphandle);
+EXPORT_SYMBOL(qmc_chan_get_byphandles_index);
 
 struct qmc_chan *qmc_chan_get_bychild(struct device_node *np)
 {
@@ -1827,9 +1829,10 @@ static void devm_qmc_chan_release(struct device *dev, void *res)
 	qmc_chan_put(*qmc_chan);
 }
 
-struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
-					     struct device_node *np,
-					     const char *phandle_name)
+struct qmc_chan *devm_qmc_chan_get_byphandles_index(struct device *dev,
+						    struct device_node *np,
+						    const char *phandles_name,
+						    int index)
 {
 	struct qmc_chan *qmc_chan;
 	struct qmc_chan **dr;
@@ -1838,7 +1841,7 @@ struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
 	if (!dr)
 		return ERR_PTR(-ENOMEM);
 
-	qmc_chan = qmc_chan_get_byphandle(np, phandle_name);
+	qmc_chan = qmc_chan_get_byphandles_index(np, phandles_name, index);
 	if (!IS_ERR(qmc_chan)) {
 		*dr = qmc_chan;
 		devres_add(dev, dr);
@@ -1848,7 +1851,7 @@ struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
 
 	return qmc_chan;
 }
-EXPORT_SYMBOL(devm_qmc_chan_get_byphandle);
+EXPORT_SYMBOL(devm_qmc_chan_get_byphandles_index);
 
 struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev,
 					   struct device_node *np)
diff --git a/include/soc/fsl/qe/qmc.h b/include/soc/fsl/qe/qmc.h
index 2a333fc1ea81..0fa7205145ce 100644
--- a/include/soc/fsl/qe/qmc.h
+++ b/include/soc/fsl/qe/qmc.h
@@ -16,11 +16,30 @@ struct device_node;
 struct device;
 struct qmc_chan;
 
-struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phandle_name);
+struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
+					       const char *phandles_name,
+					       int index);
+struct qmc_chan *devm_qmc_chan_get_byphandles_index(struct device *dev,
+						    struct device_node *np,
+						    const char *phandles_name,
+						    int index);
+
+static inline struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np,
+						      const char *phandle_name)
+{
+	return qmc_chan_get_byphandles_index(np, phandle_name, 0);
+}
+
+static inline struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
+							   struct device_node *np,
+							   const char *phandle_name)
+{
+	return devm_qmc_chan_get_byphandles_index(dev, np, phandle_name, 0);
+}
+
 struct qmc_chan *qmc_chan_get_bychild(struct device_node *np);
 void qmc_chan_put(struct qmc_chan *chan);
-struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev, struct device_node *np,
-					     const char *phandle_name);
+
 struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev, struct device_node *np);
 
 enum qmc_mode {
-- 
2.45.0
Re: [PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
Posted by Mark Brown 1 year, 5 months ago
On Mon, Jul 01, 2024 at 01:30:34PM +0200, Herve Codina wrote:
> qmc_chan_get_byphandle() and the resource managed version retrieve a
> channel from a simple phandle.
> 
> Extend the API and introduce qmc_chan_get_byphandles_index() and the
> resource managed version in order to retrieve a channel from a phandle
> list using the provided index to identify the phandle in the list.

These two PowerPC patches seem trivial enough and have got no response,
unless someone objects I'll go ahead and apply them.
Re: [PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
Posted by Michael Ellerman 1 year, 5 months ago
Mark Brown <broonie@kernel.org> writes:
> On Mon, Jul 01, 2024 at 01:30:34PM +0200, Herve Codina wrote:
>> qmc_chan_get_byphandle() and the resource managed version retrieve a
>> channel from a simple phandle.
>> 
>> Extend the API and introduce qmc_chan_get_byphandles_index() and the
>> resource managed version in order to retrieve a channel from a phandle
>> list using the provided index to identify the phandle in the list.
>
> These two PowerPC patches seem trivial enough and have got no response,
> unless someone objects I'll go ahead and apply them.

Ack.

MAINTAINERS says:

FREESCALE QUICC ENGINE LIBRARY
M:      Qiang Zhao <qiang.zhao@nxp.com>
L:      linuxppc-dev@lists.ozlabs.org
S:      Maintained
F:      drivers/soc/fsl/qe/
F:      include/soc/fsl/qe/

But I see no email from that address since January 2021:

  https://lore.kernel.org/all/?q=f%3Aqiang.zhao%40nxp.com

And actually drivers/soc/fsl was marked orphan in April, maybe this
should be also.

Or does Herve want to take over maintaining it?

cheers
Re: [PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
Posted by LEROY Christophe 1 year, 5 months ago

Le 04/07/2024 à 05:01, Michael Ellerman a écrit :
> Mark Brown <broonie@kernel.org> writes:
>> On Mon, Jul 01, 2024 at 01:30:34PM +0200, Herve Codina wrote:
>>> qmc_chan_get_byphandle() and the resource managed version retrieve a
>>> channel from a simple phandle.
>>>
>>> Extend the API and introduce qmc_chan_get_byphandles_index() and the
>>> resource managed version in order to retrieve a channel from a phandle
>>> list using the provided index to identify the phandle in the list.
>>
>> These two PowerPC patches seem trivial enough and have got no response,
>> unless someone objects I'll go ahead and apply them.
> 
> Ack.
> 
> MAINTAINERS says:
> 
> FREESCALE QUICC ENGINE LIBRARY
> M:      Qiang Zhao <qiang.zhao@nxp.com>
> L:      linuxppc-dev@lists.ozlabs.org
> S:      Maintained
> F:      drivers/soc/fsl/qe/
> F:      include/soc/fsl/qe/
> 
> But I see no email from that address since January 2021:
> 
>    https://lore.kernel.org/all/?q=f%3Aqiang.zhao%40nxp.com
> 
> And actually drivers/soc/fsl was marked orphan in April, maybe this
> should be also.
> 
> Or does Herve want to take over maintaining it?

We had some discussion about that in April, see 
https://lore.kernel.org/linuxppc-dev/20240219153016.ntltc76bphwrv6hn@skbuf/T/#mf6d4a5eef79e8eae7ae0456a2794c01e630a6756

Hervé has some of our hardware for a limited period of time because he 
is doing some implementation for us, but he won't keep that hardware on 
the long run.

I will send a patch to take over maintaining drivers/soc/fsl/

Christophe
Re: [PATCH v2 07/10] soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
Posted by Michael Ellerman 1 year, 5 months ago
LEROY Christophe <christophe.leroy2@cs-soprasteria.com> writes:
> Le 04/07/2024 à 05:01, Michael Ellerman a écrit :
>> Mark Brown <broonie@kernel.org> writes:
>>> On Mon, Jul 01, 2024 at 01:30:34PM +0200, Herve Codina wrote:
>>>> qmc_chan_get_byphandle() and the resource managed version retrieve a
>>>> channel from a simple phandle.
>>>>
>>>> Extend the API and introduce qmc_chan_get_byphandles_index() and the
>>>> resource managed version in order to retrieve a channel from a phandle
>>>> list using the provided index to identify the phandle in the list.
>>>
>>> These two PowerPC patches seem trivial enough and have got no response,
>>> unless someone objects I'll go ahead and apply them.
>> 
>> Ack.
>> 
>> MAINTAINERS says:
>> 
>> FREESCALE QUICC ENGINE LIBRARY
>> M:      Qiang Zhao <qiang.zhao@nxp.com>
>> L:      linuxppc-dev@lists.ozlabs.org
>> S:      Maintained
>> F:      drivers/soc/fsl/qe/
>> F:      include/soc/fsl/qe/
>> 
>> But I see no email from that address since January 2021:
>> 
>>    https://lore.kernel.org/all/?q=f%3Aqiang.zhao%40nxp.com
>> 
>> And actually drivers/soc/fsl was marked orphan in April, maybe this
>> should be also.
>> 
>> Or does Herve want to take over maintaining it?
>
> We had some discussion about that in April, see 
> https://lore.kernel.org/linuxppc-dev/20240219153016.ntltc76bphwrv6hn@skbuf/T/#mf6d4a5eef79e8eae7ae0456a2794c01e630a6756
>
> Hervé has some of our hardware for a limited period of time because he 
> is doing some implementation for us, but he won't keep that hardware on 
> the long run.
>
> I will send a patch to take over maintaining drivers/soc/fsl/

Thanks.

cheers