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) /* -*- mode: c; c-basic-offset: 8; -*-
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * vim: noexpandtab sw=8 ts=8 sts=0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * sys.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * OCFS2 cluster sysfs interface
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * Copyright (C) 2005 Oracle.  All rights reserved.
^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/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/kobject.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "ocfs2_nodemanager.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "masklog.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "sys.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 			    char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) static struct kobj_attribute attr_version =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	__ATTR(interface_revision, S_IRUGO, version_show, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static struct attribute *o2cb_attrs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	&attr_version.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static struct attribute_group o2cb_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	.attrs = o2cb_attrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static struct kset *o2cb_kset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) void o2cb_sys_shutdown(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	mlog_sys_shutdown();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	kset_unregister(o2cb_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) int o2cb_sys_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	o2cb_kset = kset_create_and_add("o2cb", NULL, fs_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	if (!o2cb_kset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	ret = sysfs_create_group(&o2cb_kset->kobj, &o2cb_attr_group);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	ret = mlog_sys_init(o2cb_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 		goto error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) error:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	kset_unregister(o2cb_kset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }