Skip to content

Commit

Permalink
drivers: uio_dmem_genirq: Don't mix address spaces for dynamic region…
Browse files Browse the repository at this point in the history
… vaddr

Assigning the virtual address returned from dma_alloc_coherent to the the
internal_addr element of uioinfo produces the following sparse errors since
internal_addr is a void __iomem * and dma_alloc_coherent returns void *.

+ drivers/uio/uio_dmem_genirq.c:65:39: sparse: incorrect type in assignment (different address spaces)
  drivers/uio/uio_dmem_genirq.c:65:39:    expected void [noderef] <asn:2>*internal_addr
  drivers/uio/uio_dmem_genirq.c:65:39:    got void *[assigned] addr
+ drivers/uio/uio_dmem_genirq.c:93:17: sparse: incorrect type in argument 3 (different address spaces)
  drivers/uio/uio_dmem_genirq.c:93:17:    expected void *vaddr
  drivers/uio/uio_dmem_genirq.c:93:17:    got void [noderef] <asn:2>*internal_addr

Store the void * in the driver's private data instead.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
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>
  • Loading branch information
Damian Hobson-Garcia authored and Greg Kroah-Hartman committed Nov 21, 2012
1 parent 9b96c31 commit 24fce61
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/uio/uio_dmem_genirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct uio_dmem_genirq_platdata {
struct platform_device *pdev;
unsigned int dmem_region_start;
unsigned int num_dmem_regions;
void *dmem_region_vaddr[MAX_UIO_MAPS];
struct mutex alloc_lock;
unsigned int refcnt;
};
Expand All @@ -46,6 +47,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
struct uio_dmem_genirq_platdata *priv = info->priv;
struct uio_mem *uiomem;
int ret = 0;
int dmem_region = priv->dmem_region_start;

uiomem = &priv->uioinfo->mem[priv->dmem_region_start];

Expand All @@ -61,8 +63,7 @@ static int uio_dmem_genirq_open(struct uio_info *info, struct inode *inode)
ret = -ENOMEM;
break;
}

uiomem->internal_addr = addr;
priv->dmem_region_vaddr[dmem_region++] = addr;
++uiomem;
}
priv->refcnt++;
Expand All @@ -77,6 +78,7 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
{
struct uio_dmem_genirq_platdata *priv = info->priv;
struct uio_mem *uiomem;
int dmem_region = priv->dmem_region_start;

/* Tell the Runtime PM code that the device has become idle */
pm_runtime_put_sync(&priv->pdev->dev);
Expand All @@ -91,7 +93,8 @@ static int uio_dmem_genirq_release(struct uio_info *info, struct inode *inode)
break;

dma_free_coherent(&priv->pdev->dev, uiomem->size,
uiomem->internal_addr, uiomem->addr);
priv->dmem_region_vaddr[dmem_region++],
uiomem->addr);
uiomem->addr = DMA_ERROR_CODE;
++uiomem;
}
Expand Down

0 comments on commit 24fce61

Please sign in to comment.