public inbox for chrome-platform@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint
@ 2026-02-08 22:13 trunix-creator
  2026-02-23  8:17 ` Tzung-Bi Shih
  0 siblings, 1 reply; 2+ messages in thread
From: trunix-creator @ 2026-02-08 22:13 UTC (permalink / raw)
  To: bleung; +Cc: tzungbi, groeck, chrome-platform, linux-kernel, trunix-creator

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-23  8:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08 22:13 [PATCH] platform/chrome: cros_ec_lightbar: replace sscanf with kstrtouint trunix-creator
2026-02-23  8:17 ` Tzung-Bi Shih

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox