lkml.org 
[lkml]   [2008]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] [UIO] Add alignment warnings for uio-mem

mmap works page aligned. If uio-mem areas were set up unaligned, mmap
would silently align it and the corresponding attributes in sysfs would
not reflect it. This patch fixes such values during init to what the
kernel will do anyway and adds a warning.

Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/uio/uio.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

Index: drivers/uio/uio.c
===================================================================
--- drivers/uio/uio.c.orig
+++ drivers/uio/uio.c
@@ -656,6 +656,8 @@
struct uio_info *info)
{
struct uio_device *idev;
+ struct uio_mem *mem;
+ unsigned int offset;
int ret = 0;

if (!parent || !info || !info->name || !info->version)
@@ -691,6 +693,16 @@
goto err_device_create;
}

+ for (mem = info->mem; mem->size; mem++) {
+ offset = mem->addr & ~PAGE_MASK;
+ if (offset) {
+ mem->addr -= offset;
+ mem->size += offset;
+ dev_warn(idev->dev, "mem[%d] not page aligned!"
+ "Fixing values.\n", mem - info->mem);
+ }
+ }
+
ret = uio_dev_add_attributes(idev);
if (ret)
goto err_uio_dev_add_attributes;
--
Dipl.-Ing. Wolfram Sang | http://www.pengutronix.de
Pengutronix - Linux Solutions for Science and Industry[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2008-09-18 16:49    [W:0.064 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site