| 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | #include <linux/types.h> |
| 4 | #include <linux/kconfig.h> |
| 5 | #include <linux/list.h> |
| 6 | #include <linux/slab.h> |
| 7 | #include <linux/export.h> |
| 8 | #include <linux/security.h> |
| 9 | #include <linux/highmem.h> |
| 10 | #include <linux/umh.h> |
| 11 | #include <linux/sysctl.h> |
| 12 | |
| 13 | #include "fallback.h" |
| 14 | #include "firmware.h" |
| 15 | |
| 16 | /* |
| 17 | * firmware fallback configuration table |
| 18 | */ |
| 19 | |
| 20 | struct firmware_fallback_config fw_fallback_config = { |
| 21 | .force_sysfs_fallback = IS_ENABLED(CONFIG_FW_LOADER_USER_HELPER_FALLBACK), |
| 22 | .loading_timeout = 60, |
| 23 | .old_timeout = 60, |
| 24 | }; |
| 25 | EXPORT_SYMBOL_NS_GPL(fw_fallback_config, "FIRMWARE_LOADER_PRIVATE" ); |
| 26 | |
| 27 | #ifdef CONFIG_SYSCTL |
| 28 | static const struct ctl_table firmware_config_table[] = { |
| 29 | { |
| 30 | .procname = "force_sysfs_fallback" , |
| 31 | .data = &fw_fallback_config.force_sysfs_fallback, |
| 32 | .maxlen = sizeof(unsigned int), |
| 33 | .mode = 0644, |
| 34 | .proc_handler = proc_douintvec_minmax, |
| 35 | .extra1 = SYSCTL_ZERO, |
| 36 | .extra2 = SYSCTL_ONE, |
| 37 | }, |
| 38 | { |
| 39 | .procname = "ignore_sysfs_fallback" , |
| 40 | .data = &fw_fallback_config.ignore_sysfs_fallback, |
| 41 | .maxlen = sizeof(unsigned int), |
| 42 | .mode = 0644, |
| 43 | .proc_handler = proc_douintvec_minmax, |
| 44 | .extra1 = SYSCTL_ZERO, |
| 45 | .extra2 = SYSCTL_ONE, |
| 46 | }, |
| 47 | }; |
| 48 | |
| 49 | static struct ctl_table_header *; |
| 50 | int register_firmware_config_sysctl(void) |
| 51 | { |
| 52 | firmware_config_sysct_table_header = |
| 53 | register_sysctl("kernel/firmware_config" , |
| 54 | firmware_config_table); |
| 55 | if (!firmware_config_sysct_table_header) |
| 56 | return -ENOMEM; |
| 57 | return 0; |
| 58 | } |
| 59 | EXPORT_SYMBOL_NS_GPL(register_firmware_config_sysctl, "FIRMWARE_LOADER_PRIVATE" ); |
| 60 | |
| 61 | void unregister_firmware_config_sysctl(void) |
| 62 | { |
| 63 | unregister_sysctl_table(table: firmware_config_sysct_table_header); |
| 64 | firmware_config_sysct_table_header = NULL; |
| 65 | } |
| 66 | EXPORT_SYMBOL_NS_GPL(unregister_firmware_config_sysctl, "FIRMWARE_LOADER_PRIVATE" ); |
| 67 | |
| 68 | #endif /* CONFIG_SYSCTL */ |
| 69 | |