All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sherry Yang <sherryy@android.com>
To: linux-kernel@vger.kernel.org
Cc: tkjos@google.com, maco@google.com,
	"Sherry Yang" <sherryy@android.com>,
	"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Arve Hjønnevåg" <arve@android.com>,
	"Riley Andrews" <riandrews@android.com>,
	devel@driverdev.osuosl.org (open list:ANDROID DRIVERS)
Subject: [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function
Date: Tue, 29 Aug 2017 17:46:57 -0700	[thread overview]
Message-ID: <20170830004702.120371-2-sherryy@android.com> (raw)
In-Reply-To: <20170830004702.120371-1-sherryy@android.com>

Use helper functions buffer_next and buffer_prev instead
of list_entry to get the next and previous buffers.

Signed-off-by: Sherry Yang <sherryy@android.com>
---
 drivers/android/binder_alloc.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 40f31df60580..f15af2b55a62 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -48,14 +48,23 @@ module_param_named(debug_mask, binder_alloc_debug_mask,
 			pr_info(x); \
 	} while (0)
 
+static struct binder_buffer *binder_buffer_next(struct binder_buffer *buffer)
+{
+	return list_entry(buffer->entry.next, struct binder_buffer, entry);
+}
+
+static struct binder_buffer *binder_buffer_prev(struct binder_buffer *buffer)
+{
+	return list_entry(buffer->entry.prev, struct binder_buffer, entry);
+}
+
 static size_t binder_alloc_buffer_size(struct binder_alloc *alloc,
 				       struct binder_buffer *buffer)
 {
 	if (list_is_last(&buffer->entry, &alloc->buffers))
 		return alloc->buffer +
 		       alloc->buffer_size - (void *)buffer->data;
-	return (size_t)list_entry(buffer->entry.next,
-			  struct binder_buffer, entry) - (size_t)buffer->data;
+	return (size_t)binder_buffer_next(buffer) - (size_t)buffer->data;
 }
 
 static void binder_insert_free_buffer(struct binder_alloc *alloc,
@@ -470,7 +479,7 @@ static void binder_delete_free_buffer(struct binder_alloc *alloc,
 	int free_page_start = 1;
 
 	BUG_ON(alloc->buffers.next == &buffer->entry);
-	prev = list_entry(buffer->entry.prev, struct binder_buffer, entry);
+	prev = binder_buffer_prev(buffer);
 	BUG_ON(!prev->free);
 	if (buffer_end_page(prev) == buffer_start_page(buffer)) {
 		free_page_start = 0;
@@ -482,8 +491,7 @@ static void binder_delete_free_buffer(struct binder_alloc *alloc,
 	}
 
 	if (!list_is_last(&buffer->entry, &alloc->buffers)) {
-		next = list_entry(buffer->entry.next,
-				  struct binder_buffer, entry);
+		next = binder_buffer_next(buffer);
 		if (buffer_start_page(next) == buffer_end_page(buffer)) {
 			free_page_end = 0;
 			if (buffer_start_page(next) ==
@@ -544,8 +552,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,
 	rb_erase(&buffer->rb_node, &alloc->allocated_buffers);
 	buffer->free = 1;
 	if (!list_is_last(&buffer->entry, &alloc->buffers)) {
-		struct binder_buffer *next = list_entry(buffer->entry.next,
-						struct binder_buffer, entry);
+		struct binder_buffer *next = binder_buffer_next(buffer);
 
 		if (next->free) {
 			rb_erase(&next->rb_node, &alloc->free_buffers);
@@ -553,8 +560,7 @@ static void binder_free_buf_locked(struct binder_alloc *alloc,
 		}
 	}
 	if (alloc->buffers.next != &buffer->entry) {
-		struct binder_buffer *prev = list_entry(buffer->entry.prev,
-						struct binder_buffer, entry);
+		struct binder_buffer *prev = binder_buffer_prev(buffer);
 
 		if (prev->free) {
 			binder_delete_free_buffer(alloc, buffer);
-- 
2.14.1.342.g6490525c54-goog

  reply	other threads:[~2017-08-30  0:47 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-30  0:46 [PATCH 0/6] android: binder: move allocator metadata and add shrinker Sherry Yang
2017-08-30  0:46 ` Sherry Yang [this message]
2017-08-30  6:07   ` [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function Greg Kroah-Hartman
2017-08-30 19:46     ` Sherry Yang
2017-08-30 20:08       ` Dan Carpenter
2017-08-31  4:28       ` Greg Kroah-Hartman
2017-08-31 17:26         ` [PATCH] android: binder: fixup crash introduced by moving buffer hdr Sherry Yang
2017-09-01  6:52           ` Greg KH
2017-08-31 17:30         ` [PATCH v3 1/6] android: binder: Refactor prev and next buffer into a helper function Sherry Yang
2017-08-31 18:47           ` Greg Kroah-Hartman
2017-08-31 18:56             ` [PATCH] android: binder: Add page usage in binder stats Sherry Yang
2017-08-30  0:46 ` [PATCH v3 2/6] android: binder: Add allocator selftest Sherry Yang
2017-08-30  0:46 ` [PATCH v3 3/6] android: binder: Move buffer out of area shared with user space Sherry Yang
2017-08-30  9:29   ` Dan Carpenter
2017-08-30 20:04     ` Arve Hjønnevåg
2017-08-30 20:20       ` Dan Carpenter
2017-08-30 21:03         ` Todd Kjos
2017-08-30  0:47 ` [PATCH v3 4/6] android: binder: Add global lru shrinker to binder Sherry Yang
2017-08-30  0:47 ` [PATCH v3 5/6] android: binder: Add shrinker tracepoints Sherry Yang
2017-08-30  0:47 ` [PATCH v3 6/6] android: binder: Add page usage in binder stats Sherry Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170830004702.120371-2-sherryy@android.com \
    --to=sherryy@android.com \
    --cc=arve@android.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maco@google.com \
    --cc=riandrews@android.com \
    --cc=tkjos@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.