From 88a28ab7b20d5eec70e9d0a335952ba0904d9b7e Mon Sep 17 00:00:00 2001 From: Varun Wadekar Date: Wed, 29 Jun 2011 16:17:36 +0530 Subject: arm: tegra: fuse: accept strings starting with 0x/x some users might enter fuse data starting with 0x/x. this will mess up the fuse programming. do not consider 0x/x while programming the fuses. also fix some compilation warnings Change-Id: I5e888a769eb15dbe7eb35ce2d290246fcf9788c9 Signed-off-by: Varun Wadekar Reviewed-on: http://git-master/r/38933 Reviewed-by: Bharat Nihalani --- arch/arm/mach-tegra/tegra2_fuse.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm/mach-tegra/tegra2_fuse.c b/arch/arm/mach-tegra/tegra2_fuse.c index e62a3357dd85..7934b5104343 100644 --- a/arch/arm/mach-tegra/tegra2_fuse.c +++ b/arch/arm/mach-tegra/tegra2_fuse.c @@ -722,9 +722,6 @@ static ssize_t fuse_store(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; } - if (!isxdigit(*buf)) - return -EINVAL; - if (fuse_odm_prod_mode()) { pr_err("%s: device locked. odm fuse already blown\n", __func__); return -EPERM; @@ -737,6 +734,15 @@ static ssize_t fuse_store(struct kobject *kobj, struct kobj_attribute *attr, return -EINVAL; } + /* see if the string has 0x/x at the start */ + if (*buf == 'x') { + count -= 1; + buf++; + } else if (*(buf + 1) == 'x') { + count -= 2; + buf += 2; + } + /* wakelock to avoid device powering down while programming */ wake_lock_init(&fuse_wk_lock, WAKE_LOCK_SUSPEND, "fuse_wk_lock"); wake_lock(&fuse_wk_lock); @@ -812,7 +818,7 @@ static ssize_t fuse_show(struct kobject *kobj, struct kobj_attribute *attr, char return ret; } - strcpy(buf, ""); + strcpy(buf, "0x"); for (i = (fuse_info_tbl[param].sz/sizeof(u32)) - 1; i >= 0 ; i--) { sprintf(str, "%08x", data[i]); strcat(buf, str); -- cgit v1.2.3