Files
OrangePi_CM5/arch/um/drivers/null.c
T

51 lines
970 B
C
Raw Normal View History

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