}
local_buf = kzalloc(sizeof(char)*(count), GFP_KERNEL);
+ if (!local_buf) {
+ ret = -ENOMEM;
+ pr_err("efuse: failed to allocate memory!\n");
+ return ret;
+ }
memcpy(local_buf, buf, count);
}
local_buf = kzalloc(sizeof(char)*(info.size), GFP_KERNEL);
+ if (!local_buf) {
+ ret = -ENOMEM;
+ pr_err("efuse: failed to allocate memory!\n");
+ return ret;
+ }
+
memset(local_buf, 0, info.size);
pos = ((loff_t)(info.offset)) & 0xffffffff;
return ret;
}
+ssize_t efuse_user_attr_read(char *name, char *buf)
+{
+ char *local_buf;
+ ssize_t ret;
+ struct efusekey_info info;
+ loff_t pos;
+
+ if (efuse_getinfo(name, &info) < 0) {
+ pr_err("%s is not found\n", name);
+ return -EFAULT;
+ }
+
+ local_buf = kzalloc(sizeof(char)*(info.size), GFP_KERNEL);
+ if (!local_buf) {
+ ret = -ENOMEM;
+ pr_err("efuse: failed to allocate memory!\n");
+ return ret;
+ }
+
+ memset(local_buf, 0, info.size);
+
+ pos = ((loff_t)(info.offset)) & 0xffffffff;
+ ret = efuse_read_usr(local_buf, info.size, &pos);
+ if (ret == -1) {
+ pr_err("ERROR: efuse read user data fail!\n");
+ goto error_exit;
+ }
+ if (ret != info.size)
+ pr_err("ERROR: read %zd byte(s) not %d byte(s) data\n",
+ ret, info.size);
+
+ memcpy(buf, local_buf, info.size);
+
+error_exit:
+ kfree(local_buf);
+ return ret;
+}
+
static ssize_t userdata_show(struct class *cla,
struct class_attribute *attr, char *buf)
{
static int key_efuse_write(char *keyname, unsigned char *keydata,
unsigned int datalen)
{
-#ifdef CONFIG_EFUSE
+#if defined(CONFIG_ARM64) && defined(CONFIG_AMLOGIC_EFUSE)
char *title = keyname;
struct efusekey_info info;
static int key_efuse_read(char *keyname, unsigned char *keydata,
unsigned int datalen, unsigned int *reallen)
{
-#ifdef CONFIG_EFUSE
+#if defined(CONFIG_ARM64) && defined(CONFIG_AMLOGIC_EFUSE)
char *title = keyname;
struct efusekey_info info;
int err = 0;
return -ENOMEM;
memset(buf, 0, info.size);
- err = efuse_user_attr_show(title, buf);
+ err = efuse_user_attr_read(title, buf);
if (err >= 0) {
*reallen = info.size;
if (datalen > info.size)
static int key_efuse_query(char *keyname, unsigned int *keystate)
{
int err = -EINVAL;
-#ifdef CONFIG_EFUSE
+#if defined(CONFIG_ARM64) && defined(CONFIG_AMLOGIC_EFUSE)
int i;
char *title = keyname;
struct efusekey_info info;
return -ENOMEM;
}
memset(buf, 0, info.size);
- err = efuse_user_attr_show(title, buf);
+ err = efuse_user_attr_read(title, buf);
*keystate = KEY_NO_EXIST;
if (err > 0) {
for (i = 0; i < info.size; i++) {
if (unifykey->permit & KEY_M_PERMIT_READ) {
switch (unifykey->dev) {
-#ifdef CONFIG_EFUSE
+#if defined(CONFIG_ARM64) && defined(CONFIG_AMLOGIC_EFUSE)
case KEY_M_EFUSE:
{
struct efusekey_info info;
int efuse_getinfo(char *item, struct efusekey_info *info);
ssize_t efuse_user_attr_show(char *name, char *buf);
ssize_t efuse_user_attr_store(char *name, const char *buf, size_t count);
+ssize_t efuse_user_attr_read(char *name, char *buf);
#else
int efuse_read_intlItem(char *intl_item, char *buf, int size);
#endif