aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Repinski <repinski23@gmail.com>2016-10-07 02:58:38 -0500
committerZiyan <jaraidaniel@gmail.com>2016-10-29 01:33:58 +0200
commit643a326c45fb2ca90d02f098e5d4bae2d1109d04 (patch)
tree45b021847b3be91fd9d5fdf1abbb59fa09089f13
parent0e24f3291247cea524ea5cb865a8a01abe2f5d5b (diff)
downloadkernel_samsung_tuna-643a326c45fb2ca90d02f098e5d4bae2d1109d04.zip
kernel_samsung_tuna-643a326c45fb2ca90d02f098e5d4bae2d1109d04.tar.gz
kernel_samsung_tuna-643a326c45fb2ca90d02f098e5d4bae2d1109d04.tar.bz2
ashmem: Move to drivers/staging/android; fix odd merges.
Change-Id: Ie8d4dea92c9bc9c5efe69886db05f93b3487f3a4 Signed-off-by: Kyle Repinski <repinski23@gmail.com>
-rw-r--r--drivers/staging/android/Kconfig12
-rw-r--r--drivers/staging/android/Makefile1
-rw-r--r--drivers/staging/android/ashmem.c (renamed from mm/ashmem.c)47
-rw-r--r--drivers/staging/android/ashmem.h (renamed from include/linux/ashmem.h)1
-rw-r--r--init/Kconfig9
-rw-r--r--mm/Makefile1
6 files changed, 36 insertions, 35 deletions
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 90f7e2a..3346269 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -12,6 +12,18 @@ config ANDROID_BINDER_IPC
bool "Android Binder IPC Driver"
default n
+config ASHMEM
+ bool "Enable the Anonymous Shared Memory Subsystem"
+ default n
+ depends on SHMEM || TINY_SHMEM
+ help
+ The ashmem subsystem is a new shared memory allocator, similar to
+ POSIX SHM but with different behavior and sporting a simpler
+ file-based API.
+
+ It is, in theory, a good memory allocator for low-memory devices,
+ because it can discard shared memory units when under memory pressure.
+
config ANDROID_RAM_CONSOLE
bool "Android RAM buffer console"
default n
diff --git a/drivers/staging/android/Makefile b/drivers/staging/android/Makefile
index c16e2bf..20d46a3 100644
--- a/drivers/staging/android/Makefile
+++ b/drivers/staging/android/Makefile
@@ -1,6 +1,7 @@
ccflags-y += -I$(src) # needed for trace events
obj-$(CONFIG_ANDROID_BINDER_IPC) += binder.o
+obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_ANDROID_LOGGER) += logger.o
obj-$(CONFIG_ANDROID_RAM_CONSOLE) += ram_console.o
obj-$(CONFIG_ANDROID_TIMED_OUTPUT) += timed_output.o
diff --git a/mm/ashmem.c b/drivers/staging/android/ashmem.c
index 62fab28..d660b66 100644
--- a/mm/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -28,7 +28,7 @@
#include <linux/bitops.h>
#include <linux/mutex.h>
#include <linux/shmem_fs.h>
-#include <linux/ashmem.h>
+#include "ashmem.h"
#define ASHMEM_NAME_PREFIX "dev/ashmem/"
#define ASHMEM_NAME_PREFIX_LEN (sizeof(ASHMEM_NAME_PREFIX) - 1)
@@ -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 */
};
/*
@@ -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)
@@ -220,9 +220,8 @@ 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_unlock;
- }
if (!asma->file) {
ret = -EBADF;
@@ -267,9 +266,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;
@@ -279,10 +277,9 @@ out:
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);
}
@@ -302,7 +299,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;
}
@@ -682,12 +679,12 @@ static long ashmem_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return ret;
}
-static struct file_operations ashmem_fops = {
+static const 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,
diff --git a/include/linux/ashmem.h b/drivers/staging/android/ashmem.h
index 1976b10..39f571f 100644
--- a/include/linux/ashmem.h
+++ b/drivers/staging/android/ashmem.h
@@ -14,6 +14,7 @@
#include <linux/limits.h>
#include <linux/ioctl.h>
+#include <linux/types.h>
#define ASHMEM_NAME_LEN 256
diff --git a/init/Kconfig b/init/Kconfig
index 1115d2f..676b9ed 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1102,15 +1102,6 @@ config SHMEM
option replaces shmem and tmpfs with the much simpler ramfs code,
which may be appropriate on small systems without swap.
-config ASHMEM
- bool "Enable the Anonymous Shared Memory Subsystem"
- default n
- depends on SHMEM || TINY_SHMEM
- help
- The ashmem subsystem is a new shared memory allocator, similar to
- POSIX SHM but with different behavior and sporting a simpler
- file-based API.
-
config AIO
bool "Enable AIO support" if EXPERT
default y
diff --git a/mm/Makefile b/mm/Makefile
index 7ec5e3b..9edc919 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -30,7 +30,6 @@ obj-$(CONFIG_HUGETLBFS) += hugetlb.o
obj-$(CONFIG_NUMA) += mempolicy.o
obj-$(CONFIG_SPARSEMEM) += sparse.o
obj-$(CONFIG_SPARSEMEM_VMEMMAP) += sparse-vmemmap.o
-obj-$(CONFIG_ASHMEM) += ashmem.o
obj-$(CONFIG_SLOB) += slob.o
obj-$(CONFIG_MMU_NOTIFIER) += mmu_notifier.o
obj-$(CONFIG_KSM) += ksm.o