summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@suse.com>2014-07-02 12:55:05 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-08 18:28:16 -0400
commitc868edf42b4db89907b467c92b7f035c8c1cb0e5 (patch)
tree739f930880e8c098f01f88eb44a0bb5fac2c54c3
parenta76040d835776f0e8cc2bf5f9edcfa2092449ae9 (diff)
firmware loader: inform direct failure when udev loader is disabled
Now that the udev firmware loader is optional request_firmware() will not provide any information on the kernel ring buffer if direct firmware loading failed and udev firmware loading is disabled. If no information is needed request_firmware_direct() should be used for optional firmware, at which point drivers can take on the onus over informing of any failures, if udev firmware loading is disabled though we should at the very least provide some sort of information as when the udev loader was enabled by default back in the days. With this change with a simple firmware load test module [0]: Example output without FW_LOADER_USER_HELPER_FALLBACK platform fake-dev.0: Direct firmware load for fake.bin failed with error -2 Example with FW_LOADER_USER_HELPER_FALLBACK platform fake-dev.0: Direct firmware load for fake.bin failed with error -2 platform fake-dev.0: Falling back to user helper Without this change without FW_LOADER_USER_HELPER_FALLBACK we get no output logged upon failure. Cc: Tom Gundersen <teg@jklm.no> Cc: Ming Lei <ming.lei@canonical.com> Cc: Abhay Salunke <Abhay_Salunke@dell.com> Cc: Stefan Roese <sr@denx.de> Cc: Arnd Bergmann <arnd@arndb.de> Cc: Kay Sievers <kay@vrfy.org> Signed-off-by: Luis R. Rodriguez <mcgrof@suse.com> Reviewed-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/firmware_class.c13
-rw-r--r--include/linux/firmware.h15
2 files changed, 15 insertions, 13 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 28bc6db9fbf4..124d50ceb116 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -109,6 +109,7 @@ static inline long firmware_loading_timeout(void)
109#else 109#else
110#define FW_OPT_FALLBACK 0 110#define FW_OPT_FALLBACK 0
111#endif 111#endif
112#define FW_OPT_NO_WARN (1U << 3)
112 113
113struct firmware_cache { 114struct firmware_cache {
114 /* firmware_buf instance will be added into the below list */ 115 /* firmware_buf instance will be added into the below list */
@@ -1105,10 +1106,11 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
1105 1106
1106 ret = fw_get_filesystem_firmware(device, fw->priv); 1107 ret = fw_get_filesystem_firmware(device, fw->priv);
1107 if (ret) { 1108 if (ret) {
1108 if (opt_flags & FW_OPT_USERHELPER) { 1109 if (!(opt_flags & FW_OPT_NO_WARN))
1109 dev_warn(device, 1110 dev_warn(device,
1110 "Direct firmware load failed with error %d\n", 1111 "Direct firmware load for %s failed with error %d\n",
1111 ret); 1112 name, ret);
1113 if (opt_flags & FW_OPT_USERHELPER) {
1112 dev_warn(device, "Falling back to user helper\n"); 1114 dev_warn(device, "Falling back to user helper\n");
1113 ret = fw_load_from_user_helper(fw, name, device, 1115 ret = fw_load_from_user_helper(fw, name, device,
1114 opt_flags, timeout); 1116 opt_flags, timeout);
@@ -1165,7 +1167,6 @@ request_firmware(const struct firmware **firmware_p, const char *name,
1165} 1167}
1166EXPORT_SYMBOL(request_firmware); 1168EXPORT_SYMBOL(request_firmware);
1167 1169
1168#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
1169/** 1170/**
1170 * request_firmware: - load firmware directly without usermode helper 1171 * request_firmware: - load firmware directly without usermode helper
1171 * @firmware_p: pointer to firmware image 1172 * @firmware_p: pointer to firmware image
@@ -1182,12 +1183,12 @@ int request_firmware_direct(const struct firmware **firmware_p,
1182{ 1183{
1183 int ret; 1184 int ret;
1184 __module_get(THIS_MODULE); 1185 __module_get(THIS_MODULE);
1185 ret = _request_firmware(firmware_p, name, device, FW_OPT_UEVENT); 1186 ret = _request_firmware(firmware_p, name, device,
1187 FW_OPT_UEVENT | FW_OPT_NO_WARN);
1186 module_put(THIS_MODULE); 1188 module_put(THIS_MODULE);
1187 return ret; 1189 return ret;
1188} 1190}
1189EXPORT_SYMBOL_GPL(request_firmware_direct); 1191EXPORT_SYMBOL_GPL(request_firmware_direct);
1190#endif
1191 1192
1192/** 1193/**
1193 * release_firmware: - release the resource associated with a firmware image 1194 * release_firmware: - release the resource associated with a firmware image
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 67e5b801af0c..5c41c5e75b5c 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -45,6 +45,8 @@ int request_firmware_nowait(
45 struct module *module, bool uevent, 45 struct module *module, bool uevent,
46 const char *name, struct device *device, gfp_t gfp, void *context, 46 const char *name, struct device *device, gfp_t gfp, void *context,
47 void (*cont)(const struct firmware *fw, void *context)); 47 void (*cont)(const struct firmware *fw, void *context));
48int request_firmware_direct(const struct firmware **fw, const char *name,
49 struct device *device);
48 50
49void release_firmware(const struct firmware *fw); 51void release_firmware(const struct firmware *fw);
50#else 52#else
@@ -66,13 +68,12 @@ static inline void release_firmware(const struct firmware *fw)
66{ 68{
67} 69}
68 70
69#endif 71static inline int request_firmware_direct(const struct firmware **fw,
72 const char *name,
73 struct device *device)
74{
75 return -EINVAL;
76}
70 77
71#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
72int request_firmware_direct(const struct firmware **fw, const char *name,
73 struct device *device);
74#else
75#define request_firmware_direct request_firmware
76#endif 78#endif
77
78#endif 79#endif