[PATCH 015/437] char/nsc_gpio: convert to read/write iterators

Jens Axboe
2024-04-11T15:31:56Z

drivers/char/nsc_gpio.c | 22 ++++++++++++++++------
include/linux/nsc_gpio.h | 8 ++------
2 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/drivers/char/nsc_gpio.c b/drivers/char/nsc_gpio.c
index da930c72bc74..0df6fb1232cd 100644
--- a/drivers/char/nsc_gpio.c
+++ b/drivers/char/nsc_gpio.c
@@ -39,8 +39,8 @@ void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index)
amp->gpio_get(index), amp->gpio_current(index));
}

-ssize_t nsc_gpio_write(struct file *file, const char __user *data,
- size_t len, loff_t *ppos)
+static ssize_t nsc_gpio_write(struct file *file, const char __user *data,
+ size_t len, loff_t *ppos)
{
unsigned m = iminor(file_inode(file));
struct nsc_gpio_ops *amp = file->private_data;
@@ -102,8 +102,8 @@ ssize_t nsc_gpio_write(struct file *file, const char __user *data,
return len;
}

-ssize_t nsc_gpio_read(struct file *file, char __user * buf,
- size_t len, loff_t * ppos)
+static ssize_t nsc_gpio_read(struct file *file, char __user * buf, size_t len,
+ loff_t * ppos)
{
unsigned m = iminor(file_inode(file));
int value;
@@ -116,9 +116,19 @@ ssize_t nsc_gpio_read(struct file *file, char __user * buf,
return 1;
}

+ssize_t nsc_gpio_read_iter(struct kiocb *iocb, struct iov_iter *to)
+{
+ return vfs_read_iter(iocb, to, nsc_gpio_read);
+}
+EXPORT_SYMBOL(nsc_gpio_read_iter);
+
+ssize_t nsc_gpio_write_iter(struct kiocb *iocb, struct iov_iter *from)
+{
+ return vfs_write_iter(iocb, from, nsc_gpio_write);
+}
+EXPORT_SYMBOL(nsc_gpio_write_iter);
+
/* common file-ops routines for both scx200_gpio and pc87360_gpio */
-EXPORT_SYMBOL(nsc_gpio_write);
-EXPORT_SYMBOL(nsc_gpio_read);
EXPORT_SYMBOL(nsc_gpio_dump);

static int __init nsc_gpio_init(void)
diff --git a/include/linux/nsc_gpio.h b/include/linux/nsc_gpio.h
index d7a04a6e3783..a97111b2e85d 100644
--- a/include/linux/nsc_gpio.h
+++ b/include/linux/nsc_gpio.h
@@ -31,11 +31,7 @@ struct nsc_gpio_ops {
struct device* dev; /* for dev_dbg() support, set in init */
};

-extern ssize_t nsc_gpio_write(struct file *file, const char __user *data,
- size_t len, loff_t *ppos);
-
-extern ssize_t nsc_gpio_read(struct file *file, char __user *buf,
- size_t len, loff_t *ppos);
-
+ssize_t nsc_gpio_write_iter(struct kiocb *iocb, struct iov_iter *from);
+ssize_t nsc_gpio_read_iter(struct kiocb *iocb, struct iov_iter *to);
extern void nsc_gpio_dump(struct nsc_gpio_ops *amp, unsigned index);

--
2.43.0