[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080918144615.GD4226@pengutronix.de>
Date: Thu, 18 Sep 2008 16:46:15 +0200
From: Wolfram Sang <w.sang@...gutronix.de>
To: linux-kernel@...r.kernel.org
Cc: hjk@...utronix.de, gregkh@...e.de
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@...gutronix.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
Download attachment "signature.asc" of type "application/pgp-signature" (190 bytes)
Powered by blists - more mailing lists