device/queue: borrow reference to the queue when creating buffer mapping
Any call to REQBUFS will fail if there is a buffer mapping active. Use
lifetimes to ensure that a mapping cannot outlive its queue.
diff --git a/src/device/queue.rs b/src/device/queue.rs
index 2b9dcf5..43eab6b 100644
--- a/src/device/queue.rs
+++ b/src/device/queue.rs
@@ -451,8 +451,12 @@
}
impl<D: Direction> Queue<D, BuffersAllocated<MMAP>> {
+ // Map the plane `plane_index` from buffer `buffer_index` and return a
+ // mapping object.
+ // The mapping borrows a reference to the queue, meaning that all mappings
+ // must be released before e.g. buffers are deallocated.
pub fn map_plane<'a>(
- &self,
+ &'a self,
buffer_index: usize,
plane_index: usize,
) -> Result<PlaneMapping<'a>> {