From 7c3937aef8d956453ad64a5c52e33e69fa92abe0 Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Mon, 11 Nov 2013 11:42:47 +0400 Subject: [PATCH] [REFACTOR] separate definitions and kernel operations in buffer Change-Id: I602a03b4f4bec4d95632ad5b30040d7057c7cbbb Signed-off-by: Alexander Aksenov --- buffer/buffer_description.h | 2 +- buffer/buffer_queue.c | 1 + buffer/data_types.h | 43 +++++++++++++++++++++++++++++++++++++++++++ buffer/kernel_operations.h | 9 +-------- buffer/swap_buffer_module.c | 1 + driver/driver_to_buffer.c | 1 + 6 files changed, 48 insertions(+), 9 deletions(-) create mode 100644 buffer/data_types.h diff --git a/buffer/buffer_description.h b/buffer/buffer_description.h index 988c780..2be9eaf 100644 --- a/buffer/buffer_description.h +++ b/buffer/buffer_description.h @@ -27,7 +27,7 @@ #ifndef __BUFFER_DESCRIPTION_H__ #define __BUFFER_DESCRIPTION_H__ -#include "kernel_operations.h" +#include "data_types.h" struct swap_subbuffer { /* Pointer to the next subbuffer in queue */ diff --git a/buffer/buffer_queue.c b/buffer/buffer_queue.c index 28f7640..7ba67fb 100644 --- a/buffer/buffer_queue.c +++ b/buffer/buffer_queue.c @@ -45,6 +45,7 @@ #include "buffer_queue.h" #include "swap_buffer_to_buffer_queue.h" #include "swap_buffer_errors.h" +#include "kernel_operations.h" /* Queue structure. Consist of pointers to the first and the last elements of * queue. */ diff --git a/buffer/data_types.h b/buffer/data_types.h new file mode 100644 index 0000000..6da8b4c --- /dev/null +++ b/buffer/data_types.h @@ -0,0 +1,43 @@ +/* + * SWAP Buffer Module + * modules/buffer/data_types.h + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * Copyright (C) Samsung Electronics, 2013 + * + * 2013 Alexander Aksenov : SWAP Buffer implement + * + */ + +#ifndef __DATA_TYPES_H__ +#define __DATA_TYPES_H__ + + +#include + + +struct page; + +/* Using spinlocks as sync primitives */ +struct sync_t { + spinlock_t spinlock; + unsigned long flags; +}; + +/* swap_subbuffer_ptr points to the first memory page of the subbuffer */ +typedef struct page *swap_subbuffer_ptr; + +#endif /* __DATA_TYPES_H__ */ diff --git a/buffer/kernel_operations.h b/buffer/kernel_operations.h index 1c41f98..9327c1e 100644 --- a/buffer/kernel_operations.h +++ b/buffer/kernel_operations.h @@ -36,6 +36,7 @@ #include #include +#include "data_types.h" /* MESSAGES */ @@ -55,12 +56,6 @@ /* LOCKS */ -/* Using spinlocks as sync primitives */ -struct sync_t { - spinlock_t spinlock; - unsigned long flags; -}; - /* Spinlocks initialization */ static inline void sync_init(struct sync_t *buffer_sync) { @@ -82,8 +77,6 @@ static inline void sync_unlock(struct sync_t *buffer_sync) /* SWAP SUBBUFER */ -/* swap_subbuffer_ptr points to the first memory page of the subbuffer */ -typedef struct page *swap_subbuffer_ptr; /* We alloc memory for swap_subbuffer structures with common kmalloc */ #define memory_allocation(memory_size) kmalloc(memory_size, GFP_KERNEL) diff --git a/buffer/swap_buffer_module.c b/buffer/swap_buffer_module.c index c0da9f5..17d8f70 100644 --- a/buffer/swap_buffer_module.c +++ b/buffer/swap_buffer_module.c @@ -28,6 +28,7 @@ #include "buffer_queue.h" #include "buffer_description.h" #include "swap_buffer_errors.h" +#include "kernel_operations.h" /* Bitwise mask for buffer status */ enum _swap_buffer_status_mask { diff --git a/driver/driver_to_buffer.c b/driver/driver_to_buffer.c index 9fd59c9..dd2836a 100644 --- a/driver/driver_to_buffer.c +++ b/driver/driver_to_buffer.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include -- 2.7.4