|
21 | 21 | #include <linux/ioport.h>
|
22 | 22 | #include <linux/acpi.h>
|
23 | 23 | #include <linux/acpi_dma.h>
|
| 24 | +#include <linux/property.h> |
24 | 25 |
|
25 | 26 | static LIST_HEAD(acpi_dma_list);
|
26 | 27 | static DEFINE_MUTEX(acpi_dma_lock);
|
@@ -413,21 +414,29 @@ EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
|
413 | 414 | * translate the names "tx" and "rx" here based on the most common case where
|
414 | 415 | * the first FixedDMA descriptor is TX and second is RX.
|
415 | 416 | *
|
| 417 | + * If the device has "dma-names" property the FixedDMA descriptor indices |
| 418 | + * are retrieved based on those. Otherwise the function falls back using |
| 419 | + * hardcoded indices. |
| 420 | + * |
416 | 421 | * Return:
|
417 | 422 | * Pointer to appropriate dma channel on success or an error pointer.
|
418 | 423 | */
|
419 | 424 | struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
|
420 | 425 | const char *name)
|
421 | 426 | {
|
422 |
| - size_t index; |
423 |
| - |
424 |
| - if (!strcmp(name, "tx")) |
425 |
| - index = 0; |
426 |
| - else if (!strcmp(name, "rx")) |
427 |
| - index = 1; |
428 |
| - else |
429 |
| - return ERR_PTR(-ENODEV); |
| 427 | + int index; |
| 428 | + |
| 429 | + index = device_property_match_string(dev, "dma-names", name); |
| 430 | + if (index < 0) { |
| 431 | + if (!strcmp(name, "tx")) |
| 432 | + index = 0; |
| 433 | + else if (!strcmp(name, "rx")) |
| 434 | + index = 1; |
| 435 | + else |
| 436 | + return ERR_PTR(-ENODEV); |
| 437 | + } |
430 | 438 |
|
| 439 | + dev_dbg(dev, "found DMA channel \"%s\" at index %d\n", name, index); |
431 | 440 | return acpi_dma_request_slave_chan_by_index(dev, index);
|
432 | 441 | }
|
433 | 442 | EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_name);
|
|
0 commit comments