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.

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 <herve.codina@bootlin.com>
Link: https://patch.msgid.link/20240701113038.55144-8-herve.codina@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Herve Codina and committed by
Mark Brown
37797c60 b81cfa66

+33 -11
+11 -8
drivers/soc/fsl/qe/qmc.c
··· 1777 1777 return qmc_chan; 1778 1778 } 1779 1779 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) 1781 1783 { 1782 1784 struct of_phandle_args out_args; 1783 1785 struct qmc_chan *qmc_chan; 1784 1786 int ret; 1785 1787 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, 1787 1789 &out_args); 1788 1790 if (ret < 0) 1789 1791 return ERR_PTR(ret); ··· 1799 1797 of_node_put(out_args.np); 1800 1798 return qmc_chan; 1801 1799 } 1802 - EXPORT_SYMBOL(qmc_chan_get_byphandle); 1800 + EXPORT_SYMBOL(qmc_chan_get_byphandles_index); 1803 1801 1804 1802 struct qmc_chan *qmc_chan_get_bychild(struct device_node *np) 1805 1803 { ··· 1829 1827 qmc_chan_put(*qmc_chan); 1830 1828 } 1831 1829 1832 - struct qmc_chan *devm_qmc_chan_get_byphandle(struct device *dev, 1833 - struct device_node *np, 1834 - const char *phandle_name) 1830 + struct qmc_chan *devm_qmc_chan_get_byphandles_index(struct device *dev, 1831 + struct device_node *np, 1832 + const char *phandles_name, 1833 + int index) 1835 1834 { 1836 1835 struct qmc_chan *qmc_chan; 1837 1836 struct qmc_chan **dr; ··· 1841 1838 if (!dr) 1842 1839 return ERR_PTR(-ENOMEM); 1843 1840 1844 - qmc_chan = qmc_chan_get_byphandle(np, phandle_name); 1841 + qmc_chan = qmc_chan_get_byphandles_index(np, phandles_name, index); 1845 1842 if (!IS_ERR(qmc_chan)) { 1846 1843 *dr = qmc_chan; 1847 1844 devres_add(dev, dr); ··· 1851 1848 1852 1849 return qmc_chan; 1853 1850 } 1854 - EXPORT_SYMBOL(devm_qmc_chan_get_byphandle); 1851 + EXPORT_SYMBOL(devm_qmc_chan_get_byphandles_index); 1855 1852 1856 1853 struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev, 1857 1854 struct device_node *np)
+22 -3
include/soc/fsl/qe/qmc.h
··· 16 16 struct device; 17 17 struct qmc_chan; 18 18 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 + 20 40 struct qmc_chan *qmc_chan_get_bychild(struct device_node *np); 21 41 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 + 24 43 struct qmc_chan *devm_qmc_chan_get_bychild(struct device *dev, struct device_node *np); 25 44 26 45 enum qmc_mode {