Skip to content

Commit

Permalink
wifi: ti: Convert sprintf/snprintf to sysfs_emit
Browse files Browse the repository at this point in the history
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: Li Zhijian <lizhijian@fujitsu.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240315055211.1347548-3-lizhijian@fujitsu.com
  • Loading branch information
Li Zhijian authored and Kalle Valo committed Mar 21, 2024
1 parent 6db5c15 commit 48be577
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions drivers/net/wireless/ti/wlcore/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 48be577

Please sign in to comment.