Skip to content

Commit 3cfc029

Browse files
committed
drivers/iovec: revert vector io implement from loop/null/zero driver
basic driver does not need such complex wrapper Signed-off-by: chao an <[email protected]>
1 parent dc3ab55 commit 3cfc029

File tree

3 files changed

+65
-75
lines changed

3 files changed

+65
-75
lines changed

drivers/loop/loop.c

+15-16
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
* Private Function Prototypes
4141
****************************************************************************/
4242

43-
static ssize_t loop_readv(FAR struct file *filep, FAR struct uio *uio);
44-
static ssize_t loop_writev(FAR struct file *filep, FAR struct uio *uio);
43+
static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
44+
size_t buflen);
45+
static ssize_t loop_write(FAR struct file *filep, FAR const char *buffer,
46+
size_t buflen);
4547
static int loop_ioctl(FAR struct file *filep, int cmd,
4648
unsigned long arg);
4749

@@ -53,42 +55,39 @@ static const struct file_operations g_loop_fops =
5355
{
5456
NULL, /* open */
5557
NULL, /* close */
56-
NULL, /* read */
57-
NULL, /* write */
58+
loop_read, /* read */
59+
loop_write, /* write */
5860
NULL, /* seek */
5961
loop_ioctl, /* ioctl */
6062
NULL, /* mmap */
6163
NULL, /* truncate */
6264
NULL, /* poll */
63-
loop_readv, /* readv */
64-
loop_writev /* writev */
65+
NULL, /* readv */
66+
NULL /* writev */
6567
};
6668

6769
/****************************************************************************
6870
* Private Functions
6971
****************************************************************************/
7072

7173
/****************************************************************************
72-
* Name: loop_readv
74+
* Name: loop_read
7375
****************************************************************************/
7476

75-
static ssize_t loop_readv(FAR struct file *filep, FAR struct uio *uio)
77+
static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
78+
size_t len)
7679
{
7780
return 0; /* Return EOF */
7881
}
7982

8083
/****************************************************************************
81-
* Name: loop_writev
84+
* Name: loop_write
8285
****************************************************************************/
8386

84-
static ssize_t loop_writev(FAR struct file *filep, FAR struct uio *uio)
87+
static ssize_t loop_write(FAR struct file *filep, FAR const char *buffer,
88+
size_t len)
8589
{
86-
/* Say that everything was written */
87-
88-
size_t ret = uio->uio_resid;
89-
90-
uio_advance(uio, ret);
91-
return ret;
90+
return len; /* Say that everything was written */
9291
}
9392

9493
/****************************************************************************

drivers/misc/dev_null.c

+25-24
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
* Private Function Prototypes
4141
****************************************************************************/
4242

43-
static ssize_t devnull_readv(FAR struct file *filep, FAR struct uio *uio);
44-
static ssize_t devnull_writev(FAR struct file *filep, FAR struct uio *uio);
43+
static ssize_t devnull_read(FAR struct file *filep, FAR char *buffer,
44+
size_t buflen);
45+
static ssize_t devnull_write(FAR struct file *filep, FAR const char *buffer,
46+
size_t buflen);
4547
static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
4648
bool setup);
4749

@@ -51,49 +53,48 @@ static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
5153

5254
static const struct file_operations g_devnull_fops =
5355
{
54-
NULL, /* open */
55-
NULL, /* close */
56-
NULL, /* read */
57-
NULL, /* writev */
58-
NULL, /* seek */
59-
NULL, /* ioctl */
60-
NULL, /* mmap */
61-
NULL, /* truncate */
62-
devnull_poll, /* poll */
63-
devnull_readv, /* readv */
64-
devnull_writev /* writev */
56+
NULL, /* open */
57+
NULL, /* close */
58+
devnull_read, /* read */
59+
devnull_write, /* write */
60+
NULL, /* seek */
61+
NULL, /* ioctl */
62+
NULL, /* mmap */
63+
NULL, /* truncate */
64+
devnull_poll, /* poll */
65+
NULL, /* readv */
66+
NULL /* writev */
6567
};
6668

6769
/****************************************************************************
6870
* Private Functions
6971
****************************************************************************/
7072

7173
/****************************************************************************
72-
* Name: devnull_readv
74+
* Name: devnull_read
7375
****************************************************************************/
7476

