forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/firmware/efi/capsule-loader.c
....@@ -1,10 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * EFI capsule loader driver.
34 *
45 * Copyright 2015 Intel Corporation
5
- *
6
- * This file is part of the Linux kernel, and is made available under
7
- * the terms of the GNU General Public License version 2.
86 */
97
108 #define pr_fmt(fmt) "efi: " fmt
....@@ -13,6 +11,7 @@
1311 #include <linux/module.h>
1412 #include <linux/miscdevice.h>
1513 #include <linux/highmem.h>
14
+#include <linux/io.h>
1615 #include <linux/slab.h>
1716 #include <linux/mutex.h>
1817 #include <linux/efi.h>
....@@ -169,7 +168,7 @@
169168 static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
170169 size_t count, loff_t *offp)
171170 {
172
- int ret = 0;
171
+ int ret;
173172 struct capsule_info *cap_info = file->private_data;
174173 struct page *page;
175174 void *kbuff = NULL;
....@@ -244,29 +243,6 @@
244243 }
245244
246245 /**
247
- * efi_capsule_flush - called by file close or file flush
248
- * @file: file pointer
249
- * @id: not used
250
- *
251
- * If a capsule is being partially uploaded then calling this function
252
- * will be treated as upload termination and will free those completed
253
- * buffer pages and -ECANCELED will be returned.
254
- **/
255
-static int efi_capsule_flush(struct file *file, fl_owner_t id)
256
-{
257
- int ret = 0;
258
- struct capsule_info *cap_info = file->private_data;
259
-
260
- if (cap_info->index > 0) {
261
- pr_err("capsule upload not complete\n");
262
- efi_free_all_buff_pages(cap_info);
263
- ret = -ECANCELED;
264
- }
265
-
266
- return ret;
267
-}
268
-
269
-/**
270246 * efi_capsule_release - called by file close
271247 * @inode: not used
272248 * @file: file pointer
....@@ -277,6 +253,13 @@
277253 static int efi_capsule_release(struct inode *inode, struct file *file)
278254 {
279255 struct capsule_info *cap_info = file->private_data;
256
+
257
+ if (cap_info->index > 0 &&
258
+ (cap_info->header.headersize == 0 ||
259
+ cap_info->count < cap_info->total_size)) {
260
+ pr_err("capsule upload not complete\n");
261
+ efi_free_all_buff_pages(cap_info);
262
+ }
280263
281264 kfree(cap_info->pages);
282265 kfree(cap_info->phys);
....@@ -325,7 +308,6 @@
325308 .owner = THIS_MODULE,
326309 .open = efi_capsule_open,
327310 .write = efi_capsule_write,
328
- .flush = efi_capsule_flush,
329311 .release = efi_capsule_release,
330312 .llseek = no_llseek,
331313 };