main.c (ff36e78fdb251b9fa65028554689806961e011eb) main.c (e4c2c0ff00ecaf8e245455a199b86ce22143becf)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * main.c - Multi purpose firmware loading support
4 *
5 * Copyright (c) 2003 Manuel Estrada Sainz
6 *
7 * Please see Documentation/driver-api/firmware/ for more information.
8 *

--- 479 unchanged lines hidden (view full) ---

488 len = snprintf(path, PATH_MAX, "%s/%s%s",
489 fw_path[i], fw_priv->fw_name, suffix);
490 if (len >= PATH_MAX) {
491 rc = -ENAMETOOLONG;
492 break;
493 }
494
495 fw_priv->size = 0;
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * main.c - Multi purpose firmware loading support
4 *
5 * Copyright (c) 2003 Manuel Estrada Sainz
6 *
7 * Please see Documentation/driver-api/firmware/ for more information.
8 *

--- 479 unchanged lines hidden (view full) ---

488 len = snprintf(path, PATH_MAX, "%s/%s%s",
489 fw_path[i], fw_priv->fw_name, suffix);
490 if (len >= PATH_MAX) {
491 rc = -ENAMETOOLONG;
492 break;
493 }
494
495 fw_priv->size = 0;
496 rc = kernel_read_file_from_path(path, &buffer, &size,
497 msize, id);
496
497 /* load firmware files from the mount namespace of init */
498 rc = kernel_read_file_from_path_initns(path, &buffer,
499 &size, msize, id);
498 if (rc) {
499 if (rc != -ENOENT)
500 dev_warn(device, "loading %s failed with error %d\n",
501 path, rc);
502 else
503 dev_dbg(device, "loading %s failed for no such file or directory.\n",
504 path);
505 continue;

--- 265 unchanged lines hidden (view full) ---

771
772 ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL);
773#ifdef CONFIG_FW_LOADER_COMPRESS
774 if (ret == -ENOENT)
775 ret = fw_get_filesystem_firmware(device, fw->priv, ".xz",
776 fw_decompress_xz);
777#endif
778
500 if (rc) {
501 if (rc != -ENOENT)
502 dev_warn(device, "loading %s failed with error %d\n",
503 path, rc);
504 else
505 dev_dbg(device, "loading %s failed for no such file or directory.\n",
506 path);
507 continue;

--- 265 unchanged lines hidden (view full) ---

773
774 ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL);
775#ifdef CONFIG_FW_LOADER_COMPRESS
776 if (ret == -ENOENT)
777 ret = fw_get_filesystem_firmware(device, fw->priv, ".xz",
778 fw_decompress_xz);
779#endif
780
781 if (ret == -ENOENT)
782 ret = firmware_fallback_platform(fw->priv, opt_flags);
783
779 if (ret) {
780 if (!(opt_flags & FW_OPT_NO_WARN))
781 dev_warn(device,
782 "Direct firmware load for %s failed with error %d\n",
783 name, ret);
784 ret = firmware_fallback_sysfs(fw, name, device, opt_flags, ret);
785 } else
786 ret = assign_fw(fw, device, opt_flags);

--- 92 unchanged lines hidden (view full) ---

879 FW_OPT_UEVENT | FW_OPT_NO_WARN |
880 FW_OPT_NOFALLBACK_SYSFS);
881 module_put(THIS_MODULE);
882 return ret;
883}
884EXPORT_SYMBOL_GPL(request_firmware_direct);
885
886/**
784 if (ret) {
785 if (!(opt_flags & FW_OPT_NO_WARN))
786 dev_warn(device,
787 "Direct firmware load for %s failed with error %d\n",
788 name, ret);
789 ret = firmware_fallback_sysfs(fw, name, device, opt_flags, ret);
790 } else
791 ret = assign_fw(fw, device, opt_flags);

--- 92 unchanged lines hidden (view full) ---

884 FW_OPT_UEVENT | FW_OPT_NO_WARN |
885 FW_OPT_NOFALLBACK_SYSFS);
886 module_put(THIS_MODULE);
887 return ret;
888}
889EXPORT_SYMBOL_GPL(request_firmware_direct);
890
891/**
892 * firmware_request_platform() - request firmware with platform-fw fallback
893 * @firmware: pointer to firmware image
894 * @name: name of firmware file
895 * @device: device for which firmware is being loaded
896 *
897 * This function is similar in behaviour to request_firmware, except that if
898 * direct filesystem lookup fails, it will fallback to looking for a copy of the
899 * requested firmware embedded in the platform's main (e.g. UEFI) firmware.
900 **/
901int firmware_request_platform(const struct firmware **firmware,
902 const char *name, struct device *device)
903{
904 int ret;
905
906 /* Need to pin this module until return */
907 __module_get(THIS_MODULE);
908 ret = _request_firmware(firmware, name, device, NULL, 0,
909 FW_OPT_UEVENT | FW_OPT_FALLBACK_PLATFORM);
910 module_put(THIS_MODULE);
911 return ret;
912}
913EXPORT_SYMBOL_GPL(firmware_request_platform);
914
915/**
887 * firmware_request_cache() - cache firmware for suspend so resume can use it
888 * @name: name of firmware file
889 * @device: device for which firmware should be cached for
890 *
891 * There are some devices with an optimization that enables the device to not
892 * require loading firmware on system reboot. This optimization may still
893 * require the firmware present on resume from suspend. This routine can be
894 * used to ensure the firmware is present on resume from suspend in these

--- 576 unchanged lines hidden ---
916 * firmware_request_cache() - cache firmware for suspend so resume can use it
917 * @name: name of firmware file
918 * @device: device for which firmware should be cached for
919 *
920 * There are some devices with an optimization that enables the device to not
921 * require loading firmware on system reboot. This optimization may still
922 * require the firmware present on resume from suspend. This routine can be
923 * used to ensure the firmware is present on resume from suspend in these

--- 576 unchanged lines hidden ---