mirror of
https://github.com/torvalds/linux.git
synced 2026-06-02 03:24:19 +02:00
gpu: nova-core: firmware: move firmware request code into a function
When all the firmware files are loaded from `Firmware::new`, it makes sense to have the firmware request code as a closure. However, since we eventually want each individual firmware constructor to request its own file (and get rid of `Firmware` altogether), move this code into a dedicated function that can be called by individual firmware types. Acked-by: Danilo Krummrich <dakr@kernel.org> Link: https://lore.kernel.org/r/20250913-nova_firmware-v6-4-9007079548b0@nvidia.com Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>
This commit is contained in:
parent
b345c917d7
commit
ebe658732c
|
|
@ -19,6 +19,19 @@
|
|||
|
||||
pub(crate) const FIRMWARE_VERSION: &str = "535.113.01";
|
||||
|
||||
/// Requests the GPU firmware `name` suitable for `chipset`, with version `ver`.
|
||||
fn request_firmware(
|
||||
dev: &device::Device,
|
||||
chipset: gpu::Chipset,
|
||||
name: &str,
|
||||
ver: &str,
|
||||
) -> Result<firmware::Firmware> {
|
||||
let chip_name = chipset.name();
|
||||
|
||||
CString::try_from_fmt(fmt!("nvidia/{chip_name}/gsp/{name}-{ver}.bin"))
|
||||
.and_then(|path| firmware::Firmware::request(&path, dev))
|
||||
}
|
||||
|
||||
/// Structure encapsulating the firmware blobs required for the GPU to operate.
|
||||
#[expect(dead_code)]
|
||||
pub(crate) struct Firmware {
|
||||
|
|
@ -30,12 +43,7 @@ pub(crate) struct Firmware {
|
|||
|
||||
impl Firmware {
|
||||
pub(crate) fn new(dev: &device::Device, chipset: Chipset, ver: &str) -> Result<Firmware> {
|
||||
let chip_name = chipset.name();
|
||||
|
||||
let request = |name_| {
|
||||
CString::try_from_fmt(fmt!("nvidia/{chip_name}/gsp/{name_}-{ver}.bin"))
|
||||
.and_then(|path| firmware::Firmware::request(&path, dev))
|
||||
};
|
||||
let request = |name| request_firmware(dev, chipset, name, ver);
|
||||
|
||||
Ok(Firmware {
|
||||
booter_load: request("booter_load")?,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user