Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2)  * JFFS2 -- Journalling Flash File System, Version 2.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Copyright © 2001-2007 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Created by David Woodhouse <dwmw2@infradead.org>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  * For licensing information, see the file 'LICENCE' in this directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/mtd/mtd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "nodelist.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) int jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct kvec *vecs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 			      unsigned long count, loff_t to, size_t *retlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	if (!jffs2_is_writebuffered(c)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		if (jffs2_sum_active()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 			int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 			res = jffs2_sum_add_kvec(c, vecs, count, (uint32_t) to);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 			if (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 				return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	return mtd_writev(c->mtd, vecs, count, to, retlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) int jffs2_flash_direct_write(struct jffs2_sb_info *c, loff_t ofs, size_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 			size_t *retlen, const u_char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	ret = mtd_write(c->mtd, ofs, len, retlen, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	if (jffs2_sum_active()) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		struct kvec vecs[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		int res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		vecs[0].iov_base = (unsigned char *) buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		vecs[0].iov_len = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 		res = jffs2_sum_add_kvec(c, vecs, 1, (uint32_t) ofs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		if (res) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 			return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) }