From 9165264469f359a9b1c40bcf293d1dc292969566 Mon Sep 17 00:00:00 2001 From: Zelong Ren Date: Mon, 21 Jun 2021 17:13:59 +0530 Subject: [PATCH] soc: qcom: hab: Updating return value for function attributed to kobject Updating the return value of vchan_store, ctx_store, expimp_show functions to return an integer count. Submit code on behalf of Yashovardhan Bhatt. Change-Id: I5c1ec7ed7add2471ed5809a9bb359d0b02792486 Signed-off-by: Zelong Ren --- drivers/soc/qcom/hab/khab_test.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/hab/khab_test.c b/drivers/soc/qcom/hab/khab_test.c index 8f0d263d171c..f25b932e7deb 100644 --- a/drivers/soc/qcom/hab/khab_test.c +++ b/drivers/soc/qcom/hab/khab_test.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2018-2021, The Linux Foundation. All rights reserved. */ #include "hab.h" #include @@ -274,7 +274,7 @@ static ssize_t vchan_store(struct kobject *kobj, struct kobj_attribute *attr, pr_err("failed to read anything from input %d\n", ret); return 0; } else - return vchan_stat; + return count; } static ssize_t ctx_show(struct kobject *kobj, struct kobj_attribute *attr, @@ -293,7 +293,7 @@ static ssize_t ctx_store(struct kobject *kobj, struct kobj_attribute *attr, pr_err("failed to read anything from input %d\n", ret); return 0; } else - return context_stat; + return count; } static ssize_t expimp_show(struct kobject *kobj, struct kobj_attribute *attr, @@ -305,10 +305,11 @@ static ssize_t expimp_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t expimp_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - int ret; + int ret = -1; char str[36] = {0}; + unsigned long temp; - ret = sscanf(buf, "%35s", str); + ret = sscanf(buf, "%s", str); if (ret < 1) pr_err("failed to read anything from input %d\n", ret); @@ -319,11 +320,16 @@ static ssize_t expimp_store(struct kobject *kobj, struct kobj_attribute *attr, return strlen("dump_pipe"); } - ret = sscanf(buf, "%du", &pid_stat); - if (ret < 1) - pr_err("failed to read anything from input %d\n", ret); - else - return pid_stat; /* good result stored */ + if (buf) { + ret = kstrtol(buf, 10, &temp); + pid_stat = temp; + + if (ret < 0) + pr_err("failed to read anything from input %d\n", ret); + else + return count; /* good result stored */ + } + return -EEXIST; }