aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis R. Rodriguez <mcgrof@kernel.org>2017-11-20 13:23:57 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-11-29 05:18:43 -0500
commit25d3913181b3e397549cb6584d7ab1a37709d104 (patch)
tree5912222a1d3464c744873a66f6642c8d7f4083ff
parent5711ae6d3054e13a95858da6df6d142bec90d832 (diff)
firmware: provide helper for FW_OPT_USERHELPER
The macro FW_OPT_USERHELPER is only currently defined when CONFIG_FW_LOADER_USER_HELPER is set. This is handled via an ifdef around CONFIG_FW_LOADER_USER_HELPER. This makes reading and understanding use FW_OPT_USERHELPER a bit convoluted. Instead wrap the functionality implemented behind CONFIG_FW_LOADER_USER_HELPER as we typically do in the kernel. Now when CONFIG_FW_LOADER_USER_HELPER is *not set*, then simply the helper fw_sysfs_fallback() will not do anything. Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/base/firmware_class.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index aba3f2cbe2f4..316991429032 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -61,11 +61,7 @@ struct fw_state {
61/* firmware behavior options */ 61/* firmware behavior options */
62#define FW_OPT_UEVENT (1U << 0) 62#define FW_OPT_UEVENT (1U << 0)
63#define FW_OPT_NOWAIT (1U << 1) 63#define FW_OPT_NOWAIT (1U << 1)
64#ifdef CONFIG_FW_LOADER_USER_HELPER
65#define FW_OPT_USERHELPER (1U << 2) 64#define FW_OPT_USERHELPER (1U << 2)
66#else
67#define FW_OPT_USERHELPER 0
68#endif
69#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK 65#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
70#define FW_OPT_FALLBACK FW_OPT_USERHELPER 66#define FW_OPT_FALLBACK FW_OPT_USERHELPER
71#else 67#else
@@ -1158,12 +1154,25 @@ out_unlock:
1158 return ret; 1154 return ret;
1159} 1155}
1160 1156
1157static int fw_sysfs_fallback(struct firmware *fw, const char *name,
1158 struct device *device,
1159 unsigned int opt_flags,
1160 int ret)
1161{
1162 if (!(opt_flags & FW_OPT_USERHELPER))
1163 return ret;
1164
1165 dev_warn(device, "Falling back to user helper\n");
1166 return fw_load_from_user_helper(fw, name, device, opt_flags);
1167}
1161#else /* CONFIG_FW_LOADER_USER_HELPER */ 1168#else /* CONFIG_FW_LOADER_USER_HELPER */
1162static inline int 1169static int fw_sysfs_fallback(struct firmware *fw, const char *name,
1163fw_load_from_user_helper(struct firmware *firmware, const char *name, 1170 struct device *device,
1164 struct device *device, unsigned int opt_flags) 1171 unsigned int opt_flags,
1172 int ret)
1165{ 1173{
1166 return -ENOENT; 1174 /* Keep carrying over the same error */
1175 return ret;
1167} 1176}
1168 1177
1169static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { } 1178static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
@@ -1273,11 +1282,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
1273 dev_warn(device, 1282 dev_warn(device,
1274 "Direct firmware load for %s failed with error %d\n", 1283 "Direct firmware load for %s failed with error %d\n",
1275 name, ret); 1284 name, ret);
1276 if (opt_flags & FW_OPT_USERHELPER) { 1285 ret = fw_sysfs_fallback(fw, name, device, opt_flags, ret);
1277 dev_warn(device, "Falling back to user helper\n");
1278 ret = fw_load_from_user_helper(fw, name, device,
1279 opt_flags);
1280 }
1281 } else 1286 } else
1282 ret = assign_fw(fw, device, opt_flags); 1287 ret = assign_fw(fw, device, opt_flags);
1283 1288