USB: mon nopage
Convert USB mon driver from nopage to fault. Signed-off-by: Nick Piggin <npiggin@suse.de> Acked-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d0fab0ddf3
commit
041509db39
@@ -1047,33 +1047,31 @@ static void mon_bin_vma_close(struct vm_area_struct *vma)
|
|||||||
/*
|
/*
|
||||||
* Map ring pages to user space.
|
* Map ring pages to user space.
|
||||||
*/
|
*/
|
||||||
struct page *mon_bin_vma_nopage(struct vm_area_struct *vma,
|
static int mon_bin_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
|
||||||
unsigned long address, int *type)
|
|
||||||
{
|
{
|
||||||
struct mon_reader_bin *rp = vma->vm_private_data;
|
struct mon_reader_bin *rp = vma->vm_private_data;
|
||||||
unsigned long offset, chunk_idx;
|
unsigned long offset, chunk_idx;
|
||||||
struct page *pageptr;
|
struct page *pageptr;
|
||||||
|
|
||||||
offset = (address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
|
offset = vmf->pgoff << PAGE_SHIFT;
|
||||||
if (offset >= rp->b_size)
|
if (offset >= rp->b_size)
|
||||||
return NOPAGE_SIGBUS;
|
return VM_FAULT_SIGBUS;
|
||||||
chunk_idx = offset / CHUNK_SIZE;
|
chunk_idx = offset / CHUNK_SIZE;
|
||||||
pageptr = rp->b_vec[chunk_idx].pg;
|
pageptr = rp->b_vec[chunk_idx].pg;
|
||||||
get_page(pageptr);
|
get_page(pageptr);
|
||||||
if (type)
|
vmf->page = pageptr;
|
||||||
*type = VM_FAULT_MINOR;
|
return 0;
|
||||||
return pageptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct vm_operations_struct mon_bin_vm_ops = {
|
struct vm_operations_struct mon_bin_vm_ops = {
|
||||||
.open = mon_bin_vma_open,
|
.open = mon_bin_vma_open,
|
||||||
.close = mon_bin_vma_close,
|
.close = mon_bin_vma_close,
|
||||||
.nopage = mon_bin_vma_nopage,
|
.fault = mon_bin_vma_fault,
|
||||||
};
|
};
|
||||||
|
|
||||||
int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma)
|
int mon_bin_mmap(struct file *filp, struct vm_area_struct *vma)
|
||||||
{
|
{
|
||||||
/* don't do anything here: "nopage" will set up page table entries */
|
/* don't do anything here: "fault" will set up page table entries */
|
||||||
vma->vm_ops = &mon_bin_vm_ops;
|
vma->vm_ops = &mon_bin_vm_ops;
|
||||||
vma->vm_flags |= VM_RESERVED;
|
vma->vm_flags |= VM_RESERVED;
|
||||||
vma->vm_private_data = filp->private_data;
|
vma->vm_private_data = filp->private_data;
|
||||||
|
Reference in New Issue
Block a user