ATH11K Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kalle Valo <kvalo@codeaurora.org>
To: ath11k@lists.infradead.org
Subject: [PATCH 4/4] ath11k: use kstrtoint_from_user() instead of sscanf()
Date: Wed, 26 Jun 2019 18:18:15 +0300	[thread overview]
Message-ID: <1561562295-17402-4-git-send-email-kvalo@codeaurora.org> (raw)
In-Reply-To: <1561562295-17402-1-git-send-email-kvalo@codeaurora.org>

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 --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);
-- 
2.7.4


_______________________________________________
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

  parent reply	other threads:[~2019-06-26 15:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-26 15:18 [PATCH 1/4] ath11k: Alignment should match open parenthesis Kalle Valo
2019-06-26 15:18 ` [PATCH 2/4] ath11k: Remove prototype interface Kalle Valo
2019-06-26 15:18 ` [PATCH 3/4] ath11k: line over 90 characters Kalle Valo
2019-06-26 15:18 ` Kalle Valo [this message]
2019-06-27 11:15 ` [PATCH 1/4] ath11k: Alignment should match open parenthesis Kalle Valo

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=1561562295-17402-4-git-send-email-kvalo@codeaurora.org \
    --to=kvalo@codeaurora.org \
    --cc=ath11k@lists.infradead.org \
    /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