aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamian Hobson-Garcia <dhobsong@igel.co.jp>2012-11-16 00:46:10 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-11-21 16:44:10 -0500
commit87c4d1a7dce956b86e34329ed1b11a751ba9a8ea (patch)
treec16d799b2c39dbe51045c30ee94e9a88ec609b89
parent24fce61b0b7f1bc94970036db1f1d65b0770d168 (diff)
drivers: uio_dmem_genirq: Don't use DMA_ERROR_CODE to indicate unmapped regions
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> Cc: "Hans J. Koch" <hjk@hansjkoch.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/DocBook/uio-howto.tmpl2
-rw-r--r--drivers/uio/uio_dmem_genirq.c6
2 files changed, 5 insertions, 3 deletions
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index fdbf86fcfccd..ddb05e98af0d 100644
--- a/Documentation/DocBook/uio-howto.tmpl
+++ b/Documentation/DocBook/uio-howto.tmpl
@@ -771,7 +771,7 @@ framework to set up sysfs files for this region. Simply leave it alone.
771 <varname>/sys/class/uio/uioX/maps/mapY/*</varname>. 771 <varname>/sys/class/uio/uioX/maps/mapY/*</varname>.
772 The dynmaic memory regions will be freed when the UIO device file is 772 The dynmaic memory regions will be freed when the UIO device file is
773 closed. When no processes are holding the device file open, the address 773 closed. When no processes are holding the device file open, the address
774 returned to userspace is DMA_ERROR_CODE. 774 returned to userspace is ~0.
775 </para> 775 </para>
776</sect1> 776</sect1>
777 777
diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index d8bbe0783cdc..7be8d0421cae 100644
--- a/drivers/uio/uio_dmem_genirq.c
+++ b/drivers/uio/uio_dmem_genirq.c
@@ -29,6 +29,7 @@
29#include <linux/of_address.h> 29#include <linux/of_address.h>
30 30
31#define DRIVER_NAME "uio_dmem_genirq" 31#define DRIVER_NAME "uio_dmem_genirq"
32#define DMEM_MAP_ERROR (~0)
32 33
33struct uio_dmem_genirq_platdata { 34struct uio_dmem_genirq_platdata {
34 struct uio_info *uioinfo; 35 struct uio_info *uioinfo;
@@ -60,6 +61,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
60 addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size, 61 addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size,
61 (dma_addr_t *)&uiomem->addr, GFP_KERNEL); 62 (dma_addr_t *)&uiomem->addr, GFP_KERNEL);
62 if (!addr) { 63 if (!addr) {
64 uiomem->addr = DMEM_MAP_ERROR;
63 ret = -ENOMEM; 65 ret = -ENOMEM;
64 break; 66 break;
65 } 67 }
@@ -95,7 +97,7 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
95 dma_free_coherent(&priv->pdev->dev, uiomem->size, 97 dma_free_coherent(&priv->pdev->dev, uiomem->size,
96 priv->dmem_region_vaddr[dmem_region++], 98 priv->dmem_region_vaddr[dmem_region++],
97 uiomem->addr); 99 uiomem->addr);
98 uiomem->addr = DMA_ERROR_CODE; 100 uiomem->addr = DMEM_MAP_ERROR;
99 ++uiomem; 101 ++uiomem;
100 } 102 }
101 103
@@ -238,7 +240,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
238 break; 240 break;
239 } 241 }
240 uiomem->memtype = UIO_MEM_PHYS; 242 uiomem->memtype = UIO_MEM_PHYS;
241 uiomem->addr = DMA_ERROR_CODE; 243 uiomem->addr = DMEM_MAP_ERROR;
242 uiomem->size = pdata->dynamic_region_sizes[i]; 244 uiomem->size = pdata->dynamic_region_sizes[i];
243 ++uiomem; 245 ++uiomem;
244 } 246 }