2019-08-25 16:49:16 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2007-10-16 15:27:34 +07:00
|
|
|
/*
|
2007-10-16 15:26:41 +07:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
|
|
|
|
2007-10-16 15:26:41 +07:00
|
|
|
#include <stddef.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <errno.h>
|
2007-10-16 15:26:41 +07:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include "chan_user.h"
|
2012-10-08 09:27:32 +07:00
|
|
|
#include <os.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-10-20 06:23:03 +07:00
|
|
|
/* This address is used only as a unique identifier */
|
2005-04-17 05:20:36 +07:00
|
|
|
static int null_chan;
|
|
|
|
|
2006-09-27 15:50:33 +07:00
|
|
|
static void *null_init(char *str, int device, const struct chan_opts *opts)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2007-10-16 15:26:41 +07:00
|
|
|
return &null_chan;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_open(int input, int output, int primary, void *d,
|
|
|
|
char **dev_out)
|
|
|
|
{
|
2007-10-16 15:26:41 +07:00
|
|
|
int fd;
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
*dev_out = NULL;
|
2007-10-16 15:26:41 +07:00
|
|
|
|
|
|
|
fd = open(DEV_NULL, O_RDWR);
|
|
|
|
return (fd < 0) ? -errno : fd;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int null_read(int fd, char *c_out, void *unused)
|
|
|
|
{
|
2007-10-16 15:26:41 +07:00
|
|
|
return -ENODEV;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void null_free(void *data)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-09-27 15:50:33 +07:00
|
|
|
const struct chan_ops null_ops = {
|
2005-04-17 05:20:36 +07: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,
|
|
|
|
};
|