75-
static ssize_t devnull_readv(FAR struct file *filep, FAR struct uio *uio)
77+
static ssize_t devnull_read(FAR struct file *filep, FAR char *buffer,
78+
size_t len)
7679
{
7780
UNUSED(filep);
78-
UNUSED(uio);
81+
UNUSED(buffer);
82+
UNUSED(len);
7983

8084
return 0; /* Return EOF */
8185
}
8286

8387
/****************************************************************************
84-
* Name: devnull_writev
88+
* Name: devnull_write
8589
****************************************************************************/
8690

87-
static ssize_t devnull_writev(FAR struct file *filep, FAR struct uio *uio)
91+
static ssize_t devnull_write(FAR struct file *filep, FAR const char *buffer,
92+
size_t len)
8893
{
8994
UNUSED(filep);
95+
UNUSED(buffer);
9096

91-
/* Say that everything was written */
92-
93-
size_t ret = uio->uio_resid;
94-
95-
uio_advance(uio, ret);
96-
return ret;
97+
return len; /* Say that everything was written */
9798
}
9899

99100
/****************************************************************************

drivers/misc/dev_zero.c

+25-35
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
* Private Function Prototypes
4141
****************************************************************************/
4242

43-
static ssize_t devzero_readv(FAR struct file *filep, FAR struct uio *uio);
44-
static ssize_t devzero_writev(FAR struct file *filep, FAR struct uio *uio);
43+
static ssize_t devzero_read(FAR struct file *filep, FAR char *buffer,
44+
size_t buflen);
45+
static ssize_t devzero_write(FAR struct file *filep, FAR const char *buffer,
46+
size_t buflen);
4547
static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
4648
bool setup);
4749

@@ -51,59 +53,47 @@ static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
5153

5254
static const struct file_operations g_devzero_fops =
5355
{
54-
NULL, /* open */
55-
NULL, /* close */
56-
NULL, /* read */
57-
NULL, /* write */
58-
NULL, /* seek */
59-
NULL, /* ioctl */
60-
NULL, /* mmap */
61-
NULL, /* truncate */
62-
devzero_poll, /* poll */
63-
devzero_readv, /* readv */
64-
devzero_writev /* writev */
56+
NULL, /* open */
57+
NULL, /* close */
58+
devzero_read, /* read */
59+
devzero_write, /* write */
60+
NULL, /* seek */
61+
NULL, /* ioctl */
62+
NULL, /* mmap */
63+
NULL, /* truncate */
64+
devzero_poll, /* poll */
65+
NULL, /* readv */
66+
NULL /* writev */
6567
};
6668

6769
/****************************************************************************
6870
* Private Functions
6971
****************************************************************************/
7072

7173
/****************************************************************************
72-
* Name: devzero_readv
74+
* Name: devzero_read
7375
****************************************************************************/
7476

75-
static ssize_t devzero_readv(FAR struct file *filep, FAR struct uio *uio)
77+
static ssize_t devzero_read(FAR struct file *filep, FAR char *buffer,
78+
size_t len)
7679
{
77-
size_t total = uio->uio_resid;
78-
FAR const struct iovec *iov = uio->uio_iov;
79-
int iovcnt = uio->uio_iovcnt;
80-
int i;
81-
8280
UNUSED(filep);
8381

84-
for (i = 0; i < iovcnt; i++)
85-
{
86-
memset(iov[i].iov_base, 0, iov[i].iov_len);
87-
}
88-
89-
uio_advance(uio, total);
90-
91-
return total;
82+
memset(buffer, 0, len);
83+
return len;
9284
}
9385

9486
/****************************************************************************
95-
* Name: devzero_writev
87+
* Name: devzero_write
9688
****************************************************************************/
9789

98-
static ssize_t devzero_writev(FAR struct file *filep, FAR struct uio *uio)
90+
static ssize_t devzero_write(FAR struct file *filep, FAR const char *buffer,
91+
size_t len)
9992
{
100-
size_t total;
10193
UNUSED(filep);
94+
UNUSED(buffer);
10295

103-
total = uio->uio_resid;
104-
105-
uio_advance(uio, total);
106-
return total;
96+
return len;
10797
}
10898

10999
/****************************************************************************

0 commit comments

Comments
 (0)