You would typically load firmware and then load it into your device somehow. The typical firmware work flow is reflected below:
if(request_firmware(&fw_entry, $FIRMWARE, device) == 0)
copy_fw_to_device(fw_entry->data, fw_entry->size);
release_firmware(fw_entry);
Synchronous firmware requests will wait until the firmware is found or until an error is returned.
send firmware request and wait for it
Parameters
Description
firmware_p will be used to return a firmware image by the name of name for device device.
Should be called from user context where sleeping is allowed.
name will be used as $FIRMWARE in the uevent environment and should be distinctive enough not to be confused with any other firmware image for this or any other device.
Caller must hold the reference count of device.
The function can be called safely inside device’s suspend and resume callback.
load firmware directly without usermode helper
Parameters
Description
This function works pretty much like request_firmware(), but this doesn’t fall back to usermode helper even if the firmware couldn’t be loaded directly from fs. Hence it’s useful for loading optional firmwares, which aren’t always present, without extra long timeouts of udev.
load firmware into a previously allocated buffer
Parameters
Description
This function works pretty much like request_firmware(), but it doesn’t allocate a buffer to hold the firmware data. Instead, the firmware is loaded directly into the buffer pointed to by buf and the firmware_p data member is pointed at buf.
This function doesn’t cache firmware either.
Asynchronous firmware requests allow driver code to not have to wait until the firmware or an error is returned. Function callbacks are provided so that when the firmware or an error is found the driver is informed through the callback. request_firmware_nowait() cannot be called in atomic contexts.
asynchronous version of request_firmware
Parameters
Description
Caller must hold the reference count of device.
- Asynchronous variant of request_firmware() for user contexts:
- sleep for as small periods as possible since it may increase kernel boot time of built-in device drivers requesting firmware in their ->:c:func:probe() methods, if gfp is GFP_KERNEL.
- can’t sleep at all if gfp is GFP_ATOMIC.
Once an API call returns you process the firmware and then release the firmware. For example if you used request_firmware() and it returns, the driver has the firmware image accessible in fw_entry->{data,size}. If something went wrong request_firmware() returns non-zero and fw_entry is set to NULL. Once your driver is done with processing the firmware it can call call release_firmware(fw_entry) to release the firmware image and any related resource.