Skip to content

Commit 82057dd

Browse files
authored
Merge pull request #314 from wedsonaf/defs
binder: Export more constants via the `defs` module.
2 parents 843de5c + 71763f8 commit 82057dd

File tree

4 files changed

+23
-15
lines changed

4 files changed

+23
-15
lines changed

drivers/android/allocation.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use core::mem::{size_of, MaybeUninit};
55
use kernel::{bindings, pages::Pages, prelude::*, user_ptr::UserSlicePtrReader, Error};
66

77
use crate::{
8+
defs::*,
89
node::NodeRef,
910
process::{AllocationInfo, Process},
1011
thread::{BinderError, BinderResult},
@@ -117,19 +118,19 @@ impl<'a> Allocation<'a> {
117118
let header = view.read::<bindings::binder_object_header>(offset)?;
118119
// TODO: Handle other types.
119120
match header.type_ {
120-
bindings::BINDER_TYPE_WEAK_BINDER | bindings::BINDER_TYPE_BINDER => {
121+
BINDER_TYPE_WEAK_BINDER | BINDER_TYPE_BINDER => {
121122
let obj = view.read::<bindings::flat_binder_object>(offset)?;
122-
let strong = header.type_ == bindings::BINDER_TYPE_BINDER;
123+
let strong = header.type_ == BINDER_TYPE_BINDER;
123124
// SAFETY: The type is `BINDER_TYPE_{WEAK_}BINDER`, so the `binder` field is
124125
// populated.
125126
let ptr = unsafe { obj.__bindgen_anon_1.binder } as usize;
126127
let cookie = obj.cookie as usize;
127128
self.process.update_node(ptr, cookie, strong, false);
128129
Ok(())
129130
}
130-
bindings::BINDER_TYPE_WEAK_HANDLE | bindings::BINDER_TYPE_HANDLE => {
131+
BINDER_TYPE_WEAK_HANDLE | BINDER_TYPE_HANDLE => {
131132
let obj = view.read::<bindings::flat_binder_object>(offset)?;
132-
let strong = header.type_ == bindings::BINDER_TYPE_HANDLE;
133+
let strong = header.type_ == BINDER_TYPE_HANDLE;
133134
// SAFETY: The type is `BINDER_TYPE_{WEAK_}HANDLE`, so the `handle` field is
134135
// populated.
135136
let handle = unsafe { obj.__bindgen_anon_1.handle } as _;
@@ -203,9 +204,9 @@ impl<'a> AllocationView<'a> {
203204
let newobj = bindings::flat_binder_object {
204205
hdr: bindings::binder_object_header {
205206
type_: if strong {
206-
bindings::BINDER_TYPE_BINDER
207+
BINDER_TYPE_BINDER
207208
} else {
208-
bindings::BINDER_TYPE_WEAK_BINDER
209+
BINDER_TYPE_WEAK_BINDER
209210
},
210211
},
211212
flags: obj.flags,
@@ -228,9 +229,9 @@ impl<'a> AllocationView<'a> {
228229
let newobj = bindings::flat_binder_object {
229230
hdr: bindings::binder_object_header {
230231
type_: if strong {
231-
bindings::BINDER_TYPE_HANDLE
232+
BINDER_TYPE_HANDLE
232233
} else {
233-
bindings::BINDER_TYPE_WEAK_HANDLE
234+
BINDER_TYPE_WEAK_HANDLE
234235
},
235236
},
236237
flags: obj.flags,

drivers/android/defs.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ pub_no_prefix!(
5151
BC_DEAD_BINDER_DONE
5252
);
5353

54+
pub_no_prefix!(transaction_flags_, TF_ONE_WAY, TF_ACCEPT_FDS);
55+
56+
pub(crate) use bindings::{
57+
BINDER_TYPE_BINDER, BINDER_TYPE_FD, BINDER_TYPE_HANDLE, BINDER_TYPE_WEAK_BINDER,
58+
BINDER_TYPE_WEAK_HANDLE, FLAT_BINDER_FLAG_ACCEPTS_FDS,
59+
};
60+
5461
macro_rules! decl_wrapper {
5562
($newname:ident, $wrapped:ty) => {
5663
#[derive(Copy, Clone, Default)]

drivers/android/thread.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,17 @@ impl Thread {
383383
let header = view.read::<bindings::binder_object_header>(offset)?;
384384
// TODO: Handle other types.
385385
match header.type_ {
386-
bindings::BINDER_TYPE_WEAK_BINDER | bindings::BINDER_TYPE_BINDER => {
387-
let strong = header.type_ == bindings::BINDER_TYPE_BINDER;
386+
BINDER_TYPE_WEAK_BINDER | BINDER_TYPE_BINDER => {
387+
let strong = header.type_ == BINDER_TYPE_BINDER;
388388
view.transfer_binder_object(offset, strong, |obj| {
389389
// SAFETY: The type is `BINDER_TYPE_{WEAK_}BINDER`, so `binder` is populated.
390390
let ptr = unsafe { obj.__bindgen_anon_1.binder } as _;
391391
let cookie = obj.cookie as _;
392392
Ok(self.process.get_node(ptr, cookie, strong, Some(self))?)
393393
})?;
394394
}
395-
bindings::BINDER_TYPE_WEAK_HANDLE | bindings::BINDER_TYPE_HANDLE => {
396-
let strong = header.type_ == bindings::BINDER_TYPE_HANDLE;
395+
BINDER_TYPE_WEAK_HANDLE | BINDER_TYPE_HANDLE => {
396+
let strong = header.type_ == BINDER_TYPE_HANDLE;
397397
view.transfer_binder_object(offset, strong, |obj| {
398398
// SAFETY: The type is `BINDER_TYPE_{WEAK_}HANDLE`, so `handle` is populated.
399399
let handle = unsafe { obj.__bindgen_anon_1.handle } as _;
@@ -615,7 +615,7 @@ impl Thread {
615615
match reader.read::<u32>()? {
616616
BC_TRANSACTION => {
617617
let tr = reader.read::<BinderTransactionData>()?;
618-
if tr.flags & bindings::transaction_flags_TF_ONE_WAY != 0 {
618+
if tr.flags & TF_ONE_WAY != 0 {
619619
self.transaction(&tr, Self::oneway_transaction_inner)
620620
} else {
621621
self.transaction(&tr, Self::transaction_inner)

drivers/android/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use alloc::sync::Arc;
44
use core::sync::atomic::{AtomicBool, Ordering};
55
use kernel::{
6-
bindings, io_buffer::IoBufferWriter, linked_list::Links, prelude::*, sync::Ref,
6+
io_buffer::IoBufferWriter, linked_list::Links, prelude::*, sync::Ref,
77
user_ptr::UserSlicePtrWriter,
88
};
99

@@ -179,7 +179,7 @@ impl DeliverToRead for Transaction {
179179

180180
// When this is not a reply and not an async transaction, update `current_transaction`. If
181181
// it's a reply, `current_transaction` has already been updated appropriately.
182-
if self.node_ref.is_some() && tr.flags & bindings::transaction_flags_TF_ONE_WAY == 0 {
182+
if self.node_ref.is_some() && tr.flags & TF_ONE_WAY == 0 {
183183
thread.set_current_transaction(self);
184184
}
185185

0 commit comments

Comments
 (0)