|
9 | 9 |
|
10 | 10 | #![allow(dead_code)]
|
11 | 11 |
|
| 12 | +use crate::prelude::*; |
12 | 13 | use crate::{bindings, error::from_kernel_result, types::PointerWrapper, Error, Result};
|
13 | 14 | use core::ops::Deref;
|
14 | 15 |
|
@@ -95,14 +96,11 @@ pub enum ExtraResult {
|
95 | 96 | /// It is a trait for the functions defined in [`struct irq_chip`].
|
96 | 97 | ///
|
97 | 98 | /// [`struct irq_chip`]: ../../../include/linux/irq.h
|
| 99 | +#[vtable] |
98 | 100 | pub trait Chip: Sized {
|
99 | 101 | /// The type of the context data stored in the irq chip and made available on each callback.
|
100 | 102 | type Data: PointerWrapper;
|
101 | 103 |
|
102 |
| - /// The methods to use to populate [`struct irq_chip`]. This is typically populated with |
103 |
| - /// [`declare_irq_chip_operations`]. |
104 |
| - const TO_USE: ToUse; |
105 |
| - |
106 | 104 | /// Called at the start of a new interrupt.
|
107 | 105 | fn ack(data: <Self::Data as PointerWrapper>::Borrowed<'_>, irq_data: &IrqData);
|
108 | 106 |
|
@@ -144,49 +142,15 @@ pub(crate) unsafe fn init_chip<T: Chip>(chip: &mut bindings::irq_chip) {
|
144 | 142 | chip.irq_mask = Some(irq_mask_callback::<T>);
|
145 | 143 | chip.irq_unmask = Some(irq_unmask_callback::<T>);
|
146 | 144 |
|
147 |
| - if T::TO_USE.set_type { |
| 145 | + if T::HAS_SET_TYPE { |
148 | 146 | chip.irq_set_type = Some(irq_set_type_callback::<T>);
|
149 | 147 | }
|
150 | 148 |
|
151 |
| - if T::TO_USE.set_wake { |
| 149 | + if T::HAS_SET_WAKE { |
152 | 150 | chip.irq_set_wake = Some(irq_set_wake_callback::<T>);
|
153 | 151 | }
|
154 | 152 | }
|
155 | 153 |
|
156 |
| -/// Represents which fields of [`struct irq_chip`] should be populated with pointers. |
157 |
| -/// |
158 |
| -/// This is typically populated with the [`declare_irq_chip_operations`] macro. |
159 |
| -pub struct ToUse { |
160 |
| - /// The `irq_set_type` field of [`struct irq_chip`]. |
161 |
| - pub set_type: bool, |
162 |
| - |
163 |
| - /// The `irq_set_wake` field of [`struct irq_chip`]. |
164 |
| - pub set_wake: bool, |
165 |
| -} |
166 |
| - |
167 |
| -/// A constant version where all values are to set to `false`, that is, all supported fields will |
168 |
| -/// be set to null pointers. |
169 |
| -pub const USE_NONE: ToUse = ToUse { |
170 |
| - set_type: false, |
171 |
| - set_wake: false, |
172 |
| -}; |
173 |
| - |
174 |
| -/// Defines the [`Chip::TO_USE`] field based on a list of fields to be populated. |
175 |
| -#[macro_export] |
176 |
| -macro_rules! declare_irq_chip_operations { |
177 |
| - () => { |
178 |
| - const TO_USE: $crate::irq::ToUse = $crate::irq::USE_NONE; |
179 |
| - }; |
180 |
| - ($($i:ident),+) => { |
181 |
| - #[allow(clippy::needless_update)] |
182 |
| - const TO_USE: $crate::irq::ToUse = |
183 |
| - $crate::irq::ToUse { |
184 |
| - $($i: true),+ , |
185 |
| - ..$crate::irq::USE_NONE |
186 |
| - }; |
187 |
| - }; |
188 |
| -} |
189 |
| - |
190 | 154 | /// Enables or disables power-management wake-on for the given irq number.
|
191 | 155 | pub fn set_wake(irq: u32, on: bool) -> Result {
|
192 | 156 | // SAFETY: Just an FFI call, there are no extra requirements for safety.
|
|
0 commit comments