@@ -117,6 +117,12 @@ struct fw_name_devm {
const char *name;
};
+struct firmware_config {
+ bool force_sysfs_fallback;
+};
+
+static struct firmware_config fw_config;
+
static inline struct fw_priv *to_fw_priv(struct kref *ref)
{
return container_of(ref, struct fw_priv, ref);
@@ -1151,18 +1157,25 @@ static int fw_load_from_user_helper(struct firmware *firmware,
}
#ifdef CONFIG_FW_LOADER_USER_HELPER_FALLBACK
-static bool fw_force_sysfs_fallback(unsigned int opt_flags)
+static void __init fw_config_init(void)
{
- return true;
+ fw_config.force_sysfs_fallback = true;
}
+
#else
+static void __init fw_config_init(void)
+{
+}
+#endif
+
static bool fw_force_sysfs_fallback(unsigned int opt_flags)
{
+ if (fw_config.force_sysfs_fallback)
+ return true;
if (!(opt_flags & FW_OPT_USERHELPER))
return false;
return true;
}
-#endif
static bool fw_run_sysfs_fallback(unsigned int opt_flags)
{
@@ -1911,6 +1924,7 @@ static int __init firmware_class_init(void)
int ret;
/* No need to unfold these on exit */
+ fw_config_init();
fw_cache_init();
ret = register_fw_pm_ops();
After which we can add two generic syfs firmware knobs to help do the same as I did
for debugfs, only we actually support it as proper API. Thoughts?
For instance for changing to force the usermode helper:
@@ -41,6 +41,9 @@ MODULE_AUTHOR("Manuel Estrada Sainz");
MODULE_DESCRIPTION("Multi purpose firmware loading support");
MODULE_LICENSE("GPL");
+static unsigned int zero;
+static unsigned int one = 1;
+
enum fw_status {
FW_STATUS_UNKNOWN,
FW_STATUS_LOADING,
@@ -1919,6 +1922,19 @@ static struct notifier_block fw_shutdown_nb = {
.notifier_call = fw_shutdown_notify,
};
+struct ctl_table firmware_config_table[] = {
+ {
+ .procname = "force_sysfs_fallback",
+ .data = &fw_config.force_sysfs_fallback,
+ .maxlen = sizeof(unsigned int),
+ .mode = 0644,
+ .proc_handler = proc_douintvec_minmax,
+ .extra1 = &zero,
+ .extra2 = &one,
+ },
+ { }
+};
+
static int __init firmware_class_init(void)
{
int ret;
@@ -251,6 +251,10 @@ extern struct ctl_table random_table[];
extern struct ctl_table epoll_table[];
#endif
+#ifdef CONFIG_FW_LOADER
+extern struct ctl_table firmware_config_table[];
+#endif
+
#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
int sysctl_legacy_va_layout;
#endif
@@ -746,6 +750,13 @@ static struct ctl_table kern_table[] = {
.mode = 0555,
.child = usermodehelper_table,
},
+#ifdef CONFIG_FW_LOADER
+ {
+ .procname = "firmware_config",
+ .mode = 0555,
+ .child = firmware_config_table,
+ },
+#endif
{
.procname = "overflowuid",
.data = &overflowuid,