diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-17 20:24:28 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-11-17 20:24:28 +0000 |
commit | cff1141190d60f819078be1ad0ed0186b47fd637 (patch) | |
tree | 487fc2ad11a4e20eb21f1ad746ed16d88541c05e /nuttx/drivers/dev_zero.c | |
parent | 33f0979adc4165594164fb13611961d60f0f2cfc (diff) | |
download | nuttx-cff1141190d60f819078be1ad0ed0186b47fd637.tar.gz nuttx-cff1141190d60f819078be1ad0ed0186b47fd637.tar.bz2 nuttx-cff1141190d60f819078be1ad0ed0186b47fd637.zip |
Add poll() method
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1262 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/dev_zero.c')
-rw-r--r-- | nuttx/drivers/dev_zero.c | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/nuttx/drivers/dev_zero.c b/nuttx/drivers/dev_zero.c index 876734770..08815ace5 100644 --- a/nuttx/drivers/dev_zero.c +++ b/nuttx/drivers/dev_zero.c @@ -45,6 +45,7 @@ #include <sys/types.h> #include <string.h> +#include <poll.h> #include <errno.h> #include <nuttx/fs.h> @@ -54,6 +55,9 @@ static ssize_t devzero_read(FAR struct file *, FAR char *, size_t); static ssize_t devzero_write(FAR struct file *, FAR const char *, size_t); +#ifndef CONFIG_DISABLE_POLL +static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds); +#endif /**************************************************************************** * Private Data @@ -66,26 +70,55 @@ static struct file_operations devzero_fops = devzero_read, /* read */ devzero_write, /* write */ 0, /* seek */ - 0, /* ioctl */ - 0 /* poll */ + 0 /* ioctl */ +#ifndef CONFIG_DISABLE_POLL + , devzero_poll /* poll */ +#endif }; /**************************************************************************** * Private Functions ****************************************************************************/ +/**************************************************************************** + * Name: devzero_read + ****************************************************************************/ + static ssize_t devzero_read(FAR struct file *filp, FAR char *buffer, size_t len) { memset(buffer, 0, len); return len; } +/**************************************************************************** + * Name: devzero_write + ****************************************************************************/ + static ssize_t devzero_write(FAR struct file *filp, FAR const char *buffer, size_t len) { return len; } /**************************************************************************** + * Name: devzero_poll + ****************************************************************************/ + +#ifndef CONFIG_DISABLE_POLL +static int devzero_poll(FAR struct file *filp, FAR struct pollfd *fds) +{ + if (fds) + { + fds->revents |= (fds->events & (POLLIN|POLLOUT)); + if (fds->revents != 0) + { + sem_post(fds->sem); + } + } + return OK; +} +#endif + +/**************************************************************************** * Public Functions ****************************************************************************/ |