Re: [PATCH v6 3/6] rust: irq: add support for non-threaded IRQs and handlers

Benno Lossin
2025-07-07T20:30:32Z

On Mon Jul 7, 2025 at 6:18 PM CEST, Daniel Almeida wrote:
> Alice,
>
> […]
>
>>> +/// The value that can be returned from an IrqHandler or a ThreadedIrqHandler.
>>> +pub enum IrqReturn {
>>> + /// The interrupt was not from this device or was not handled.
>>> + None,
>>> +
>>> + /// The interrupt was handled by this device.
>>> + Handled,
>>> +}
>>> +
>>> +impl IrqReturn {
>>> + fn into_inner(self) -> u32 {
>>> + match self {
>>> + IrqReturn::None => bindings::irqreturn_IRQ_NONE,
>>> + IrqReturn::Handled => bindings::irqreturn_IRQ_HANDLED,
>>
>> One option is to specify these in the enum:
>>
>> /// The value that can be returned from an IrqHandler or a ThreadedIrqHandler.
>> pub enum IrqReturn {
>> /// The interrupt was not from this device or was not handled.
>> None = bindings::irqreturn_IRQ_NONE,
>>
>> /// The interrupt was handled by this device.
>> Handled = bindings::irqreturn_IRQ_HANDLED,
>> }
>
> This requires explicitly setting #[repr(u32)], which is something that was
> reverted at an earlier iteration of the series on Benno’s request.

Yeah I requested this, because it increases the size of the enum to 4
bytes and I think we should try to make rust enums as small as possible.

@Alice what's the benefit of doing it directly in the enum?

---
Cheers,
Benno