Skip to content

Commit 4fce628

Browse files
author
Vinod Koul
committed
Merge branch 'topic/defer_probe' into for-linus
2 parents 1080411 + 0ad7c00 commit 4fce628

File tree

3 files changed

+48
-10
lines changed

3 files changed

+48
-10
lines changed

drivers/dma/dmaengine.c

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ EXPORT_SYMBOL_GPL(dma_get_slave_channel);
540540
* @mask: capabilities that the channel must satisfy
541541
* @fn: optional callback to disposition available channels
542542
* @fn_param: opaque parameter to pass to dma_filter_fn
543+
*
544+
* Returns pointer to appropriate DMA channel on success or NULL.
543545
*/
544546
struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
545547
dma_filter_fn fn, void *fn_param)
@@ -591,18 +593,43 @@ EXPORT_SYMBOL_GPL(__dma_request_channel);
591593
* dma_request_slave_channel - try to allocate an exclusive slave channel
592594
* @dev: pointer to client device structure
593595
* @name: slave channel name
596+
*
597+
* Returns pointer to appropriate DMA channel on success or an error pointer.
594598
*/
595-
struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name)
599+
struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
600+
const char *name)
596601
{
602+
struct dma_chan *chan;
603+
597604
/* If device-tree is present get slave info from here */
598605
if (dev->of_node)
599606
return of_dma_request_slave_channel(dev->of_node, name);
600607

601608
/* If device was enumerated by ACPI get slave info from here */
602-
if (ACPI_HANDLE(dev))
603-
return acpi_dma_request_slave_chan_by_name(dev, name);
609+
if (ACPI_HANDLE(dev)) {
610+
chan = acpi_dma_request_slave_chan_by_name(dev, name);
611+
if (chan)
612+
return chan;
613+
}
604614

605-
return NULL;
615+
return ERR_PTR(-ENODEV);
616+
}
617+
EXPORT_SYMBOL_GPL(dma_request_slave_channel_reason);
618+
619+
/**
620+
* dma_request_slave_channel - try to allocate an exclusive slave channel
621+
* @dev: pointer to client device structure
622+
* @name: slave channel name
623+
*
624+
* Returns pointer to appropriate DMA channel on success or NULL.
625+
*/
626+
struct dma_chan *dma_request_slave_channel(struct device *dev,
627+
const char *name)
628+
{
629+
struct dma_chan *ch = dma_request_slave_channel_reason(dev, name);
630+
if (IS_ERR(ch))
631+
return NULL;
632+
return ch;
606633
}
607634
EXPORT_SYMBOL_GPL(dma_request_slave_channel);
608635

drivers/dma/of-dma.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ static int of_dma_match_channel(struct device_node *np, const char *name,
143143
* @np: device node to get DMA request from
144144
* @name: name of desired channel
145145
*
146-
* Returns pointer to appropriate dma channel on success or NULL on error.
146+
* Returns pointer to appropriate DMA channel on success or an error pointer.
147147
*/
148148
struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
149149
const char *name)
@@ -152,17 +152,18 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
152152
struct of_dma *ofdma;
153153
struct dma_chan *chan;
154154
int count, i;
155+
int ret_no_channel = -ENODEV;
155156

156157
if (!np || !name) {
157158
pr_err("%s: not enough information provided\n", __func__);
158-
return NULL;
159+
return ERR_PTR(-ENODEV);
159160
}
160161

161162
count = of_property_count_strings(np, "dma-names");
162163
if (count < 0) {
163164
pr_err("%s: dma-names property of node '%s' missing or empty\n",
164165
__func__, np->full_name);
165-
return NULL;
166+
return ERR_PTR(-ENODEV);
166167
}
167168

168169
for (i = 0; i < count; i++) {
@@ -172,10 +173,12 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
172173
mutex_lock(&of_dma_lock);
173174
ofdma = of_dma_find_controller(&dma_spec);
174175

175-
if (ofdma)
176+
if (ofdma) {
176177
chan = ofdma->of_dma_xlate(&dma_spec, ofdma);
177-
else
178+
} else {
179+
ret_no_channel = -EPROBE_DEFER;
178180
chan = NULL;
181+
}
179182

180183
mutex_unlock(&of_dma_lock);
181184

@@ -185,7 +188,7 @@ struct dma_chan *of_dma_request_slave_channel(struct device_node *np,
185188
return chan;
186189
}
187190

188-
return NULL;
191+
return ERR_PTR(ret_no_channel);
189192
}
190193

191194
/**

include/linux/dmaengine.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#define LINUX_DMAENGINE_H
2323

2424
#include <linux/device.h>
25+
#include <linux/err.h>
2526
#include <linux/uio.h>
2627
#include <linux/bug.h>
2728
#include <linux/scatterlist.h>
@@ -1039,6 +1040,8 @@ enum dma_status dma_wait_for_async_tx(struct dma_async_tx_descriptor *tx);
10391040
void dma_issue_pending_all(void);
10401041
struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
10411042
dma_filter_fn fn, void *fn_param);
1043+
struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
1044+
const char *name);
10421045
struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name);
10431046
void dma_release_channel(struct dma_chan *chan);
10441047
#else
@@ -1062,6 +1065,11 @@ static inline struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask,
10621065
{
10631066
return NULL;
10641067
}
1068+
static inline struct dma_chan *dma_request_slave_channel_reason(
1069+
struct device *dev, const char *name)
1070+
{
1071+
return ERR_PTR(-ENODEV);
1072+
}
10651073
static inline struct dma_chan *dma_request_slave_channel(struct device *dev,
10661074
const char *name)
10671075
{

0 commit comments

Comments
 (0)