aboutsummaryrefslogtreecommitdiff
path: root/cyw43/src
diff options
context:
space:
mode:
Diffstat (limited to 'cyw43/src')
-rw-r--r--cyw43/src/events.rs25
-rw-r--r--cyw43/src/ioctl.rs8
-rw-r--r--cyw43/src/lib.rs2
3 files changed, 25 insertions, 10 deletions
diff --git a/cyw43/src/events.rs b/cyw43/src/events.rs
index 44bfa98e9..2a78b38c3 100644
--- a/cyw43/src/events.rs
+++ b/cyw43/src/events.rs
@@ -296,10 +296,10 @@ pub struct Events {
296} 296}
297 297
298impl Events { 298impl Events {
299 pub fn new() -> Self { 299 pub const fn new() -> Self {
300 Self { 300 Self {
301 queue: EventQueue::new(), 301 queue: EventQueue::new(),
302 mask: SharedEventMask::default(), 302 mask: SharedEventMask::new(),
303 } 303 }
304 } 304 }
305} 305}
@@ -333,7 +333,6 @@ impl Message {
333 } 333 }
334} 334}
335 335
336#[derive(Default)]
337struct EventMask { 336struct EventMask {
338 mask: [u32; Self::WORD_COUNT], 337 mask: [u32; Self::WORD_COUNT],
339} 338}
@@ -341,6 +340,12 @@ struct EventMask {
341impl EventMask { 340impl EventMask {
342 const WORD_COUNT: usize = ((Event::LAST as u32 + (u32::BITS - 1)) / u32::BITS) as usize; 341 const WORD_COUNT: usize = ((Event::LAST as u32 + (u32::BITS - 1)) / u32::BITS) as usize;
343 342
343 const fn new() -> Self {
344 Self {
345 mask: [0; Self::WORD_COUNT],
346 }
347 }
348
344 fn enable(&mut self, event: Event) { 349 fn enable(&mut self, event: Event) {
345 let n = event as u32; 350 let n = event as u32;
346 let word = n / u32::BITS; 351 let word = n / u32::BITS;
@@ -366,13 +371,17 @@ impl EventMask {
366 } 371 }
367} 372}
368 373
369#[derive(Default)]
370
371pub struct SharedEventMask { 374pub struct SharedEventMask {
372 mask: RefCell<EventMask>, 375 mask: RefCell<EventMask>,
373} 376}
374 377
375impl SharedEventMask { 378impl SharedEventMask {
379 pub const fn new() -> Self {
380 Self {
381 mask: RefCell::new(EventMask::new()),
382 }
383 }
384
376 pub fn enable(&self, events: &[Event]) { 385 pub fn enable(&self, events: &[Event]) {
377 let mut mask = self.mask.borrow_mut(); 386 let mut mask = self.mask.borrow_mut();
378 for event in events { 387 for event in events {
@@ -398,3 +407,9 @@ impl SharedEventMask {
398 mask.is_enabled(event) 407 mask.is_enabled(event)
399 } 408 }
400} 409}
410
411impl Default for SharedEventMask {
412 fn default() -> Self {
413 Self::new()
414 }
415}
diff --git a/cyw43/src/ioctl.rs b/cyw43/src/ioctl.rs
index af8bb695b..35135e296 100644
--- a/cyw43/src/ioctl.rs
+++ b/cyw43/src/ioctl.rs
@@ -33,8 +33,8 @@ struct Wakers {
33 runner: WakerRegistration, 33 runner: WakerRegistration,
34} 34}
35 35
36impl Default for Wakers { 36impl Wakers {
37 fn default() -> Self { 37 const fn new() -> Self {
38 Self { 38 Self {
39 control: WakerRegistration::new(), 39 control: WakerRegistration::new(),
40 runner: WakerRegistration::new(), 40 runner: WakerRegistration::new(),
@@ -48,10 +48,10 @@ pub struct IoctlState {
48} 48}
49 49
50impl IoctlState { 50impl IoctlState {
51 pub fn new() -> Self { 51 pub const fn new() -> Self {
52 Self { 52 Self {
53 state: Cell::new(IoctlStateInner::Done { resp_len: 0 }), 53 state: Cell::new(IoctlStateInner::Done { resp_len: 0 }),
54 wakers: Default::default(), 54 wakers: RefCell::new(Wakers::new()),
55 } 55 }
56 } 56 }
57 57
diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs
index aab13d8b8..16b436e66 100644
--- a/cyw43/src/lib.rs
+++ b/cyw43/src/lib.rs
@@ -124,7 +124,7 @@ struct NetState {
124 124
125impl State { 125impl State {
126 /// Create new driver state holder. 126 /// Create new driver state holder.
127 pub fn new() -> Self { 127 pub const fn new() -> Self {
128 Self { 128 Self {
129 ioctl_state: IoctlState::new(), 129 ioctl_state: IoctlState::new(),
130 net: NetState { 130 net: NetState {