diff mbox series

[4/4] ath11k: use kstrtoint_from_user() instead of sscanf()

Message ID 1561562295-17402-4-git-send-email-kvalo@codeaurora.org (mailing list archive)
State Accepted
Commit 4c6476d00657feeb8639da49ee9daf428e3093fe
Delegated to: Kalle Valo
Headers show
Series [1/4] ath11k: Alignment should match open parenthesis | expand

Commit Message

Kalle Valo June 26, 2019, 3:18 p.m. UTC
Fix checkpatch warning:

drivers/net/wireless/ath/ath11k/debugfs_sta.c:494: Prefer kstrto<type> to single variable sscanf

As kstrtoint_from_user() can read directly from user buffer no need copy the buffer separately.

Compile tested only.

Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
---
 drivers/net/wireless/ath/ath11k/debugfs_sta.c | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/debugfs_sta.c b/drivers/net/wireless/ath/ath11k/debugfs_sta.c
index 4a30293bbae4..82bada5a7479 100644
--- a/drivers/net/wireless/ath/ath11k/debugfs_sta.c
+++ b/drivers/net/wireless/ath/ath11k/debugfs_sta.c
@@ -467,15 +467,13 @@  static const struct file_operations fops_htt_peer_stats = {
 };
 
 static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
-						const char __user *ubuf,
+						const char __user *buf,
 						size_t count, loff_t *ppos)
 {
 	struct ieee80211_sta *sta = file->private_data;
 	struct ath11k_sta *arsta = (struct ath11k_sta *)sta->drv_priv;
 	struct ath11k *ar = arsta->arvif->ar;
-	u8 buf[32] = {0};
 	int ret, enable;
-	ssize_t rc;
 
 	mutex_lock(&ar->conf_mutex);
 
@@ -484,18 +482,9 @@  static ssize_t ath11k_dbg_sta_write_peer_pktlog(struct file *file,
 		goto out;
 	}
 
-	rc = simple_write_to_buffer(buf, sizeof(buf) - 1, ppos, ubuf, count);
-	if (rc < 0) {
-		ret = rc;
+	ret = kstrtoint_from_user(buf, count, 0, &enable);
+	if (ret)
 		goto out;
-	}
-	buf[rc] = '\0';
-
-	ret = sscanf(buf, "%d", &enable);
-	if (ret != 1) {
-		ret = -EINVAL;
-		goto out;
-	}
 
 	ar->debug.pktlog_peer_valid = enable;
 	memcpy(ar->debug.pktlog_peer_addr, sta->addr, ETH_ALEN);