mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
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:
+15
-16
@@ -40,8 +40,10 @@
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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,
|
||||||
static ssize_t loop_writev(FAR struct file *filep, FAR struct uio *uio);
|
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,
|
static int loop_ioctl(FAR struct file *filep, int cmd,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
|
|
||||||
@@ -53,15 +55,15 @@ static const struct file_operations g_loop_fops =
|
|||||||
{
|
{
|
||||||
NULL, /* open */
|
NULL, /* open */
|
||||||
NULL, /* close */
|
NULL, /* close */
|
||||||
NULL, /* read */
|
loop_read, /* read */
|
||||||
NULL, /* write */
|
loop_write, /* write */
|
||||||
NULL, /* seek */
|
NULL, /* seek */
|
||||||
loop_ioctl, /* ioctl */
|
loop_ioctl, /* ioctl */
|
||||||
NULL, /* mmap */
|
NULL, /* mmap */
|
||||||
NULL, /* truncate */
|
NULL, /* truncate */
|
||||||
NULL, /* poll */
|
NULL, /* poll */
|
||||||
loop_readv, /* readv */
|
NULL, /* readv */
|
||||||
loop_writev /* writev */
|
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 */
|
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 */
|
return len; /* Say that everything was written */
|
||||||
|
|
||||||
size_t ret = uio->uio_resid;
|
|
||||||
|
|
||||||
uio_advance(uio, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+18
-17
@@ -40,8 +40,10 @@
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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,
|
||||||
static ssize_t devnull_writev(FAR struct file *filep, FAR struct uio *uio);
|
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,
|
static int devnull_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup);
|
bool setup);
|
||||||
|
|
||||||
@@ -53,15 +55,15 @@ static const struct file_operations g_devnull_fops =
|
|||||||
{
|
{
|
||||||
NULL, /* open */
|
NULL, /* open */
|
||||||
NULL, /* close */
|
NULL, /* close */
|
||||||
NULL, /* read */
|
devnull_read, /* read */
|
||||||
NULL, /* writev */
|
devnull_write, /* write */
|
||||||
NULL, /* seek */
|
NULL, /* seek */
|
||||||
NULL, /* ioctl */
|
NULL, /* ioctl */
|
||||||
NULL, /* mmap */
|
NULL, /* mmap */
|
||||||
NULL, /* truncate */
|
NULL, /* truncate */
|
||||||
devnull_poll, /* poll */
|
devnull_poll, /* poll */
|
||||||
devnull_readv, /* readv */
|
NULL, /* readv */
|
||||||
devnull_writev /* writev */
|
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(filep);
|
||||||
UNUSED(uio);
|
UNUSED(buffer);
|
||||||
|
UNUSED(len);
|
||||||
|
|
||||||
return 0; /* Return EOF */
|
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(filep);
|
||||||
|
UNUSED(buffer);
|
||||||
|
|
||||||
/* Say that everything was written */
|
return len; /* Say that everything was written */
|
||||||
|
|
||||||
size_t ret = uio->uio_resid;
|
|
||||||
|
|
||||||
uio_advance(uio, ret);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
+18
-28
@@ -40,8 +40,10 @@
|
|||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
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,
|
||||||
static ssize_t devzero_writev(FAR struct file *filep, FAR struct uio *uio);
|
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,
|
static int devzero_poll(FAR struct file *filep, FAR struct pollfd *fds,
|
||||||
bool setup);
|
bool setup);
|
||||||
|
|
||||||
@@ -53,15 +55,15 @@ static const struct file_operations g_devzero_fops =
|
|||||||
{
|
{
|
||||||
NULL, /* open */
|
NULL, /* open */
|
||||||
NULL, /* close */
|
NULL, /* close */
|
||||||
NULL, /* read */
|
devzero_read, /* read */
|
||||||
NULL, /* write */
|
devzero_write, /* write */
|
||||||
NULL, /* seek */
|
NULL, /* seek */
|
||||||
NULL, /* ioctl */
|
NULL, /* ioctl */
|
||||||
NULL, /* mmap */
|
NULL, /* mmap */
|
||||||
NULL, /* truncate */
|
NULL, /* truncate */
|
||||||
devzero_poll, /* poll */
|
devzero_poll, /* poll */
|
||||||
devzero_readv, /* readv */
|
NULL, /* readv */
|
||||||
devzero_writev /* writev */
|
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);
|
UNUSED(filep);
|
||||||
|
|
||||||
for (i = 0; i < iovcnt; i++)
|
memset(buffer, 0, len);
|
||||||
{
|
return len;
|
||||||
memset(iov[i].iov_base, 0, iov[i].iov_len);
|
|
||||||
}
|
|
||||||
|
|
||||||
uio_advance(uio, total);
|
|
||||||
|
|
||||||
return total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* 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(filep);
|
||||||
|
UNUSED(buffer);
|
||||||
|
|
||||||
total = uio->uio_resid;
|
return len;
|
||||||
|
|
||||||
uio_advance(uio, total);
|
|
||||||
return total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
Reference in New Issue
Block a user