mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Damian Hobson-Garcia <dhobsong@igel.co.jp>
To: hjk@hansjkoch.de, gregkh@linuxfoundation.org,
	magnus.damm@gmail.com, horms@verge.net.au
Cc: linux-kernel@vger.kernel.org, linux-sh@vger.kernel.org,
	Damian Hobson-Garcia <dhobsong@igel.co.jp>
Subject: [PATCH 2/4] drivers: uio_dmem_genirq: Don't use DMA_ERROR_CODE to indicate unmapped regions
Date: Fri, 16 Nov 2012 14:46:10 +0900	[thread overview]
Message-ID: <1353044772-18803-3-git-send-email-dhobsong@igel.co.jp> (raw)
In-Reply-To: <1353044772-18803-1-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(-)

diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl
index fdbf86f..ddb05e9 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.
 	<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>
 
diff --git a/drivers/uio/uio_dmem_genirq.c b/drivers/uio/uio_dmem_genirq.c
index d8bbe07..7be8d04 100644
--- 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 uio_info *info, struct inode *inode)
 		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(struct uio_info *info, struct inode *inode)
 		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 platform_device *pdev)
 			break;
 		}
 		uiomem->memtype = UIO_MEM_PHYS;
-		uiomem->addr = DMA_ERROR_CODE;
+		uiomem->addr = DMEM_MAP_ERROR;
 		uiomem->size = pdata->dynamic_region_sizes[i];
 		++uiomem;
 	}
-- 
1.7.5.4


  parent reply	other threads:[~2012-11-16  5:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16  5:46 [PATCH 0/4] UIO platform device fixes Damian Hobson-Garcia
2012-11-16  5:46 ` [PATCH 1/4] drivers: uio_dmem_genirq: Don't mix address spaces for dynamic region vaddr Damian Hobson-Garcia
2012-11-16  5:46 ` Damian Hobson-Garcia [this message]
2012-11-16  5:46 ` [PATCH 3/4] drivers: uio_dmem_genirq: Allow partial success when opening device Damian Hobson-Garcia
2012-11-16  5:46 ` [PATCH 4/4] drivers: uio: Only allocate new private data when probing device tree node Damian Hobson-Garcia

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353044772-18803-3-git-send-email-dhobsong@igel.co.jp \
    --to=dhobsong@igel.co.jp \
    --cc=gregkh@linuxfoundation.org \
    --cc=hjk@hansjkoch.de \
    --cc=horms@verge.net.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®