diff options
author | Daniel Mack <zonque@gmail.com> | 2013-08-12 10:37:18 +0200 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-08-14 19:54:30 +0100 |
commit | 6446221c14ef3bf58754cf1948631128dbe62700 (patch) | |
tree | 85b98c217d9528e1a1771f8599875c4814a3b1db /arch/arm/plat-pxa | |
parent | 1c459de1e645b213a07b9492884a54f5861409f5 (diff) |
ARM: pxa: ssp: add pxa_ssp_request_of()
Add a function to lookup ssp devices from device tree. This way, users
can reference the ssp devices in order to register to them.
Signed-off-by: Daniel Mack <zonque@gmail.com>
Acked-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'arch/arm/plat-pxa')
-rw-r--r-- | arch/arm/plat-pxa/ssp.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/arch/arm/plat-pxa/ssp.c b/arch/arm/plat-pxa/ssp.c index f2661355fa4e..c83f27b6bdda 100644 --- a/arch/arm/plat-pxa/ssp.c +++ b/arch/arm/plat-pxa/ssp.c @@ -62,6 +62,30 @@ struct ssp_device *pxa_ssp_request(int port, const char *label) } EXPORT_SYMBOL(pxa_ssp_request); +struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node, + const char *label) +{ + struct ssp_device *ssp = NULL; + + mutex_lock(&ssp_lock); + + list_for_each_entry(ssp, &ssp_list, node) { + if (ssp->of_node == of_node && ssp->use_count == 0) { + ssp->use_count++; + ssp->label = label; + break; + } + } + + mutex_unlock(&ssp_lock); + + if (&ssp->node == &ssp_list) + return NULL; + + return ssp; +} +EXPORT_SYMBOL(pxa_ssp_request_of); + void pxa_ssp_free(struct ssp_device *ssp) { mutex_lock(&ssp_lock); @@ -185,6 +209,7 @@ static int pxa_ssp_probe(struct platform_device *pdev) } ssp->use_count = 0; + ssp->of_node = dev->of_node; mutex_lock(&ssp_lock); list_add(&ssp->node, &ssp_list); |