From 0f4c94256fb69188efad81873f4198de7914aee2 Mon Sep 17 00:00:00 2001 From: Varun Wadekar Date: Thu, 14 Jul 2011 15:11:51 +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 Reviewed-on: http://git-master/r/#change,38933 Original-Change-Id: I36b525c71b6d5c437affbaf0724667f8e5984aa6 Signed-off-by: Varun Wadekar Reviewed-on: http://git-master/r/41016 Reviewed-by: Bharat Nihalani Rebase-Id: Rb6a134adfa8049865bb4154353763d43f743e052 --- arch/arm/mach-tegra/tegra_odm_fuses.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'arch/arm/mach-tegra/tegra_odm_fuses.c') diff --git a/arch/arm/mach-tegra/tegra_odm_fuses.c b/arch/arm/mach-tegra/tegra_odm_fuses.c index 9cd7aa86a224..96f69f4b0458 100644 --- a/arch/arm/mach-tegra/tegra_odm_fuses.c +++ b/arch/arm/mach-tegra/tegra_odm_fuses.c @@ -758,9 +758,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; @@ -773,6 +770,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; + } + /* we need to fit each character into a single nibble */ raw_byte_data += DIV_ROUND_UP(count, 2) - 1; @@ -842,7 +848,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