Commit 48be5774 authored by Li Zhijian's avatar Li Zhijian Committed by Kalle Valo
Browse files

wifi: ti: Convert sprintf/snprintf to sysfs_emit



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

CC: Kalle Valo <kvalo@kernel.org>
CC: linux-wireless@vger.kernel.org
Signed-off-by: default avatarLi Zhijian <lizhijian@fujitsu.com>
Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240315055211.1347548-3-lizhijian@fujitsu.com
parent 6db5c15c
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -19,11 +19,8 @@ static ssize_t bt_coex_state_show(struct device *dev,
	struct wl1271 *wl = dev_get_drvdata(dev);
	ssize_t len;

	len = PAGE_SIZE;

	mutex_lock(&wl->mutex);
	len = snprintf(buf, len, "%d\n\n0 - off\n1 - on\n",
		       wl->sg_enabled);
	len = sysfs_emit(buf, "%d\n\n0 - off\n1 - on\n", wl->sg_enabled);
	mutex_unlock(&wl->mutex);

	return len;
@@ -78,13 +75,11 @@ static ssize_t hw_pg_ver_show(struct device *dev,
	struct wl1271 *wl = dev_get_drvdata(dev);
	ssize_t len;

	len = PAGE_SIZE;

	mutex_lock(&wl->mutex);
	if (wl->hw_pg_ver >= 0)
		len = snprintf(buf, len, "%d\n", wl->hw_pg_ver);
		len = sysfs_emit(buf, "%d\n", wl->hw_pg_ver);
	else
		len = snprintf(buf, len, "n/a\n");
		len = sysfs_emit(buf, "n/a\n");
	mutex_unlock(&wl->mutex);

	return len;