diff options
Diffstat (limited to 'drivers/dma/dmaengine.c')
| -rw-r--r-- | drivers/dma/dmaengine.c | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c index ea806bdc12ef..24095ff8a93b 100644 --- a/drivers/dma/dmaengine.c +++ b/drivers/dma/dmaengine.c | |||
| @@ -535,11 +535,41 @@ struct dma_chan *dma_get_slave_channel(struct dma_chan *chan) | |||
| 535 | } | 535 | } |
| 536 | EXPORT_SYMBOL_GPL(dma_get_slave_channel); | 536 | EXPORT_SYMBOL_GPL(dma_get_slave_channel); |
| 537 | 537 | ||
| 538 | struct dma_chan *dma_get_any_slave_channel(struct dma_device *device) | ||
| 539 | { | ||
| 540 | dma_cap_mask_t mask; | ||
| 541 | struct dma_chan *chan; | ||
| 542 | int err; | ||
| 543 | |||
| 544 | dma_cap_zero(mask); | ||
| 545 | dma_cap_set(DMA_SLAVE, mask); | ||
| 546 | |||
| 547 | /* lock against __dma_request_channel */ | ||
| 548 | mutex_lock(&dma_list_mutex); | ||
| 549 | |||
| 550 | chan = private_candidate(&mask, device, NULL, NULL); | ||
| 551 | if (chan) { | ||
| 552 | err = dma_chan_get(chan); | ||
| 553 | if (err) { | ||
| 554 | pr_debug("%s: failed to get %s: (%d)\n", | ||
| 555 | __func__, dma_chan_name(chan), err); | ||
| 556 | chan = NULL; | ||
| 557 | } | ||
| 558 | } | ||
| 559 | |||
| 560 | mutex_unlock(&dma_list_mutex); | ||
| 561 | |||
| 562 | return chan; | ||
| 563 | } | ||
| 564 | EXPORT_SYMBOL_GPL(dma_get_any_slave_channel); | ||
| 565 | |||
| 538 | /** | 566 | /** |
| 539 | * __dma_request_channel - try to allocate an exclusive channel | 567 | * __dma_request_channel - try to allocate an exclusive channel |
| 540 | * @mask: capabilities that the channel must satisfy | 568 | * @mask: capabilities that the channel must satisfy |
| 541 | * @fn: optional callback to disposition available channels | 569 | * @fn: optional callback to disposition available channels |
| 542 | * @fn_param: opaque parameter to pass to dma_filter_fn | 570 | * @fn_param: opaque parameter to pass to dma_filter_fn |
| 571 | * | ||
| 572 | * Returns pointer to appropriate DMA channel on success or NULL. | ||
| 543 | */ | 573 | */ |
| 544 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, | 574 | struct dma_chan *__dma_request_channel(const dma_cap_mask_t *mask, |
| 545 | dma_filter_fn fn, void *fn_param) | 575 | dma_filter_fn fn, void *fn_param) |
| @@ -591,18 +621,43 @@ EXPORT_SYMBOL_GPL(__dma_request_channel); | |||
| 591 | * dma_request_slave_channel - try to allocate an exclusive slave channel | 621 | * dma_request_slave_channel - try to allocate an exclusive slave channel |
| 592 | * @dev: pointer to client device structure | 622 | * @dev: pointer to client device structure |
| 593 | * @name: slave channel name | 623 | * @name: slave channel name |
| 624 | * | ||
| 625 | * Returns pointer to appropriate DMA channel on success or an error pointer. | ||
| 594 | */ | 626 | */ |
| 595 | struct dma_chan *dma_request_slave_channel(struct device *dev, const char *name) | 627 | struct dma_chan *dma_request_slave_channel_reason(struct device *dev, |
| 628 | const char *name) | ||
| 596 | { | 629 | { |
| 630 | struct dma_chan *chan; | ||
| 631 | |||
| 597 | /* If device-tree is present get slave info from here */ | 632 | /* If device-tree is present get slave info from here */ |
| 598 | if (dev->of_node) | 633 | if (dev->of_node) |
| 599 | return of_dma_request_slave_channel(dev->of_node, name); | 634 | return of_dma_request_slave_channel(dev->of_node, name); |
| 600 | 635 | ||
| 601 | /* If device was enumerated by ACPI get slave info from here */ | 636 | /* If device was enumerated by ACPI get slave info from here */ |
| 602 | if (ACPI_HANDLE(dev)) | 637 | if (ACPI_HANDLE(dev)) { |
| 603 | return acpi_dma_request_slave_chan_by_name(dev, name); | 638 | chan = acpi_dma_request_slave_chan_by_name(dev, name); |
| 639 | if (chan) | ||
| 640 | return chan; | ||
| 641 | } | ||
| 604 | 642 | ||
| 605 | return NULL; | 643 | return ERR_PTR(-ENODEV); |
| 644 | } | ||
| 645 | EXPORT_SYMBOL_GPL(dma_request_slave_channel_reason); | ||
| 646 | |||
| 647 | /** | ||
| 648 | * dma_request_slave_channel - try to allocate an exclusive slave channel | ||
| 649 | * @dev: pointer to client device structure | ||
| 650 | * @name: slave channel name | ||
| 651 | * | ||
| 652 | * Returns pointer to appropriate DMA channel on success or NULL. | ||
| 653 | */ | ||
| 654 | struct dma_chan *dma_request_slave_channel(struct device *dev, | ||
| 655 | const char *name) | ||
| 656 | { | ||
| 657 | struct dma_chan *ch = dma_request_slave_channel_reason(dev, name); | ||
| 658 | if (IS_ERR(ch)) | ||
| 659 | return NULL; | ||
| 660 | return ch; | ||
| 606 | } | 661 | } |
| 607 | EXPORT_SYMBOL_GPL(dma_request_slave_channel); | 662 | EXPORT_SYMBOL_GPL(dma_request_slave_channel); |
| 608 | 663 | ||
