Squashed backup commit (no shallow-clone history issues) of xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream commit 9eece662e) plus all fixes applied to get everpal_defconfig building clean against a modern (GCC 15.2.0) toolchain -- see the previous commit message on the lineage-23.2 branch (also in this repo history is not available here since this is a squashed snapshot; full incremental history lives in the local DL380 checkout and the upstream GitHub remote). Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
135 lines
3.1 KiB
C
135 lines
3.1 KiB
C
/*
|
|
* Copyright (C) 2016 MediaTek Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
* See http://www.gnu.org/licenses/gpl-2.0.html for more details.
|
|
*/
|
|
#include <linux/kobject.h>
|
|
#include "ccci_fsm_internal.h"
|
|
#include "ccci_fsm_sys.h"
|
|
|
|
#define CCCI_KOBJ_NAME "md"
|
|
|
|
struct mdee_info_collect mdee_collect;
|
|
|
|
void fsm_sys_mdee_info_notify(const char *buf)
|
|
{
|
|
int ret = 0;
|
|
|
|
spin_lock(&mdee_collect.mdee_info_lock);
|
|
memset(mdee_collect.mdee_info, 0x0, AED_STR_LEN);
|
|
ret = snprintf(mdee_collect.mdee_info, AED_STR_LEN, "%s", buf);
|
|
if (ret < 0 || ret >= AED_STR_LEN)
|
|
CCCI_ERROR_LOG(-1, FSM,
|
|
"%s-%d:snprintf fail,ret = %d\n", __func__, __LINE__, ret);
|
|
spin_unlock(&mdee_collect.mdee_info_lock);
|
|
}
|
|
|
|
static struct kobject fsm_kobj;
|
|
|
|
struct ccci_attribute {
|
|
struct attribute attr;
|
|
ssize_t (*show)(char *buf);
|
|
ssize_t (*store)(const char *buf, size_t count);
|
|
};
|
|
|
|
#define CCCI_ATTR(_name, _mode, _show, _store) \
|
|
static struct ccci_attribute ccci_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
.show = _show, \
|
|
.store = _store, \
|
|
}
|
|
|
|
static void fsm_obj_release(struct kobject *kobj)
|
|
{
|
|
CCCI_NORMAL_LOG(-1, FSM, "release fsm kobject\n");
|
|
}
|
|
|
|
static ssize_t ccci_attr_show(struct kobject *kobj,
|
|
struct attribute *attr, char *buf)
|
|
{
|
|
ssize_t len = 0;
|
|
|
|
struct ccci_attribute *a
|
|
= container_of(attr, struct ccci_attribute, attr);
|
|
|
|
if (a->show)
|
|
len = a->show(buf);
|
|
|
|
return len;
|
|
}
|
|
|
|
static ssize_t ccci_attr_store(struct kobject *kobj,
|
|
struct attribute *attr, const char *buf, size_t count)
|
|
{
|
|
ssize_t len = 0;
|
|
|
|
struct ccci_attribute *a
|
|
= container_of(attr, struct ccci_attribute, attr);
|
|
|
|
if (a->store)
|
|
len = a->store(buf, count);
|
|
|
|
return len;
|
|
}
|
|
|
|
static const struct sysfs_ops fsm_sysfs_ops = {
|
|
.show = ccci_attr_show,
|
|
.store = ccci_attr_store,
|
|
};
|
|
|
|
static ssize_t ccci_mdee_info_show(char *buf)
|
|
{
|
|
int curr = 0;
|
|
|
|
spin_lock(&mdee_collect.mdee_info_lock);
|
|
curr = snprintf(buf, AED_STR_LEN, "%s\n", mdee_collect.mdee_info);
|
|
if (curr < 0 || curr >= AED_STR_LEN) {
|
|
CCCI_ERROR_LOG(-1, FSM,
|
|
"%s-%d:snprintf fail,curr = %d\n", __func__, __LINE__, curr);
|
|
spin_unlock(&mdee_collect.mdee_info_lock);
|
|
return -1;
|
|
}
|
|
spin_unlock(&mdee_collect.mdee_info_lock);
|
|
|
|
return curr;
|
|
}
|
|
|
|
CCCI_ATTR(mdee, 0444, &ccci_mdee_info_show, NULL);
|
|
|
|
/* Sys -- Add to group */
|
|
static struct attribute *ccci_default_attrs[] = {
|
|
&ccci_attr_mdee.attr,
|
|
NULL
|
|
};
|
|
|
|
static struct kobj_type fsm_ktype = {
|
|
.release = fsm_obj_release,
|
|
.sysfs_ops = &fsm_sysfs_ops,
|
|
.default_attrs = ccci_default_attrs
|
|
};
|
|
|
|
int fsm_sys_init(void)
|
|
{
|
|
int ret = 0;
|
|
|
|
spin_lock_init(&mdee_collect.mdee_info_lock);
|
|
|
|
ret = kobject_init_and_add(&fsm_kobj, &fsm_ktype,
|
|
kernel_kobj, CCCI_KOBJ_NAME);
|
|
if (ret < 0) {
|
|
kobject_put(&fsm_kobj);
|
|
CCCI_ERROR_LOG(-1, FSM, "fail to add fsm kobject\n");
|
|
return ret;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|