| From dhobsong@igel.co.jp Wed Nov 21 18:27:20 2012 |
| From: Damian Hobson-Garcia <dhobsong@igel.co.jp> |
| Date: Thu, 22 Nov 2012 11:26:51 +0900 |
| Subject: [PATCH 4/6] drivers: uio_dmem_genirq: Don't use DMA_ERROR_CODE to indicate unmapped regions |
| To: gregkh@linuxfoundation.org |
| Cc: ltsi-dev@lists.linuxfoundation.org, Damian Hobson-Garcia <dhobsong@igel.co.jp> |
| Message-ID: <1353551213-17996-5-git-send-email-dhobsong@igel.co.jp> |
| |
| |
| DMA_ERROR_CODE is not defined on all architectures and is architecture |
| specific. Instead, use the constant, ~0 to indicate unmapped regions. |
| |
| Reported-by: Fengguang Wu <fengguang.wu@intel.com> |
| Reported-by: Geert Uytterhoeven <geert@linux-m68k.org> |
| |
| Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp> |
| --- |
| Documentation/DocBook/uio-howto.tmpl | 2 +- |
| drivers/uio/uio_dmem_genirq.c | 6 ++++-- |
| 2 files changed, 5 insertions(+), 3 deletions(-) |
| |
| --- a/Documentation/DocBook/uio-howto.tmpl |
| +++ b/Documentation/DocBook/uio-howto.tmpl |
| @@ -771,7 +771,7 @@ framework to set up sysfs files for this |
| <varname>/sys/class/uio/uioX/maps/mapY/*</varname>. |
| The dynmaic memory regions will be freed when the UIO device file is |
| closed. When no processes are holding the device file open, the address |
| - returned to userspace is DMA_ERROR_CODE. |
| + returned to userspace is ~0. |
| </para> |
| </sect1> |
| |
| --- a/drivers/uio/uio_dmem_genirq.c |
| +++ b/drivers/uio/uio_dmem_genirq.c |
| @@ -29,6 +29,7 @@ |
| #include <linux/of_address.h> |
| |
| #define DRIVER_NAME "uio_dmem_genirq" |
| +#define DMEM_MAP_ERROR (~0) |
| |
| struct uio_dmem_genirq_platdata { |
| struct uio_info *uioinfo; |
| @@ -60,6 +61,7 @@ static int uio_dmem_genirq_open(struct u |
| addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size, |
| (dma_addr_t *)&uiomem->addr, GFP_KERNEL); |
| if (!addr) { |
| + uiomem->addr = DMEM_MAP_ERROR; |
| ret = -ENOMEM; |
| break; |
| } |
| @@ -95,7 +97,7 @@ static int uio_dmem_genirq_release(struc |
| dma_free_coherent(&priv->pdev->dev, uiomem->size, |
| priv->dmem_region_vaddr[dmem_region++], |
| uiomem->addr); |
| - uiomem->addr = DMA_ERROR_CODE; |
| + uiomem->addr = DMEM_MAP_ERROR; |
| ++uiomem; |
| } |
| |
| @@ -238,7 +240,7 @@ static int uio_dmem_genirq_probe(struct |
| break; |
| } |
| uiomem->memtype = UIO_MEM_PHYS; |
| - uiomem->addr = DMA_ERROR_CODE; |
| + uiomem->addr = DMEM_MAP_ERROR; |
| uiomem->size = pdata->dynamic_region_sizes[i]; |
| ++uiomem; |
| } |