Replace the use of sscanf() with kstrtouint(), which is the favored kernel
API for parsing integers from strings. This avoids format string parsing
overhead and improves robustness.
Signed-off-by: trunix-creator <trunixcodes@zohomail.com>
---
drivers/platform/chrome/cros_ec_lightbar.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
index 922758c2cec1..e455ff440b11 100644
--- a/drivers/platform/chrome/cros_ec_lightbar.c
+++ b/drivers/platform/chrome/cros_ec_lightbar.c
@@ -243,10 +243,10 @@ static ssize_t led_rgb_store(struct device *dev, struct device_attribute *attr,
if (!*buf)
break;
- ret = sscanf(buf, "%i", &val[i++]);
+ ret = kstrtouint(buf, 0, &val[i]);
if (ret == 0)
goto exit;
-
+ i++;
if (i == 4) {
param = (struct ec_params_lightbar *)msg->data;
param->cmd = LIGHTBAR_CMD_SET_RGB;
--
2.43.0