2018-03-10 14:14:49 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#ifndef __FIRMWARE_FALLBACK_H
|
|
|
|
#define __FIRMWARE_FALLBACK_H
|
|
|
|
|
|
|
|
#include <linux/firmware.h>
|
|
|
|
#include <linux/device.h>
|
|
|
|
|
2018-05-10 20:08:37 +00:00
|
|
|
#include "firmware.h"
|
|
|
|
|
2018-03-10 14:14:49 +00:00
|
|
|
/**
|
2018-04-25 16:25:39 +00:00
|
|
|
* struct firmware_fallback_config - firmware fallback configuration settings
|
2018-03-10 14:14:49 +00:00
|
|
|
*
|
|
|
|
* Helps describe and fine tune the fallback mechanism.
|
|
|
|
*
|
|
|
|
* @force_sysfs_fallback: force the sysfs fallback mechanism to be used
|
|
|
|
* as if one had enabled CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y.
|
2018-03-10 14:14:51 +00:00
|
|
|
* Useful to help debug a CONFIG_FW_LOADER_USER_HELPER_FALLBACK=y
|
|
|
|
* functionality on a kernel where that config entry has been disabled.
|
2018-03-10 14:14:52 +00:00
|
|
|
* @ignore_sysfs_fallback: force to disable the sysfs fallback mechanism.
|
|
|
|
* This emulates the behaviour as if we had set the kernel
|
|
|
|
* config CONFIG_FW_LOADER_USER_HELPER=n.
|
2018-03-10 14:14:49 +00:00
|
|
|
* @old_timeout: for internal use
|
|
|
|
* @loading_timeout: the timeout to wait for the fallback mechanism before
|
|
|
|
* giving up, in seconds.
|
|
|
|
*/
|
|
|
|
struct firmware_fallback_config {
|
2018-03-10 14:14:51 +00:00
|
|
|
unsigned int force_sysfs_fallback;
|
2018-03-10 14:14:52 +00:00
|
|
|
unsigned int ignore_sysfs_fallback;
|
2018-03-10 14:14:49 +00:00
|
|
|
int old_timeout;
|
|
|
|
int loading_timeout;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef CONFIG_FW_LOADER_USER_HELPER
|
2018-05-10 20:08:39 +00:00
|
|
|
int firmware_fallback_sysfs(struct firmware *fw, const char *name,
|
|
|
|
struct device *device,
|
2020-05-22 23:12:02 +00:00
|
|
|
u32 opt_flags,
|
2018-05-10 20:08:39 +00:00
|
|
|
int ret);
|
2018-03-10 14:14:49 +00:00
|
|
|
void kill_pending_fw_fallback_reqs(bool only_kill_custom);
|
|
|
|
|
|
|
|
void fw_fallback_set_cache_timeout(void);
|
|
|
|
void fw_fallback_set_default_timeout(void);
|
|
|
|
|
|
|
|
int register_sysfs_loader(void);
|
|
|
|
void unregister_sysfs_loader(void);
|
2022-01-22 06:12:13 +00:00
|
|
|
#ifdef CONFIG_SYSCTL
|
|
|
|
extern int register_firmware_config_sysctl(void);
|
|
|
|
extern void unregister_firmware_config_sysctl(void);
|
|
|
|
#else
|
|
|
|
static inline int register_firmware_config_sysctl(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline void unregister_firmware_config_sysctl(void) { }
|
|
|
|
#endif /* CONFIG_SYSCTL */
|
|
|
|
|
2018-03-10 14:14:49 +00:00
|
|
|
#else /* CONFIG_FW_LOADER_USER_HELPER */
|
2018-05-10 20:08:39 +00:00
|
|
|
static inline int firmware_fallback_sysfs(struct firmware *fw, const char *name,
|
|
|
|
struct device *device,
|
2020-05-22 23:12:02 +00:00
|
|
|
u32 opt_flags,
|
2018-05-10 20:08:39 +00:00
|
|
|
int ret)
|
2018-03-10 14:14:49 +00:00
|
|
|
{
|
|
|
|
/* Keep carrying over the same error */
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void kill_pending_fw_fallback_reqs(bool only_kill_custom) { }
|
|
|
|
static inline void fw_fallback_set_cache_timeout(void) { }
|
|
|
|
static inline void fw_fallback_set_default_timeout(void) { }
|
|
|
|
|
|
|
|
static inline int register_sysfs_loader(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void unregister_sysfs_loader(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FW_LOADER_USER_HELPER */
|
|
|
|
|
2020-01-15 16:35:48 +00:00
|
|
|
#ifdef CONFIG_EFI_EMBEDDED_FIRMWARE
|
2020-10-02 17:38:26 +00:00
|
|
|
int firmware_fallback_platform(struct fw_priv *fw_priv);
|
2020-01-15 16:35:48 +00:00
|
|
|
#else
|
2020-10-02 17:38:26 +00:00
|
|
|
static inline int firmware_fallback_platform(struct fw_priv *fw_priv)
|
2020-01-15 16:35:48 +00:00
|
|
|
{
|
|
|
|
return -ENOENT;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-10 14:14:49 +00:00
|
|
|
#endif /* __FIRMWARE_FALLBACK_H */
|