provide information whether requested firmware is bult-in
Subsystems (2)
RFC PATCH 1/1 provide information whether requested firmware is bult-in
As indicated by several threads on lkml, currently the only safe way to reload external firmware in resume method is to cache it in memory. In this case if firmware was already built in, we just create useless copy. The patch suggests framework which can be used to return information whether firmware was loaded dynamically or already available in memory. Requestor can check it to decide whether local copy is required.
Alternative would be request_cached_firwmare() function to manage cache in one place.
Comments? Is there any other reliable way to ensure firmware can be loaded on resume?
-andrey
drivers/base/firmware_class.c +3 -7
@@ -415,6 +415,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, name); firmware->size = builtin->size; firmware->data = builtin->data; + firmware->flags |=FW_FL_BUILTIN ;return 0 ; }
@@ -491,13 +492,8 @@ release_firmware(const struct firmware *fw)struct builtin_fw *builtin;if (fw) { -for (builtin = __start_builtin_fw; builtin != __end_builtin_fw; - builtin++) { -if (fw->data == builtin->data) - goto free_fw; - } -vfree (fw->data); - free_fw: +if (!(fw->flags&FW_FL_BUILTIN )) +vfree (fw->data);kfree (fw); } }
include/linux/firmware.h +3 -0
@@ -9,9 +9,12 @@#define FW_ACTION_NOHOTPLUG 0#define FW_ACTION_HOTPLUG 1 +#define FW_FL_BUILTIN (1<<0)/* Firmware image is built in kernel */ +struct firmware {size_t size;const u8 *data; +unsigned short flags; };struct device ;