[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240411153126.16201-153-axboe@kernel.dk>
Date: Thu, 11 Apr 2024 09:14:52 -0600
From: Jens Axboe <axboe@...nel.dk>
To: linux-kernel@...r.kernel.org
Cc: Jens Axboe <axboe@...nel.dk>
Subject: [PATCH 152/437] drivers/rtc: convert to read/write iterators
Signed-off-by: Jens Axboe <axboe@...nel.dk>
---
drivers/rtc/dev.c | 20 ++++++++------------
drivers/rtc/rtc-m41t80.c | 18 +++++++-----------
2 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/drivers/rtc/dev.c b/drivers/rtc/dev.c
index 4aad9bb99868..b37e6d448ee4 100644
--- a/drivers/rtc/dev.c
+++ b/drivers/rtc/dev.c
@@ -138,10 +138,10 @@ EXPORT_SYMBOL(rtc_dev_update_irq_enable_emul);
#endif /* CONFIG_RTC_INTF_DEV_UIE_EMUL */
-static ssize_t
-rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
+static ssize_t rtc_dev_read(struct kiocb *iocb, struct iov_iter *to)
{
- struct rtc_device *rtc = file->private_data;
+ struct rtc_device *rtc = iocb->ki_filp->private_data;
+ size_t count = iov_iter_count(to);
DECLARE_WAITQUEUE(wait, current);
unsigned long data;
@@ -163,7 +163,7 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
ret = 0;
break;
}
- if (file->f_flags & O_NONBLOCK) {
+ if (iocb->ki_filp->f_flags & O_NONBLOCK) {
ret = -EAGAIN;
break;
}
@@ -177,13 +177,9 @@ rtc_dev_read(struct file *file, char __user *buf, size_t count, loff_t *ppos)
remove_wait_queue(&rtc->irq_queue, &wait);
if (ret == 0) {
- if (sizeof(int) != sizeof(long) &&
- count == sizeof(unsigned int))
- ret = put_user(data, (unsigned int __user *)buf) ?:
- sizeof(unsigned int);
- else
- ret = put_user(data, (unsigned long __user *)buf) ?:
- sizeof(unsigned long);
+ ret = sizeof(data);
+ if (put_iter(data, to))
+ ret = -EFAULT;
}
return ret;
}
@@ -524,7 +520,7 @@ static int rtc_dev_release(struct inode *inode, struct file *file)
static const struct file_operations rtc_dev_fops = {
.owner = THIS_MODULE,
.llseek = no_llseek,
- .read = rtc_dev_read,
+ .read_iter = rtc_dev_read,
.poll = rtc_dev_poll,
.unlocked_ioctl = rtc_dev_ioctl,
#ifdef CONFIG_COMPAT
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c
index 0013bff0447d..2487aafd9698 100644
--- a/drivers/rtc/rtc-m41t80.c
+++ b/drivers/rtc/rtc-m41t80.c
@@ -686,26 +686,22 @@ static void wdt_disable(void)
/**
* wdt_write - write to watchdog.
- * @file: file handle to the watchdog
- * @buf: buffer to write (unused as data does not matter here
- * @count: count of bytes
- * @ppos: pointer to the position to write. No seeks allowed
+ * @iocb: metadata for IO
+ * @from: buffer to write (unused as data does not matter here
*
* A write to a watchdog device is defined as a keepalive signal. Any
* write of data will do, as we don't define content meaning.
*/
-static ssize_t wdt_write(struct file *file, const char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t wdt_write(struct kiocb *iocb, struct iov_iter *from)
{
- if (count) {
+ if (iov_iter_count(from)) {
wdt_ping();
return 1;
}
return 0;
}
-static ssize_t wdt_read(struct file *file, char __user *buf,
- size_t count, loff_t *ppos)
+static ssize_t wdt_read(struct kiocb *iocb, struct iov_iter *to)
{
return 0;
}
@@ -844,10 +840,10 @@ static int wdt_notify_sys(struct notifier_block *this, unsigned long code,
static const struct file_operations wdt_fops = {
.owner = THIS_MODULE,
- .read = wdt_read,
+ .read_iter = wdt_read,
.unlocked_ioctl = wdt_unlocked_ioctl,
.compat_ioctl = compat_ptr_ioctl,
- .write = wdt_write,
+ .write_iter = wdt_write,
.open = wdt_open,
.release = wdt_release,
.llseek = no_llseek,
--
2.43.0
Powered by blists - more mailing lists