diff options
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r-- | drivers/uio/uio.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 4ca85a113aa2..03efb065455f 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c | |||
@@ -61,6 +61,14 @@ struct uio_map { | |||
61 | }; | 61 | }; |
62 | #define to_map(map) container_of(map, struct uio_map, kobj) | 62 | #define to_map(map) container_of(map, struct uio_map, kobj) |
63 | 63 | ||
64 | static ssize_t map_name_show(struct uio_mem *mem, char *buf) | ||
65 | { | ||
66 | if (unlikely(!mem->name)) | ||
67 | mem->name = ""; | ||
68 | |||
69 | return sprintf(buf, "%s\n", mem->name); | ||
70 | } | ||
71 | |||
64 | static ssize_t map_addr_show(struct uio_mem *mem, char *buf) | 72 | static ssize_t map_addr_show(struct uio_mem *mem, char *buf) |
65 | { | 73 | { |
66 | return sprintf(buf, "0x%lx\n", mem->addr); | 74 | return sprintf(buf, "0x%lx\n", mem->addr); |
@@ -82,6 +90,8 @@ struct map_sysfs_entry { | |||
82 | ssize_t (*store)(struct uio_mem *, const char *, size_t); | 90 | ssize_t (*store)(struct uio_mem *, const char *, size_t); |
83 | }; | 91 | }; |
84 | 92 | ||
93 | static struct map_sysfs_entry name_attribute = | ||
94 | __ATTR(name, S_IRUGO, map_name_show, NULL); | ||
85 | static struct map_sysfs_entry addr_attribute = | 95 | static struct map_sysfs_entry addr_attribute = |
86 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); | 96 | __ATTR(addr, S_IRUGO, map_addr_show, NULL); |
87 | static struct map_sysfs_entry size_attribute = | 97 | static struct map_sysfs_entry size_attribute = |
@@ -90,6 +100,7 @@ static struct map_sysfs_entry offset_attribute = | |||
90 | __ATTR(offset, S_IRUGO, map_offset_show, NULL); | 100 | __ATTR(offset, S_IRUGO, map_offset_show, NULL); |
91 | 101 | ||
92 | static struct attribute *attrs[] = { | 102 | static struct attribute *attrs[] = { |
103 | &name_attribute.attr, | ||
93 | &addr_attribute.attr, | 104 | &addr_attribute.attr, |
94 | &size_attribute.attr, | 105 | &size_attribute.attr, |
95 | &offset_attribute.attr, | 106 | &offset_attribute.attr, |
@@ -133,6 +144,14 @@ struct uio_portio { | |||
133 | }; | 144 | }; |
134 | #define to_portio(portio) container_of(portio, struct uio_portio, kobj) | 145 | #define to_portio(portio) container_of(portio, struct uio_portio, kobj) |
135 | 146 | ||
147 | static ssize_t portio_name_show(struct uio_port *port, char *buf) | ||
148 | { | ||
149 | if (unlikely(!port->name)) | ||
150 | port->name = ""; | ||
151 | |||
152 | return sprintf(buf, "%s\n", port->name); | ||
153 | } | ||
154 | |||
136 | static ssize_t portio_start_show(struct uio_port *port, char *buf) | 155 | static ssize_t portio_start_show(struct uio_port *port, char *buf) |
137 | { | 156 | { |
138 | return sprintf(buf, "0x%lx\n", port->start); | 157 | return sprintf(buf, "0x%lx\n", port->start); |
@@ -159,6 +178,8 @@ struct portio_sysfs_entry { | |||
159 | ssize_t (*store)(struct uio_port *, const char *, size_t); | 178 | ssize_t (*store)(struct uio_port *, const char *, size_t); |
160 | }; | 179 | }; |
161 | 180 | ||
181 | static struct portio_sysfs_entry portio_name_attribute = | ||
182 | __ATTR(name, S_IRUGO, portio_name_show, NULL); | ||
162 | static struct portio_sysfs_entry portio_start_attribute = | 183 | static struct portio_sysfs_entry portio_start_attribute = |
163 | __ATTR(start, S_IRUGO, portio_start_show, NULL); | 184 | __ATTR(start, S_IRUGO, portio_start_show, NULL); |
164 | static struct portio_sysfs_entry portio_size_attribute = | 185 | static struct portio_sysfs_entry portio_size_attribute = |
@@ -167,6 +188,7 @@ static struct portio_sysfs_entry portio_porttype_attribute = | |||
167 | __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); | 188 | __ATTR(porttype, S_IRUGO, portio_porttype_show, NULL); |
168 | 189 | ||
169 | static struct attribute *portio_attrs[] = { | 190 | static struct attribute *portio_attrs[] = { |
191 | &portio_name_attribute.attr, | ||
170 | &portio_start_attribute.attr, | 192 | &portio_start_attribute.attr, |
171 | &portio_size_attribute.attr, | 193 | &portio_size_attribute.attr, |
172 | &portio_porttype_attribute.attr, | 194 | &portio_porttype_attribute.attr, |
@@ -686,7 +708,8 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma) | |||
686 | return -EINVAL; | 708 | return -EINVAL; |
687 | 709 | ||
688 | requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; | 710 | requested_pages = (vma->vm_end - vma->vm_start) >> PAGE_SHIFT; |
689 | actual_pages = (idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; | 711 | actual_pages = ((idev->info->mem[mi].addr & ~PAGE_MASK) |
712 | + idev->info->mem[mi].size + PAGE_SIZE -1) >> PAGE_SHIFT; | ||
690 | if (requested_pages > actual_pages) | 713 | if (requested_pages > actual_pages) |
691 | return -EINVAL; | 714 | return -EINVAL; |
692 | 715 | ||