Use 'kstrtou16_from_user()' to simplify 'airtime_flags_write()'. Signed-off-by: Dmitry Antipov --- net/mac80211/debugfs.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index a4d5461f6480..081dd6e8037e 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c @@ -171,23 +171,10 @@ static ssize_t airtime_flags_write(struct file *file, size_t count, loff_t *ppos) { struct ieee80211_local *local = file->private_data; - char buf[16]; - - if (count >= sizeof(buf)) - return -EINVAL; - - if (copy_from_user(buf, user_buf, count)) - return -EFAULT; - - if (count && buf[count - 1] == '\n') - buf[count - 1] = '\0'; - else - buf[count] = '\0'; - - if (kstrtou16(buf, 0, &local->airtime_flags)) - return -EINVAL; + int ret; - return count; + ret = kstrtou16_from_user(user_buf, count, 0, &local->airtime_flags); + return ret ? : count; } static const struct debugfs_short_fops airtime_flags_ops = { -- 2.55.0