Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Daniel Mack and committed by
Mark Brown
6446221c 1c459de1

+36
+25
arch/arm/plat-pxa/ssp.c
··· 62 62 } 63 63 EXPORT_SYMBOL(pxa_ssp_request); 64 64 65 + struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node, 66 + const char *label) 67 + { 68 + struct ssp_device *ssp = NULL; 69 + 70 + mutex_lock(&ssp_lock); 71 + 72 + list_for_each_entry(ssp, &ssp_list, node) { 73 + if (ssp->of_node == of_node && ssp->use_count == 0) { 74 + ssp->use_count++; 75 + ssp->label = label; 76 + break; 77 + } 78 + } 79 + 80 + mutex_unlock(&ssp_lock); 81 + 82 + if (&ssp->node == &ssp_list) 83 + return NULL; 84 + 85 + return ssp; 86 + } 87 + EXPORT_SYMBOL(pxa_ssp_request_of); 88 + 65 89 void pxa_ssp_free(struct ssp_device *ssp) 66 90 { 67 91 mutex_lock(&ssp_lock); ··· 209 185 } 210 186 211 187 ssp->use_count = 0; 188 + ssp->of_node = dev->of_node; 212 189 213 190 mutex_lock(&ssp_lock); 214 191 list_add(&ssp->node, &ssp_list);
+11
include/linux/pxa2xx_ssp.h
··· 21 21 22 22 #include <linux/list.h> 23 23 #include <linux/io.h> 24 + #include <linux/of.h> 25 + 24 26 25 27 /* 26 28 * SSP Serial Port Registers ··· 192 190 int irq; 193 191 int drcmr_rx; 194 192 int drcmr_tx; 193 + 194 + struct device_node *of_node; 195 195 }; 196 196 197 197 /** ··· 222 218 #ifdef CONFIG_ARCH_PXA 223 219 struct ssp_device *pxa_ssp_request(int port, const char *label); 224 220 void pxa_ssp_free(struct ssp_device *); 221 + struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node, 222 + const char *label); 225 223 #else 226 224 static inline struct ssp_device *pxa_ssp_request(int port, const char *label) 225 + { 226 + return NULL; 227 + } 228 + static inline struct ssp_device *pxa_ssp_request_of(const struct device_node *n, 229 + const char *name) 227 230 { 228 231 return NULL; 229 232 }