Skip to content

Commit

Permalink
efuse: fix INCOMPATIBLE_CAST and NEGATIVE_RETURNS errs
Browse files Browse the repository at this point in the history
PD#152879: driver defect clean up
 torvalds#299
 torvalds#300
 torvalds#320
 torvalds#321

Change-Id: I3756489ea81520ab042c74642b0483f36bff6fba
Signed-off-by: Jiamin Ma <[email protected]>
  • Loading branch information
Jiamin Ma authored and akiernan committed Nov 3, 2022
1 parent f900c2a commit dbf9ba9
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions drivers/amlogic/efuse/efuse64.c
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ ssize_t efuse_user_attr_store(char *name, const char *buf, size_t count)
const char *c, *s;
struct efusekey_info info;
unsigned int uint_val;
loff_t pos;

if (efuse_getinfo(name, &info) < 0) {
pr_err("%s is not found\n", name);
Expand Down Expand Up @@ -338,7 +339,8 @@ ssize_t efuse_user_attr_store(char *name, const char *buf, size_t count)
}
}

ret = efuse_write_usr(local_buf, info.size, (loff_t *)&(info.offset));
pos = ((loff_t)(info.offset)) & 0xffffffff;
ret = efuse_write_usr(local_buf, info.size, &pos);
if (ret == -1) {
pr_err("ERROR: efuse write user data fail!\n");
goto error_exit;
Expand All @@ -364,6 +366,7 @@ ssize_t efuse_user_attr_show(char *name, char *buf)
ssize_t ret;
int i;
struct efusekey_info info;
loff_t pos;

if (efuse_getinfo(name, &info) < 0) {
pr_err("%s is not found\n", name);
Expand All @@ -373,7 +376,8 @@ ssize_t efuse_user_attr_show(char *name, char *buf)
local_buf = kzalloc(sizeof(char)*(info.size), GFP_KERNEL);
memset(local_buf, 0, info.size);

ret = efuse_read_usr(local_buf, info.size, (loff_t *)&(info.offset));
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;
Expand All @@ -399,7 +403,12 @@ static ssize_t userdata_show(struct class *cla,
loff_t offset;
unsigned int max_size;

max_size = efuse_get_max();
ret = efuse_get_max();
if (ret < 0) {
pr_err("efuse: failed to get max size\n");
return -1;
}
max_size = (unsigned int)ret;

op = kmalloc_array(max_size, sizeof(char), GFP_KERNEL);
if (!op) {
Expand Down Expand Up @@ -441,7 +450,13 @@ static ssize_t userdata_write(struct class *cla,
char *op = NULL;
unsigned int max_size;

max_size = efuse_get_max();
ret = efuse_get_max();
if (ret < 0) {
pr_err("efuse: failed to get max size\n");
return -1;
}
max_size = (unsigned int)ret;

op = kzalloc((sizeof(char)*max_size), GFP_KERNEL);
if (!op) {
pr_err("efuse: failed to allocate memory\n");
Expand Down

0 comments on commit dbf9ba9

Please sign in to comment.