Re: [PATCH v6 2/6] rust: irq: add flags module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jul 04, 2025 at 08:14:11AM +0200, Daniel Sedlak wrote:
> Hi Daniel,
> 
> On 7/3/25 9:30 PM, Daniel Almeida wrote:
> > +/// Flags to be used when registering IRQ handlers.
> > +///
> > +/// They can be combined with the operators `|`, `&`, and `!`.
> > +#[derive(Clone, Copy, PartialEq, Eq)]
> > +pub struct Flags(u64);
> 
> Why not Flags(u32)? You may get rid of all unnecessary casts later, plus
> save some extra bytes.

It looks like the C methods take an `unsigned long`. In that case, I'd
probably write the code to match that.

	pub struct Flags(c_ulong);

and git rid of the cast when calling bindings::request_irq.

As for all the constants in this file, maybe it would be nice with a
private constructor that uses the same type as bindings to avoid the
casts?

	impl Flags {
	    const fn new(value: u32) -> Flags {
	    	...
	    }
	}
	
	/// Use the interrupt line as already configured.
	pub const TRIGGER_NONE: Flags = Flags::new(bindings::IRQF_TRIGGER_NONE);

Not a big deal, but avoiding the cast when calling bindings::request_irq
is a good idea I think.

With that:
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

Alice




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux