From: Jiamin Ma Date: Thu, 26 Oct 2017 06:04:32 +0000 (+0800) Subject: efuse: fix INCOMPATIBLE_CAST and NEGATIVE_RETURNS errs X-Git-Tag: khadas-vims-v0.9.6-release~2727 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f7b7bd3df5dedbc8f71bd472ffd22b7d21cd2a4a;p=platform%2Fkernel%2Flinux-amlogic.git efuse: fix INCOMPATIBLE_CAST and NEGATIVE_RETURNS errs PD#152879: driver defect clean up #299 #300 #320 #321 Change-Id: I3756489ea81520ab042c74642b0483f36bff6fba Signed-off-by: Jiamin Ma --- diff --git a/drivers/amlogic/efuse/efuse64.c b/drivers/amlogic/efuse/efuse64.c index 7526452..71c6bbe 100644 --- a/drivers/amlogic/efuse/efuse64.c +++ b/drivers/amlogic/efuse/efuse64.c @@ -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); @@ -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; @@ -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); @@ -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; @@ -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) { @@ -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");