drivers/iovec: revert vector io implement from loop/null/zero driver

basic driver does not need such complex wrapper

Signed-off-by: chao an <anchao.archer@bytedance.com>
This commit is contained in:
chao an 2025-01-19 21:34:12 +08:00 committed by Xiang Xiao
parent 5918335b7f
commit 0ffb0b716e
3 changed files with 65 additions and 75 deletions

View file

@ -40,8 +40,10 @@
* Private Function Prototypes
****************************************************************************/
static ssize_t loop_readv(FAR struct file *filep, FAR struct uio *uio);
static ssize_t loop_writev(FAR struct file *filep, FAR struct uio *uio);
static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t loop_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int loop_ioctl(FAR struct file *filep, int cmd,
unsigned long arg);
@ -53,15 +55,15 @@ static const struct file_operations g_loop_fops =
{
NULL, /* open */
NULL, /* close */
NULL, /* read */
NULL, /* write */
loop_read, /* read */
loop_write, /* write */
NULL, /* seek */
loop_ioctl, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
NULL, /* poll */
loop_readv, /* readv */
loop_writev /* writev */
NULL, /* readv */
NULL /* writev */
};
/****************************************************************************
@ -69,26 +71,23 @@ static const struct file_operations g_loop_fops =
****************************************************************************/
/****************************************************************************
* Name: loop_readv
* Name: loop_read
****************************************************************************/
static ssize_t loop_readv(FAR struct file *filep, FAR struct uio *uio)
static ssize_t loop_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
return 0; /* Return EOF */
}
/****************************************************************************
* Name: loop_writev
* Name: loop_write
****************************************************************************/
static ssize_t loop_writev(FAR struct file *filep, FAR struct uio *uio)
static ssize_t loop_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
/* Say that everything was written */
size_t ret = uio->uio_resid;
uio_advance(uio, ret);
return ret;
return len; /* Say that everything was written */
}
/****************************************************************************

View file

@ -40,8 +40,10 @@
* Private Function Prototypes
****************************************************************************/
static ssize_t devnull_readv(FAR struct file *filep, FAR struct uio *uio);
static ssize_t devnull_writev(FAR struct file *filep, FAR struct uio *uio);
static ssize_t devnull_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t devnull_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
@ -51,17 +53,17 @@ static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
static const struct file_operations g_devnull_fops =
{
NULL, /* open */
NULL, /* close */
NULL, /* read */
NULL, /* writev */
NULL, /* seek */
NULL, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
devnull_poll, /* poll */
devnull_readv, /* readv */
devnull_writev /* writev */
NULL, /* open */
NULL, /* close */
devnull_read, /* read */
devnull_write, /* write */
NULL, /* seek */
NULL, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
devnull_poll, /* poll */
NULL, /* readv */
NULL /* writev */
};
/****************************************************************************
@ -69,31 +71,30 @@ static const struct file_operations g_devnull_fops =
****************************************************************************/
/****************************************************************************
* Name: devnull_readv
* Name: devnull_read
****************************************************************************/
static ssize_t devnull_readv(FAR struct file *filep, FAR struct uio *uio)
static ssize_t devnull_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
UNUSED(filep);
UNUSED(uio);
UNUSED(buffer);
UNUSED(len);
return 0; /* Return EOF */
}
/****************************************************************************
* Name: devnull_writev
* Name: devnull_write
****************************************************************************/
static ssize_t devnull_writev(FAR struct file *filep, FAR struct uio *uio)
static ssize_t devnull_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
UNUSED(filep);
UNUSED(buffer);
/* Say that everything was written */
size_t ret = uio->uio_resid;
uio_advance(uio, ret);
return ret;
return len; /* Say that everything was written */
}
/****************************************************************************

View file

@ -40,8 +40,10 @@
* Private Function Prototypes
****************************************************************************/
static ssize_t devzero_readv(FAR struct file *filep, FAR struct uio *uio);
static ssize_t devzero_writev(FAR struct file *filep, FAR struct uio *uio);
static ssize_t devzero_read(FAR struct file *filep, FAR char *buffer,
size_t buflen);
static ssize_t devzero_write(FAR struct file *filep, FAR const char *buffer,
size_t buflen);
static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
bool setup);
@ -51,17 +53,17 @@ static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
static const struct file_operations g_devzero_fops =
{
NULL, /* open */
NULL, /* close */
NULL, /* read */
NULL, /* write */
NULL, /* seek */
NULL, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
devzero_poll, /* poll */
devzero_readv, /* readv */
devzero_writev /* writev */
NULL, /* open */
NULL, /* close */
devzero_read, /* read */
devzero_write, /* write */
NULL, /* seek */
NULL, /* ioctl */
NULL, /* mmap */
NULL, /* truncate */
devzero_poll, /* poll */
NULL, /* readv */
NULL /* writev */
};
/****************************************************************************
@ -69,41 +71,29 @@ static const struct file_operations g_devzero_fops =
****************************************************************************/
/****************************************************************************
* Name: devzero_readv
* Name: devzero_read
****************************************************************************/
static ssize_t devzero_readv(FAR struct file *filep, FAR struct uio *uio)
static ssize_t devzero_read(FAR struct file *filep, FAR char *buffer,
size_t len)
{
size_t total = uio->uio_resid;
FAR const struct iovec *iov = uio->uio_iov;
int iovcnt = uio->uio_iovcnt;
int i;
UNUSED(filep);
for (i = 0; i < iovcnt; i++)
{
memset(iov[i].iov_base, 0, iov[i].iov_len);
}
uio_advance(uio, total);
return total;
memset(buffer, 0, len);
return len;
}
/****************************************************************************
* Name: devzero_writev
* Name: devzero_write
****************************************************************************/
static ssize_t devzero_writev(FAR struct file *filep, FAR struct uio *uio)
static ssize_t devzero_write(FAR struct file *filep, FAR const char *buffer,
size_t len)
{
size_t total;
UNUSED(filep);
UNUSED(buffer);
total = uio->uio_resid;
uio_advance(uio, total);
return total;
return len;
}
/****************************************************************************