Skip to content

Commit

Permalink
ashmem: Whitespace cleanups
Browse files Browse the repository at this point in the history
Fixes checkpatch warnings with the ashmem.c file

CC: Brian Swetland <[email protected]>
CC: Colin Cross <[email protected]>
CC: Arve Hjønnevåg <[email protected]>
CC: Dima Zavin <[email protected]>
CC: Robert Love <[email protected]>
Signed-off-by: John Stultz <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
johnstultz-work authored and gregkh committed Dec 21, 2011
1 parent 33e8fc4 commit 1efb343
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@
* Big Note: Mappings do NOT pin this structure; it dies on close()
*/
struct ashmem_area {
char name[ASHMEM_FULL_NAME_LEN];/* optional name for /proc/pid/maps */
struct list_head unpinned_list; /* list of all ashmem areas */
struct file *file; /* the shmem-based backing file */
size_t size; /* size of the mapping, in bytes */
unsigned long prot_mask; /* allowed prot bits, as vm_flags */
char name[ASHMEM_FULL_NAME_LEN]; /* optional name in /proc/pid/maps */
struct list_head unpinned_list; /* list of all ashmem areas */
struct file *file; /* the shmem-based backing file */
size_t size; /* size of the mapping, in bytes */
unsigned long prot_mask; /* allowed prot bits, as vm_flags */
};

/*
Expand Down Expand Up @@ -79,26 +79,26 @@ static struct kmem_cache *ashmem_area_cachep __read_mostly;
static struct kmem_cache *ashmem_range_cachep __read_mostly;

#define range_size(range) \
((range)->pgend - (range)->pgstart + 1)
((range)->pgend - (range)->pgstart + 1)

#define range_on_lru(range) \
((range)->purged == ASHMEM_NOT_PURGED)
((range)->purged == ASHMEM_NOT_PURGED)

#define page_range_subsumes_range(range, start, end) \
(((range)->pgstart >= (start)) && ((range)->pgend <= (end)))
(((range)->pgstart >= (start)) && ((range)->pgend <= (end)))

#define page_range_subsumed_by_range(range, start, end) \
(((range)->pgstart <= (start)) && ((range)->pgend >= (end)))
(((range)->pgstart <= (start)) && ((range)->pgend >= (end)))

#define page_in_range(range, page) \
(((range)->pgstart <= (page)) && ((range)->pgend >= (page)))
(((range)->pgstart <= (page)) && ((range)->pgend >= (page)))

#define page_range_in_range(range, start, end) \
(page_in_range(range, start) || page_in_range(range, end) || \
page_range_subsumes_range(range, start, end))
(page_in_range(range, start) || page_in_range(range, end) || \
page_range_subsumes_range(range, start, end))

#define range_before_page(range, page) \
((range)->pgend < (page))
((range)->pgend < (page))

#define PROT_MASK (PROT_EXEC | PROT_READ | PROT_WRITE)

Expand Down Expand Up @@ -220,19 +220,17 @@ static ssize_t ashmem_read(struct file *file, char __user *buf,
mutex_lock(&ashmem_mutex);

/* If size is not set, or set to 0, always return EOF. */
if (asma->size == 0) {
if (asma->size == 0)
goto out;
}

if (!asma->file) {
ret = -EBADF;
goto out;
}

ret = asma->file->f_op->read(asma->file, buf, len, pos);
if (ret < 0) {
if (ret < 0)
goto out;
}

/** Update backing file pos, since f_ops->read() doesn't */
asma->file->f_pos = *pos;
Expand Down Expand Up @@ -260,9 +258,8 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
}

ret = asma->file->f_op->llseek(asma->file, offset, origin);
if (ret < 0) {
if (ret < 0)
goto out;
}

/** Copy f_pos from backing file, since f_ops->llseek() sets it */
file->f_pos = asma->file->f_pos;
Expand All @@ -272,10 +269,9 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
return ret;
}

static inline unsigned long
calc_vm_may_flags(unsigned long prot)
static inline unsigned long calc_vm_may_flags(unsigned long prot)
{
return _calc_vm_trans(prot, PROT_READ, VM_MAYREAD ) |
return _calc_vm_trans(prot, PROT_READ, VM_MAYREAD) |
_calc_vm_trans(prot, PROT_WRITE, VM_MAYWRITE) |
_calc_vm_trans(prot, PROT_EXEC, VM_MAYEXEC);
}
Expand All @@ -295,7 +291,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)

/* requested protection bits must match our allowed protection mask */
if (unlikely((vma->vm_flags & ~calc_vm_prot_bits(asma->prot_mask)) &
calc_vm_prot_bits(PROT_MASK))) {
calc_vm_prot_bits(PROT_MASK))) {
ret = -EPERM;
goto out;
}
Expand Down Expand Up @@ -688,8 +684,8 @@ static struct file_operations ashmem_fops = {
.owner = THIS_MODULE,
.open = ashmem_open,
.release = ashmem_release,
.read = ashmem_read,
.llseek = ashmem_llseek,
.read = ashmem_read,
.llseek = ashmem_llseek,
.mmap = ashmem_mmap,
.unlocked_ioctl = ashmem_ioctl,
.compat_ioctl = ashmem_ioctl,
Expand Down

0 comments on commit 1efb343

Please sign in to comment.