mirror of
https://github.com/rust-vmm/vhost-device.git
synced 2026-01-08 20:57:35 +00:00
Merge pull request #161 from vireshk/gpio/libgpiod-update
gpio: Update to a newer version of libgpiod
This commit is contained in:
commit
9e40aa9110
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -195,7 +195,7 @@ checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
|
||||
[[package]]
|
||||
name = "libgpiod"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/vireshk/libgpiod#b91233f1c74ca98cc9161afaa37b17668696b0f6"
|
||||
source = "git+https://github.com/vireshk/libgpiod#d96c27a6b868a737f3601bd63fb44556ec5773d7"
|
||||
dependencies = [
|
||||
"libgpiod-sys",
|
||||
"thiserror",
|
||||
@ -205,7 +205,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "libgpiod-sys"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/vireshk/libgpiod#b91233f1c74ca98cc9161afaa37b17668696b0f6"
|
||||
source = "git+https://github.com/vireshk/libgpiod#d96c27a6b868a737f3601bd63fb44556ec5773d7"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
@ -185,10 +185,12 @@ impl GpioDevice for PhysDevice {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
VIRTIO_GPIO_DIRECTION_IN => config.set_direction_offset(Direction::Input, gpio as u32),
|
||||
VIRTIO_GPIO_DIRECTION_IN => {
|
||||
config.set_direction_override(Direction::Input, gpio as u32);
|
||||
}
|
||||
VIRTIO_GPIO_DIRECTION_OUT => {
|
||||
config.set_direction(Direction::Output);
|
||||
config.set_output_value(gpio as u32, value);
|
||||
config.set_direction_default(Direction::Output);
|
||||
config.set_output_value_override(gpio as u32, value);
|
||||
}
|
||||
|
||||
_ => return Err(Error::GpioDirectionInvalid(value)),
|
||||
@ -245,9 +247,9 @@ impl GpioDevice for PhysDevice {
|
||||
let mut config = LineConfig::new().map_err(Error::GpiodFailed)?;
|
||||
|
||||
match value as u16 {
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING => config.set_edge_detection(Edge::Rising),
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING => config.set_edge_detection(Edge::Falling),
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH => config.set_edge_detection(Edge::Both),
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_RISING => config.set_edge_detection_default(Edge::Rising),
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_FALLING => config.set_edge_detection_default(Edge::Falling),
|
||||
VIRTIO_GPIO_IRQ_TYPE_EDGE_BOTH => config.set_edge_detection_default(Edge::Both),
|
||||
|
||||
// Drop the buffer.
|
||||
VIRTIO_GPIO_IRQ_TYPE_NONE => {
|
||||
@ -313,7 +315,7 @@ impl GpioDevice for PhysDevice {
|
||||
};
|
||||
|
||||
// Wait for the interrupt for a second.
|
||||
match request.edge_event_wait(Duration::new(1, 0)) {
|
||||
match request.wait_edge_event(Duration::new(1, 0)) {
|
||||
Err(LibGpiodError::OperationTimedOut) => return Err(Error::GpioIrqOpTimedOut),
|
||||
x => x.map_err(Error::GpiodFailed)?,
|
||||
}
|
||||
@ -322,7 +324,7 @@ impl GpioDevice for PhysDevice {
|
||||
let state = &self.state[gpio as usize].write().unwrap();
|
||||
if let Some(buffer) = &state.buffer {
|
||||
request
|
||||
.edge_event_read(buffer, 1)
|
||||
.read_edge_event(buffer, 1)
|
||||
.map_err(Error::GpiodFailed)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
Loading…
Reference in New Issue
Block a user