public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Li Zhijian <lizhijian@fujitsu.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Subject: [PATCH 06/14] intel_th: Convert sprintf/snprintf to sysfs_emit
Date: Mon, 29 Apr 2024 15:09:00 +0300	[thread overview]
Message-ID: <20240429120908.3723458-7-alexander.shishkin@linux.intel.com> (raw)
In-Reply-To: <20240429120908.3723458-1-alexander.shishkin@linux.intel.com>

From: Li Zhijian <lizhijian@fujitsu.com>

Per filesystems/sysfs.rst, show() should only use sysfs_emit()
or sysfs_emit_at() when formatting the value to be returned to user space.

coccinelle complains that there are still a couple of functions that use
snprintf(). Convert them to sysfs_emit().

sprintf() will be converted as weel if they have.

Generally, this patch is generated by
make coccicheck M=<path/to/file> MODE=patch \
COCCI=scripts/coccinelle/api/device_attr_show.cocci

No functional change intended

Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hwtracing/intel_th/gth.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/intel_th/gth.c b/drivers/hwtracing/intel_th/gth.c
index b3308934a687..3883f99fd5d5 100644
--- a/drivers/hwtracing/intel_th/gth.c
+++ b/drivers/hwtracing/intel_th/gth.c
@@ -154,9 +154,9 @@ static ssize_t master_attr_show(struct device *dev,
 	spin_unlock(&gth->gth_lock);
 
 	if (port >= 0)
-		count = snprintf(buf, PAGE_SIZE, "%x\n", port);
+		count = sysfs_emit(buf, "%x\n", port);
 	else
-		count = snprintf(buf, PAGE_SIZE, "disabled\n");
+		count = sysfs_emit(buf, "disabled\n");
 
 	return count;
 }
@@ -332,8 +332,8 @@ static ssize_t output_attr_show(struct device *dev,
 	pm_runtime_get_sync(dev);
 
 	spin_lock(&gth->gth_lock);
-	count = snprintf(buf, PAGE_SIZE, "%x\n",
-			 gth_output_parm_get(gth, oa->port, oa->parm));
+	count = sysfs_emit(buf, "%x\n",
+			   gth_output_parm_get(gth, oa->port, oa->parm));
 	spin_unlock(&gth->gth_lock);
 
 	pm_runtime_put(dev);
-- 
2.43.0


  parent reply	other threads:[~2024-04-29 12:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 12:08 [PATCH 00/14] stm class/intel_th: Updates for v6.10 Alexander Shishkin
2024-04-29 12:08 ` [PATCH 01/14] stm class: Fix a double free in stm_register_device() Alexander Shishkin
2024-04-29 12:08 ` [PATCH 02/14] stm class: Add source type Alexander Shishkin
2024-04-29 12:08 ` [PATCH 03/14] stm class: Propagate source type to protocols Alexander Shishkin
2024-04-29 12:08 ` [PATCH 04/14] stm class: sys-t: Improve ftrace source handling Alexander Shishkin
2024-04-29 12:08 ` [PATCH 05/14] intel_th: Constify the struct device_type usage Alexander Shishkin
2024-04-29 12:09 ` Alexander Shishkin [this message]
2024-04-29 12:09 ` [PATCH 07/14] intel_th: Remove redundant initialization of pointer outp Alexander Shishkin
2024-04-29 12:09 ` [PATCH 08/14] intel_th: msu: Fix kernel-doc warnings Alexander Shishkin
2024-04-29 12:09 ` [PATCH 09/14] intel_th: pci: Add Granite Rapids support Alexander Shishkin
2024-04-29 12:09 ` [PATCH 10/14] intel_th: pci: Add Granite Rapids SOC support Alexander Shishkin
2024-04-29 12:09 ` [PATCH 11/14] intel_th: pci: Add Sapphire " Alexander Shishkin
2024-04-29 12:09 ` [PATCH 12/14] intel_th: pci: Add Meteor Lake-S support Alexander Shishkin
2024-04-29 12:09 ` [PATCH 13/14] intel_th: pci: Add Meteor Lake-S CPU support Alexander Shishkin
2024-04-29 12:09 ` [PATCH 14/14] intel_th: pci: Add Lunar Lake support Alexander Shishkin
2024-04-29 13:05 ` [PATCH 00/14] stm class/intel_th: Updates for v6.10 Alexander Shishkin

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=20240429120908.3723458-7-alexander.shishkin@linux.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhijian@fujitsu.com \
    /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