2005-04-17 06:20:36 +08:00
|
|
|
/*
|
2007-10-16 16:26:41 +08:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2007-10-16 16:26:41 +08:00
|
|
|
#include <stddef.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <errno.h>
|
2007-10-16 16:26:41 +08:00
|
|
|
#include <fcntl.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include "os.h"
|
2007-10-16 16:26:41 +08:00
|
|
|
#include "chan_user.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2006-09-29 16:58:50 +08:00
|
|
|
/* This address is used only as a unique identifer */
|
2005-04-17 06:20:36 +08:00
|
|
|
static int null_chan;
|
|
|
|
|
2006-09-27 16:50:33 +08:00
|
|
|
static void *null_init(char *str, int device, const struct chan_opts *opts)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2007-10-16 16:26:41 +08:00
|
|
|
return &null_chan;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_open(int input, int output, int primary, void *d,
|
|
|
|
char **dev_out)
|
|
|
|
{
|
2007-10-16 16:26:41 +08:00
|
|
|
int fd;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
*dev_out = NULL;
|
2007-10-16 16:26:41 +08:00
|
|
|
|
|
|
|
fd = open(DEV_NULL, O_RDWR);
|
|
|
|
return (fd < 0) ? -errno : fd;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_read(int fd, char *c_out, void *unused)
|
|
|
|
{
|
2007-10-16 16:26:41 +08:00
|
|
|
return -ENODEV;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void null_free(void *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-27 16:50:33 +08:00
|
|
|
const struct chan_ops null_ops = {
|
2005-04-17 06:20:36 +08:00
|
|
|
.type = "null",
|
|
|
|
.init = null_init,
|
|
|
|
.open = null_open,
|
|
|
|
.close = generic_close,
|
|
|
|
.read = null_read,
|
|
|
|
.write = generic_write,
|
|
|
|
.console_write = generic_console_write,
|
|
|
|
.window_size = generic_window_size,
|
|
|
|
.free = null_free,
|
|
|
|
.winch = 0,
|
|
|
|
};
|