Commit 87c4d1a7 authored by Damian Hobson-Garcia's avatar Damian Hobson-Garcia Committed by Greg Kroah-Hartman
Browse files

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: default avatarFengguang Wu <fengguang.wu@intel.com>
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarDamian Hobson-Garcia <dhobsong@igel.co.jp>
Cc: "Hans J. Koch" <hjk@hansjkoch.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 24fce61b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -771,7 +771,7 @@ framework to set up sysfs files for this region. Simply leave it alone.
	<varname>/sys/class/uio/uioX/maps/mapY/*</varname>.
	<varname>/sys/class/uio/uioX/maps/mapY/*</varname>.
	The dynmaic memory regions will be freed when the UIO device file is
	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
	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>
	</para>
</sect1>
</sect1>


+4 −2
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@
#include <linux/of_address.h>
#include <linux/of_address.h>


#define DRIVER_NAME "uio_dmem_genirq"
#define DRIVER_NAME "uio_dmem_genirq"
#define DMEM_MAP_ERROR (~0)


struct uio_dmem_genirq_platdata {
struct uio_dmem_genirq_platdata {
	struct uio_info *uioinfo;
	struct uio_info *uioinfo;
@@ -60,6 +61,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
		addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size,
		addr = dma_alloc_coherent(&priv->pdev->dev, uiomem->size,
				(dma_addr_t *)&uiomem->addr, GFP_KERNEL);
				(dma_addr_t *)&uiomem->addr, GFP_KERNEL);
		if (!addr) {
		if (!addr) {
			uiomem->addr = DMEM_MAP_ERROR;
			ret = -ENOMEM;
			ret = -ENOMEM;
			break;
			break;
		}
		}
@@ -95,7 +97,7 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
		dma_free_coherent(&priv->pdev->dev, uiomem->size,
		dma_free_coherent(&priv->pdev->dev, uiomem->size,
				priv->dmem_region_vaddr[dmem_region++],
				priv->dmem_region_vaddr[dmem_region++],
				uiomem->addr);
				uiomem->addr);
		uiomem->addr = DMA_ERROR_CODE;
		uiomem->addr = DMEM_MAP_ERROR;
		++uiomem;
		++uiomem;
	}
	}


@@ -238,7 +240,7 @@ static int uio_dmem_genirq_probe(struct platform_device *pdev)
			break;
			break;
		}
		}
		uiomem->memtype = UIO_MEM_PHYS;
		uiomem->memtype = UIO_MEM_PHYS;
		uiomem->addr = DMA_ERROR_CODE;
		uiomem->addr = DMEM_MAP_ERROR;
		uiomem->size = pdata->dynamic_region_sizes[i];
		uiomem->size = pdata->dynamic_region_sizes[i];
		++uiomem;
		++uiomem;
	}
	}