]> err.no Git - linux-2.6/blobdiff - drivers/uio/uio.c
rt2x00: Remove async vendor request calls from rt2x00usb
[linux-2.6] / drivers / uio / uio.c
index f352731add64ac11a732bbfcd1aa93c5a3749628..e8a01f264540e1cb9675eb821e0f3769c7a9667c 100644 (file)
@@ -39,7 +39,7 @@ struct uio_device {
 
 static int uio_major;
 static DEFINE_IDR(uio_idr);
-static struct file_operations uio_fops;
+static const struct file_operations uio_fops;
 
 /* UIO class infrastructure */
 static struct uio_class {
@@ -57,29 +57,29 @@ struct uio_map {
 };
 #define to_map(map) container_of(map, struct uio_map, kobj)
 
-
-static ssize_t map_attr_show(struct kobject *kobj, struct kobj_attribute *attr,
-                            char *buf)
+static ssize_t map_addr_show(struct uio_mem *mem, char *buf)
 {
-       struct uio_map *map = to_map(kobj);
-       struct uio_mem *mem = map->mem;
-
-       if (strncmp(attr->attr.name, "addr", 4) == 0)
-               return sprintf(buf, "0x%lx\n", mem->addr);
-
-       if (strncmp(attr->attr.name, "size", 4) == 0)
-               return sprintf(buf, "0x%lx\n", mem->size);
+       return sprintf(buf, "0x%lx\n", mem->addr);
+}
 
-       return -ENODEV;
+static ssize_t map_size_show(struct uio_mem *mem, char *buf)
+{
+       return sprintf(buf, "0x%lx\n", mem->size);
 }
 
-static struct kobj_attribute attr_attribute =
-       __ATTR(addr, S_IRUGO, map_attr_show, NULL);
-static struct kobj_attribute size_attribute =
-       __ATTR(size, S_IRUGO, map_attr_show, NULL);
+struct uio_sysfs_entry {
+       struct attribute attr;
+       ssize_t (*show)(struct uio_mem *, char *);
+       ssize_t (*store)(struct uio_mem *, const char *, size_t);
+};
+
+static struct uio_sysfs_entry addr_attribute =
+       __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 attribute *attrs[] = {
-       &attr_attribute.attr,
+       &addr_attribute.attr,
        &size_attribute.attr,
        NULL,   /* need to NULL terminate the list of attributes */
 };
@@ -90,8 +90,28 @@ static void map_release(struct kobject *kobj)
        kfree(map);
 }
 
+static ssize_t map_type_show(struct kobject *kobj, struct attribute *attr,
+                            char *buf)
+{
+       struct uio_map *map = to_map(kobj);
+       struct uio_mem *mem = map->mem;
+       struct uio_sysfs_entry *entry;
+
+       entry = container_of(attr, struct uio_sysfs_entry, attr);
+
+       if (!entry->show)
+               return -EIO;
+
+       return entry->show(mem, buf);
+}
+
+static struct sysfs_ops uio_sysfs_ops = {
+       .show = map_type_show,
+};
+
 static struct kobj_type map_attr_type = {
        .release        = map_release,
+       .sysfs_ops      = &uio_sysfs_ops,
        .default_attrs  = attrs,
 };
 
@@ -186,9 +206,9 @@ err:
        for (mi--; mi>=0; mi--) {
                mem = &idev->info->mem[mi];
                map = mem->map;
-               kobject_unregister(&map->kobj);
+               kobject_put(&map->kobj);
        }
-       kobject_unregister(idev->map_dir);
+       kobject_put(idev->map_dir);
        sysfs_remove_group(&idev->dev->kobj, &uio_attr_grp);
 err_group:
        dev_err(idev->dev, "error creating sysfs files (%d)\n", ret);
@@ -203,9 +223,9 @@ static void uio_dev_del_attributes(struct uio_device *idev)
                mem = &idev->info->mem[mi];
                if (mem->size == 0)
                        break;
-               kobject_unregister(&mem->map->kobj);
+               kobject_put(&mem->map->kobj);
        }
-       kobject_unregister(idev->map_dir);
+       kobject_put(idev->map_dir);
        sysfs_remove_group(&idev->dev->kobj, &uio_attr_grp);
 }
 
@@ -417,30 +437,28 @@ static void uio_vma_close(struct vm_area_struct *vma)
        idev->vma_count--;
 }
 
-static struct page *uio_vma_nopage(struct vm_area_struct *vma,
-                                  unsigned long address, int *type)
+static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
        struct uio_device *idev = vma->vm_private_data;
-       struct page* page = NOPAGE_SIGBUS;
+       struct page *page;
 
        int mi = uio_find_mem_index(vma);
        if (mi < 0)
-               return page;
+               return VM_FAULT_SIGBUS;
 
        if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL)
                page = virt_to_page(idev->info->mem[mi].addr);
        else
                page = vmalloc_to_page((void*)idev->info->mem[mi].addr);
        get_page(page);
-       if (type)
-               *type = VM_FAULT_MINOR;
-       return page;
+       vmf->page = page;
+       return 0;
 }
 
 static struct vm_operations_struct uio_vm_ops = {
        .open = uio_vma_open,
        .close = uio_vma_close,
-       .nopage = uio_vma_nopage,
+       .fault = uio_vma_fault,
 };
 
 static int uio_mmap_physical(struct vm_area_struct *vma)
@@ -508,7 +526,7 @@ static int uio_mmap(struct file *filep, struct vm_area_struct *vma)
        }
 }
 
-static struct file_operations uio_fops = {
+static const struct file_operations uio_fops = {
        .owner          = THIS_MODULE,
        .open           = uio_open,
        .release        = uio_release,