aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2009-05-11 20:00:41 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-06-19 14:00:52 -0400
commit3dffc8271f778b9ac8eb6985c99f23cef7a753d6 (patch)
tree606135209da947c5737afd7da9e8b37448ca819e
parente93daf9f8d94b9dc31a66e3ae76d7fdf80b1cb7d (diff)
Staging: android: binder: fix up some checkpatch warnings
This cleans up the majority of the checkpatch warnings in the android binder driver. All that is left now is a bunch of too-long-line stuff. Cc: San Mehat <san@android.com> Cc: Arve Hjønnevåg <arve@android.com> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/android/binder.c436
1 files changed, 274 insertions, 162 deletions
diff --git a/drivers/staging/android/binder.c b/drivers/staging/android/binder.c
index 299d29d1dadb..17d89a8124ad 100644
--- a/drivers/staging/android/binder.c
+++ b/drivers/staging/android/binder.c
@@ -44,8 +44,8 @@ static struct hlist_head binder_dead_nodes;
44static HLIST_HEAD(binder_deferred_list); 44static HLIST_HEAD(binder_deferred_list);
45static DEFINE_MUTEX(binder_deferred_lock); 45static DEFINE_MUTEX(binder_deferred_lock);
46 46
47static int binder_read_proc_proc( 47static int binder_read_proc_proc(char *page, char **start, off_t off,
48 char *page, char **start, off_t off, int count, int *eof, void *data); 48 int count, int *eof, void *data);
49 49
50/* This is only defined in include/asm-arm/sizes.h */ 50/* This is only defined in include/asm-arm/sizes.h */
51#ifndef SZ_1K 51#ifndef SZ_1K
@@ -81,12 +81,15 @@ enum {
81static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR | 81static uint32_t binder_debug_mask = BINDER_DEBUG_USER_ERROR |
82 BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION; 82 BINDER_DEBUG_FAILED_TRANSACTION | BINDER_DEBUG_DEAD_TRANSACTION;
83module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO); 83module_param_named(debug_mask, binder_debug_mask, uint, S_IWUSR | S_IRUGO);
84
84static int binder_debug_no_lock; 85static int binder_debug_no_lock;
85module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO); 86module_param_named(proc_no_lock, binder_debug_no_lock, bool, S_IWUSR | S_IRUGO);
87
86static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait); 88static DECLARE_WAIT_QUEUE_HEAD(binder_user_error_wait);
87static int binder_stop_on_user_error; 89static int binder_stop_on_user_error;
88static int binder_set_stop_on_user_error( 90
89 const char *val, struct kernel_param *kp) 91static int binder_set_stop_on_user_error(const char *val,
92 struct kernel_param *kp)
90{ 93{
91 int ret; 94 int ret;
92 ret = param_set_int(val, kp); 95 ret = param_set_int(val, kp);
@@ -185,13 +188,13 @@ struct binder_node {
185 int local_strong_refs; 188 int local_strong_refs;
186 void __user *ptr; 189 void __user *ptr;
187 void __user *cookie; 190 void __user *cookie;
188 unsigned has_strong_ref : 1; 191 unsigned has_strong_ref:1;
189 unsigned pending_strong_ref : 1; 192 unsigned pending_strong_ref:1;
190 unsigned has_weak_ref : 1; 193 unsigned has_weak_ref:1;
191 unsigned pending_weak_ref : 1; 194 unsigned pending_weak_ref:1;
192 unsigned has_async_transaction : 1; 195 unsigned has_async_transaction:1;
193 unsigned accept_fds : 1; 196 unsigned accept_fds:1;
194 int min_priority : 8; 197 unsigned min_priority:8;
195 struct list_head async_todo; 198 struct list_head async_todo;
196}; 199};
197 200
@@ -221,10 +224,10 @@ struct binder_buffer {
221 struct list_head entry; /* free and allocated entries by addesss */ 224 struct list_head entry; /* free and allocated entries by addesss */
222 struct rb_node rb_node; /* free entry by size or allocated entry */ 225 struct rb_node rb_node; /* free entry by size or allocated entry */
223 /* by address */ 226 /* by address */
224 unsigned free : 1; 227 unsigned free:1;
225 unsigned allow_user_free : 1; 228 unsigned allow_user_free:1;
226 unsigned async_transaction : 1; 229 unsigned async_transaction:1;
227 unsigned debug_id : 29; 230 unsigned debug_id:29;
228 231
229 struct binder_transaction *transaction; 232 struct binder_transaction *transaction;
230 233
@@ -306,8 +309,8 @@ struct binder_transaction {
306 struct binder_proc *to_proc; 309 struct binder_proc *to_proc;
307 struct binder_thread *to_thread; 310 struct binder_thread *to_thread;
308 struct binder_transaction *to_parent; 311 struct binder_transaction *to_parent;
309 unsigned need_reply : 1; 312 unsigned need_reply:1;
310 /*unsigned is_dead : 1;*/ /* not used at the moment */ 313 /* unsigned is_dead:1; */ /* not used at the moment */
311 314
312 struct binder_buffer *buffer; 315 struct binder_buffer *buffer;
313 unsigned int code; 316 unsigned int code;
@@ -474,8 +477,8 @@ static void binder_set_nice(long nice)
474 binder_user_error("binder: %d RLIMIT_NICE not set\n", current->pid); 477 binder_user_error("binder: %d RLIMIT_NICE not set\n", current->pid);
475} 478}
476 479
477static size_t binder_buffer_size( 480static size_t binder_buffer_size(struct binder_proc *proc,
478 struct binder_proc *proc, struct binder_buffer *buffer) 481 struct binder_buffer *buffer)
479{ 482{
480 if (list_is_last(&buffer->entry, &proc->buffers)) 483 if (list_is_last(&buffer->entry, &proc->buffers))
481 return proc->buffer + proc->buffer_size - (void *)buffer->data; 484 return proc->buffer + proc->buffer_size - (void *)buffer->data;
@@ -484,8 +487,8 @@ static size_t binder_buffer_size(
484 struct binder_buffer, entry) - (size_t)buffer->data; 487 struct binder_buffer, entry) - (size_t)buffer->data;
485} 488}
486 489
487static void binder_insert_free_buffer( 490static void binder_insert_free_buffer(struct binder_proc *proc,
488 struct binder_proc *proc, struct binder_buffer *new_buffer) 491 struct binder_buffer *new_buffer)
489{ 492{
490 struct rb_node **p = &proc->free_buffers.rb_node; 493 struct rb_node **p = &proc->free_buffers.rb_node;
491 struct rb_node *parent = NULL; 494 struct rb_node *parent = NULL;
@@ -517,8 +520,8 @@ static void binder_insert_free_buffer(
517 rb_insert_color(&new_buffer->rb_node, &proc->free_buffers); 520 rb_insert_color(&new_buffer->rb_node, &proc->free_buffers);
518} 521}
519 522
520static void binder_insert_allocated_buffer( 523static void binder_insert_allocated_buffer(struct binder_proc *proc,
521 struct binder_proc *proc, struct binder_buffer *new_buffer) 524 struct binder_buffer *new_buffer)
522{ 525{
523 struct rb_node **p = &proc->allocated_buffers.rb_node; 526 struct rb_node **p = &proc->allocated_buffers.rb_node;
524 struct rb_node *parent = NULL; 527 struct rb_node *parent = NULL;
@@ -542,8 +545,8 @@ static void binder_insert_allocated_buffer(
542 rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers); 545 rb_insert_color(&new_buffer->rb_node, &proc->allocated_buffers);
543} 546}
544 547
545static struct binder_buffer *binder_buffer_lookup( 548static struct binder_buffer *binder_buffer_lookup(struct binder_proc *proc,
546 struct binder_proc *proc, void __user *user_ptr) 549 void __user *user_ptr)
547{ 550{
548 struct rb_node *n = proc->allocated_buffers.rb_node; 551 struct rb_node *n = proc->allocated_buffers.rb_node;
549 struct binder_buffer *buffer; 552 struct binder_buffer *buffer;
@@ -567,7 +570,8 @@ static struct binder_buffer *binder_buffer_lookup(
567} 570}
568 571
569static int binder_update_page_range(struct binder_proc *proc, int allocate, 572static int binder_update_page_range(struct binder_proc *proc, int allocate,
570 void *start, void *end, struct vm_area_struct *vma) 573 void *start, void *end,
574 struct vm_area_struct *vma)
571{ 575{
572 void *page_addr; 576 void *page_addr;
573 unsigned long user_page_addr; 577 unsigned long user_page_addr;
@@ -664,7 +668,8 @@ err_no_vma:
664} 668}
665 669
666static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc, 670static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
667 size_t data_size, size_t offsets_size, int is_async) 671 size_t data_size,
672 size_t offsets_size, int is_async)
668{ 673{
669 struct rb_node *n = proc->free_buffers.rb_node; 674 struct rb_node *n = proc->free_buffers.rb_node;
670 struct binder_buffer *buffer; 675 struct binder_buffer *buffer;
@@ -692,8 +697,9 @@ static struct binder_buffer *binder_alloc_buf(struct binder_proc *proc,
692 if (is_async && 697 if (is_async &&
693 proc->free_async_space < size + sizeof(struct binder_buffer)) { 698 proc->free_async_space < size + sizeof(struct binder_buffer)) {
694 if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) 699 if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC)
695 printk(KERN_ERR "binder: %d: binder_alloc_buf size %zd f" 700 printk(KERN_ERR
696 "ailed, no async space left\n", proc->pid, size); 701 "binder: %d: binder_alloc_buf size %zd failed, "
702 "no async space left\n", proc->pid, size);
697 return NULL; 703 return NULL;
698 } 704 }
699 705
@@ -777,8 +783,8 @@ static void *buffer_end_page(struct binder_buffer *buffer)
777 return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK); 783 return (void *)(((uintptr_t)(buffer + 1) - 1) & PAGE_MASK);
778} 784}
779 785
780static void binder_delete_free_buffer( 786static void binder_delete_free_buffer(struct binder_proc *proc,
781 struct binder_proc *proc, struct binder_buffer *buffer) 787 struct binder_buffer *buffer)
782{ 788{
783 struct binder_buffer *prev, *next = NULL; 789 struct binder_buffer *prev, *next = NULL;
784 int free_page_end = 1; 790 int free_page_end = 1;
@@ -824,8 +830,8 @@ static void binder_delete_free_buffer(
824 } 830 }
825} 831}
826 832
827static void binder_free_buf( 833static void binder_free_buf(struct binder_proc *proc,
828 struct binder_proc *proc, struct binder_buffer *buffer) 834 struct binder_buffer *buffer)
829{ 835{
830 size_t size, buffer_size; 836 size_t size, buffer_size;
831 837
@@ -877,8 +883,8 @@ static void binder_free_buf(
877 binder_insert_free_buffer(proc, buffer); 883 binder_insert_free_buffer(proc, buffer);
878} 884}
879 885
880static struct binder_node * 886static struct binder_node *binder_get_node(struct binder_proc *proc,
881binder_get_node(struct binder_proc *proc, void __user *ptr) 887 void __user *ptr)
882{ 888{
883 struct rb_node *n = proc->nodes.rb_node; 889 struct rb_node *n = proc->nodes.rb_node;
884 struct binder_node *node; 890 struct binder_node *node;
@@ -896,8 +902,9 @@ binder_get_node(struct binder_proc *proc, void __user *ptr)
896 return NULL; 902 return NULL;
897} 903}
898 904
899static struct binder_node * 905static struct binder_node *binder_new_node(struct binder_proc *proc,
900binder_new_node(struct binder_proc *proc, void __user *ptr, void __user *cookie) 906 void __user *ptr,
907 void __user *cookie)
901{ 908{
902 struct rb_node **p = &proc->nodes.rb_node; 909 struct rb_node **p = &proc->nodes.rb_node;
903 struct rb_node *parent = NULL; 910 struct rb_node *parent = NULL;
@@ -935,9 +942,8 @@ binder_new_node(struct binder_proc *proc, void __user *ptr, void __user *cookie)
935 return node; 942 return node;
936} 943}
937 944
938static int 945static int binder_inc_node(struct binder_node *node, int strong, int internal,
939binder_inc_node(struct binder_node *node, int strong, int internal, 946 struct list_head *target_list)
940 struct list_head *target_list)
941{ 947{
942 if (strong) { 948 if (strong) {
943 if (internal) { 949 if (internal) {
@@ -971,8 +977,7 @@ binder_inc_node(struct binder_node *node, int strong, int internal,
971 return 0; 977 return 0;
972} 978}
973 979
974static int 980static int binder_dec_node(struct binder_node *node, int strong, int internal)
975binder_dec_node(struct binder_node *node, int strong, int internal)
976{ 981{
977 if (strong) { 982 if (strong) {
978 if (internal) 983 if (internal)
@@ -1014,8 +1019,8 @@ binder_dec_node(struct binder_node *node, int strong, int internal)
1014} 1019}
1015 1020
1016 1021
1017static struct binder_ref * 1022static struct binder_ref *binder_get_ref(struct binder_proc *proc,
1018binder_get_ref(struct binder_proc *proc, uint32_t desc) 1023 uint32_t desc)
1019{ 1024{
1020 struct rb_node *n = proc->refs_by_desc.rb_node; 1025 struct rb_node *n = proc->refs_by_desc.rb_node;
1021 struct binder_ref *ref; 1026 struct binder_ref *ref;
@@ -1033,8 +1038,8 @@ binder_get_ref(struct binder_proc *proc, uint32_t desc)
1033 return NULL; 1038 return NULL;
1034} 1039}
1035 1040
1036static struct binder_ref * 1041static struct binder_ref *binder_get_ref_for_node(struct binder_proc *proc,
1037binder_get_ref_for_node(struct binder_proc *proc, struct binder_node *node) 1042 struct binder_node *node)
1038{ 1043{
1039 struct rb_node *n; 1044 struct rb_node *n;
1040 struct rb_node **p = &proc->refs_by_node.rb_node; 1045 struct rb_node **p = &proc->refs_by_node.rb_node;
@@ -1099,8 +1104,7 @@ binder_get_ref_for_node(struct binder_proc *proc, struct binder_node *node)
1099 return new_ref; 1104 return new_ref;
1100} 1105}
1101 1106
1102static void 1107static void binder_delete_ref(struct binder_ref *ref)
1103binder_delete_ref(struct binder_ref *ref)
1104{ 1108{
1105 if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS) 1109 if (binder_debug_mask & BINDER_DEBUG_INTERNAL_REFS)
1106 printk(KERN_INFO "binder: %d delete ref %d desc %d for " 1110 printk(KERN_INFO "binder: %d delete ref %d desc %d for "
@@ -1125,9 +1129,8 @@ binder_delete_ref(struct binder_ref *ref)
1125 binder_stats.obj_deleted[BINDER_STAT_REF]++; 1129 binder_stats.obj_deleted[BINDER_STAT_REF]++;
1126} 1130}
1127 1131
1128static int 1132static int binder_inc_ref(struct binder_ref *ref, int strong,
1129binder_inc_ref( 1133 struct list_head *target_list)
1130 struct binder_ref *ref, int strong, struct list_head *target_list)
1131{ 1134{
1132 int ret; 1135 int ret;
1133 if (strong) { 1136 if (strong) {
@@ -1149,8 +1152,7 @@ binder_inc_ref(
1149} 1152}
1150 1153
1151 1154
1152static int 1155static int binder_dec_ref(struct binder_ref *ref, int strong)
1153binder_dec_ref(struct binder_ref *ref, int strong)
1154{ 1156{
1155 if (strong) { 1157 if (strong) {
1156 if (ref->strong == 0) { 1158 if (ref->strong == 0) {
@@ -1182,9 +1184,8 @@ binder_dec_ref(struct binder_ref *ref, int strong)
1182 return 0; 1184 return 0;
1183} 1185}
1184 1186
1185static void 1187static void binder_pop_transaction(struct binder_thread *target_thread,
1186binder_pop_transaction( 1188 struct binder_transaction *t)
1187 struct binder_thread *target_thread, struct binder_transaction *t)
1188{ 1189{
1189 if (target_thread) { 1190 if (target_thread) {
1190 BUG_ON(target_thread->transaction_stack != t); 1191 BUG_ON(target_thread->transaction_stack != t);
@@ -1200,8 +1201,8 @@ binder_pop_transaction(
1200 binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++; 1201 binder_stats.obj_deleted[BINDER_STAT_TRANSACTION]++;
1201} 1202}
1202 1203
1203static void 1204static void binder_send_failed_reply(struct binder_transaction *t,
1204binder_send_failed_reply(struct binder_transaction *t, uint32_t error_code) 1205 uint32_t error_code)
1205{ 1206{
1206 struct binder_thread *target_thread; 1207 struct binder_thread *target_thread;
1207 BUG_ON(t->flags & TF_ONE_WAY); 1208 BUG_ON(t->flags & TF_ONE_WAY);
@@ -1253,13 +1254,13 @@ binder_send_failed_reply(struct binder_transaction *t, uint32_t error_code)
1253 } 1254 }
1254} 1255}
1255 1256
1256static void 1257static void binder_transaction_buffer_release(struct binder_proc *proc,
1257binder_transaction_buffer_release(struct binder_proc *proc, 1258 struct binder_buffer *buffer,
1258 struct binder_buffer *buffer, size_t *failed_at); 1259 size_t *failed_at);
1259 1260
1260static void 1261static void binder_transaction(struct binder_proc *proc,
1261binder_transaction(struct binder_proc *proc, struct binder_thread *thread, 1262 struct binder_thread *thread,
1262 struct binder_transaction_data *tr, int reply) 1263 struct binder_transaction_data *tr, int reply)
1263{ 1264{
1264 struct binder_transaction *t; 1265 struct binder_transaction *t;
1265 struct binder_work *tcomplete; 1266 struct binder_work *tcomplete;
@@ -1661,8 +1662,9 @@ err_no_context_mgr_node:
1661 thread->return_error = return_error; 1662 thread->return_error = return_error;
1662} 1663}
1663 1664
1664static void 1665static void binder_transaction_buffer_release(struct binder_proc *proc,
1665binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer *buffer, size_t *failed_at) 1666 struct binder_buffer *buffer,
1667 size_t *failed_at)
1666{ 1668{
1667 size_t *offp, *off_end; 1669 size_t *offp, *off_end;
1668 int debug_id = buffer->debug_id; 1670 int debug_id = buffer->debug_id;
@@ -1730,9 +1732,8 @@ binder_transaction_buffer_release(struct binder_proc *proc, struct binder_buffer
1730 } 1732 }
1731} 1733}
1732 1734
1733int 1735int binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
1734binder_thread_write(struct binder_proc *proc, struct binder_thread *thread, 1736 void __user *buffer, int size, signed long *consumed)
1735 void __user *buffer, int size, signed long *consumed)
1736{ 1737{
1737 uint32_t cmd; 1738 uint32_t cmd;
1738 void __user *ptr = buffer + *consumed; 1739 void __user *ptr = buffer + *consumed;
@@ -2104,7 +2105,8 @@ binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
2104 } break; 2105 } break;
2105 2106
2106 default: 2107 default:
2107 printk(KERN_ERR "binder: %d:%d unknown command %d\n", proc->pid, thread->pid, cmd); 2108 printk(KERN_ERR "binder: %d:%d unknown command %d\n",
2109 proc->pid, thread->pid, cmd);
2108 return -EINVAL; 2110 return -EINVAL;
2109 } 2111 }
2110 *consumed = ptr - buffer; 2112 *consumed = ptr - buffer;
@@ -2112,8 +2114,8 @@ binder_thread_write(struct binder_proc *proc, struct binder_thread *thread,
2112 return 0; 2114 return 0;
2113} 2115}
2114 2116
2115void 2117void binder_stat_br(struct binder_proc *proc, struct binder_thread *thread,
2116binder_stat_br(struct binder_proc *proc, struct binder_thread *thread, uint32_t cmd) 2118 uint32_t cmd)
2117{ 2119{
2118 if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) { 2120 if (_IOC_NR(cmd) < ARRAY_SIZE(binder_stats.br)) {
2119 binder_stats.br[_IOC_NR(cmd)]++; 2121 binder_stats.br[_IOC_NR(cmd)]++;
@@ -2122,22 +2124,23 @@ binder_stat_br(struct binder_proc *proc, struct binder_thread *thread, uint32_t
2122 } 2124 }
2123} 2125}
2124 2126
2125static int 2127static int binder_has_proc_work(struct binder_proc *proc,
2126binder_has_proc_work(struct binder_proc *proc, struct binder_thread *thread) 2128 struct binder_thread *thread)
2127{ 2129{
2128 return !list_empty(&proc->todo) || (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); 2130 return !list_empty(&proc->todo) ||
2131 (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
2129} 2132}
2130 2133
2131static int 2134static int binder_has_thread_work(struct binder_thread *thread)
2132binder_has_thread_work(struct binder_thread *thread)
2133{ 2135{
2134 return !list_empty(&thread->todo) || thread->return_error != BR_OK || 2136 return !list_empty(&thread->todo) || thread->return_error != BR_OK ||
2135 (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN); 2137 (thread->looper & BINDER_LOOPER_STATE_NEED_RETURN);
2136} 2138}
2137 2139
2138static int 2140static int binder_thread_read(struct binder_proc *proc,
2139binder_thread_read(struct binder_proc *proc, struct binder_thread *thread, 2141 struct binder_thread *thread,
2140 void __user *buffer, int size, signed long *consumed, int non_block) 2142 void __user *buffer, int size,
2143 signed long *consumed, int non_block)
2141{ 2144{
2142 void __user *ptr = buffer + *consumed; 2145 void __user *ptr = buffer + *consumed;
2143 void __user *end = buffer + size; 2146 void __user *end = buffer + size;
@@ -2152,7 +2155,8 @@ binder_thread_read(struct binder_proc *proc, struct binder_thread *thread,
2152 } 2155 }
2153 2156
2154retry: 2157retry:
2155 wait_for_proc_work = thread->transaction_stack == NULL && list_empty(&thread->todo); 2158 wait_for_proc_work = thread->transaction_stack == NULL &&
2159 list_empty(&thread->todo);
2156 2160
2157 if (thread->return_error != BR_OK && ptr < end) { 2161 if (thread->return_error != BR_OK && ptr < end) {
2158 if (thread->return_error2 != BR_OK) { 2162 if (thread->return_error2 != BR_OK) {
@@ -2182,7 +2186,8 @@ retry:
2182 "for process work before calling BC_REGISTER_" 2186 "for process work before calling BC_REGISTER_"
2183 "LOOPER or BC_ENTER_LOOPER (state %x)\n", 2187 "LOOPER or BC_ENTER_LOOPER (state %x)\n",
2184 proc->pid, thread->pid, thread->looper); 2188 proc->pid, thread->pid, thread->looper);
2185 wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); 2189 wait_event_interruptible(binder_user_error_wait,
2190 binder_stop_on_user_error < 2);
2186 } 2191 }
2187 binder_set_nice(proc->default_priority); 2192 binder_set_nice(proc->default_priority);
2188 if (non_block) { 2193 if (non_block) {
@@ -2304,8 +2309,10 @@ retry:
2304 case BINDER_WORK_DEAD_BINDER: 2309 case BINDER_WORK_DEAD_BINDER:
2305 case BINDER_WORK_DEAD_BINDER_AND_CLEAR: 2310 case BINDER_WORK_DEAD_BINDER_AND_CLEAR:
2306 case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: { 2311 case BINDER_WORK_CLEAR_DEATH_NOTIFICATION: {
2307 struct binder_ref_death *death = container_of(w, struct binder_ref_death, work); 2312 struct binder_ref_death *death;
2308 uint32_t cmd; 2313 uint32_t cmd;
2314
2315 death = container_of(w, struct binder_ref_death, work);
2309 if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION) 2316 if (w->type == BINDER_WORK_CLEAR_DEATH_NOTIFICATION)
2310 cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE; 2317 cmd = BR_CLEAR_DEATH_NOTIFICATION_DONE;
2311 else 2318 else
@@ -2362,15 +2369,19 @@ retry:
2362 2369
2363 if (t->from) { 2370 if (t->from) {
2364 struct task_struct *sender = t->from->proc->tsk; 2371 struct task_struct *sender = t->from->proc->tsk;
2365 tr.sender_pid = task_tgid_nr_ns(sender, current->nsproxy->pid_ns); 2372 tr.sender_pid = task_tgid_nr_ns(sender,
2373 current->nsproxy->pid_ns);
2366 } else { 2374 } else {
2367 tr.sender_pid = 0; 2375 tr.sender_pid = 0;
2368 } 2376 }
2369 2377
2370 tr.data_size = t->buffer->data_size; 2378 tr.data_size = t->buffer->data_size;
2371 tr.offsets_size = t->buffer->offsets_size; 2379 tr.offsets_size = t->buffer->offsets_size;
2372 tr.data.ptr.buffer = (void *)t->buffer->data + proc->user_buffer_offset; 2380 tr.data.ptr.buffer = (void *)t->buffer->data +
2373 tr.data.ptr.offsets = tr.data.ptr.buffer + ALIGN(t->buffer->data_size, sizeof(void *)); 2381 proc->user_buffer_offset;
2382 tr.data.ptr.offsets = tr.data.ptr.buffer +
2383 ALIGN(t->buffer->data_size,
2384 sizeof(void *));
2374 2385
2375 if (put_user(cmd, (uint32_t __user *)ptr)) 2386 if (put_user(cmd, (uint32_t __user *)ptr))
2376 return -EFAULT; 2387 return -EFAULT;
@@ -2384,7 +2395,8 @@ retry:
2384 printk(KERN_INFO "binder: %d:%d %s %d %d:%d, cmd %d" 2395 printk(KERN_INFO "binder: %d:%d %s %d %d:%d, cmd %d"
2385 "size %zd-%zd ptr %p-%p\n", 2396 "size %zd-%zd ptr %p-%p\n",
2386 proc->pid, thread->pid, 2397 proc->pid, thread->pid,
2387 (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" : "BR_REPLY", 2398 (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
2399 "BR_REPLY",
2388 t->debug_id, t->from ? t->from->proc->pid : 0, 2400 t->debug_id, t->from ? t->from->proc->pid : 0,
2389 t->from ? t->from->pid : 0, cmd, 2401 t->from ? t->from->pid : 0, cmd,
2390 t->buffer->data_size, t->buffer->offsets_size, 2402 t->buffer->data_size, t->buffer->offsets_size,
@@ -2430,7 +2442,9 @@ static void binder_release_work(struct list_head *list)
2430 list_del_init(&w->entry); 2442 list_del_init(&w->entry);
2431 switch (w->type) { 2443 switch (w->type) {
2432 case BINDER_WORK_TRANSACTION: { 2444 case BINDER_WORK_TRANSACTION: {
2433 struct binder_transaction *t = container_of(w, struct binder_transaction, work); 2445 struct binder_transaction *t;
2446
2447 t = container_of(w, struct binder_transaction, work);
2434 if (t->buffer->target_node && !(t->flags & TF_ONE_WAY)) 2448 if (t->buffer->target_node && !(t->flags & TF_ONE_WAY))
2435 binder_send_failed_reply(t, BR_DEAD_REPLY); 2449 binder_send_failed_reply(t, BR_DEAD_REPLY);
2436 } break; 2450 } break;
@@ -2480,7 +2494,8 @@ static struct binder_thread *binder_get_thread(struct binder_proc *proc)
2480 return thread; 2494 return thread;
2481} 2495}
2482 2496
2483static int binder_free_thread(struct binder_proc *proc, struct binder_thread *thread) 2497static int binder_free_thread(struct binder_proc *proc,
2498 struct binder_thread *thread)
2484{ 2499{
2485 struct binder_transaction *t; 2500 struct binder_transaction *t;
2486 struct binder_transaction *send_reply = NULL; 2501 struct binder_transaction *send_reply = NULL;
@@ -2493,8 +2508,10 @@ static int binder_free_thread(struct binder_proc *proc, struct binder_thread *th
2493 while (t) { 2508 while (t) {
2494 active_transactions++; 2509 active_transactions++;
2495 if (binder_debug_mask & BINDER_DEBUG_DEAD_TRANSACTION) 2510 if (binder_debug_mask & BINDER_DEBUG_DEAD_TRANSACTION)
2496 printk(KERN_INFO "binder: release %d:%d transaction %d %s, still active\n", 2511 printk(KERN_INFO "binder: release %d:%d transaction %d "
2497 proc->pid, thread->pid, t->debug_id, (t->to_thread == thread) ? "in" : "out"); 2512 "%s, still active\n", proc->pid, thread->pid,
2513 t->debug_id,
2514 (t->to_thread == thread) ? "in" : "out");
2498 if (t->to_thread == thread) { 2515 if (t->to_thread == thread) {
2499 t->to_proc = NULL; 2516 t->to_proc = NULL;
2500 t->to_thread = NULL; 2517 t->to_thread = NULL;
@@ -2517,7 +2534,8 @@ static int binder_free_thread(struct binder_proc *proc, struct binder_thread *th
2517 return active_transactions; 2534 return active_transactions;
2518} 2535}
2519 2536
2520static unsigned int binder_poll(struct file *filp, struct poll_table_struct *wait) 2537static unsigned int binder_poll(struct file *filp,
2538 struct poll_table_struct *wait)
2521{ 2539{
2522 struct binder_proc *proc = filp->private_data; 2540 struct binder_proc *proc = filp->private_data;
2523 struct binder_thread *thread = NULL; 2541 struct binder_thread *thread = NULL;
@@ -2778,7 +2796,8 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
2778 proc->files = get_files_struct(current); 2796 proc->files = get_files_struct(current);
2779 proc->vma = vma; 2797 proc->vma = vma;
2780 2798
2781 /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n", proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/ 2799 /*printk(KERN_INFO "binder_mmap: %d %lx-%lx maps %p\n",
2800 proc->pid, vma->vm_start, vma->vm_end, proc->buffer);*/
2782 return 0; 2801 return 0;
2783 2802
2784err_alloc_small_buf_failed: 2803err_alloc_small_buf_failed:
@@ -2790,7 +2809,8 @@ err_alloc_pages_failed:
2790err_get_vm_area_failed: 2809err_get_vm_area_failed:
2791err_already_mapped: 2810err_already_mapped:
2792err_bad_arg: 2811err_bad_arg:
2793 printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n", proc->pid, vma->vm_start, vma->vm_end, failure_string, ret); 2812 printk(KERN_ERR "binder_mmap: %d %lx-%lx %s failed %d\n",
2813 proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
2794 return ret; 2814 return ret;
2795} 2815}
2796 2816
@@ -2799,7 +2819,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
2799 struct binder_proc *proc; 2819 struct binder_proc *proc;
2800 2820
2801 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) 2821 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
2802 printk(KERN_INFO "binder_open: %d:%d\n", current->group_leader->pid, current->pid); 2822 printk(KERN_INFO "binder_open: %d:%d\n",
2823 current->group_leader->pid, current->pid);
2803 2824
2804 proc = kzalloc(sizeof(*proc), GFP_KERNEL); 2825 proc = kzalloc(sizeof(*proc), GFP_KERNEL);
2805 if (proc == NULL) 2826 if (proc == NULL)
@@ -2821,7 +2842,9 @@ static int binder_open(struct inode *nodp, struct file *filp)
2821 char strbuf[11]; 2842 char strbuf[11];
2822 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid); 2843 snprintf(strbuf, sizeof(strbuf), "%u", proc->pid);
2823 remove_proc_entry(strbuf, binder_proc_dir_entry_proc); 2844 remove_proc_entry(strbuf, binder_proc_dir_entry_proc);
2824 create_proc_read_entry(strbuf, S_IRUGO, binder_proc_dir_entry_proc, binder_read_proc_proc, proc); 2845 create_proc_read_entry(strbuf, S_IRUGO,
2846 binder_proc_dir_entry_proc,
2847 binder_read_proc_proc, proc);
2825 } 2848 }
2826 2849
2827 return 0; 2850 return 0;
@@ -2925,12 +2948,15 @@ static void binder_deferred_release(struct binder_proc *proc)
2925 } 2948 }
2926 } 2949 }
2927 if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER) 2950 if (binder_debug_mask & BINDER_DEBUG_DEAD_BINDER)
2928 printk(KERN_INFO "binder: node %d now dead, refs %d, death %d\n", node->debug_id, incoming_refs, death); 2951 printk(KERN_INFO "binder: node %d now dead, "
2952 "refs %d, death %d\n", node->debug_id,
2953 incoming_refs, death);
2929 } 2954 }
2930 } 2955 }
2931 outgoing_refs = 0; 2956 outgoing_refs = 0;
2932 while ((n = rb_first(&proc->refs_by_desc))) { 2957 while ((n = rb_first(&proc->refs_by_desc))) {
2933 struct binder_ref *ref = rb_entry(n, struct binder_ref, rb_node_desc); 2958 struct binder_ref *ref = rb_entry(n, struct binder_ref,
2959 rb_node_desc);
2934 outgoing_refs++; 2960 outgoing_refs++;
2935 binder_delete_ref(ref); 2961 binder_delete_ref(ref);
2936 } 2962 }
@@ -2938,12 +2964,15 @@ static void binder_deferred_release(struct binder_proc *proc)
2938 buffers = 0; 2964 buffers = 0;
2939 2965
2940 while ((n = rb_first(&proc->allocated_buffers))) { 2966 while ((n = rb_first(&proc->allocated_buffers))) {
2941 struct binder_buffer *buffer = rb_entry(n, struct binder_buffer, rb_node); 2967 struct binder_buffer *buffer = rb_entry(n, struct binder_buffer,
2968 rb_node);
2942 t = buffer->transaction; 2969 t = buffer->transaction;
2943 if (t) { 2970 if (t) {
2944 t->buffer = NULL; 2971 t->buffer = NULL;
2945 buffer->transaction = NULL; 2972 buffer->transaction = NULL;
2946 printk(KERN_ERR "binder: release proc %d, transaction %d, not freed\n", proc->pid, t->debug_id); 2973 printk(KERN_ERR "binder: release proc %d, "
2974 "transaction %d, not freed\n",
2975 proc->pid, t->debug_id);
2947 /*BUG();*/ 2976 /*BUG();*/
2948 } 2977 }
2949 binder_free_buf(proc, buffer); 2978 binder_free_buf(proc, buffer);
@@ -2957,8 +2986,13 @@ static void binder_deferred_release(struct binder_proc *proc)
2957 int i; 2986 int i;
2958 for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) { 2987 for (i = 0; i < proc->buffer_size / PAGE_SIZE; i++) {
2959 if (proc->pages[i]) { 2988 if (proc->pages[i]) {
2960 if (binder_debug_mask & BINDER_DEBUG_BUFFER_ALLOC) 2989 if (binder_debug_mask &
2961 printk(KERN_INFO "binder_release: %d: page %d at %p not freed\n", proc->pid, i, proc->buffer + i * PAGE_SIZE); 2990 BINDER_DEBUG_BUFFER_ALLOC)
2991 printk(KERN_INFO
2992 "binder_release: %d: "
2993 "page %d at %p not freed\n",
2994 proc->pid, i,
2995 proc->buffer + i * PAGE_SIZE);
2962 __free_page(proc->pages[i]); 2996 __free_page(proc->pages[i]);
2963 page_count++; 2997 page_count++;
2964 } 2998 }
@@ -2970,8 +3004,12 @@ static void binder_deferred_release(struct binder_proc *proc)
2970 put_task_struct(proc->tsk); 3004 put_task_struct(proc->tsk);
2971 3005
2972 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE) 3006 if (binder_debug_mask & BINDER_DEBUG_OPEN_CLOSE)
2973 printk(KERN_INFO "binder_release: %d threads %d, nodes %d (ref %d), refs %d, active transactions %d, buffers %d, pages %d\n", 3007 printk(KERN_INFO
2974 proc->pid, threads, nodes, incoming_refs, outgoing_refs, active_transactions, buffers, page_count); 3008 "binder_release: %d threads %d, nodes %d (ref %d), "
3009 "refs %d, active transactions %d, buffers %d, "
3010 "pages %d\n",
3011 proc->pid, threads, nodes, incoming_refs, outgoing_refs,
3012 active_transactions, buffers, page_count);
2975 3013
2976 kfree(proc); 3014 kfree(proc);
2977} 3015}
@@ -2998,9 +3036,11 @@ static void binder_deferred_func(struct work_struct *work)
2998 mutex_unlock(&binder_deferred_lock); 3036 mutex_unlock(&binder_deferred_lock);
2999 3037
3000 files = NULL; 3038 files = NULL;
3001 if (defer & BINDER_DEFERRED_PUT_FILES) 3039 if (defer & BINDER_DEFERRED_PUT_FILES) {
3002 if ((files = proc->files)) 3040 files = proc->files;
3041 if (files)
3003 proc->files = NULL; 3042 proc->files = NULL;
3043 }
3004 3044
3005 if (defer & BINDER_DEFERRED_FLUSH) 3045 if (defer & BINDER_DEFERRED_FLUSH)
3006 binder_deferred_flush(proc); 3046 binder_deferred_flush(proc);
@@ -3027,10 +3067,14 @@ static void binder_defer_work(struct binder_proc *proc, int defer)
3027 mutex_unlock(&binder_deferred_lock); 3067 mutex_unlock(&binder_deferred_lock);
3028} 3068}
3029 3069
3030static char *print_binder_transaction(char *buf, char *end, const char *prefix, struct binder_transaction *t) 3070static char *print_binder_transaction(char *buf, char *end, const char *prefix,
3071 struct binder_transaction *t)
3031{ 3072{
3032 buf += snprintf(buf, end - buf, "%s %d: %p from %d:%d to %d:%d code %x flags %x pri %ld r%d", 3073 buf += snprintf(buf, end - buf,
3033 prefix, t->debug_id, t, t->from ? t->from->proc->pid : 0, 3074 "%s %d: %p from %d:%d to %d:%d code %x "
3075 "flags %x pri %ld r%d",
3076 prefix, t->debug_id, t,
3077 t->from ? t->from->proc->pid : 0,
3034 t->from ? t->from->pid : 0, 3078 t->from ? t->from->pid : 0,
3035 t->to_proc ? t->to_proc->pid : 0, 3079 t->to_proc ? t->to_proc->pid : 0,
3036 t->to_thread ? t->to_thread->pid : 0, 3080 t->to_thread ? t->to_thread->pid : 0,
@@ -3053,7 +3097,8 @@ static char *print_binder_transaction(char *buf, char *end, const char *prefix,
3053 return buf; 3097 return buf;
3054} 3098}
3055 3099
3056static char *print_binder_buffer(char *buf, char *end, const char *prefix, struct binder_buffer *buffer) 3100static char *print_binder_buffer(char *buf, char *end, const char *prefix,
3101 struct binder_buffer *buffer)
3057{ 3102{
3058 buf += snprintf(buf, end - buf, "%s %d: %p size %zd:%zd %s\n", 3103 buf += snprintf(buf, end - buf, "%s %d: %p size %zd:%zd %s\n",
3059 prefix, buffer->debug_id, buffer->data, 3104 prefix, buffer->debug_id, buffer->data,
@@ -3063,7 +3108,8 @@ static char *print_binder_buffer(char *buf, char *end, const char *prefix, struc
3063} 3108}
3064 3109
3065static char *print_binder_work(char *buf, char *end, const char *prefix, 3110static char *print_binder_work(char *buf, char *end, const char *prefix,
3066 const char *transaction_prefix, struct binder_work *w) 3111 const char *transaction_prefix,
3112 struct binder_work *w)
3067{ 3113{
3068 struct binder_node *node; 3114 struct binder_node *node;
3069 struct binder_transaction *t; 3115 struct binder_transaction *t;
@@ -3080,7 +3126,8 @@ static char *print_binder_work(char *buf, char *end, const char *prefix,
3080 case BINDER_WORK_NODE: 3126 case BINDER_WORK_NODE:
3081 node = container_of(w, struct binder_node, work); 3127 node = container_of(w, struct binder_node, work);
3082 buf += snprintf(buf, end - buf, "%snode work %d: u%p c%p\n", 3128 buf += snprintf(buf, end - buf, "%snode work %d: u%p c%p\n",
3083 prefix, node->debug_id, node->ptr, node->cookie); 3129 prefix, node->debug_id, node->ptr,
3130 node->cookie);
3084 break; 3131 break;
3085 case BINDER_WORK_DEAD_BINDER: 3132 case BINDER_WORK_DEAD_BINDER:
3086 buf += snprintf(buf, end - buf, "%shas dead binder\n", prefix); 3133 buf += snprintf(buf, end - buf, "%shas dead binder\n", prefix);
@@ -3101,27 +3148,33 @@ static char *print_binder_work(char *buf, char *end, const char *prefix,
3101 return buf; 3148 return buf;
3102} 3149}
3103 3150
3104static char *print_binder_thread(char *buf, char *end, struct binder_thread *thread, int print_always) 3151static char *print_binder_thread(char *buf, char *end,
3152 struct binder_thread *thread,
3153 int print_always)
3105{ 3154{
3106 struct binder_transaction *t; 3155 struct binder_transaction *t;
3107 struct binder_work *w; 3156 struct binder_work *w;
3108 char *start_buf = buf; 3157 char *start_buf = buf;
3109 char *header_buf; 3158 char *header_buf;
3110 3159
3111 buf += snprintf(buf, end - buf, " thread %d: l %02x\n", thread->pid, thread->looper); 3160 buf += snprintf(buf, end - buf, " thread %d: l %02x\n",
3161 thread->pid, thread->looper);
3112 header_buf = buf; 3162 header_buf = buf;
3113 t = thread->transaction_stack; 3163 t = thread->transaction_stack;
3114 while (t) { 3164 while (t) {
3115 if (buf >= end) 3165 if (buf >= end)
3116 break; 3166 break;
3117 if (t->from == thread) { 3167 if (t->from == thread) {
3118 buf = print_binder_transaction(buf, end, " outgoing transaction", t); 3168 buf = print_binder_transaction(buf, end,
3169 " outgoing transaction", t);
3119 t = t->from_parent; 3170 t = t->from_parent;
3120 } else if (t->to_thread == thread) { 3171 } else if (t->to_thread == thread) {
3121 buf = print_binder_transaction(buf, end, " incoming transaction", t); 3172 buf = print_binder_transaction(buf, end,
3173 " incoming transaction", t);
3122 t = t->to_parent; 3174 t = t->to_parent;
3123 } else { 3175 } else {
3124 buf = print_binder_transaction(buf, end, " bad transaction", t); 3176 buf = print_binder_transaction(buf, end,
3177 " bad transaction", t);
3125 t = NULL; 3178 t = NULL;
3126 } 3179 }
3127 } 3180 }
@@ -3142,11 +3195,14 @@ static char *print_binder_node(char *buf, char *end, struct binder_node *node)
3142 struct hlist_node *pos; 3195 struct hlist_node *pos;
3143 struct binder_work *w; 3196 struct binder_work *w;
3144 int count; 3197 int count;
3198
3145 count = 0; 3199 count = 0;
3146 hlist_for_each_entry(ref, pos, &node->refs, node_entry) 3200 hlist_for_each_entry(ref, pos, &node->refs, node_entry)
3147 count++; 3201 count++;
3148 3202
3149 buf += snprintf(buf, end - buf, " node %d: u%p c%p hs %d hw %d ls %d lw %d is %d iw %d", 3203 buf += snprintf(buf, end - buf,
3204 " node %d: u%p c%p hs %d hw %d ls %d lw %d "
3205 "is %d iw %d",
3150 node->debug_id, node->ptr, node->cookie, 3206 node->debug_id, node->ptr, node->cookie,
3151 node->has_strong_ref, node->has_weak_ref, 3207 node->has_strong_ref, node->has_weak_ref,
3152 node->local_strong_refs, node->local_weak_refs, 3208 node->local_strong_refs, node->local_weak_refs,
@@ -3175,13 +3231,16 @@ static char *print_binder_node(char *buf, char *end, struct binder_node *node)
3175 3231
3176static char *print_binder_ref(char *buf, char *end, struct binder_ref *ref) 3232static char *print_binder_ref(char *buf, char *end, struct binder_ref *ref)
3177{ 3233{
3178 buf += snprintf(buf, end - buf, " ref %d: desc %d %snode %d s %d w %d d %p\n", 3234 buf += snprintf(buf, end - buf,
3179 ref->debug_id, ref->desc, ref->node->proc ? "" : "dead ", 3235 " ref %d: desc %d %snode %d s %d w %d d %p\n",
3180 ref->node->debug_id, ref->strong, ref->weak, ref->death); 3236 ref->debug_id, ref->desc,
3237 ref->node->proc ? "" : "dead ", ref->node->debug_id,
3238 ref->strong, ref->weak, ref->death);
3181 return buf; 3239 return buf;
3182} 3240}
3183 3241
3184static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, int print_all) 3242static char *print_binder_proc(char *buf, char *end,
3243 struct binder_proc *proc, int print_all)
3185{ 3244{
3186 struct binder_work *w; 3245 struct binder_work *w;
3187 struct rb_node *n; 3246 struct rb_node *n;
@@ -3191,19 +3250,34 @@ static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, i
3191 buf += snprintf(buf, end - buf, "proc %d\n", proc->pid); 3250 buf += snprintf(buf, end - buf, "proc %d\n", proc->pid);
3192 header_buf = buf; 3251 header_buf = buf;
3193 3252
3194 for (n = rb_first(&proc->threads); n != NULL && buf < end; n = rb_next(n)) 3253 for (n = rb_first(&proc->threads);
3195 buf = print_binder_thread(buf, end, rb_entry(n, struct binder_thread, rb_node), print_all); 3254 n != NULL && buf < end;
3196 for (n = rb_first(&proc->nodes); n != NULL && buf < end; n = rb_next(n)) { 3255 n = rb_next(n))
3197 struct binder_node *node = rb_entry(n, struct binder_node, rb_node); 3256 buf = print_binder_thread(buf, end,
3257 rb_entry(n, struct binder_thread,
3258 rb_node), print_all);
3259 for (n = rb_first(&proc->nodes);
3260 n != NULL && buf < end;
3261 n = rb_next(n)) {
3262 struct binder_node *node = rb_entry(n, struct binder_node,
3263 rb_node);
3198 if (print_all || node->has_async_transaction) 3264 if (print_all || node->has_async_transaction)
3199 buf = print_binder_node(buf, end, node); 3265 buf = print_binder_node(buf, end, node);
3200 } 3266 }
3201 if (print_all) { 3267 if (print_all) {
3202 for (n = rb_first(&proc->refs_by_desc); n != NULL && buf < end; n = rb_next(n)) 3268 for (n = rb_first(&proc->refs_by_desc);
3203 buf = print_binder_ref(buf, end, rb_entry(n, struct binder_ref, rb_node_desc)); 3269 n != NULL && buf < end;
3204 } 3270 n = rb_next(n))
3205 for (n = rb_first(&proc->allocated_buffers); n != NULL && buf < end; n = rb_next(n)) 3271 buf = print_binder_ref(buf, end,
3206 buf = print_binder_buffer(buf, end, " buffer", rb_entry(n, struct binder_buffer, rb_node)); 3272 rb_entry(n, struct binder_ref,
3273 rb_node_desc));
3274 }
3275 for (n = rb_first(&proc->allocated_buffers);
3276 n != NULL && buf < end;
3277 n = rb_next(n))
3278 buf = print_binder_buffer(buf, end, " buffer",
3279 rb_entry(n, struct binder_buffer,
3280 rb_node));
3207 list_for_each_entry(w, &proc->todo, entry) { 3281 list_for_each_entry(w, &proc->todo, entry) {
3208 if (buf >= end) 3282 if (buf >= end)
3209 break; 3283 break;
@@ -3213,7 +3287,8 @@ static char *print_binder_proc(char *buf, char *end, struct binder_proc *proc, i
3213 list_for_each_entry(w, &proc->delivered_death, entry) { 3287 list_for_each_entry(w, &proc->delivered_death, entry) {
3214 if (buf >= end) 3288 if (buf >= end)
3215 break; 3289 break;
3216 buf += snprintf(buf, end - buf, " has delivered dead binder\n"); 3290 buf += snprintf(buf, end - buf,
3291 " has delivered dead binder\n");
3217 break; 3292 break;
3218 } 3293 }
3219 if (!print_all && buf == header_buf) 3294 if (!print_all && buf == header_buf)
@@ -3272,20 +3347,24 @@ static const char *binder_objstat_strings[] = {
3272 "transaction_complete" 3347 "transaction_complete"
3273}; 3348};
3274 3349
3275static char *print_binder_stats(char *buf, char *end, const char *prefix, struct binder_stats *stats) 3350static char *print_binder_stats(char *buf, char *end, const char *prefix,
3351 struct binder_stats *stats)
3276{ 3352{
3277 int i; 3353 int i;
3278 3354
3279 BUILD_BUG_ON(ARRAY_SIZE(stats->bc) != ARRAY_SIZE(binder_command_strings)); 3355 BUILD_BUG_ON(ARRAY_SIZE(stats->bc) !=
3356 ARRAY_SIZE(binder_command_strings));
3280 for (i = 0; i < ARRAY_SIZE(stats->bc); i++) { 3357 for (i = 0; i < ARRAY_SIZE(stats->bc); i++) {
3281 if (stats->bc[i]) 3358 if (stats->bc[i])
3282 buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix, 3359 buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix,
3283 binder_command_strings[i], stats->bc[i]); 3360 binder_command_strings[i],
3361 stats->bc[i]);
3284 if (buf >= end) 3362 if (buf >= end)
3285 return buf; 3363 return buf;
3286 } 3364 }
3287 3365
3288 BUILD_BUG_ON(ARRAY_SIZE(stats->br) != ARRAY_SIZE(binder_return_strings)); 3366 BUILD_BUG_ON(ARRAY_SIZE(stats->br) !=
3367 ARRAY_SIZE(binder_return_strings));
3289 for (i = 0; i < ARRAY_SIZE(stats->br); i++) { 3368 for (i = 0; i < ARRAY_SIZE(stats->br); i++) {
3290 if (stats->br[i]) 3369 if (stats->br[i])
3291 buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix, 3370 buf += snprintf(buf, end - buf, "%s%s: %d\n", prefix,
@@ -3294,13 +3373,17 @@ static char *print_binder_stats(char *buf, char *end, const char *prefix, struct
3294 return buf; 3373 return buf;
3295 } 3374 }
3296 3375
3297 BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != ARRAY_SIZE(binder_objstat_strings)); 3376 BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
3298 BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) != ARRAY_SIZE(stats->obj_deleted)); 3377 ARRAY_SIZE(binder_objstat_strings));
3378 BUILD_BUG_ON(ARRAY_SIZE(stats->obj_created) !=
3379 ARRAY_SIZE(stats->obj_deleted));
3299 for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) { 3380 for (i = 0; i < ARRAY_SIZE(stats->obj_created); i++) {
3300 if (stats->obj_created[i] || stats->obj_deleted[i]) 3381 if (stats->obj_created[i] || stats->obj_deleted[i])
3301 buf += snprintf(buf, end - buf, "%s%s: active %d total %d\n", prefix, 3382 buf += snprintf(buf, end - buf,
3383 "%s%s: active %d total %d\n", prefix,
3302 binder_objstat_strings[i], 3384 binder_objstat_strings[i],
3303 stats->obj_created[i] - stats->obj_deleted[i], 3385 stats->obj_created[i] -
3386 stats->obj_deleted[i],
3304 stats->obj_created[i]); 3387 stats->obj_created[i]);
3305 if (buf >= end) 3388 if (buf >= end)
3306 return buf; 3389 return buf;
@@ -3308,7 +3391,8 @@ static char *print_binder_stats(char *buf, char *end, const char *prefix, struct
3308 return buf; 3391 return buf;
3309} 3392}
3310 3393
3311static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *proc) 3394static char *print_binder_proc_stats(char *buf, char *end,
3395 struct binder_proc *proc)
3312{ 3396{
3313 struct binder_work *w; 3397 struct binder_work *w;
3314 struct rb_node *n; 3398 struct rb_node *n;
@@ -3340,12 +3424,14 @@ static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *p
3340 strong = 0; 3424 strong = 0;
3341 weak = 0; 3425 weak = 0;
3342 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) { 3426 for (n = rb_first(&proc->refs_by_desc); n != NULL; n = rb_next(n)) {
3343 struct binder_ref *ref = rb_entry(n, struct binder_ref, rb_node_desc); 3427 struct binder_ref *ref = rb_entry(n, struct binder_ref,
3428 rb_node_desc);
3344 count++; 3429 count++;
3345 strong += ref->strong; 3430 strong += ref->strong;
3346 weak += ref->weak; 3431 weak += ref->weak;
3347 } 3432 }
3348 buf += snprintf(buf, end - buf, " refs: %d s %d w %d\n", count, strong, weak); 3433 buf += snprintf(buf, end - buf, " refs: %d s %d w %d\n",
3434 count, strong, weak);
3349 if (buf >= end) 3435 if (buf >= end)
3350 return buf; 3436 return buf;
3351 3437
@@ -3376,8 +3462,8 @@ static char *print_binder_proc_stats(char *buf, char *end, struct binder_proc *p
3376} 3462}
3377 3463
3378 3464
3379static int binder_read_proc_state( 3465static int binder_read_proc_state(char *page, char **start, off_t off,
3380 char *page, char **start, off_t off, int count, int *eof, void *data) 3466 int count, int *eof, void *data)
3381{ 3467{
3382 struct binder_proc *proc; 3468 struct binder_proc *proc;
3383 struct hlist_node *pos; 3469 struct hlist_node *pos;
@@ -3424,8 +3510,8 @@ static int binder_read_proc_state(
3424 return len < count ? len : count; 3510 return len < count ? len : count;
3425} 3511}
3426 3512
3427static int binder_read_proc_stats( 3513static int binder_read_proc_stats(char *page, char **start, off_t off,
3428 char *page, char **start, off_t off, int count, int *eof, void *data) 3514 int count, int *eof, void *data)
3429{ 3515{
3430 struct binder_proc *proc; 3516 struct binder_proc *proc;
3431 struct hlist_node *pos; 3517 struct hlist_node *pos;
@@ -3464,8 +3550,8 @@ static int binder_read_proc_stats(
3464 return len < count ? len : count; 3550 return len < count ? len : count;
3465} 3551}
3466 3552
3467static int binder_read_proc_transactions( 3553static int binder_read_proc_transactions(char *page, char **start, off_t off,
3468 char *page, char **start, off_t off, int count, int *eof, void *data) 3554 int count, int *eof, void *data)
3469{ 3555{
3470 struct binder_proc *proc; 3556 struct binder_proc *proc;
3471 struct hlist_node *pos; 3557 struct hlist_node *pos;
@@ -3502,8 +3588,8 @@ static int binder_read_proc_transactions(
3502 return len < count ? len : count; 3588 return len < count ? len : count;
3503} 3589}
3504 3590
3505static int binder_read_proc_proc( 3591static int binder_read_proc_proc(char *page, char **start, off_t off,
3506 char *page, char **start, off_t off, int count, int *eof, void *data) 3592 int count, int *eof, void *data)
3507{ 3593{
3508 struct binder_proc *proc = data; 3594 struct binder_proc *proc = data;
3509 int len = 0; 3595 int len = 0;
@@ -3533,9 +3619,12 @@ static int binder_read_proc_proc(
3533 return len < count ? len : count; 3619 return len < count ? len : count;
3534} 3620}
3535 3621
3536static char *print_binder_transaction_log_entry(char *buf, char *end, struct binder_transaction_log_entry *e) 3622static char *print_binder_transaction_log_entry(char *buf, char *end,
3623 struct binder_transaction_log_entry *e)
3537{ 3624{
3538 buf += snprintf(buf, end - buf, "%d: %s from %d:%d to %d:%d node %d handle %d size %d:%d\n", 3625 buf += snprintf(buf, end - buf,
3626 "%d: %s from %d:%d to %d:%d node %d handle %d "
3627 "size %d:%d\n",
3539 e->debug_id, (e->call_type == 2) ? "reply" : 3628 e->debug_id, (e->call_type == 2) ? "reply" :
3540 ((e->call_type == 1) ? "async" : "call "), e->from_proc, 3629 ((e->call_type == 1) ? "async" : "call "), e->from_proc,
3541 e->from_thread, e->to_proc, e->to_thread, e->to_node, 3630 e->from_thread, e->to_proc, e->to_thread, e->to_node,
@@ -3559,13 +3648,15 @@ static int binder_read_proc_transaction_log(
3559 for (i = log->next; i < ARRAY_SIZE(log->entry); i++) { 3648 for (i = log->next; i < ARRAY_SIZE(log->entry); i++) {
3560 if (buf >= end) 3649 if (buf >= end)
3561 break; 3650 break;
3562 buf = print_binder_transaction_log_entry(buf, end, &log->entry[i]); 3651 buf = print_binder_transaction_log_entry(buf, end,
3652 &log->entry[i]);
3563 } 3653 }
3564 } 3654 }
3565 for (i = 0; i < log->next; i++) { 3655 for (i = 0; i < log->next; i++) {
3566 if (buf >= end) 3656 if (buf >= end)
3567 break; 3657 break;
3568 buf = print_binder_transaction_log_entry(buf, end, &log->entry[i]); 3658 buf = print_binder_transaction_log_entry(buf, end,
3659 &log->entry[i]);
3569 } 3660 }
3570 3661
3571 *start = page + off; 3662 *start = page + off;
@@ -3579,7 +3670,7 @@ static int binder_read_proc_transaction_log(
3579 return len < count ? len : count; 3670 return len < count ? len : count;
3580} 3671}
3581 3672
3582static struct file_operations binder_fops = { 3673static const struct file_operations binder_fops = {
3583 .owner = THIS_MODULE, 3674 .owner = THIS_MODULE,
3584 .poll = binder_poll, 3675 .poll = binder_poll,
3585 .unlocked_ioctl = binder_ioctl, 3676 .unlocked_ioctl = binder_ioctl,
@@ -3601,14 +3692,35 @@ static int __init binder_init(void)
3601 3692
3602 binder_proc_dir_entry_root = proc_mkdir("binder", NULL); 3693 binder_proc_dir_entry_root = proc_mkdir("binder", NULL);
3603 if (binder_proc_dir_entry_root) 3694 if (binder_proc_dir_entry_root)
3604 binder_proc_dir_entry_proc = proc_mkdir("proc", binder_proc_dir_entry_root); 3695 binder_proc_dir_entry_proc = proc_mkdir("proc",
3696 binder_proc_dir_entry_root);
3605 ret = misc_register(&binder_miscdev); 3697 ret = misc_register(&binder_miscdev);
3606 if (binder_proc_dir_entry_root) { 3698 if (binder_proc_dir_entry_root) {
3607 create_proc_read_entry("state", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_state, NULL); 3699 create_proc_read_entry("state",
3608 create_proc_read_entry("stats", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_stats, NULL); 3700 S_IRUGO,
3609 create_proc_read_entry("transactions", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transactions, NULL); 3701 binder_proc_dir_entry_root,
3610 create_proc_read_entry("transaction_log", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transaction_log, &binder_transaction_log); 3702 binder_read_proc_state,
3611 create_proc_read_entry("failed_transaction_log", S_IRUGO, binder_proc_dir_entry_root, binder_read_proc_transaction_log, &binder_transaction_log_failed); 3703 NULL);
3704 create_proc_read_entry("stats",
3705 S_IRUGO,
3706 binder_proc_dir_entry_root,
3707 binder_read_proc_stats,
3708 NULL);
3709 create_proc_read_entry("transactions",
3710 S_IRUGO,
3711 binder_proc_dir_entry_root,
3712 binder_read_proc_transactions,
3713 NULL);
3714 create_proc_read_entry("transaction_log",
3715 S_IRUGO,
3716 binder_proc_dir_entry_root,
3717 binder_read_proc_transaction_log,
3718 &binder_transaction_log);
3719 create_proc_read_entry("failed_transaction_log",
3720 S_IRUGO,
3721 binder_proc_dir_entry_root,
3722 binder_read_proc_transaction_log,
3723 &binder_transaction_log_failed);
3612 } 3724 }
3613 return ret; 3725 return ret;
3614} 3726}