aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/base/firmware_loader/fallback.c12
-rw-r--r--drivers/base/firmware_loader/fallback.h6
-rw-r--r--drivers/base/firmware_loader/firmware.h37
-rw-r--r--drivers/base/firmware_loader/main.c6
4 files changed, 42 insertions, 19 deletions
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index 358354148dec..b57a7b3b4122 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -512,7 +512,7 @@ static const struct attribute_group *fw_dev_attr_groups[] = {
512 512
513static struct fw_sysfs * 513static struct fw_sysfs *
514fw_create_instance(struct firmware *firmware, const char *fw_name, 514fw_create_instance(struct firmware *firmware, const char *fw_name,
515 struct device *device, unsigned int opt_flags) 515 struct device *device, enum fw_opt opt_flags)
516{ 516{
517 struct fw_sysfs *fw_sysfs; 517 struct fw_sysfs *fw_sysfs;
518 struct device *f_dev; 518 struct device *f_dev;
@@ -545,7 +545,7 @@ exit:
545 * In charge of constructing a sysfs fallback interface for firmware loading. 545 * In charge of constructing a sysfs fallback interface for firmware loading.
546 **/ 546 **/
547static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs, 547static int fw_load_sysfs_fallback(struct fw_sysfs *fw_sysfs,
548 unsigned int opt_flags, long timeout) 548 enum fw_opt opt_flags, long timeout)
549{ 549{
550 int retval = 0; 550 int retval = 0;
551 struct device *f_dev = &fw_sysfs->dev; 551 struct device *f_dev = &fw_sysfs->dev;
@@ -599,7 +599,7 @@ err_put_dev:
599 599
600static int fw_load_from_user_helper(struct firmware *firmware, 600static int fw_load_from_user_helper(struct firmware *firmware,
601 const char *name, struct device *device, 601 const char *name, struct device *device,
602 unsigned int opt_flags) 602 enum fw_opt opt_flags)
603{ 603{
604 struct fw_sysfs *fw_sysfs; 604 struct fw_sysfs *fw_sysfs;
605 long timeout; 605 long timeout;
@@ -640,7 +640,7 @@ out_unlock:
640 return ret; 640 return ret;
641} 641}
642 642
643static bool fw_force_sysfs_fallback(unsigned int opt_flags) 643static bool fw_force_sysfs_fallback(enum fw_opt opt_flags)
644{ 644{
645 if (fw_fallback_config.force_sysfs_fallback) 645 if (fw_fallback_config.force_sysfs_fallback)
646 return true; 646 return true;
@@ -649,7 +649,7 @@ static bool fw_force_sysfs_fallback(unsigned int opt_flags)
649 return true; 649 return true;
650} 650}
651 651
652static bool fw_run_sysfs_fallback(unsigned int opt_flags) 652static bool fw_run_sysfs_fallback(enum fw_opt opt_flags)
653{ 653{
654 if (fw_fallback_config.ignore_sysfs_fallback) { 654 if (fw_fallback_config.ignore_sysfs_fallback) {
655 pr_info_once("Ignoring firmware sysfs fallback due to sysctl knob\n"); 655 pr_info_once("Ignoring firmware sysfs fallback due to sysctl knob\n");
@@ -664,7 +664,7 @@ static bool fw_run_sysfs_fallback(unsigned int opt_flags)
664 664
665int fw_sysfs_fallback(struct firmware *fw, const char *name, 665int fw_sysfs_fallback(struct firmware *fw, const char *name,
666 struct device *device, 666 struct device *device,
667 unsigned int opt_flags, 667 enum fw_opt opt_flags,
668 int ret) 668 int ret)
669{ 669{
670 if (!fw_run_sysfs_fallback(opt_flags)) 670 if (!fw_run_sysfs_fallback(opt_flags))
diff --git a/drivers/base/firmware_loader/fallback.h b/drivers/base/firmware_loader/fallback.h
index f8255670a663..a3b73a09db6c 100644
--- a/drivers/base/firmware_loader/fallback.h
+++ b/drivers/base/firmware_loader/fallback.h
@@ -5,6 +5,8 @@
5#include <linux/firmware.h> 5#include <linux/firmware.h>
6#include <linux/device.h> 6#include <linux/device.h>
7 7
8#include "firmware.h"
9
8/** 10/**
9 * struct firmware_fallback_config - firmware fallback configuration settings 11 * struct firmware_fallback_config - firmware fallback configuration settings
10 * 12 *
@@ -31,7 +33,7 @@ struct firmware_fallback_config {
31#ifdef CONFIG_FW_LOADER_USER_HELPER 33#ifdef CONFIG_FW_LOADER_USER_HELPER
32int fw_sysfs_fallback(struct firmware *fw, const char *name, 34int fw_sysfs_fallback(struct firmware *fw, const char *name,
33 struct device *device, 35 struct device *device,
34 unsigned int opt_flags, 36 enum fw_opt opt_flags,
35 int ret); 37 int ret);
36void kill_pending_fw_fallback_reqs(bool only_kill_custom); 38void kill_pending_fw_fallback_reqs(bool only_kill_custom);
37 39
@@ -43,7 +45,7 @@ void unregister_sysfs_loader(void);
43#else /* CONFIG_FW_LOADER_USER_HELPER */ 45#else /* CONFIG_FW_LOADER_USER_HELPER */
44static inline int fw_sysfs_fallback(struct firmware *fw, const char *name, 46static inline int fw_sysfs_fallback(struct firmware *fw, const char *name,
45 struct device *device, 47 struct device *device,
46 unsigned int opt_flags, 48 enum fw_opt opt_flags,
47 int ret) 49 int ret)
48{ 50{
49 /* Keep carrying over the same error */ 51 /* Keep carrying over the same error */
diff --git a/drivers/base/firmware_loader/firmware.h b/drivers/base/firmware_loader/firmware.h
index 64acbb1a392c..4f433b447367 100644
--- a/drivers/base/firmware_loader/firmware.h
+++ b/drivers/base/firmware_loader/firmware.h
@@ -2,6 +2,7 @@
2#ifndef __FIRMWARE_LOADER_H 2#ifndef __FIRMWARE_LOADER_H
3#define __FIRMWARE_LOADER_H 3#define __FIRMWARE_LOADER_H
4 4
5#include <linux/bitops.h>
5#include <linux/firmware.h> 6#include <linux/firmware.h>
6#include <linux/types.h> 7#include <linux/types.h>
7#include <linux/kref.h> 8#include <linux/kref.h>
@@ -10,13 +11,33 @@
10 11
11#include <generated/utsrelease.h> 12#include <generated/utsrelease.h>
12 13
13/* firmware behavior options */ 14/**
14#define FW_OPT_UEVENT (1U << 0) 15 * enum fw_opt - options to control firmware loading behaviour
15#define FW_OPT_NOWAIT (1U << 1) 16 *
16#define FW_OPT_USERHELPER (1U << 2) 17 * @FW_OPT_UEVENT: Enables the fallback mechanism to send a kobject uevent
17#define FW_OPT_NO_WARN (1U << 3) 18 * when the firmware is not found. Userspace is in charge to load the
18#define FW_OPT_NOCACHE (1U << 4) 19 * firmware using the sysfs loading facility.
19#define FW_OPT_NOFALLBACK (1U << 5) 20 * @FW_OPT_NOWAIT: Used to describe the firmware request is asynchronous.
21 * @FW_OPT_USERHELPER: Enable the fallback mechanism, in case the direct
22 * filesystem lookup fails at finding the firmware. For details refer to
23 * fw_sysfs_fallback().
24 * @FW_OPT_NO_WARN: Quiet, avoid printing warning messages.
25 * @FW_OPT_NOCACHE: Disables firmware caching. Firmware caching is used to
26 * cache the firmware upon suspend, so that upon resume races against the
27 * firmware file lookup on storage is avoided. Used for calls where the
28 * file may be too big, or where the driver takes charge of its own
29 * firmware caching mechanism.
30 * @FW_OPT_NOFALLBACK: Disable the fallback mechanism. Takes precedence over
31 * &FW_OPT_UEVENT and &FW_OPT_USERHELPER.
32 */
33enum fw_opt {
34 FW_OPT_UEVENT = BIT(0),
35 FW_OPT_NOWAIT = BIT(1),
36 FW_OPT_USERHELPER = BIT(2),
37 FW_OPT_NO_WARN = BIT(3),
38 FW_OPT_NOCACHE = BIT(4),
39 FW_OPT_NOFALLBACK = BIT(5),
40};
20 41
21enum fw_status { 42enum fw_status {
22 FW_STATUS_UNKNOWN, 43 FW_STATUS_UNKNOWN,
@@ -110,6 +131,6 @@ static inline void fw_state_done(struct fw_priv *fw_priv)
110} 131}
111 132
112int assign_fw(struct firmware *fw, struct device *device, 133int assign_fw(struct firmware *fw, struct device *device,
113 unsigned int opt_flags); 134 enum fw_opt opt_flags);
114 135
115#endif /* __FIRMWARE_LOADER_H */ 136#endif /* __FIRMWARE_LOADER_H */
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index eb34089e4299..9919f0e6a7cc 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -443,7 +443,7 @@ static int fw_add_devm_name(struct device *dev, const char *name)
443#endif 443#endif
444 444
445int assign_fw(struct firmware *fw, struct device *device, 445int assign_fw(struct firmware *fw, struct device *device,
446 unsigned int opt_flags) 446 enum fw_opt opt_flags)
447{ 447{
448 struct fw_priv *fw_priv = fw->priv; 448 struct fw_priv *fw_priv = fw->priv;
449 int ret; 449 int ret;
@@ -558,7 +558,7 @@ static void fw_abort_batch_reqs(struct firmware *fw)
558static int 558static int
559_request_firmware(const struct firmware **firmware_p, const char *name, 559_request_firmware(const struct firmware **firmware_p, const char *name,
560 struct device *device, void *buf, size_t size, 560 struct device *device, void *buf, size_t size,
561 unsigned int opt_flags) 561 enum fw_opt opt_flags)
562{ 562{
563 struct firmware *fw = NULL; 563 struct firmware *fw = NULL;
564 int ret; 564 int ret;
@@ -734,7 +734,7 @@ struct firmware_work {
734 struct device *device; 734 struct device *device;
735 void *context; 735 void *context;
736 void (*cont)(const struct firmware *fw, void *context); 736 void (*cont)(const struct firmware *fw, void *context);
737 unsigned int opt_flags; 737 enum fw_opt opt_flags;
738}; 738};
739 739
740static void request_firmware_work_func(struct work_struct *work) 740static void request_firmware_work_func(struct work_struct *work)