]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
poll: rust: allow poll_table ptrs to be null
authorAlice Ryhl <aliceryhl@google.com>
Mon, 23 Jun 2025 13:57:27 +0000 (13:57 +0000)
committerChristian Brauner <brauner@kernel.org>
Mon, 14 Jul 2025 12:12:24 +0000 (14:12 +0200)
commitde747bd023c09b5b7f3bf5c952d7b1da77a9caaa
tree821cb9111e8e85008ab87e8b551ffc0cafde1662
parent19272b37aa4f83ca52bdf9c16d5d81bdd1354494
poll: rust: allow poll_table ptrs to be null

It's possible for a poll_table to be null. This can happen if an
end-user just wants to know if a resource has events right now without
registering a waiter for when events become available. Furthermore,
these null pointers should be handled transparently by the API, so we
should not change `from_ptr` to return an `Option`. Thus, change
`PollTable` to wrap a raw pointer rather than use a reference so that
you can pass null.

Comments mentioning `struct poll_table` are changed to just `poll_table`
since `poll_table` is a typedef. (It's a typedef because it's supposed
to be opaque.)

Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
rust/helpers/helpers.c
rust/helpers/poll.c [new file with mode: 0644]
rust/kernel/sync/poll.rs