[PATCH 306/437] drivers/net/wireless/broadcom: convert to read/write iterators

Jens Axboe
2024-04-11T15:40:10Z

drivers/net/wireless/broadcom/b43/debugfs.c | 30 +++++++++---------
.../net/wireless/broadcom/b43legacy/debugfs.c | 31 +++++++++----------
.../broadcom/brcm80211/brcmfmac/core.c | 10 +++---
.../broadcom/brcm80211/brcmsmac/debug.c | 2 +-
4 files changed, 35 insertions(+), 38 deletions(-)

diff --git a/drivers/net/wireless/broadcom/b43/debugfs.c b/drivers/net/wireless/broadcom/b43/debugfs.c
index efa98444e3fb..bd82fc337500 100644
--- a/drivers/net/wireless/broadcom/b43/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43/debugfs.c
@@ -487,8 +487,7 @@ static ssize_t loctls_read_file(struct b43_wldev *dev,

#undef fappend

-static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
- size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
{
struct b43_wldev *dev;
struct b43_debugfs_fops *dfops;
@@ -497,11 +496,12 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
char *buf;
const size_t bufsize = 1024 * 16; /* 16 kiB buffer */
const size_t buforder = get_order(bufsize);
+ size_t count = iov_iter_count(to);
int err = 0;

if (!count)
return 0;
- dev = file->private_data;
+ dev = iocb->ki_filp->private_data;
if (!dev)
return -ENODEV;

@@ -511,7 +511,7 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
goto out_unlock;
}

- dfops = container_of(debugfs_real_fops(file),
+ dfops = container_of(debugfs_real_fops(iocb->ki_filp),
struct b43_debugfs_fops, fops);
if (!dfops->read) {
err = -ENOSYS;
@@ -536,10 +536,9 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
dfile->buffer = buf;
}

- ret = simple_read_from_buffer(userbuf, count, ppos,
- dfile->buffer,
- dfile->data_len);
- if (*ppos >= dfile->data_len) {
+ ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos, dfile->data_len,
+ to);
+ if (iocb->ki_pos >= dfile->data_len) {
free_pages((unsigned long)dfile->buffer, buforder);
dfile->buffer = NULL;
dfile->data_len = 0;
@@ -550,12 +549,11 @@ static ssize_t b43_debugfs_read(struct file *file, char __user *userbuf,
return err ? err : ret;
}

-static ssize_t b43_debugfs_write(struct file *file,
- const char __user *userbuf,
- size_t count, loff_t *ppos)
+static ssize_t b43_debugfs_write(struct kiocb *iocb, struct iov_iter *from)
{
struct b43_wldev *dev;
struct b43_debugfs_fops *dfops;
+ size_t count = iov_iter_count(from);
char *buf;
int err = 0;

@@ -563,7 +561,7 @@ static ssize_t b43_debugfs_write(struct file *file,
return 0;
if (count > PAGE_SIZE)
return -E2BIG;
- dev = file->private_data;
+ dev = iocb->ki_filp->private_data;
if (!dev)
return -ENODEV;

@@ -573,7 +571,7 @@ static ssize_t b43_debugfs_write(struct file *file,
goto out_unlock;
}

- dfops = container_of(debugfs_real_fops(file),
+ dfops = container_of(debugfs_real_fops(iocb->ki_filp),
struct b43_debugfs_fops, fops);
if (!dfops->write) {
err = -ENOSYS;
@@ -585,7 +583,7 @@ static ssize_t b43_debugfs_write(struct file *file,
err = -ENOMEM;
goto out_unlock;
}
- if (copy_from_user(buf, userbuf, count)) {
+ if (!copy_from_iter_full(buf, count, from)) {
err = -EFAULT;
goto out_freepage;
}
@@ -608,8 +606,8 @@ static ssize_t b43_debugfs_write(struct file *file,
.write = _write, \
.fops = { \
.open = simple_open, \
- .read = b43_debugfs_read, \
- .write = b43_debugfs_write, \
+ .read_iter = b43_debugfs_read, \
+ .write_iter = b43_debugfs_write, \
.llseek = generic_file_llseek, \
}, \
.file_struct_offset = offsetof(struct b43_dfsentry, \
diff --git a/drivers/net/wireless/broadcom/b43legacy/debugfs.c b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
index 6b0e8d117061..3746e2fab874 100644
--- a/drivers/net/wireless/broadcom/b43legacy/debugfs.c
+++ b/drivers/net/wireless/broadcom/b43legacy/debugfs.c
@@ -184,8 +184,7 @@ static int restart_write_file(struct b43legacy_wldev *dev, const char *buf, size

#undef fappend

-static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
- size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_read(struct kiocb *iocb, struct iov_iter *to)
{
struct b43legacy_wldev *dev;
struct b43legacy_debugfs_fops *dfops;
@@ -194,11 +193,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
char *buf;
const size_t bufsize = 1024 * 16; /* 16 KiB buffer */
const size_t buforder = get_order(bufsize);
+ size_t count = iov_iter_count(to);
int err = 0;

if (!count)
return 0;
- dev = file->private_data;
+ dev = iocb->ki_filp->private_data;
if (!dev)
return -ENODEV;

@@ -208,7 +208,7 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
goto out_unlock;
}

- dfops = container_of(debugfs_real_fops(file),
+ dfops = container_of(debugfs_real_fops(iocb->ki_filp),
struct b43legacy_debugfs_fops, fops);
if (!dfops->read) {
err = -ENOSYS;
@@ -238,10 +238,9 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
dfile->buffer = buf;
}

- ret = simple_read_from_buffer(userbuf, count, ppos,
- dfile->buffer,
- dfile->data_len);
- if (*ppos >= dfile->data_len) {
+ ret = simple_copy_to_iter(dfile->buffer, &iocb->ki_pos,
+ dfile->data_len, to);
+ if (iocb->ki_pos >= dfile->data_len) {
free_pages((unsigned long)dfile->buffer, buforder);
dfile->buffer = NULL;
dfile->data_len = 0;
@@ -252,12 +251,12 @@ static ssize_t b43legacy_debugfs_read(struct file *file, char __user *userbuf,
return err ? err : ret;
}

-static ssize_t b43legacy_debugfs_write(struct file *file,
- const char __user *userbuf,
- size_t count, loff_t *ppos)
+static ssize_t b43legacy_debugfs_write(struct kiocb *iocb,
+ struct iov_iter *from)
{
struct b43legacy_wldev *dev;
struct b43legacy_debugfs_fops *dfops;
+ size_t count = iov_iter_count(from);
char *buf;
int err = 0;

@@ -265,7 +264,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
return 0;
if (count > PAGE_SIZE)
return -E2BIG;
- dev = file->private_data;
+ dev = iocb->ki_filp->private_data;
if (!dev)
return -ENODEV;

@@ -275,7 +274,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
goto out_unlock;
}

- dfops = container_of(debugfs_real_fops(file),
+ dfops = container_of(debugfs_real_fops(iocb->ki_filp),
struct b43legacy_debugfs_fops, fops);
if (!dfops->write) {
err = -ENOSYS;
@@ -287,7 +286,7 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
err = -ENOMEM;
goto out_unlock;
}
- if (copy_from_user(buf, userbuf, count)) {
+ if (!copy_from_iter_full(buf, count, from)) {
err = -EFAULT;
goto out_freepage;
}
@@ -315,8 +314,8 @@ static ssize_t b43legacy_debugfs_write(struct file *file,
.write = _write, \
.fops = { \
.open = simple_open, \
- .read = b43legacy_debugfs_read, \
- .write = b43legacy_debugfs_write, \
+ .read_iter = b43legacy_debugfs_read, \
+ .write_iter = b43legacy_debugfs_write, \
.llseek = generic_file_llseek, \
}, \
.file_struct_offset = offsetof(struct b43legacy_dfsentry, \
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
index bf91b1e1368f..d02dd7944bad 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
@@ -1165,13 +1165,13 @@ static void brcmf_core_bus_reset(struct work_struct *work)
brcmf_bus_reset(drvr->bus_if);
}

-static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t bus_reset_write(struct kiocb *iocb, struct iov_iter *from)
{
- struct brcmf_pub *drvr = file->private_data;
+ struct brcmf_pub *drvr = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(from);
u8 value;

- if (kstrtou8_from_user(user_buf, count, 0, &value))
+ if (kstrtou8_from_iter(from, count, 0, &value))
return -EINVAL;

if (value != 1)
@@ -1185,7 +1185,7 @@ static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
static const struct file_operations bus_reset_fops = {
.open = simple_open,
.llseek = no_llseek,
- .write = bus_reset_write,
+ .write_iter = bus_reset_write,
};

static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
index 6d776ef6ff54..cfc7ff6d3503 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/debug.c
@@ -182,7 +182,7 @@ static const struct file_operations brcms_debugfs_def_ops = {
.owner = THIS_MODULE,
.open = brcms_debugfs_entry_open,
.release = single_release,
- .read = seq_read,
+ .read_iter = seq_read_iter,
.llseek = seq_lseek
};

--
2.43.0