| * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) |
| #include <linux/completion.h> |
| #include <linux/irqreturn.h> |
| static irqreturn_t xterm_interrupt(int irq, void *data) |
| struct xterm_wait *xterm = data; |
| fd = os_rcv_fd(xterm->fd, &xterm->pid); |
| int xterm_fd(int socket, int *pid_out) |
| data = kmalloc(sizeof(*data), GFP_KERNEL); |
| printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n"); |
| /* This is a locked semaphore... */ |
| *data = ((struct xterm_wait) { .fd = socket, |
| init_completion(&data->ready); |
| err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt, |
| IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM, |
| printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, " |
| /* ... so here we wait for an xterm interrupt. |
| * XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY |
| * isn't set) this will hang... */ |
| wait_for_completion(&data->ready); |
| free_irq(XTERM_IRQ, data); |