[PATCH 337/437] powerpc/kernel: convert to read/write iterators

Jens Axboe
2024-04-11T15:41:00Z

arch/powerpc/kernel/eeh.c | 58 ++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index ab316e155ea9..35ea1c80e0de 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1588,9 +1588,8 @@ static int proc_eeh_show(struct seq_file *m, void *v)
#ifdef CONFIG_DEBUG_FS

-static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static struct pci_dev *eeh_debug_lookup_pdev(struct kiocb *iocb,
+ struct iov_iter *from)
{
uint32_t domain, bus, dev, fn;
struct pci_dev *pdev;
@@ -1598,7 +1597,7 @@ static struct pci_dev *eeh_debug_lookup_pdev(struct file *filp,
int ret;

memset(buf, 0, sizeof(buf));
- ret = simple_write_to_buffer(buf, sizeof(buf)-1, ppos, user_buf, count);
+ ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf)-1, from);
if (!ret)
return ERR_PTR(-EFAULT);

@@ -1637,17 +1636,16 @@ static int eeh_enable_dbgfs_get(void *data, u64 *val)
DEFINE_DEBUGFS_ATTRIBUTE(eeh_enable_dbgfs_ops, eeh_enable_dbgfs_get,
eeh_enable_dbgfs_set, "0x%llx\n");

-static ssize_t eeh_force_recover_write(struct file *filp,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t eeh_force_recover_write(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
struct pci_controller *hose;
uint32_t phbid, pe_no;
struct eeh_pe *pe;
char buf[20];
int ret;

- ret = simple_write_to_buffer(buf, sizeof(buf), ppos, user_buf, count);
+ ret = simple_copy_from_iter(buf, &iocb->ki_pos, sizeof(buf), from);
if (!ret)
return -EFAULT;

@@ -1690,28 +1688,23 @@ static ssize_t eeh_force_recover_write(struct file *filp,
static const struct file_operations eeh_force_recover_fops = {
.open = simple_open,
.llseek = no_llseek,
- .write = eeh_force_recover_write,
+ .write_iter = eeh_force_recover_write,
};

-static ssize_t eeh_debugfs_dev_usage(struct file *filp,
- char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t eeh_debugfs_dev_usage(struct kiocb *iocb, struct iov_iter *to)
{
static const char usage[] = "input format: <domain>:<bus>:<dev>. \n";

- return simple_read_from_buffer(user_buf, count, ppos,
- usage, sizeof(usage) - 1);
+ return simple_copy_to_iter(usage, &iocb->ki_pos, sizeof(usage) - 1, to);
}

-static ssize_t eeh_dev_check_write(struct file *filp,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t eeh_dev_check_write(struct kiocb *iocb, struct iov_iter *from)
{
struct pci_dev *pdev;
struct eeh_dev *edev;
int ret;

- pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+ pdev = eeh_debug_lookup_pdev(iocb, from);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

@@ -1728,14 +1721,14 @@ static ssize_t eeh_dev_check_write(struct file *filp,

pci_dev_put(pdev);

- return count;
+ return iov_iter_count(from);
}

static const struct file_operations eeh_dev_check_fops = {
.open = simple_open,
.llseek = no_llseek,
- .write = eeh_dev_check_write,
- .read = eeh_debugfs_dev_usage,
+ .write_iter = eeh_dev_check_write,
+ .read_iter = eeh_debugfs_dev_usage,
};

static int eeh_debugfs_break_device(struct pci_dev *pdev)
@@ -1831,14 +1824,12 @@ static int eeh_debugfs_break_device(struct pci_dev *pdev)
return 0;
}

-static ssize_t eeh_dev_break_write(struct file *filp,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t eeh_dev_break_write(struct kiocb *iocb, struct iov_iter *from)
{
struct pci_dev *pdev;
int ret;

- pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+ pdev = eeh_debug_lookup_pdev(iocb, from);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

@@ -1848,25 +1839,24 @@ static ssize_t eeh_dev_break_write(struct file *filp,
if (ret < 0)
return ret;

- return count;
+ return iov_iter_count(from);
}

static const struct file_operations eeh_dev_break_fops = {
.open = simple_open,
.llseek = no_llseek,
- .write = eeh_dev_break_write,
- .read = eeh_debugfs_dev_usage,
+ .write_iter = eeh_dev_break_write,
+ .read_iter = eeh_debugfs_dev_usage,
};

-static ssize_t eeh_dev_can_recover(struct file *filp,
- const char __user *user_buf,
- size_t count, loff_t *ppos)
+static ssize_t eeh_dev_can_recover(struct kiocb *iocb, struct iov_iter *from)
{
+ size_t count = iov_iter_count(from);
struct pci_driver *drv;
struct pci_dev *pdev;
size_t ret;

- pdev = eeh_debug_lookup_pdev(filp, user_buf, count, ppos);
+ pdev = eeh_debug_lookup_pdev(iocb, from);
if (IS_ERR(pdev))
return PTR_ERR(pdev);

@@ -1901,8 +1891,8 @@ static ssize_t eeh_dev_can_recover(struct file *filp,
static const struct file_operations eeh_dev_can_recover_fops = {
.open = simple_open,
.llseek = no_llseek,
- .write = eeh_dev_can_recover,
- .read = eeh_debugfs_dev_usage,
+ .write_iter = eeh_dev_can_recover,
+ .read_iter = eeh_debugfs_dev_usage,
};

#endif
--
2.43.0