Commit 10a5709f authored by Dave Jones's avatar Dave Jones

[AGP] mmap readability cleanup

parent 0a5bd7ac
...@@ -584,14 +584,12 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -584,14 +584,12 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
AGP_LOCK(); AGP_LOCK();
if (agp_fe.backend_acquired != TRUE) { if (agp_fe.backend_acquired != TRUE)
AGP_UNLOCK(); goto out_eperm;
return -EPERM;
} if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags)))
if (!(test_bit(AGP_FF_IS_VALID, &priv->access_flags))) { goto out_eperm;
AGP_UNLOCK();
return -EPERM;
}
agp_copy_info(&kerninfo); agp_copy_info(&kerninfo);
size = vma->vm_end - vma->vm_start; size = vma->vm_end - vma->vm_start;
current_size = kerninfo.aper_size; current_size = kerninfo.aper_size;
...@@ -599,45 +597,48 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -599,45 +597,48 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
offset = vma->vm_pgoff << PAGE_SHIFT; offset = vma->vm_pgoff << PAGE_SHIFT;
if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) { if (test_bit(AGP_FF_IS_CLIENT, &priv->access_flags)) {
if ((size + offset) > current_size) { if ((size + offset) > current_size)
AGP_UNLOCK(); goto out_inval;
return -EINVAL;
}
client = agp_find_client_by_pid(current->pid); client = agp_find_client_by_pid(current->pid);
if (client == NULL) { if (client == NULL)
AGP_UNLOCK(); goto out_eperm;
return -EPERM;
} if (!agp_find_seg_in_client(client, offset, size, vma->vm_page_prot))
if (!agp_find_seg_in_client(client, offset, goto out_inval;
size, vma->vm_page_prot)) {
AGP_UNLOCK(); if (remap_page_range(vma, vma->vm_start, (kerninfo.aper_base + offset),
return -EINVAL;
}
if (remap_page_range(vma, vma->vm_start,
(kerninfo.aper_base + offset),
size, vma->vm_page_prot)) { size, vma->vm_page_prot)) {
AGP_UNLOCK(); goto out_again;
return -EAGAIN;
} }
AGP_UNLOCK(); AGP_UNLOCK();
return 0; return 0;
} }
if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) { if (test_bit(AGP_FF_IS_CONTROLLER, &priv->access_flags)) {
if (size != current_size) { if (size != current_size)
AGP_UNLOCK(); goto out_inval;
return -EINVAL;
}
if (remap_page_range(vma, vma->vm_start, kerninfo.aper_base, if (remap_page_range(vma, vma->vm_start, kerninfo.aper_base,
size, vma->vm_page_prot)) { size, vma->vm_page_prot)) {
AGP_UNLOCK(); goto out_again;
return -EAGAIN;
} }
AGP_UNLOCK(); AGP_UNLOCK();
return 0; return 0;
} }
out_eperm:
AGP_UNLOCK(); AGP_UNLOCK();
return -EPERM; return -EPERM;
out_inval:
AGP_UNLOCK();
return -EINVAL;
out_again:
AGP_UNLOCK();
return -EAGAIN;
} }
static int agp_release(struct inode *inode, struct file *file) static int agp_release(struct inode *inode, struct file *file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment