Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-2.6] / arch / um / kernel / sigio.c
CommitLineData
8e367065 1/*
1da177e4
LT
2 * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/kernel.h"
7#include "linux/list.h"
8#include "linux/slab.h"
9#include "linux/signal.h"
10#include "linux/interrupt.h"
11#include "init.h"
12#include "sigio.h"
13#include "irq_user.h"
14#include "irq_kern.h"
8e367065 15#include "os.h"
1da177e4
LT
16
17/* Protected by sigio_lock() called from write_sigio_workaround */
18static int sigio_irq_fd = -1;
19
7bea96fd 20static irqreturn_t sigio_interrupt(int irq, void *data)
1da177e4 21{
8e367065
JD
22 char c;
23
a6ea4cce 24 os_read_file(sigio_irq_fd, &c, sizeof(c));
1da177e4 25 reactivate_fd(sigio_irq_fd, SIGIO_WRITE_IRQ);
4cffb7fa 26 return IRQ_HANDLED;
1da177e4
LT
27}
28
29int write_sigio_irq(int fd)
30{
31 int err;
32
33 err = um_request_irq(SIGIO_WRITE_IRQ, fd, IRQ_READ, sigio_interrupt,
1d3468a6 34 IRQF_DISABLED|IRQF_SAMPLE_RANDOM, "write sigio",
1da177e4
LT
35 NULL);
36 if(err){
37 printk("write_sigio_irq : um_request_irq failed, err = %d\n",
38 err);
4cffb7fa 39 return -1;
1da177e4
LT
40 }
41 sigio_irq_fd = fd;
4cffb7fa 42 return 0;
1da177e4
LT
43}
44
d9f9d319 45/* These are called from os-Linux/sigio.c to protect its pollfds arrays. */
1da177e4
LT
46static DEFINE_SPINLOCK(sigio_spinlock);
47
48void sigio_lock(void)
49{
50 spin_lock(&sigio_spinlock);
51}
52
53void sigio_unlock(void)
54{
55 spin_unlock(&sigio_spinlock);
56}