diff mbox series

[01/11] mem: remove duplicate ops for /dev/zero and /dev/null

Message ID 20200817073212.830069-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/11] mem: remove duplicate ops for /dev/zero and /dev/null | expand

Commit Message

Christoph Hellwig Aug. 17, 2020, 7:32 a.m. UTC
There is no good reason to implement both the traditional ->read and
->write as well as the iter based ops.  So implement just the iter
based ones.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 drivers/char/mem.c | 16 ----------------
 1 file changed, 16 deletions(-)

Comments

Kees Cook Aug. 18, 2020, 7:33 p.m. UTC | #1
On Mon, Aug 17, 2020 at 09:32:02AM +0200, Christoph Hellwig wrote:
> There is no good reason to implement both the traditional ->read and
> ->write as well as the iter based ops.  So implement just the iter
> based ones.
> 
> Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Reviewed-by: Kees Cook <keescook@chromium.org>
diff mbox series

Patch

diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index 687d4af6945d36..14851f36787372 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -670,18 +670,6 @@  static ssize_t write_port(struct file *file, const char __user *buf,
 	return tmp-buf;
 }
 
-static ssize_t read_null(struct file *file, char __user *buf,
-			 size_t count, loff_t *ppos)
-{
-	return 0;
-}
-
-static ssize_t write_null(struct file *file, const char __user *buf,
-			  size_t count, loff_t *ppos)
-{
-	return count;
-}
-
 static ssize_t read_iter_null(struct kiocb *iocb, struct iov_iter *to)
 {
 	return 0;
@@ -872,7 +860,6 @@  static int open_port(struct inode *inode, struct file *filp)
 
 #define zero_lseek	null_lseek
 #define full_lseek      null_lseek
-#define write_zero	write_null
 #define write_iter_zero	write_iter_null
 #define open_mem	open_port
 #define open_kmem	open_mem
@@ -903,8 +890,6 @@  static const struct file_operations __maybe_unused kmem_fops = {
 
 static const struct file_operations null_fops = {
 	.llseek		= null_lseek,
-	.read		= read_null,
-	.write		= write_null,
 	.read_iter	= read_iter_null,
 	.write_iter	= write_iter_null,
 	.splice_write	= splice_write_null,
@@ -919,7 +904,6 @@  static const struct file_operations __maybe_unused port_fops = {
 
 static const struct file_operations zero_fops = {
 	.llseek		= zero_lseek,
-	.write		= write_zero,
 	.read_iter	= read_iter_zero,
 	.write_iter	= write_iter_zero,
 	.mmap		= mmap_zero,