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

Christoph Hellwig hch at lst.de
Mon Aug 17 17:32:02 AEST 2020


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 at zeniv.linux.org.uk>
Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 drivers/char/mem.c | 16 ----------------
 1 file changed, 16 deletions(-)

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,
-- 
2.28.0



More information about the Linuxppc-dev mailing list