aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndres Rodriguez <andresx7@gmail.com>2018-05-10 16:08:45 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-05-14 10:44:41 -0400
commit7dcc01343e483efda0882456f8361f061a5f416d (patch)
tree5c118e816d686682a60890e9443cd5fb9c93faec
parent27d5d7dc9aafd6db3d7aeb49cdbfe578fc1b8663 (diff)
firmware: add firmware_request_nowarn() - load firmware without warnings
Currently the firmware loader only exposes one silent path for querying optional firmware, and that is firmware_request_direct(). This function also disables the sysfs fallback mechanism, which might not always be the desired behaviour [0]. This patch introduces a variations of request_firmware() that enable the caller to disable the undesired warning messages but enables the sysfs fallback mechanism. This is equivalent to adding FW_OPT_NO_WARN to the old behaviour. [0]: https://git.kernel.org/linus/c0cc00f250e1 Signed-off-by: Andres Rodriguez <andresx7@gmail.com> Reviewed-by: Kees Cook <keescook@chromium.org> Acked-by: Luis R. Rodriguez <mcgrof@kernel.org> [mcgrof: used the old API calls as the full rename is not done yet, and add the caller for when FW_LOADER is disabled, enhance documentation ] Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/driver-api/firmware/request_firmware.rst5
-rw-r--r--drivers/base/firmware_loader/main.c27
-rw-r--r--include/linux/firmware.h10
3 files changed, 42 insertions, 0 deletions
diff --git a/Documentation/driver-api/firmware/request_firmware.rst b/Documentation/driver-api/firmware/request_firmware.rst
index d5ec95a7195b..f62bdcbfed5b 100644
--- a/Documentation/driver-api/firmware/request_firmware.rst
+++ b/Documentation/driver-api/firmware/request_firmware.rst
@@ -20,6 +20,11 @@ request_firmware
20.. kernel-doc:: drivers/base/firmware_loader/main.c 20.. kernel-doc:: drivers/base/firmware_loader/main.c
21 :functions: request_firmware 21 :functions: request_firmware
22 22
23firmware_request_nowarn
24-----------------------
25.. kernel-doc:: drivers/base/firmware_loader/main.c
26 :functions: firmware_request_nowarn
27
23request_firmware_direct 28request_firmware_direct
24----------------------- 29-----------------------
25.. kernel-doc:: drivers/base/firmware_loader/main.c 30.. kernel-doc:: drivers/base/firmware_loader/main.c
diff --git a/drivers/base/firmware_loader/main.c b/drivers/base/firmware_loader/main.c
index abdc4e4d55f1..0943e7065e0e 100644
--- a/drivers/base/firmware_loader/main.c
+++ b/drivers/base/firmware_loader/main.c
@@ -632,6 +632,33 @@ request_firmware(const struct firmware **firmware_p, const char *name,
632EXPORT_SYMBOL(request_firmware); 632EXPORT_SYMBOL(request_firmware);
633 633
634/** 634/**
635 * firmware_request_nowarn() - request for an optional fw module
636 * @firmware: pointer to firmware image
637 * @name: name of firmware file
638 * @device: device for which firmware is being loaded
639 *
640 * This function is similar in behaviour to request_firmware(), except
641 * it doesn't produce warning messages when the file is not found.
642 * The sysfs fallback mechanism is enabled if direct filesystem lookup fails,
643 * however, however failures to find the firmware file with it are still
644 * suppressed. It is therefore up to the driver to check for the return value
645 * of this call and to decide when to inform the users of errors.
646 **/
647int firmware_request_nowarn(const struct firmware **firmware, const char *name,
648 struct device *device)
649{
650 int ret;
651
652 /* Need to pin this module until return */
653 __module_get(THIS_MODULE);
654 ret = _request_firmware(firmware, name, device, NULL, 0,
655 FW_OPT_UEVENT | FW_OPT_NO_WARN);
656 module_put(THIS_MODULE);
657 return ret;
658}
659EXPORT_SYMBOL_GPL(firmware_request_nowarn);
660
661/**
635 * request_firmware_direct() - load firmware directly without usermode helper 662 * request_firmware_direct() - load firmware directly without usermode helper
636 * @firmware_p: pointer to firmware image 663 * @firmware_p: pointer to firmware image
637 * @name: name of firmware file 664 * @name: name of firmware file
diff --git a/include/linux/firmware.h b/include/linux/firmware.h
index 41050417cafb..2dd566c91d44 100644
--- a/include/linux/firmware.h
+++ b/include/linux/firmware.h
@@ -42,6 +42,8 @@ struct builtin_fw {
42#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE)) 42#if defined(CONFIG_FW_LOADER) || (defined(CONFIG_FW_LOADER_MODULE) && defined(MODULE))
43int request_firmware(const struct firmware **fw, const char *name, 43int request_firmware(const struct firmware **fw, const char *name,
44 struct device *device); 44 struct device *device);
45int firmware_request_nowarn(const struct firmware **fw, const char *name,
46 struct device *device);
45int request_firmware_nowait( 47int request_firmware_nowait(
46 struct module *module, bool uevent, 48 struct module *module, bool uevent,
47 const char *name, struct device *device, gfp_t gfp, void *context, 49 const char *name, struct device *device, gfp_t gfp, void *context,
@@ -59,6 +61,14 @@ static inline int request_firmware(const struct firmware **fw,
59{ 61{
60 return -EINVAL; 62 return -EINVAL;
61} 63}
64
65static inline int firmware_request_nowarn(const struct firmware **fw,
66 const char *name,
67 struct device *device)
68{
69 return -EINVAL;
70}
71
62static inline int request_firmware_nowait( 72static inline int request_firmware_nowait(
63 struct module *module, bool uevent, 73 struct module *module, bool uevent,
64 const char *name, struct device *device, gfp_t gfp, void *context, 74 const char *name, struct device *device, gfp_t gfp, void *context,