hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/base/firmware_loader/firmware.h
....@@ -27,16 +27,23 @@
2727 * firmware file lookup on storage is avoided. Used for calls where the
2828 * file may be too big, or where the driver takes charge of its own
2929 * firmware caching mechanism.
30
- * @FW_OPT_NOFALLBACK: Disable the fallback mechanism. Takes precedence over
31
- * &FW_OPT_UEVENT and &FW_OPT_USERHELPER.
30
+ * @FW_OPT_NOFALLBACK_SYSFS: Disable the sysfs fallback mechanism. Takes
31
+ * precedence over &FW_OPT_UEVENT and &FW_OPT_USERHELPER.
32
+ * @FW_OPT_FALLBACK_PLATFORM: Enable fallback to device fw copy embedded in
33
+ * the platform's main firmware. If both this fallback and the sysfs
34
+ * fallback are enabled, then this fallback will be tried first.
35
+ * @FW_OPT_PARTIAL: Allow partial read of firmware instead of needing to read
36
+ * entire file.
3237 */
3338 enum 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),
39
+ FW_OPT_UEVENT = BIT(0),
40
+ FW_OPT_NOWAIT = BIT(1),
41
+ FW_OPT_USERHELPER = BIT(2),
42
+ FW_OPT_NO_WARN = BIT(3),
43
+ FW_OPT_NOCACHE = BIT(4),
44
+ FW_OPT_NOFALLBACK_SYSFS = BIT(5),
45
+ FW_OPT_FALLBACK_PLATFORM = BIT(6),
46
+ FW_OPT_PARTIAL = BIT(7),
4047 };
4148
4249 enum fw_status {
....@@ -64,12 +71,16 @@
6471 void *data;
6572 size_t size;
6673 size_t allocated_size;
67
-#ifdef CONFIG_FW_LOADER_USER_HELPER
74
+ size_t offset;
75
+ u32 opt_flags;
76
+#ifdef CONFIG_FW_LOADER_PAGED_BUF
6877 bool is_paged_buf;
69
- bool need_uevent;
7078 struct page **pages;
7179 int nr_pages;
7280 int page_array_size;
81
+#endif
82
+#ifdef CONFIG_FW_LOADER_USER_HELPER
83
+ bool need_uevent;
7384 struct list_head pending_list;
7485 #endif
7586 const char *fw_name;
....@@ -138,7 +149,18 @@
138149 __fw_state_set(fw_priv, FW_STATUS_DONE);
139150 }
140151
141
-int assign_fw(struct firmware *fw, struct device *device,
142
- enum fw_opt opt_flags);
152
+int assign_fw(struct firmware *fw, struct device *device);
153
+
154
+#ifdef CONFIG_FW_LOADER_PAGED_BUF
155
+void fw_free_paged_buf(struct fw_priv *fw_priv);
156
+int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed);
157
+int fw_map_paged_buf(struct fw_priv *fw_priv);
158
+bool fw_is_paged_buf(struct fw_priv *fw_priv);
159
+#else
160
+static inline void fw_free_paged_buf(struct fw_priv *fw_priv) {}
161
+static inline int fw_grow_paged_buf(struct fw_priv *fw_priv, int pages_needed) { return -ENXIO; }
162
+static inline int fw_map_paged_buf(struct fw_priv *fw_priv) { return -ENXIO; }
163
+static inline bool fw_is_paged_buf(struct fw_priv *fw_priv) { return false; }
164
+#endif
143165
144166 #endif /* __FIRMWARE_LOADER_H */