From nobody Fri Dec 19 17:16:37 2025 Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5006E1D9FF0 for ; Thu, 11 Apr 2024 15:40:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850013; cv=none; b=uvHGf7qvPgBU22v2Ovlxrqcb+IG3dnd6V0cQ0KOD3vCyzqrcqs1do6jbRHJ+kfzC0Sq6AHEjjclaUS9mLKyYPF7uo+cEQpm9bM1A90NO0iTs17M/8Zhg5QLvZYv0Xt20NzxRBfOVbhN0HvgqAaLY50Any0joQkFlEBfxiaVD80k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712850013; c=relaxed/simple; bh=xaPo/E+IHrGYl158KTEbt+Rq4YIWcoKYrAt5fO6c1fM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aE28s5swn/f1i5dIVvQ1XeDv/unqO9DwEox5NVDr6ztN5GAKyxP7QfWcq5+T28x3/6jZb6j3C9D62Lep3b25lGE7+f5E1/OBo4a2LOJCMP3xAIFnkYuWEJBjh8IHkjnduaVhjEsTvX2maFzhpYPxi1ozdSXi48iyI1kXWqaWA1Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=f2pQgJzL; arc=none smtp.client-ip=209.85.166.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="f2pQgJzL" Received: by mail-io1-f49.google.com with SMTP id ca18e2360f4ac-7d6112ba6baso58190039f.1 for ; Thu, 11 Apr 2024 08:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1712850009; x=1713454809; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c2bDHnSOqzvj8tuTT6HXHmHeyHcGyehDT+1ibrSmR/0=; b=f2pQgJzLB7Wgluzo8SGfOzzWm1ajfeorjVEAYqmjg+JYI59l260MweCEjV35y8WVV2 hUPMPXhg8k7/9L+iTgyoUzZZnRi2E6JQylZtNgAEdV42cv2ARkbIPu0VgTfKimmjfw4k jmnuQAsZWa5lVs+p+fEhK1J1Ou3jl9TsNCJ7o8HJ8ySeTY5l33pi21jkohUXpDVENDTX weNPkAzEHbTEcJ/BH2e62qKsCebpNB7UkuYMb6dCvhV0BjCs3OQwZ5j4tqSOgFNwNDEg o1wSaOeJXNwo3wG6BO6PcC4y35Cknt1sbLsENc96Yqp9DhXVM6vz0T4Vx7MaR3mcEFI2 0KIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712850009; x=1713454809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c2bDHnSOqzvj8tuTT6HXHmHeyHcGyehDT+1ibrSmR/0=; b=hdBB9rHOI2EfSE2msOeCdjd690Ly+BesE3zG1ZMHs4J3O7AIvADjQo1yjnAe1xRqJG pF10leYRzl99MoGz/lg/hP9n+stNfJzSlUZpZ8eM81da7fsrOVMWHRKA3FMjTGYBJs8a 9gRRVOOD3AKfOjRxyy2Bwa8QG34vHjZDW6O5wK4XNZrHIbYThcBD2FhVIW9GcSYc95Wk Exks7fH8ndt0B/uDVfJvgH2jrP6cz94tdfkBg7PKwIzYe3XEUQkqr02TzGth7Ou/Jsno zzAVxSTRCeXLKjzRGTnA+PLoG7DMT8Jn5UC1Ck9QXcyAjP/UHXHbCT/L9t0p/WGjKpBJ eoXg== X-Gm-Message-State: AOJu0Yzevv7gUPZR4l7bf9AJaSmPZzgjQP0y0g4wHd7FMUlH7QP1AVby d/oWPulPyJLVQQFQIeLXPzD+60aMTSzKuDrEhgeDEQgVJ+0vRResl24v0lU3wYE59JL748Xrdjv s X-Google-Smtp-Source: AGHT+IF5K/+DOq4hDjIJXrRGHOjlo6cqi5YkglAMElzRIjm+hByFQ7GLfwfllWTPuG4GBfjZiiUxhw== X-Received: by 2002:a6b:f312:0:b0:7d5:de23:13a9 with SMTP id m18-20020a6bf312000000b007d5de2313a9mr172179ioh.1.1712850009465; Thu, 11 Apr 2024 08:40:09 -0700 (PDT) Received: from localhost.localdomain ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id jc25-20020a056638891900b0047f14b7f6c0sm457056jab.5.2024.04.11.08.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 08:40:09 -0700 (PDT) From: Jens Axboe To: linux-kernel@vger.kernel.org Cc: Jens Axboe Subject: [PATCH 307/437] drivers/net/wireless/ralink: convert to read/write iterators Date: Thu, 11 Apr 2024 09:17:27 -0600 Message-ID: <20240411153126.16201-308-axboe@kernel.dk> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411153126.16201-1-axboe@kernel.dk> References: <20240411153126.16201-1-axboe@kernel.dk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Jens Axboe --- .../net/wireless/ralink/rt2x00/rt2x00debug.c | 122 ++++++++---------- 1 file changed, 55 insertions(+), 67 deletions(-) diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net= /wireless/ralink/rt2x00/rt2x00debug.c index f2395309ec00..80f84dc700be 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c @@ -238,17 +238,16 @@ static int rt2x00debug_release_queue_dump(struct inod= e *inode, struct file *file return rt2x00debug_file_release(inode, file); } =20 -static ssize_t rt2x00debug_read_queue_dump(struct file *file, - char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_read_queue_dump(struct kiocb *iocb, + struct iov_iter *to) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; + size_t length =3D iov_iter_count(to); struct sk_buff *skb; size_t status; int retval; =20 - if (file->f_flags & O_NONBLOCK) + if (iocb->ki_filp->f_flags & O_NONBLOCK) return -EAGAIN; =20 retval =3D @@ -259,12 +258,12 @@ static ssize_t rt2x00debug_read_queue_dump(struct fil= e *file, return retval; =20 status =3D min_t(size_t, skb->len, length); - if (copy_to_user(buf, skb->data, status)) { + if (!copy_to_iter_full(skb->data, status, to)) { status =3D -EFAULT; goto exit; } =20 - *offset +=3D status; + iocb->ki_pos +=3D status; =20 exit: kfree_skb(skb); @@ -287,27 +286,26 @@ static __poll_t rt2x00debug_poll_queue_dump(struct fi= le *file, =20 static const struct file_operations rt2x00debug_fop_queue_dump =3D { .owner =3D THIS_MODULE, - .read =3D rt2x00debug_read_queue_dump, + .read_iter =3D rt2x00debug_read_queue_dump, .poll =3D rt2x00debug_poll_queue_dump, .open =3D rt2x00debug_open_queue_dump, .release =3D rt2x00debug_release_queue_dump, .llseek =3D default_llseek, }; =20 -static ssize_t rt2x00debug_read_queue_stats(struct file *file, - char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_read_queue_stats(struct kiocb *iocb, + struct iov_iter *to) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; struct data_queue *queue; unsigned long irqflags; unsigned int lines =3D 1 + intf->rt2x00dev->data_queues; + size_t length =3D iov_iter_count(to); size_t size; char *data; char *temp; =20 - if (*offset) + if (iocb->ki_pos) return 0; =20 data =3D kcalloc(lines, MAX_LINE_LENGTH, GFP_KERNEL); @@ -333,39 +331,38 @@ static ssize_t rt2x00debug_read_queue_stats(struct fi= le *file, size =3D strlen(data); size =3D min(size, length); =20 - if (copy_to_user(buf, data, size)) { + if (!copy_to_iter_full(data, size, to)) { kfree(data); return -EFAULT; } =20 kfree(data); =20 - *offset +=3D size; + iocb->ki_pos +=3D size; return size; } =20 static const struct file_operations rt2x00debug_fop_queue_stats =3D { .owner =3D THIS_MODULE, - .read =3D rt2x00debug_read_queue_stats, + .read_iter =3D rt2x00debug_read_queue_stats, .open =3D rt2x00debug_file_open, .release =3D rt2x00debug_file_release, .llseek =3D default_llseek, }; =20 #ifdef CONFIG_RT2X00_LIB_CRYPTO -static ssize_t rt2x00debug_read_crypto_stats(struct file *file, - char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_read_crypto_stats(struct kiocb *iocb, + struct iov_iter *to) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; static const char * const name[] =3D { "WEP64", "WEP128", "TKIP", "AES" }; + size_t length =3D iov_iter_count(to); char *data; char *temp; size_t size; unsigned int i; =20 - if (*offset) + if (iocb->ki_pos) return 0; =20 data =3D kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL); @@ -386,20 +383,20 @@ static ssize_t rt2x00debug_read_crypto_stats(struct f= ile *file, size =3D strlen(data); size =3D min(size, length); =20 - if (copy_to_user(buf, data, size)) { + if (!copy_to_iter_full(data, size, to)) { kfree(data); return -EFAULT; } =20 kfree(data); =20 - *offset +=3D size; + iocb->ki_pos +=3D size; return size; } =20 static const struct file_operations rt2x00debug_fop_crypto_stats =3D { .owner =3D THIS_MODULE, - .read =3D rt2x00debug_read_crypto_stats, + .read_iter =3D rt2x00debug_read_crypto_stats, .open =3D rt2x00debug_file_open, .release =3D rt2x00debug_file_release, .llseek =3D default_llseek, @@ -407,19 +404,17 @@ static const struct file_operations rt2x00debug_fop_c= rypto_stats =3D { #endif =20 #define RT2X00DEBUGFS_OPS_READ(__name, __format, __type) \ -static ssize_t rt2x00debug_read_##__name(struct file *file, \ - char __user *buf, \ - size_t length, \ - loff_t *offset) \ +static ssize_t rt2x00debug_read_##__name(struct kiocb *iocb, \ + struct iov_iter *to) \ { \ - struct rt2x00debug_intf *intf =3D file->private_data; \ + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; \ const struct rt2x00debug *debug =3D intf->debug; \ char line[16]; \ size_t size; \ unsigned int index =3D intf->offset_##__name; \ __type value; \ \ - if (*offset) \ + if (iocb->ki_pos) \ return 0; \ \ if (index >=3D debug->__name.word_count) \ @@ -435,23 +430,22 @@ static ssize_t rt2x00debug_read_##__name(struct file = *file, \ \ size =3D sprintf(line, __format, value); \ \ - return simple_read_from_buffer(buf, length, offset, line, size); \ + return simple_copy_to_iter(line, &iocb->ki_pos, size, to); \ } =20 #define RT2X00DEBUGFS_OPS_WRITE(__name, __type) \ -static ssize_t rt2x00debug_write_##__name(struct file *file, \ - const char __user *buf,\ - size_t length, \ - loff_t *offset) \ +static ssize_t rt2x00debug_write_##__name(struct kiocb *iocb, \ + struct iov_iter *from)\ { \ - struct rt2x00debug_intf *intf =3D file->private_data; \ + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; \ const struct rt2x00debug *debug =3D intf->debug; \ + size_t length =3D iov_iter_count(from); \ char line[17]; \ size_t size; \ unsigned int index =3D intf->offset_##__name; \ __type value; \ \ - if (*offset) \ + if (iocb->ki_pos) \ return 0; \ \ if (index >=3D debug->__name.word_count) \ @@ -460,7 +454,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *= file, \ if (length > sizeof(line)) \ return -EINVAL; \ \ - if (copy_from_user(line, buf, length)) \ + if (!copy_from_iter_full(line, length, from)) \ return -EFAULT; \ line[16] =3D 0; \ \ @@ -475,7 +469,7 @@ static ssize_t rt2x00debug_write_##__name(struct file *= file, \ \ debug->__name.write(intf->rt2x00dev, index, value); \ \ - *offset +=3D size; \ + iocb->ki_pos +=3D size; \ return size; \ } =20 @@ -485,8 +479,8 @@ RT2X00DEBUGFS_OPS_WRITE(__name, __type); \ \ static const struct file_operations rt2x00debug_fop_##__name =3D {\ .owner =3D THIS_MODULE, \ - .read =3D rt2x00debug_read_##__name, \ - .write =3D rt2x00debug_write_##__name, \ + .read_iter =3D rt2x00debug_read_##__name, \ + .write_iter =3D rt2x00debug_write_##__name, \ .open =3D rt2x00debug_file_open, \ .release =3D rt2x00debug_file_release, \ .llseek =3D generic_file_llseek, \ @@ -498,62 +492,56 @@ RT2X00DEBUGFS_OPS(bbp, "0x%.2x\n", u8); RT2X00DEBUGFS_OPS(rf, "0x%.8x\n", u32); RT2X00DEBUGFS_OPS(rfcsr, "0x%.2x\n", u8); =20 -static ssize_t rt2x00debug_read_dev_flags(struct file *file, - char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_read_dev_flags(struct kiocb *iocb, + struct iov_iter *to) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; char line[16]; size_t size; =20 - if (*offset) + if (iocb->ki_pos) return 0; =20 size =3D sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->flags); =20 - return simple_read_from_buffer(buf, length, offset, line, size); + return simple_copy_to_iter(line, &iocb->ki_pos, size, to); } =20 static const struct file_operations rt2x00debug_fop_dev_flags =3D { .owner =3D THIS_MODULE, - .read =3D rt2x00debug_read_dev_flags, + .read_iter =3D rt2x00debug_read_dev_flags, .open =3D rt2x00debug_file_open, .release =3D rt2x00debug_file_release, .llseek =3D default_llseek, }; =20 -static ssize_t rt2x00debug_read_cap_flags(struct file *file, - char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_read_cap_flags(struct kiocb *iocb, + struct iov_iter *to) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; char line[16]; size_t size; =20 - if (*offset) + if (iocb->ki_pos) return 0; =20 size =3D sprintf(line, "0x%.8x\n", (unsigned int)intf->rt2x00dev->cap_fla= gs); =20 - return simple_read_from_buffer(buf, length, offset, line, size); + return simple_copy_to_iter(line, &iocb->ki_pos, size, to); } =20 static const struct file_operations rt2x00debug_fop_cap_flags =3D { .owner =3D THIS_MODULE, - .read =3D rt2x00debug_read_cap_flags, + .read_iter =3D rt2x00debug_read_cap_flags, .open =3D rt2x00debug_file_open, .release =3D rt2x00debug_file_release, .llseek =3D default_llseek, }; =20 -static ssize_t rt2x00debug_write_restart_hw(struct file *file, - const char __user *buf, - size_t length, - loff_t *offset) +static ssize_t rt2x00debug_write_restart_hw(struct kiocb *iocb, + struct iov_iter *from) { - struct rt2x00debug_intf *intf =3D file->private_data; + struct rt2x00debug_intf *intf =3D iocb->ki_filp->private_data; struct rt2x00_dev *rt2x00dev =3D intf->rt2x00dev; static unsigned long last_reset =3D INITIAL_JIFFIES; =20 @@ -566,12 +554,12 @@ static ssize_t rt2x00debug_write_restart_hw(struct fi= le *file, last_reset =3D jiffies; =20 ieee80211_restart_hw(rt2x00dev->hw); - return length; + return iov_iter_count(from); } =20 static const struct file_operations rt2x00debug_restart_hw =3D { .owner =3D THIS_MODULE, - .write =3D rt2x00debug_write_restart_hw, + .write_iter =3D rt2x00debug_write_restart_hw, .open =3D simple_open, .llseek =3D generic_file_llseek, }; --=20 2.43.0