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) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /* inode.c: /proc/openprom handling routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 1996-1999 Jakub Jelinek  (jakub@redhat.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1998      Eddie C. Dost  (ecd@skynet.be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/fs_context.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/magic.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <asm/openprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <asm/oplib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <asm/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) static DEFINE_MUTEX(op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define OPENPROM_ROOT_INO	0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) enum op_inode_type {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	op_inode_node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	op_inode_prop,
^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) union op_inode_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	struct device_node	*node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	struct property		*prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) struct op_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct inode		vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	enum op_inode_type	type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	union op_inode_data	u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static struct inode *openprom_iget(struct super_block *sb, ino_t ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static inline struct op_inode_info *OP_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	return container_of(inode, struct op_inode_info, vfs_inode);
^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) static int is_string(unsigned char *p, int len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	for (i = 0; i < len; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		unsigned char val = p[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		if ((i && !val) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		    (val >= ' ' && val <= '~'))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static int property_show(struct seq_file *f, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct property *prop = f->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	void *pval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	len = prop->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	pval = prop->value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	if (is_string(pval, len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		while (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 			int n = strlen(pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 			seq_printf(f, "%s", (char *) pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 			/* Skip over the NULL byte too.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 			pval += n + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			len -= n + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 			if (len > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				seq_printf(f, " + ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		if (len & 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			while (len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 				len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 				if (len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 					seq_printf(f, "%02x.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 						   *(unsigned char *) pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 					seq_printf(f, "%02x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 						   *(unsigned char *) pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 				pval++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			while (len >= 4) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 				len -= 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 				if (len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 					seq_printf(f, "%08x.",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 						   *(unsigned int *) pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 				else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 					seq_printf(f, "%08x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 						   *(unsigned int *) pval);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 				pval += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	seq_printf(f, "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) static void *property_start(struct seq_file *f, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	if (*pos == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) static void *property_next(struct seq_file *f, void *v, loff_t *pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	(*pos)++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void property_stop(struct seq_file *f, void *v)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	/* Nothing to do */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) static const struct seq_operations property_op = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	.start		= property_start,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	.next		= property_next,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	.stop		= property_stop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	.show		= property_show
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) static int property_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	struct op_inode_info *oi = OP_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	BUG_ON(oi->type != op_inode_prop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	ret = seq_open(file, &property_op);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 		struct seq_file *m = file->private_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		m->private = oi->u.prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) static const struct file_operations openpromfs_prop_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.open		= property_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.read		= seq_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.llseek		= seq_lseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	.release	= seq_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static int openpromfs_readdir(struct file *, struct dir_context *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static const struct file_operations openprom_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.read		= generic_read_dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	.iterate_shared	= openpromfs_readdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	.llseek		= generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) static struct dentry *openpromfs_lookup(struct inode *, struct dentry *, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static const struct inode_operations openprom_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.lookup		= openpromfs_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static struct dentry *openpromfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	struct op_inode_info *ent_oi, *oi = OP_I(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct device_node *dp, *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	enum op_inode_type ent_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	union op_inode_data ent_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	unsigned int ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	BUG_ON(oi->type != op_inode_node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	dp = oi->u.node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	name = dentry->d_name.name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	len = dentry->d_name.len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	mutex_lock(&op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	child = dp->child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	while (child) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 		const char *node_name = kbasename(child->full_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		int n = strlen(node_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		if (len == n &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		    !strncmp(node_name, name, len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 			ent_type = op_inode_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 			ent_data.node = child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 			ino = child->unique_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 			goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 		child = child->sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	prop = dp->properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	while (prop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		int n = strlen(prop->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 		if (len == n && !strncmp(prop->name, name, len)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 			ent_type = op_inode_prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 			ent_data.prop = prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			ino = prop->unique_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 			goto found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		prop = prop->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	mutex_unlock(&op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	return ERR_PTR(-ENOENT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	inode = openprom_iget(dir->i_sb, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	mutex_unlock(&op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	if (IS_ERR(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		return ERR_CAST(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	ent_oi = OP_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	ent_oi->type = ent_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	ent_oi->u = ent_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	switch (ent_type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	case op_inode_node:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		inode->i_op = &openprom_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		inode->i_fop = &openprom_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		set_nlink(inode, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	case op_inode_prop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		if (of_node_name_eq(dp, "options") && (len == 17) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		    !strncmp (name, "security-password", 17))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			inode->i_mode = S_IFREG | S_IRUSR | S_IWUSR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			inode->i_mode = S_IFREG | S_IRUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		inode->i_fop = &openpromfs_prop_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 		set_nlink(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		inode->i_size = ent_oi->u.prop->length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	return d_splice_alias(inode, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static int openpromfs_readdir(struct file *file, struct dir_context *ctx)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	struct inode *inode = file_inode(file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	struct op_inode_info *oi = OP_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	struct device_node *dp = oi->u.node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	struct device_node *child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	struct property *prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	mutex_lock(&op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	if (ctx->pos == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 		if (!dir_emit(ctx, ".", 1, inode->i_ino, DT_DIR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		ctx->pos = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if (ctx->pos == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		if (!dir_emit(ctx, "..", 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 			    (dp->parent == NULL ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 			     OPENPROM_ROOT_INO :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 			     dp->parent->unique_id), DT_DIR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		ctx->pos = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	i = ctx->pos - 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	/* First, the children nodes as directories.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	child = dp->child;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	while (i && child) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		child = child->sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		i--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	while (child) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 		if (!dir_emit(ctx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			    kbasename(child->full_name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			    strlen(kbasename(child->full_name)),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 			    child->unique_id, DT_DIR))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 		ctx->pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 		child = child->sibling;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	/* Next, the properties as files.  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	prop = dp->properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	while (i && prop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 		prop = prop->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 		i--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	while (prop) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		if (!dir_emit(ctx, prop->name, strlen(prop->name),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			    prop->unique_id, DT_REG))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 			goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 		ctx->pos++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		prop = prop->next;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	mutex_unlock(&op_mutex);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) static struct kmem_cache *op_inode_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static struct inode *openprom_alloc_inode(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	struct op_inode_info *oi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	oi = kmem_cache_alloc(op_inode_cachep, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	if (!oi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	return &oi->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) static void openprom_free_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	kmem_cache_free(op_inode_cachep, OP_I(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) static struct inode *openprom_iget(struct super_block *sb, ino_t ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 	inode = iget_locked(sb, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	if (inode->i_state & I_NEW) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		if (inode->i_ino == OPENPROM_ROOT_INO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			inode->i_op = &openprom_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 			inode->i_fop = &openprom_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 		unlock_new_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) static int openprom_remount(struct super_block *sb, int *flags, char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	sync_filesystem(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	*flags |= SB_NOATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) static const struct super_operations openprom_sops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	.alloc_inode	= openprom_alloc_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	.free_inode	= openprom_free_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	.statfs		= simple_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	.remount_fs	= openprom_remount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) static int openprom_fill_super(struct super_block *s, struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	struct inode *root_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	struct op_inode_info *oi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	s->s_flags |= SB_NOATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	s->s_blocksize = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	s->s_blocksize_bits = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	s->s_magic = OPENPROM_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	s->s_op = &openprom_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	s->s_time_gran = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	root_inode = openprom_iget(s, OPENPROM_ROOT_INO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (IS_ERR(root_inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		ret = PTR_ERR(root_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	oi = OP_I(root_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	oi->type = op_inode_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	oi->u.node = of_find_node_by_path("/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	s->s_root = d_make_root(root_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	if (!s->s_root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		goto out_no_root_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) out_no_root_dentry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) out_no_root:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	printk("openprom_fill_super: get root inode failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) static int openpromfs_get_tree(struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	return get_tree_single(fc, openprom_fill_super);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) static const struct fs_context_operations openpromfs_context_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	.get_tree	= openpromfs_get_tree,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static int openpromfs_init_fs_context(struct fs_context *fc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	fc->ops = &openpromfs_context_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static struct file_system_type openprom_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	.name		= "openpromfs",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	.init_fs_context = openpromfs_init_fs_context,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	.kill_sb	= kill_anon_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) MODULE_ALIAS_FS("openpromfs");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) static void op_inode_init_once(void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 	struct op_inode_info *oi = (struct op_inode_info *) data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 	inode_init_once(&oi->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static int __init init_openprom_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 	op_inode_cachep = kmem_cache_create("op_inode_cache",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 					    sizeof(struct op_inode_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 					    0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 					    (SLAB_RECLAIM_ACCOUNT |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 					     SLAB_MEM_SPREAD | SLAB_ACCOUNT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 					    op_inode_init_once);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	if (!op_inode_cachep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	err = register_filesystem(&openprom_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		kmem_cache_destroy(op_inode_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) static void __exit exit_openprom_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	unregister_filesystem(&openprom_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	 * Make sure all delayed rcu free inodes are flushed before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	 * destroy cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	rcu_barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 	kmem_cache_destroy(op_inode_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) module_init(init_openprom_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) module_exit(exit_openprom_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) MODULE_LICENSE("GPL");