Skip to content

Commit efc1b10

Browse files
committed
gpio: pl061: fix 32-bit builds of PL061 Rust driver.
Hw irq numbers are 32 bits in 32-bit archs, so use the type alias to convert to it. Signed-off-by: Wedson Almeida Filho <[email protected]>
1 parent 402f419 commit efc1b10

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

drivers/gpio/gpio_pl061_rust.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ impl irq::Chip for PL061Device {
223223
}
224224

225225
fn mask(data: RefBorrow<'_, DeviceData>, irq_data: &IrqData) {
226-
let mask = bit(irq_data.hwirq() % u64::from(PL061_GPIO_NR));
226+
let mask = bit(irq_data.hwirq() % irq::HwNumber::from(PL061_GPIO_NR));
227227
let _guard = data.lock();
228228
if let Some(pl061) = data.resources() {
229229
let gpioie = pl061.base.readb(GPIOIE) & !mask;
@@ -232,7 +232,7 @@ impl irq::Chip for PL061Device {
232232
}
233233

234234
fn unmask(data: RefBorrow<'_, DeviceData>, irq_data: &IrqData) {
235-
let mask = bit(irq_data.hwirq() % u64::from(PL061_GPIO_NR));
235+
let mask = bit(irq_data.hwirq() % irq::HwNumber::from(PL061_GPIO_NR));
236236
let _guard = data.lock();
237237
if let Some(pl061) = data.resources() {
238238
let gpioie = pl061.base.readb(GPIOIE) | mask;
@@ -244,7 +244,7 @@ impl irq::Chip for PL061Device {
244244
// (interrupt-clear) register. For level IRQs this is not needed: these go away when the level
245245
// signal goes away.
246246
fn ack(data: RefBorrow<'_, DeviceData>, irq_data: &IrqData) {
247-
let mask = bit(irq_data.hwirq() % u64::from(PL061_GPIO_NR));
247+
let mask = bit(irq_data.hwirq() % irq::HwNumber::from(PL061_GPIO_NR));
248248
let _guard = data.lock();
249249
if let Some(pl061) = data.resources() {
250250
pl061.base.writeb(mask.into(), GPIOIC);

rust/kernel/irq.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
use crate::{bindings, c_types, error::from_kernel_result, types::PointerWrapper, Error, Result};
1313
use core::ops::Deref;
1414

15-
type IrqHwNumber = bindings::irq_hw_number_t;
15+
/// The type of irq hardware numbers.
16+
pub type HwNumber = bindings::irq_hw_number_t;
1617

1718
/// Wraps the kernel's `struct irq_data`.
1819
///
@@ -37,7 +38,7 @@ impl IrqData {
3738
}
3839

3940
/// Returns the hardware irq number.
40-
pub fn hwirq(&self) -> IrqHwNumber {
41+
pub fn hwirq(&self) -> HwNumber {
4142
// SAFETY: By the type invariants, it's ok to dereference `ptr`.
4243
unsafe { (*self.ptr).hwirq }
4344
}

0 commit comments

Comments
 (0)