Merge branch 'topic/of' into for-linus
Conflicts: include/linux/dmaengine.h Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
commit
b2396f7984
|
@ -560,7 +560,7 @@ EXPORT_SYMBOL_GPL(__dma_request_channel);
|
||||||
* @dev: pointer to client device structure
|
* @dev: pointer to client device structure
|
||||||
* @name: slave channel name
|
* @name: slave channel name
|
||||||
*/
|
*/
|
||||||
struct dma_chan *dma_request_slave_channel(struct device *dev, char *name)
|
struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name)
|
||||||
{
|
{
|
||||||
/* If device-tree is present get slave info from here */
|
/* If device-tree is present get slave info from here */
|
||||||
if (dev->of_node)
|
if (dev->of_node)
|
||||||
|
|
|
@ -13,43 +13,31 @@
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/err.h>
|
#include <linux/err.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/rculist.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <linux/of.h>
|
#include <linux/of.h>
|
||||||
#include <linux/of_dma.h>
|
#include <linux/of_dma.h>
|
||||||
|
|
||||||
static LIST_HEAD(of_dma_list);
|
static LIST_HEAD(of_dma_list);
|
||||||
static DEFINE_SPINLOCK(of_dma_lock);
|
static DEFINE_MUTEX(of_dma_lock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_dma_get_controller - Get a DMA controller in DT DMA helpers list
|
* of_dma_find_controller - Get a DMA controller in DT DMA helpers list
|
||||||
* @dma_spec: pointer to DMA specifier as found in the device tree
|
* @dma_spec: pointer to DMA specifier as found in the device tree
|
||||||
*
|
*
|
||||||
* Finds a DMA controller with matching device node and number for dma cells
|
* Finds a DMA controller with matching device node and number for dma cells
|
||||||
* in a list of registered DMA controllers. If a match is found the use_count
|
* in a list of registered DMA controllers. If a match is found a valid pointer
|
||||||
* variable is increased and a valid pointer to the DMA data stored is retuned.
|
* to the DMA data stored is retuned. A NULL pointer is returned if no match is
|
||||||
* A NULL pointer is returned if no match is found.
|
* found.
|
||||||
*/
|
*/
|
||||||
static struct of_dma *of_dma_get_controller(struct of_phandle_args *dma_spec)
|
static struct of_dma *of_dma_find_controller(struct of_phandle_args *dma_spec)
|
||||||
{
|
{
|
||||||
struct of_dma *ofdma;
|
struct of_dma *ofdma;
|
||||||
|
|
||||||
spin_lock(&of_dma_lock);
|
|
||||||
|
|
||||||
if (list_empty(&of_dma_list)) {
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
list_for_each_entry(ofdma, &of_dma_list, of_dma_controllers)
|
list_for_each_entry(ofdma, &of_dma_list, of_dma_controllers)
|
||||||
if ((ofdma->of_node == dma_spec->np) &&
|
if ((ofdma->of_node == dma_spec->np) &&
|
||||||
(ofdma->of_dma_nbcells == dma_spec->args_count)) {
|
(ofdma->of_dma_nbcells == dma_spec->args_count))
|
||||||
ofdma->use_count++;
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
return ofdma;
|
return ofdma;
|
||||||
}
|
|
||||||
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
|
|
||||||
pr_debug("%s: can't find DMA controller %s\n", __func__,
|
pr_debug("%s: can't find DMA controller %s\n", __func__,
|
||||||
dma_spec->np->full_name);
|
dma_spec->np->full_name);
|
||||||
|
@ -57,22 +45,6 @@ static struct of_dma *of_dma_get_controller(struct of_phandle_args *dma_spec)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* of_dma_put_controller - Decrement use count for a registered DMA controller
|
|
||||||
* @of_dma: pointer to DMA controller data
|
|
||||||
*
|
|
||||||
* Decrements the use_count variable in the DMA data structure. This function
|
|
||||||
* should be called only when a valid pointer is returned from
|
|
||||||
* of_dma_get_controller() and no further accesses to data referenced by that
|
|
||||||
* pointer are needed.
|
|
||||||
*/
|
|
||||||
static void of_dma_put_controller(struct of_dma *ofdma)
|
|
||||||
{
|
|
||||||
spin_lock(&of_dma_lock);
|
|
||||||
ofdma->use_count--;
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* of_dma_controller_register - Register a DMA controller to DT DMA helpers
|
* of_dma_controller_register - Register a DMA controller to DT DMA helpers
|
||||||
* @np: device node of DMA controller
|
* @np: device node of DMA controller
|
||||||
|
@ -93,6 +65,7 @@ int of_dma_controller_register(struct device_node *np,
|
||||||
{
|
{
|
||||||
struct of_dma *ofdma;
|
struct of_dma *ofdma;
|
||||||
int nbcells;
|
int nbcells;
|
||||||
|
const __be32 *prop;
|
||||||
|
|
||||||
if (!np || !of_dma_xlate) {
|
if (!np || !of_dma_xlate) {
|
||||||
pr_err("%s: not enough information provided\n", __func__);
|
pr_err("%s: not enough information provided\n", __func__);
|
||||||
|
@ -103,8 +76,11 @@ int of_dma_controller_register(struct device_node *np,
|
||||||
if (!ofdma)
|
if (!ofdma)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
nbcells = be32_to_cpup(of_get_property(np, "#dma-cells", NULL));
|
prop = of_get_property(np, "#dma-cells", NULL);
|
||||||
if (!nbcells) {
|
if (prop)
|
||||||
|
nbcells = be32_to_cpup(prop);
|
||||||
|
|
||||||
|
if (!prop || !nbcells) {
|
||||||
pr_err("%s: #dma-cells property is missing or invalid\n",
|
pr_err("%s: #dma-cells property is missing or invalid\n",
|
||||||
__func__);
|
__func__);
|
||||||
kfree(ofdma);
|
kfree(ofdma);
|
||||||
|
@ -115,12 +91,11 @@ int of_dma_controller_register(struct device_node *np,
|
||||||
ofdma->of_dma_nbcells = nbcells;
|
ofdma->of_dma_nbcells = nbcells;
|
||||||
ofdma->of_dma_xlate = of_dma_xlate;
|
ofdma->of_dma_xlate = of_dma_xlate;
|
||||||
ofdma->of_dma_data = data;
|
ofdma->of_dma_data = data;
|
||||||
ofdma->use_count = 0;
|
|
||||||
|
|
||||||
/* Now queue of_dma controller structure in list */
|
/* Now queue of_dma controller structure in list */
|
||||||
spin_lock(&of_dma_lock);
|
mutex_lock(&of_dma_lock);
|
||||||
list_add_tail(&ofdma->of_dma_controllers, &of_dma_list);
|
list_add_tail(&ofdma->of_dma_controllers, &of_dma_list);
|
||||||
spin_unlock(&of_dma_lock);
|
mutex_unlock(&of_dma_lock);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -132,32 +107,20 @@ EXPORT_SYMBOL_GPL(of_dma_controller_register);
|
||||||
*
|
*
|
||||||
* Memory allocated by of_dma_controller_register() is freed here.
|
* Memory allocated by of_dma_controller_register() is freed here.
|
||||||
*/
|
*/
|
||||||
int of_dma_controller_free(struct device_node *np)
|
void of_dma_controller_free(struct device_node *np)
|
||||||
{
|
{
|
||||||
struct of_dma *ofdma;
|
struct of_dma *ofdma;
|
||||||
|
|
||||||
spin_lock(&of_dma_lock);
|
mutex_lock(&of_dma_lock);
|
||||||
|
|
||||||
if (list_empty(&of_dma_list)) {
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
list_for_each_entry(ofdma, &of_dma_list, of_dma_controllers)
|
list_for_each_entry(ofdma, &of_dma_list, of_dma_controllers)
|
||||||
if (ofdma->of_node == np) {
|
if (ofdma->of_node == np) {
|
||||||
if (ofdma->use_count) {
|
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
return -EBUSY;
|
|
||||||
}
|
|
||||||
|
|
||||||
list_del(&ofdma->of_dma_controllers);
|
list_del(&ofdma->of_dma_controllers);
|
||||||
spin_unlock(&of_dma_lock);
|
|
||||||
kfree(ofdma);
|
kfree(ofdma);
|
||||||
return 0;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock(&of_dma_lock);
|
mutex_unlock(&of_dma_lock);
|
||||||
return -ENODEV;
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(of_dma_controller_free);
|
EXPORT_SYMBOL_GPL(of_dma_controller_free);
|
||||||
|
|
||||||
|
@ -172,8 +135,8 @@ EXPORT_SYMBOL_GPL(of_dma_controller_free);
|
||||||
* specifiers, matches the name provided. Returns 0 if the name matches and
|
* specifiers, matches the name provided. Returns 0 if the name matches and
|
||||||
* a valid pointer to the DMA specifier is found. Otherwise returns -ENODEV.
|
* a valid pointer to the DMA specifier is found. Otherwise returns -ENODEV.
|
||||||
*/
|
*/
|
||||||
static int of_dma_match_channel(struct device_node *np, char *name, int index,
|
static int of_dma_match_channel(struct device_node *np, const char *name,
|
||||||
struct of_phandle_args *dma_spec)
|
int index, struct of_phandle_args *dma_spec)
|
||||||
{
|
{
|
||||||
const char *s;
|
const char *s;
|
||||||
|
|
||||||
|
@ -198,7 +161,7 @@ static int of_dma_match_channel(struct device_node *np, char *name, int index,
|
||||||
* Returns pointer to appropriate dma channel on success or NULL on error.
|
* Returns pointer to appropriate dma channel on success or NULL on error.
|
||||||
*/
|
*/
|
||||||
struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
||||||
char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
struct of_phandle_args dma_spec;
|
struct of_phandle_args dma_spec;
|
||||||
struct of_dma *ofdma;
|
struct of_dma *ofdma;
|
||||||
|
@ -220,14 +183,15 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
||||||
if (of_dma_match_channel(np, name, i, &dma_spec))
|
if (of_dma_match_channel(np, name, i, &dma_spec))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ofdma = of_dma_get_controller(&dma_spec);
|
mutex_lock(&of_dma_lock);
|
||||||
|
ofdma = of_dma_find_controller(&dma_spec);
|
||||||
|
|
||||||
if (!ofdma)
|
if (ofdma)
|
||||||
continue;
|
chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
|
||||||
|
else
|
||||||
|
chan = NULL;
|
||||||
|
|
||||||
chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
|
mutex_unlock(&of_dma_lock);
|
||||||
|
|
||||||
of_dma_put_controller(ofdma);
|
|
||||||
|
|
||||||
of_node_put(dma_spec.np);
|
of_node_put(dma_spec.np);
|
||||||
|
|
||||||
|
|
|
@ -969,7 +969,7 @@ enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
|
||||||
void dma_issue_pending_all(void);
|
void dma_issue_pending_all(void);
|
||||||
struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
|
struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
|
||||||
dma_filter_fn fn, void *fn_param);
|
dma_filter_fn fn, void *fn_param);
|
||||||
struct dma_chan *dma_request_slave_channel(struct device *dev, char *name);
|
struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
|
||||||
void dma_release_channel(struct dma_chan *chan);
|
void dma_release_channel(struct dma_chan *chan);
|
||||||
#else
|
#else
|
||||||
static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
|
static inline enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx)
|
||||||
|
@ -985,7 +985,7 @@ static inline struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static inline struct dma_chan *dma_request_slave_channel(struct device *dev,
|
static inline struct dma_chan *dma_request_slave_channel(struct device *dev,
|
||||||
char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@ struct of_dma {
|
||||||
struct dma_chan *(*of_dma_xlate)
|
struct dma_chan *(*of_dma_xlate)
|
||||||
(struct of_phandle_args *, struct of_dma *);
|
(struct of_phandle_args *, struct of_dma *);
|
||||||
void *of_dma_data;
|
void *of_dma_data;
|
||||||
int use_count;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct of_dma_filter_info {
|
struct of_dma_filter_info {
|
||||||
|
@ -38,9 +37,9 @@ extern int of_dma_controller_register(struct device_node *np,
|
||||||
struct dma_chan *(*of_dma_xlate)
|
struct dma_chan *(*of_dma_xlate)
|
||||||
(struct of_phandle_args *, struct of_dma *),
|
(struct of_phandle_args *, struct of_dma *),
|
||||||
void *data);
|
void *data);
|
||||||
extern int of_dma_controller_free(struct device_node *np);
|
extern void of_dma_controller_free(struct device_node *np);
|
||||||
extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
extern struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
||||||
char *name);
|
const char *name);
|
||||||
extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
|
extern struct dma_chan *of_dma_simple_xlate(struct of_phandle_args *dma_spec,
|
||||||
struct of_dma *ofdma);
|
struct of_dma *ofdma);
|
||||||
#else
|
#else
|
||||||
|
@ -52,13 +51,12 @@ static inline int of_dma_controller_register(struct device_node *np,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int of_dma_controller_free(struct device_node *np)
|
static inline void of_dma_controller_free(struct device_node *np)
|
||||||
{
|
{
|
||||||
return -ENODEV;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
static inline struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
|
||||||
char *name)
|
const char *name)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue