Merge tag 'for-v3.7' of git://git.infradead.org/battery-2.6
[deliverable/linux.git] / arch / um / drivers / null.c
CommitLineData
cb8fa61c 1/*
e99525f9 2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
1da177e4
LT
3 * Licensed under the GPL
4 */
5
e99525f9 6#include <stddef.h>
1da177e4 7#include <errno.h>
e99525f9 8#include <fcntl.h>
e99525f9 9#include "chan_user.h"
cb8fa61c 10#include "os.h"
1da177e4 11
b60745b9 12/* This address is used only as a unique identifier */
1da177e4
LT
13static int null_chan;
14
5e7672ec 15static void *null_init(char *str, int device, const struct chan_opts *opts)
1da177e4 16{
e99525f9 17 return &null_chan;
1da177e4
LT
18}
19
20static int null_open(int input, int output, int primary, void *d,
21 char **dev_out)
22{
e99525f9
JD
23 int fd;
24
1da177e4 25 *dev_out = NULL;
e99525f9
JD
26
27 fd = open(DEV_NULL, O_RDWR);
28 return (fd < 0) ? -errno : fd;
1da177e4
LT
29}
30
31static int null_read(int fd, char *c_out, void *unused)
32{
e99525f9 33 return -ENODEV;
1da177e4
LT
34}
35
36static void null_free(void *data)
37{
38}
39
5e7672ec 40const struct chan_ops null_ops = {
1da177e4
LT
41 .type = "null",
42 .init = null_init,
43 .open = null_open,
44 .close = generic_close,
45 .read = null_read,
46 .write = generic_write,
47 .console_write = generic_console_write,
48 .window_size = generic_window_size,
49 .free = null_free,
50 .winch = 0,
51};
This page took 0.720874 seconds and 5 git commands to generate.