mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 14:12:06 +00:00
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>
This commit is contained in:
parent
1c459de1e6
commit
6446221c14
@ -62,6 +62,30 @@ struct ssp_device *pxa_ssp_request(int port, const char *label)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(pxa_ssp_request);
|
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)
|
void pxa_ssp_free(struct ssp_device *ssp)
|
||||||
{
|
{
|
||||||
mutex_lock(&ssp_lock);
|
mutex_lock(&ssp_lock);
|
||||||
@ -185,6 +209,7 @@ static int pxa_ssp_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssp->use_count = 0;
|
ssp->use_count = 0;
|
||||||
|
ssp->of_node = dev->of_node;
|
||||||
|
|
||||||
mutex_lock(&ssp_lock);
|
mutex_lock(&ssp_lock);
|
||||||
list_add(&ssp->node, &ssp_list);
|
list_add(&ssp->node, &ssp_list);
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
|
#include <linux/of.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SSP Serial Port Registers
|
* SSP Serial Port Registers
|
||||||
@ -190,6 +192,8 @@ struct ssp_device {
|
|||||||
int irq;
|
int irq;
|
||||||
int drcmr_rx;
|
int drcmr_rx;
|
||||||
int drcmr_tx;
|
int drcmr_tx;
|
||||||
|
|
||||||
|
struct device_node *of_node;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -218,11 +222,18 @@ static inline u32 pxa_ssp_read_reg(struct ssp_device *dev, u32 reg)
|
|||||||
#ifdef CONFIG_ARCH_PXA
|
#ifdef CONFIG_ARCH_PXA
|
||||||
struct ssp_device *pxa_ssp_request(int port, const char *label);
|
struct ssp_device *pxa_ssp_request(int port, const char *label);
|
||||||
void pxa_ssp_free(struct ssp_device *);
|
void pxa_ssp_free(struct ssp_device *);
|
||||||
|
struct ssp_device *pxa_ssp_request_of(const struct device_node *of_node,
|
||||||
|
const char *label);
|
||||||
#else
|
#else
|
||||||
static inline struct ssp_device *pxa_ssp_request(int port, const char *label)
|
static inline struct ssp_device *pxa_ssp_request(int port, const char *label)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
static inline struct ssp_device *pxa_ssp_request_of(const struct device_node *n,
|
||||||
|
const char *name)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
static inline void pxa_ssp_free(struct ssp_device *ssp) {}
|
static inline void pxa_ssp_free(struct ssp_device *ssp) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user