Skip to content

Commit 37797c6

Browse files
hcodinabroonie
authored andcommitted
soc: fsl: cpm1: qmc: Introduce functions to get a channel from a phandle list
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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent b81cfa6 commit 37797c6

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

drivers/soc/fsl/qe/qmc.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,13 +1777,15 @@ static struct qmc_chan *qmc_chan_get_from_qmc(struct device_node *qmc_np, unsign
17771777
return qmc_chan;
17781778
}
17791779

1780-
struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phandle_name)
1780+
struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
1781+
const char *phandles_name,
1782+
int index)
17811783
{
17821784
struct of_phandle_args out_args;
17831785
struct qmc_chan *qmc_chan;
17841786
int ret;
17851787

1786-
ret = of_parse_phandle_with_fixed_args(np, phandle_name, 1, 0,
1788+
ret = of_parse_phandle_with_fixed_args(np, phandles_name, 1, index,
17871789
&out_args);
17881790
if (ret < 0)
17891791
return ERR_PTR(ret);
@@ -1797,7 +1799,7 @@ struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phan
17971799
of_node_put(out_args.np);
17981800
return qmc_chan;
17991801
}
1800-
EXPORT_SYMBOL(qmc_chan_get_byphandle);
1802+
EXPORT_SYMBOL(qmc_chan_get_byphandles_index);
18011803

18021804
struct qmc_chan *qmc_chan_get_bychild(struct device_node *np)
18031805
{
@@ -1827,9 +1829,10 @@ static void devm_qmc_chan_release(struct device *dev, void *res)
18271829
qmc_chan_put(*qmc_chan);
18281830
}
18291831

1830-
struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
1831-
struct device_node *np,
1832-
const char *phandle_name)
1832+
struct qmc_chan *devm_qmc_chan_get_byphandles_index(struct device *dev,
1833+
struct device_node *np,
1834+
const char *phandles_name,
1835+
int index)
18331836
{
18341837
struct qmc_chan *qmc_chan;
18351838
struct qmc_chan **dr;
@@ -1838,7 +1841,7 @@ struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
18381841
if (!dr)
18391842
return ERR_PTR(-ENOMEM);
18401843

1841-
qmc_chan = qmc_chan_get_byphandle(np, phandle_name);
1844+
qmc_chan = qmc_chan_get_byphandles_index(np, phandles_name, index);
18421845
if (!IS_ERR(qmc_chan)) {
18431846
*dr = qmc_chan;
18441847
devres_add(dev, dr);
@@ -1848,7 +1851,7 @@ struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
18481851

18491852
return qmc_chan;
18501853
}
1851-
EXPORT_SYMBOL(devm_qmc_chan_get_byphandle);
1854+
EXPORT_SYMBOL(devm_qmc_chan_get_byphandles_index);
18521855

18531856
struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev,
18541857
struct device_node *np)

include/soc/fsl/qe/qmc.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,30 @@ struct device_node;
1616
struct device;
1717
struct qmc_chan;
1818

19-
struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np, const char *phandle_name);
19+
struct qmc_chan *qmc_chan_get_byphandles_index(struct device_node *np,
20+
const char *phandles_name,
21+
int index);
22+
struct qmc_chan *devm_qmc_chan_get_byphandles_index(struct device *dev,
23+
struct device_node *np,
24+
const char *phandles_name,
25+
int index);
26+
27+
static inline struct qmc_chan *qmc_chan_get_byphandle(struct device_node *np,
28+
const char *phandle_name)
29+
{
30+
return qmc_chan_get_byphandles_index(np, phandle_name, 0);
31+
}
32+
33+
static inline struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev,
34+
struct device_node *np,
35+
const char *phandle_name)
36+
{
37+
return devm_qmc_chan_get_byphandles_index(dev, np, phandle_name, 0);
38+
}
39+
2040
struct qmc_chan *qmc_chan_get_bychild(struct device_node *np);
2141
void qmc_chan_put(struct qmc_chan *chan);
22-
struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev, struct device_node *np,
23-
const char *phandle_name);
42+
2443
struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev, struct device_node *np);
2544

2645
enum qmc_mode {

0 commit comments

Comments
 (0)