mirror of
https://github.com/torvalds/linux.git
synced 2026-11-28 17:32:32 +00:00
After GSP initialization is complete, retrieve the static configuration information from GSP-RM. This information includes GPU name, capabilities, memory configuration, and other properties. On some GPU variants, it is also required to do this for initialization to complete. Signed-off-by: Alistair Popple <[email protected]> Co-developed-by: Joel Fernandes <[email protected]> Signed-off-by: Joel Fernandes <[email protected]> Reviewed-by: Lyude Paul <[email protected]> [[email protected]: properly abstract the command's bindings, add relevant methods, make str_from_null_terminated return an Option, fix size of GPU name array.] Co-developed-by: Alexandre Courbot <[email protected]> Signed-off-by: Alexandre Courbot <[email protected]> Message-ID: <[email protected]>
17 lines
615 B
Rust
17 lines
615 B
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/// Converts a null-terminated byte slice to a string, or `None` if the array does not
|
|
/// contains any null byte or contains invalid characters.
|
|
///
|
|
/// Contrary to [`kernel::str::CStr::from_bytes_with_nul`], the null byte can be anywhere in the
|
|
/// slice, and not only in the last position.
|
|
pub(crate) fn str_from_null_terminated(bytes: &[u8]) -> Option<&str> {
|
|
use kernel::str::CStr;
|
|
|
|
bytes
|
|
.iter()
|
|
.position(|&b| b == 0)
|
|
.and_then(|null_pos| CStr::from_bytes_with_nul(&bytes[..=null_pos]).ok())
|
|
.and_then(|cstr| cstr.to_str().ok())
|
|
}
|