Skip to content

Commit

Permalink
acpi-dma: convert to return error code when asked for channel
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Shevchenko authored and Vinod Koul committed Feb 11, 2014
1 parent 8f01258 commit 0f6a928
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
15 changes: 8 additions & 7 deletions drivers/dma/acpi-dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

#include <linux/device.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/list.h>
#include <linux/mutex.h>
Expand Down Expand Up @@ -343,7 +344,7 @@ static int acpi_dma_parse_fixed_dma(struct acpi_resource *res, void *data)
* @index: index of FixedDMA descriptor for @dev
*
* Return:
* Pointer to appropriate dma channel on success or NULL on error.
* Pointer to appropriate dma channel on success or an error pointer.
*/
struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
size_t index)
Expand All @@ -358,10 +359,10 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,

/* Check if the device was enumerated by ACPI */
if (!dev || !ACPI_HANDLE(dev))
return NULL;
return ERR_PTR(-ENODEV);

if (acpi_bus_get_device(ACPI_HANDLE(dev), &adev))
return NULL;
return ERR_PTR(-ENODEV);

memset(&pdata, 0, sizeof(pdata));
pdata.index = index;
Expand All @@ -376,7 +377,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
acpi_dev_free_resource_list(&resource_list);

if (dma_spec->slave_id < 0 || dma_spec->chan_id < 0)
return NULL;
return ERR_PTR(-ENODEV);

mutex_lock(&acpi_dma_lock);

Expand All @@ -399,7 +400,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_index(struct device *dev,
}

mutex_unlock(&acpi_dma_lock);
return chan;
return chan ? chan : ERR_PTR(-EPROBE_DEFER);
}
EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);

Expand All @@ -413,7 +414,7 @@ EXPORT_SYMBOL_GPL(acpi_dma_request_slave_chan_by_index);
* the first FixedDMA descriptor is TX and second is RX.
*
* Return:
* Pointer to appropriate dma channel on success or NULL on error.
* Pointer to appropriate dma channel on success or an error pointer.
*/
struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
const char *name)
Expand All @@ -425,7 +426,7 @@ struct dma_chan *acpi_dma_request_slave_chan_by_name(struct device *dev,
else if (!strcmp(name, "rx"))
index = 1;
else
return NULL;
return ERR_PTR(-ENODEV);

return acpi_dma_request_slave_chan_by_index(dev, index);
}
Expand Down
9 changes: 2 additions & 7 deletions drivers/dma/dmaengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,18 +627,13 @@ EXPORT_SYMBOL_GPL(__dma_request_channel);
struct dma_chan *dma_request_slave_channel_reason(struct device *dev,
const char *name)
{
struct dma_chan *chan;

/* If device-tree is present get slave info from here */
if (dev->of_node)
return of_dma_request_slave_channel(dev->of_node, name);

/* If device was enumerated by ACPI get slave info from here */
if (ACPI_HANDLE(dev)) {
chan = acpi_dma_request_slave_chan_by_name(dev, name);
if (chan)
return chan;
}
if (ACPI_HANDLE(dev))
return acpi_dma_request_slave_chan_by_name(dev, name);

return ERR_PTR(-ENODEV);
}
Expand Down
5 changes: 3 additions & 2 deletions include/linux/acpi_dma.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <linux/list.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/dmaengine.h>

/**
Expand Down Expand Up @@ -103,12 +104,12 @@ static inline void devm_acpi_dma_controller_free(struct device *dev)
static inline struct dma_chan *acpi_dma_request_slave_chan_by_index(
struct device *dev, size_t index)
{
return NULL;
return ERR_PTR(-ENODEV);
}
static inline struct dma_chan *acpi_dma_request_slave_chan_by_name(
struct device *dev, const char *name)
{
return NULL;
return ERR_PTR(-ENODEV);
}

#define acpi_dma_simple_xlate NULL
Expand Down

0 comments on commit 0f6a928

Please sign in to comment.