Files
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
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)
2026-09-12 13:36:46 +00:00

109 lines
2.0 KiB
C

// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2019 MediaTek Inc.
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/spinlock.h>
#include <mtk_lpm_call.h>
static DEFINE_SPINLOCK(mtk_lp_plat_call_locker);
static LIST_HEAD(mtk_lpm_callees);
int mtk_lpm_callee_registry(struct mtk_lpm_callee *callee)
{
struct mtk_lpm_callee *pos;
if (!callee)
return -EINVAL;
spin_lock(&mtk_lp_plat_call_locker);
list_for_each_entry(pos, &mtk_lpm_callees, list) {
if (pos && (pos != callee) &&
(pos->uid == callee->uid)) {
pos = NULL;
break;
}
}
if (pos) {
callee->ref = 0;
list_add(&callee->list, &mtk_lpm_callees);
}
spin_unlock(&mtk_lp_plat_call_locker);
return 0;
}
EXPORT_SYMBOL(mtk_lpm_callee_registry);
int mtk_lpm_callee_unregistry(struct mtk_lpm_callee *callee)
{
int bRet = 0;
struct mtk_lpm_callee *pos;
if (!callee)
return -EINVAL;
spin_lock(&mtk_lp_plat_call_locker);
list_for_each_entry(pos, &mtk_lpm_callees, list) {
if (pos && (pos->uid == callee->uid)) {
if (!pos->ref)
list_del(&pos->list);
else
bRet = -EPERM;
break;
}
}
spin_unlock(&mtk_lp_plat_call_locker);
return bRet;
}
EXPORT_SYMBOL(mtk_lpm_callee_unregistry);
int mtk_lpm_callee_get_impl(int uid, const struct mtk_lpm_callee **callee)
{
struct mtk_lpm_callee *pos;
if (!callee)
return -EINVAL;
*callee = NULL;
spin_lock(&mtk_lp_plat_call_locker);
list_for_each_entry(pos, &mtk_lpm_callees, list) {
if (pos && pos->uid == uid) {
pos->ref++;
*callee = pos;
break;
}
}
spin_unlock(&mtk_lp_plat_call_locker);
return *callee ? 0 : -EINVAL;
}
EXPORT_SYMBOL(mtk_lpm_callee_get_impl);
int mtk_lpm_callee_put_impl(struct mtk_lpm_callee const *callee)
{
struct mtk_lpm_callee *pos;
int ret = -EPERM;
if (!callee)
return -EINVAL;
spin_lock(&mtk_lp_plat_call_locker);
list_for_each_entry(pos, &mtk_lpm_callees, list) {
if (pos && (pos->uid == callee->uid)) {
pos->ref--;
ret = 0;
break;
}
}
spin_unlock(&mtk_lp_plat_call_locker);
return ret;
}
EXPORT_SYMBOL(mtk_lpm_callee_put_impl);