aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/uio/uio.c
diff options
context:
space:
mode:
authorBrandon Philips <brandon@ifup.org>2008-02-19 04:55:05 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2008-02-21 18:27:07 -0500
commit4f808bcdf8dcf1f1ecd028f6d5c5347db4cddc54 (patch)
tree5b0e9e6a543ae3911ddba263a64864d05e14e235 /drivers/uio/uio.c
parent46cdf871d9970b9252469531f9efd4a17243bb0b (diff)
UIO: fix Greg's stupid changes
This fixes two bugs with UIO that cropped up recently in -rc1 1) WARNING: at fs/sysfs/file.c:334 sysfs_open_file when trying to open a map addr/size file - complaining about missing sysfs_ops for ktype 2) Permission denied when reading uio/uio0/maps/map0/{addr,size} when files are mode S_IRUGO Also fix a typo: attr_attribute -> addr_attribute Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Hans J. Koch <hjk@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/uio/uio.c')
-rw-r--r--drivers/uio/uio.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 2a77e9d42c68..e8a01f264540 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -57,29 +57,29 @@ struct uio_map {
57}; 57};
58#define to_map(map) container_of(map, struct uio_map, kobj) 58#define to_map(map) container_of(map, struct uio_map, kobj)
59 59
60 60static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
61static ssize_t map_attr_show(struct kobject *kobj, struct kobj_attribute *attr,
62 char *buf)
63{ 61{
64 struct uio_map *map = to_map(kobj); 62 return sprintf(buf, "0x%lx\n", mem->addr);
65 struct uio_mem *mem = map->mem; 63}
66
67 if (strncmp(attr->attr.name, "addr", 4) == 0)
68 return sprintf(buf, "0x%lx\n", mem->addr);
69
70 if (strncmp(attr->attr.name, "size", 4) == 0)
71 return sprintf(buf, "0x%lx\n", mem->size);
72 64
73 return -ENODEV; 65static ssize_t map_size_show(struct uio_mem *mem, char *buf)
66{
67 return sprintf(buf, "0x%lx\n", mem->size);
74} 68}
75 69
76static struct kobj_attribute attr_attribute = 70struct uio_sysfs_entry {
77 __ATTR(addr, S_IRUGO, map_attr_show, NULL); 71 struct attribute attr;
78static struct kobj_attribute size_attribute = 72 ssize_t (*show)(struct uio_mem *, char *);
79 __ATTR(size, S_IRUGO, map_attr_show, NULL); 73 ssize_t (*store)(struct uio_mem *, const char *, size_t);
74};
75
76static struct uio_sysfs_entry addr_attribute =
77 __ATTR(addr, S_IRUGO, map_addr_show, NULL);
78static struct uio_sysfs_entry size_attribute =
79 __ATTR(size, S_IRUGO, map_size_show, NULL);
80 80
81static struct attribute *attrs[] = { 81static struct attribute *attrs[] = {
82 &attr_attribute.attr, 82 &addr_attribute.attr,
83 &size_attribute.attr, 83 &size_attribute.attr,
84 NULL, /* need to NULL terminate the list of attributes */ 84 NULL, /* need to NULL terminate the list of attributes */
85}; 85};
@@ -90,8 +90,28 @@ static void map_release(struct kobject *kobj)
90 kfree(map); 90 kfree(map);
91} 91}
92 92
93static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
94 char *buf)
95{
96 struct uio_map *map = to_map(kobj);
97 struct uio_mem *mem = map->mem;
98 struct uio_sysfs_entry *entry;
99
100 entry = container_of(attr, struct uio_sysfs_entry, attr);
101
102 if (!entry->show)
103 return -EIO;
104
105 return entry->show(mem, buf);
106}
107
108static struct sysfs_ops uio_sysfs_ops = {
109 .show = map_type_show,
110};
111
93static struct kobj_type map_attr_type = { 112static struct kobj_type map_attr_type = {
94 .release = map_release, 113 .release = map_release,
114 .sysfs_ops = &uio_sysfs_ops,
95 .default_attrs = attrs, 115 .default_attrs = attrs,
96}; 116};
97 117