All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf()
@ 2022-12-02  8:56 ye.xingchen
  2022-12-05  6:10 ` patchwork-bot+chrome-platform
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ye.xingchen @ 2022-12-02  8:56 UTC (permalink / raw)
  To: bleung; +Cc: groeck, chrome-platform, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

Follow the advice of the Documentation/filesystems/sysfs.rst and show()
should only use sysfs_emit() or sysfs_emit_at() when formatting the
value to be returned to user space.

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 drivers/platform/chrome/cros_ec_lightbar.c | 14 ++++++--------
 drivers/platform/chrome/cros_ec_sysfs.c    |  4 ++--
 drivers/platform/chrome/wilco_ec/sysfs.c   |  3 +--
 3 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/drivers/platform/chrome/cros_ec_lightbar.c b/drivers/platform/chrome/cros_ec_lightbar.c
index 1674105decfb..376425bbd8ff 100644
--- a/drivers/platform/chrome/cros_ec_lightbar.c
+++ b/drivers/platform/chrome/cros_ec_lightbar.c
@@ -34,7 +34,7 @@ static ssize_t interval_msec_show(struct device *dev,
 {
 	unsigned long msec = lb_interval_jiffies * 1000 / HZ;

-	return scnprintf(buf, PAGE_SIZE, "%lu\n", msec);
+	return sysfs_emit(buf, "%lu\n", msec);
 }

 static ssize_t interval_msec_store(struct device *dev,
@@ -169,7 +169,7 @@ static ssize_t version_show(struct device *dev,
 	if (!get_lightbar_version(ec, &version, &flags))
 		return -EIO;

-	return scnprintf(buf, PAGE_SIZE, "%d %d\n", version, flags);
+	return sysfs_emit(buf, "%d %d\n", version, flags);
 }

 static ssize_t brightness_store(struct device *dev,
@@ -302,17 +302,15 @@ static ssize_t sequence_show(struct device *dev,

 	ret = cros_ec_cmd_xfer_status(ec->ec_dev, msg);
 	if (ret < 0) {
-		ret = scnprintf(buf, PAGE_SIZE, "XFER / EC ERROR %d / %d\n",
-				ret, msg->result);
+		ret = sysfs_emit(buf, "XFER / EC ERROR %d / %d\n", ret, msg->result);
 		goto exit;
 	}

 	resp = (struct ec_response_lightbar *)msg->data;
 	if (resp->get_seq.num >= ARRAY_SIZE(seqname))
-		ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->get_seq.num);
+		ret = sysfs_emit(buf, "%d\n", resp->get_seq.num);
 	else
-		ret = scnprintf(buf, PAGE_SIZE, "%s\n",
-				seqname[resp->get_seq.num]);
+		ret = sysfs_emit(buf, "%s\n", seqname[resp->get_seq.num]);

 exit:
 	kfree(msg);
@@ -483,7 +481,7 @@ static ssize_t userspace_control_show(struct device *dev,
 				      struct device_attribute *attr,
 				      char *buf)
 {
-	return scnprintf(buf, PAGE_SIZE, "%d\n", userspace_control);
+	return sysfs_emit(buf, "%d\n", userspace_control);
 }

 static ssize_t userspace_control_store(struct device *dev,
diff --git a/drivers/platform/chrome/cros_ec_sysfs.c b/drivers/platform/chrome/cros_ec_sysfs.c
index f07eabcf9494..e45e57cee3a8 100644
--- a/drivers/platform/chrome/cros_ec_sysfs.c
+++ b/drivers/platform/chrome/cros_ec_sysfs.c
@@ -227,7 +227,7 @@ static ssize_t flashinfo_show(struct device *dev,

 	resp = (struct ec_response_flash_info *)msg->data;

-	ret = scnprintf(buf, PAGE_SIZE,
+	ret = sysfs_emit(buf,
 			"FlashSize %d\nWriteSize %d\n"
 			"EraseSize %d\nProtectSize %d\n",
 			resp->flash_size, resp->write_block_size,
@@ -264,7 +264,7 @@ static ssize_t kb_wake_angle_show(struct device *dev,
 		goto exit;

 	resp = (struct ec_response_motion_sense *)msg->data;
-	ret = scnprintf(buf, PAGE_SIZE, "%d\n", resp->kb_wake_angle.ret);
+	ret = sysfs_emit(buf, "%d\n", resp->kb_wake_angle.ret);
 exit:
 	kfree(msg);
 	return ret;
diff --git a/drivers/platform/chrome/wilco_ec/sysfs.c b/drivers/platform/chrome/wilco_ec/sysfs.c
index 79a5e8fa680f..893c59dde32a 100644
--- a/drivers/platform/chrome/wilco_ec/sysfs.c
+++ b/drivers/platform/chrome/wilco_ec/sysfs.c
@@ -119,8 +119,7 @@ static ssize_t get_info(struct device *dev, char *buf, enum get_ec_info_op op)
 	if (ret < 0)
 		return ret;

-	return scnprintf(buf, PAGE_SIZE, "%.*s\n", (int)sizeof(resp.value),
-			 (char *)&resp.value);
+	return sysfs_emit(buf, "%.*s\n", (int)sizeof(resp.value), (char *)&resp.value);
 }

 static ssize_t version_show(struct device *dev, struct device_attribute *attr,
-- 
2.25.1

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

* Re: [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf()
  2022-12-02  8:56 [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf() ye.xingchen
@ 2022-12-05  6:10 ` patchwork-bot+chrome-platform
  2022-12-05  6:18 ` Tzung-Bi Shih
  2022-12-05  8:40 ` patchwork-bot+chrome-platform
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+chrome-platform @ 2022-12-05  6:10 UTC (permalink / raw)
  To: ye.xingchen; +Cc: bleung, groeck, chrome-platform, linux-kernel

