From: trunix-creator <trunixcodes@zohomail.com>
To: bleung@chromium.org
Cc: tzungbi@kernel.org, groeck@chromium.org,
chrome-platform@lists.linux.dev, linux-kernel@vger.kernel.org,
trunix-creator <trunixcodes@zohomail.com>
Subject: [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint
Date: Sun, 8 Feb 2026 14:13:35 -0800 [thread overview]
Message-ID: <20260208221335.16030-1-trunixcodes@zohomail.com> (raw)
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
next reply other threads:[~2026-02-08 22:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-08 22:13 trunix-creator [this message]
2026-02-23 8:17 ` [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint Tzung-Bi Shih
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260208221335.16030-1-trunixcodes@zohomail.com \
--to=trunixcodes@zohomail.com \
--cc=bleung@chromium.org \
--cc=chrome-platform@lists.linux.dev \
--cc=groeck@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tzungbi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox