android_kernel_samsung_a7y1.../drivers/security/samsung/icdrv/oemflag.c
prashantpaddune 3bca37f224 A750FXXU4CTBC
2020-03-27 21:51:54 +05:30

61 lines
1.5 KiB
C

/*
* Set OEM flags
*
* Copyright (C) 2018 Samsung Electronics, Inc.
* Jonghun Song, <justin.song@samsung.com>
* Egor Ulesykiy, <e.uelyskiy@samsung.com>
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* 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 the
* GNU General Public License for more details.
*/
#include <linux/printk.h>
#include <linux/types.h>
#include <linux/errno.h>
#include "oemflag.h"
#include "oemflag_arch.h"
static int oem_flags_check[OEMFLAG_NUM_OF_FLAG];
static int check_flags(uint32_t flag_index)
{
return oem_flags_check[flag_index];
}
int oem_flags_set(enum oemflag_id index)
{
int ret = 0;
uint32_t name = index;
pr_info("[oemflag]START\n");
pr_info("[oemflag]set_fuse new\n");
if (name > OEMFLAG_MIN_FLAG && name < OEMFLAG_NUM_OF_FLAG) {
if (check_flags(name)) {
pr_info("[oemflag]flag is already set. %u\n", name);
return 0;
}
pr_info("[oemflag]set_fuse_name : %u\n", name);
ret = set_tamper_fuse(name);
if (ret)
pr_err("set_tamper_fuse error: ret=%d\n", ret);
ret = get_tamper_fuse(name);
if (ret)
pr_err("get_tamper_fuse error: ret=%d\n", ret);
oem_flags_check[name] = 1;
} else {
pr_info("[oemflag]param name is wrong\n");
ret = -EINVAL;
}
return ret;
}