From hjk@linutronix.de Tue Sep 23 15:59:05 2008 From: Hans J. Koch Date: Thu, 18 Sep 2008 23:53:18 +0200 Subject: UIO: Add alignment warnings for uio-mem To: Wolfram Sang Cc: linux-kernel@vger.kernel.org, hjk@linutronix.de, gregkh@suse.de Message-ID: <20080918215318.GD2991@local> Content-Disposition: inline From: Hans J. Koch This patch adds an "offset" attribute for UIO mappings. It shows the difference between the actual start address of the memory and the start address of the page. Signed-off-by: Hans J. Koch Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_ return sprintf(buf, "0x%lx\n", mem->size); } +static ssize_t map_offset_show(struct uio_mem *mem, char *buf) +{ + return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK); +} + struct uio_sysfs_entry { struct attribute attr; ssize_t (*show)(struct uio_mem *, char *); @@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attri __ATTR(addr, S_IRUGO, map_addr_show, NULL); static struct uio_sysfs_entry size_attribute = __ATTR(size, S_IRUGO, map_size_show, NULL); +static struct uio_sysfs_entry offset_attribute = + __ATTR(offset, S_IRUGO, map_offset_show, NULL); static struct attribute *attrs[] = { &addr_attribute.attr, &size_attribute.attr, + &offset_attribute.attr, NULL, /* need to NULL terminate the list of attributes */ };