Hello:

This patch was applied to chrome-platform/linux.git (for-kernelci)
by Tzung-Bi Shih <tzungbi@kernel.org>:

On Fri, 2 Dec 2022 16:56:04 +0800 (CST) you wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> 
> [...]

Here is the summary with links:
  - platform/chrome: use sysfs_emit() to instead of scnprintf()
    https://git.kernel.org/chrome-platform/c/7af6ee18ad6e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf()
  2022-12-02  8:56 [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf() ye.xingchen
  2022-12-05  6:10 ` patchwork-bot+chrome-platform
@ 2022-12-05  6:18 ` Tzung-Bi Shih
  2022-12-05  8:40 ` patchwork-bot+chrome-platform
  2 siblings, 0 replies; 4+ messages in thread
From: Tzung-Bi Shih @ 2022-12-05  6:18 UTC (permalink / raw)
  To: ye.xingchen; +Cc: bleung, groeck, chrome-platform, linux-kernel

On Fri, Dec 02, 2022 at 04:56:04PM +0800, ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Fixed the commit message a bit and queued the patch.

Also, I found a little more here: https://patchwork.kernel.org/project/chrome-platform/patch/20221205061042.1774769-1-tzungbi@kernel.org/

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

* Re: [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf()
  2022-12-02  8:56 [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf() ye.xingchen
  2022-12-05  6:10 ` patchwork-bot+chrome-platform
  2022-12-05  6:18 ` Tzung-Bi Shih
@ 2022-12-05  8:40 ` patchwork-bot+chrome-platform
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+chrome-platform @ 2022-12-05  8:40 UTC (permalink / raw)
  To: ye.xingchen; +Cc: bleung, groeck, chrome-platform, linux-kernel

Hello:

This patch was applied to chrome-platform/linux.git (for-next)
by Tzung-Bi Shih <tzungbi@kernel.org>:

On Fri, 2 Dec 2022 16:56:04 +0800 (CST) you wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
> 
> [...]

Here is the summary with links:
  - platform/chrome: use sysfs_emit() to instead of scnprintf()
    https://git.kernel.org/chrome-platform/c/7af6ee18ad6e

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-12-05  8:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02  8:56 [PATCH] platform/chrome: use sysfs_emit() to instead of scnprintf() ye.xingchen
2022-12-05  6:10 ` patchwork-bot+chrome-platform
2022-12-05  6:18 ` Tzung-Bi Shih
2022-12-05  8:40 ` patchwork-bot+chrome-platform

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.