12 #include <linux/module.h>
13 #include <linux/sched.h>
15 #include <linux/slab.h>
29 static struct irq_fd **last_irq_ptr = &active_fds;
49 for (irq_fd = active_fds; irq_fd !=
NULL;
50 irq_fd = irq_fd->
next) {
80 events = UM_POLLIN | UM_POLLPRI;
81 else events = UM_POLLOUT;
82 *new_fd = ((
struct irq_fd) { .next =
NULL,
88 .current_events = 0 } );
92 for (irq_fd = active_fds; irq_fd !=
NULL; irq_fd = irq_fd->
next) {
93 if ((irq_fd->
fd == fd) && (irq_fd->
type == type)) {
125 spin_unlock_irqrestore(&
irq_lock, flags);
135 *last_irq_ptr = new_fd;
136 last_irq_ptr = &new_fd->
next;
138 spin_unlock_irqrestore(&
irq_lock, flags);
149 spin_unlock_irqrestore(&
irq_lock, flags);
156 static void free_irq_by_cb(
int (*
test)(
struct irq_fd *,
void *),
void *
arg)
162 spin_unlock_irqrestore(&
irq_lock, flags);
170 static int same_irq_and_dev(
struct irq_fd *irq,
void *
d)
174 return ((irq->
irq == data->
irq) && (irq->
id == data->
dev));
177 static void free_irq_by_irq_and_dev(
unsigned int irq,
void *
dev)
182 free_irq_by_cb(same_irq_and_dev, &data);
185 static int same_fd(
struct irq_fd *irq,
void *fd)
187 return (irq->
fd == *((
int *)fd));
192 free_irq_by_cb(same_fd, &fd);
196 static struct irq_fd *find_irq_by_fd(
int fd,
int irqnum,
int *index_out)
202 for (irq = active_fds; irq !=
NULL; irq = irq->
next) {
203 if ((irq->
fd == fd) && (irq->
irq == irqnum))
213 if ((fdi != -1) && (fdi != fd)) {
215 "and pollfds, fd %d vs %d, need %d\n", irq->
fd,
232 irq = find_irq_by_fd(fd, irqnum, &i);
234 spin_unlock_irqrestore(&
irq_lock, flags);
238 spin_unlock_irqrestore(&
irq_lock, flags);
250 irq = find_irq_by_fd(fd, irqnum, &i);
252 spin_unlock_irqrestore(&
irq_lock, flags);
257 spin_unlock_irqrestore(&
irq_lock, flags);
274 for (irq = active_fds; irq !=
NULL; irq = irq->
next) {
296 set_irq_regs(old_regs);
302 free_irq_by_irq_and_dev(irq, dev);
309 unsigned long irqflags,
const char * devname,
315 err = activate_fd(irq, fd, type, dev_id);
320 return request_irq(irq, handler, irqflags, devname, dev_id);
335 static struct irq_chip normal_irq_type = {
337 .irq_disable =
dummy,
342 static struct irq_chip SIGVTALRM_irq_type = {
344 .irq_disable =
dummy,
406 static unsigned long pending_mask;
411 unsigned long mask, old;
414 mask =
xchg(&pending_mask, *mask_out);
428 mask =
xchg(&pending_mask, old);
429 }
while (mask != old);
447 mask =
xchg(&pending_mask, 0);
448 *mask_out |= mask | nested;
466 mask =
xchg(&pending_mask, 0);