Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / arch / um / kernel / irq.c
index 1e766ce..2ffda01 100644 (file)
@@ -5,6 +5,7 @@
  *     Copyright (C) 1992, 1998 Linus Torvalds, Ingo Molnar
  */
 
+#include "linux/config.h"
 #include "linux/kernel.h"
 #include "linux/module.h"
 #include "linux/smp.h"
@@ -62,7 +63,7 @@ int show_interrupts(struct seq_file *p, void *v)
                for_each_online_cpu(j)
                        seq_printf(p, "%10u ", kstat_cpu(j).irqs[i]);
 #endif
-               seq_printf(p, " %14s", irq_desc[i].chip->typename);
+               seq_printf(p, " %14s", irq_desc[i].handler->typename);
                seq_printf(p, "  %s", action->name);
 
                for (action=action->next; action; action = action->next)
@@ -109,7 +110,18 @@ void sigio_handler(int sig, union uml_pt_regs *regs)
        free_irqs();
 }
 
-static DEFINE_SPINLOCK(irq_lock);
+static void maybe_sigio_broken(int fd, int type)
+{
+       if (os_isatty(fd)) {
+               if ((type == IRQ_WRITE) && !pty_output_sigio) {
+                       write_sigio_workaround();
+                       add_sigio_fd(fd, 0);
+               } else if ((type == IRQ_READ) && !pty_close_sigio) {
+                       write_sigio_workaround();
+                       add_sigio_fd(fd, 1);
+               }
+       }
+}
 
 int activate_fd(int irq, int fd, int type, void *dev_id)
 {
@@ -154,7 +166,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
         * this is called only from process context, and can be locked with
         * a semaphore.
         */
-       spin_lock_irqsave(&irq_lock, flags);
+       flags = irq_lock();
        for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
                if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
                        printk("Registering fd %d twice\n", fd);
@@ -187,7 +199,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                 * so we will not be able to put new pollfd struct to pollfds
                 * then we free the buffer tmp_fds and try again.
                 */
-               spin_unlock_irqrestore(&irq_lock, flags);
+               irq_unlock(flags);
                kfree(tmp_pfd);
                tmp_pfd = NULL;
 
@@ -195,24 +207,24 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                if (tmp_pfd == NULL)
                        goto out_kfree;
 
-               spin_lock_irqsave(&irq_lock, flags);
+               flags = irq_lock();
        }
        /*-------------*/
 
        *last_irq_ptr = new_fd;
        last_irq_ptr = &new_fd->next;
 
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
 
        /* This calls activate_fd, so it has to be outside the critical
         * section.
         */
-       maybe_sigio_broken(fd, (type == IRQ_READ));
+       maybe_sigio_broken(fd, type);
 
        return(0);
 
  out_unlock:
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
  out_kfree:
        kfree(new_fd);
  out:
@@ -223,9 +235,9 @@ static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
 {
        unsigned long flags;
 
-       spin_lock_irqsave(&irq_lock, flags);
+       flags = irq_lock();
        os_free_irq_by_cb(test, arg, active_fds, &last_irq_ptr);
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
 }
 
 struct irq_and_dev {
@@ -292,19 +304,19 @@ void reactivate_fd(int fd, int irqnum)
        unsigned long flags;
        int i;
 
-       spin_lock_irqsave(&irq_lock, flags);
+       flags = irq_lock();
        irq = find_irq_by_fd(fd, irqnum, &i);
        if (irq == NULL) {
-               spin_unlock_irqrestore(&irq_lock, flags);
+               irq_unlock(flags);
                return;
        }
        os_set_pollfd(i, irq->fd);
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
 
        /* This calls activate_fd, so it has to be outside the critical
         * section.
         */
-       maybe_sigio_broken(fd, (irq->type == IRQ_READ));
+       maybe_sigio_broken(fd, irq->type);
 }
 
 void deactivate_fd(int fd, int irqnum)
@@ -313,13 +325,13 @@ void deactivate_fd(int fd, int irqnum)
        unsigned long flags;
        int i;
 
-       spin_lock_irqsave(&irq_lock, flags);
+       flags = irq_lock();
        irq = find_irq_by_fd(fd, irqnum, &i);
        if (irq == NULL)
                goto out;
        os_set_pollfd(i, -1);
  out:
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
 }
 
 int deactivate_all_fds(void)
@@ -338,14 +350,13 @@ int deactivate_all_fds(void)
        return 0;
 }
 
-#ifdef CONFIG_MODE_TT
 void forward_interrupts(int pid)
 {
        struct irq_fd *irq;
        unsigned long flags;
        int err;
 
-       spin_lock_irqsave(&irq_lock, flags);
+       flags = irq_lock();
        for (irq = active_fds; irq != NULL; irq = irq->next) {
                err = os_set_owner(irq->fd, pid);
                if (err < 0) {
@@ -358,9 +369,8 @@ void forward_interrupts(int pid)
 
                irq->pid = pid;
        }
-       spin_unlock_irqrestore(&irq_lock, flags);
+       irq_unlock(flags);
 }
-#endif
 
 /*
  * do_IRQ handles all normal device IRQ's (the special
@@ -393,6 +403,21 @@ int um_request_irq(unsigned int irq, int fd, int type,
 EXPORT_SYMBOL(um_request_irq);
 EXPORT_SYMBOL(reactivate_fd);
 
+static DEFINE_SPINLOCK(irq_spinlock);
+
+unsigned long irq_lock(void)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&irq_spinlock, flags);
+       return flags;
+}
+
+void irq_unlock(unsigned long flags)
+{
+       spin_unlock_irqrestore(&irq_spinlock, flags);
+}
+
 /* hw_interrupt_type must define (startup || enable) &&
  * (shutdown || disable) && end */
 static void dummy(unsigned int irq)
@@ -426,13 +451,13 @@ void __init init_IRQ(void)
        irq_desc[TIMER_IRQ].status = IRQ_DISABLED;
        irq_desc[TIMER_IRQ].action = NULL;
        irq_desc[TIMER_IRQ].depth = 1;
-       irq_desc[TIMER_IRQ].chip = &SIGVTALRM_irq_type;
+       irq_desc[TIMER_IRQ].handler = &SIGVTALRM_irq_type;
        enable_irq(TIMER_IRQ);
        for (i = 1; i < NR_IRQS; i++) {
                irq_desc[i].status = IRQ_DISABLED;
                irq_desc[i].action = NULL;
                irq_desc[i].depth = 1;
-               irq_desc[i].chip = &normal_irq_type;
+               irq_desc[i].handler = &normal_irq_type;
                enable_irq(i);
        }
 }
@@ -449,7 +474,7 @@ int init_aio_irq(int irq, char *name, irqreturn_t (*handler)(int, void *,
        }
 
        err = um_request_irq(irq, fds[0], IRQ_READ, handler,
-                            IRQF_DISABLED | IRQF_SAMPLE_RANDOM, name,
+                            SA_INTERRUPT | SA_SAMPLE_RANDOM, name,
                             (void *) (long) fds[0]);
        if (err) {
                printk("init_aio_irq - : um_request_irq failed, err = %d\n",