aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/acpi-dma.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2014-02-06 06:25:40 -0500
committerVinod Koul <vinod.koul@intel.com>2014-02-11 13:00:50 -0500
commit0f6a928d035b82c0b3aa387d510a73f3e6dbf8e3 (patch)
tree7be99bf9737bf54e3729d33369898b72314334da /drivers/dma/acpi-dma.c
parent8f01258385be3225331d7edd20de905df433aac4 (diff)
acpi-dma: convert to return error code when asked for channel
Currently acpi_dma_request_slave_chan_by_index() and acpi_dma_request_slave_chan_by_name() return only requested channel or NULL. This patch converts them to return appropriate error code instead of NULL in case of unsuccessfull request. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/acpi-dma.c')
-rw-r--r--drivers/dma/acpi-dma.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
index 1fda371af4b7..de361a156b34 100644
--- a/drivers/dma/acpi-dma.c
+++ b/drivers/dma/acpi-dma.c
@@ -13,6 +13,7 @@
13 */ 13 */
14 14
15#include <linux/device.h> 15#include <linux/device.h>
16#include <linux/err.h>
16#include <linux/module.h> 17#include <linux/module.h>
17#include <linux/list.h> 18#include <linux/list.h>
18#include <linux/mutex.h> 19#include <linux/mutex.h>
@@ -343,7 +344,7 @@ static int acpi_dma_parse_fixed_dma(struct acpi_resource *res, void *data)
343 * @index: index of FixedDMA descriptor for @dev 344 * @index: index of FixedDMA descriptor for @dev
344 * 345 *
345 * Return: 346 * Return:
346 * Pointer to appropriate dma channel on success or NULL on error. 347 * Pointer to appropriate dma channel on success or an error pointer.
347 */ 348 */
348struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev, 349struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
349 size_t index) 350 size_t index)
@@ -358,10 +359,10 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
358 359
359 /* Check if the device was enumerated by ACPI */ 360 /* Check if the device was enumerated by ACPI */
360 if (!dev || !ACPI_HANDLE(dev)) 361 if (!dev || !ACPI_HANDLE(dev))
361 return NULL; 362 return ERR_PTR(-ENODEV);
362 363
363 if (acpi_bus_get_device(ACPI_HANDLE(dev), &adev)) 364 if (acpi_bus_get_device(ACPI_HANDLE(dev), &adev))
364 return NULL; 365 return ERR_PTR(-ENODEV);
365 366
366 memset(&pdata, 0, sizeof(pdata)); 367 memset(&pdata, 0, sizeof(pdata));
367 pdata.index = index; 368 pdata.index = index;
@@ -376,7 +377,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
376 acpi_dev_free_resource_list(&resource_list); 377 acpi_dev_free_resource_list(&resource_list);
377 378
378 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0) 379 if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
379 return NULL; 380 return ERR_PTR(-ENODEV);
380 381
381 mutex_lock(&acpi_dma_lock); 382 mutex_lock(&acpi_dma_lock);
382 383
@@ -399,7 +400,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
399 } 400 }
400 401
401 mutex_unlock(&acpi_dma_lock); 402 mutex_unlock(&acpi_dma_lock);
402 return chan; 403 return chan ? chan : ERR_PTR(-EPROBE_DEFER);
403} 404}
404EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index); 405EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
405 406
@@ -413,7 +414,7 @@ EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
413 * the first FixedDMA descriptor is TX and second is RX. 414 * the first FixedDMA descriptor is TX and second is RX.
414 * 415 *
415 * Return: 416 * Return:
416 * Pointer to appropriate dma channel on success or NULL on error. 417 * Pointer to appropriate dma channel on success or an error pointer.
417 */ 418 */
418struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev, 419struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
419 const char *name) 420 const char *name)
@@ -425,7 +426,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
425 else if (!strcmp(name, "rx")) 426 else if (!strcmp(name, "rx"))
426 index = 1; 427 index = 1;
427 else 428 else
428 return NULL; 429 return ERR_PTR(-ENODEV);
429 430
430 return acpi_dma_request_slave_chan_by_index(dev, index); 431 return acpi_dma_request_slave_chan_by_index(dev, index);
431} 432}