Merge master.kernel.org:/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-drm-fsl-dcu.git] / arch / um / kernel / irq.c
index 5c1e611f628d548fed1716c75d5537c39d6b8cc4..8f2ed369031507c8aa01992d46dbaea62b3721ca 100644 (file)
@@ -25,7 +25,6 @@
 #include "asm/system.h"
 #include "asm/errno.h"
 #include "asm/uaccess.h"
-#include "user_util.h"
 #include "kern_util.h"
 #include "irq_user.h"
 #include "irq_kern.h"
@@ -79,7 +78,15 @@ skip:
        return 0;
 }
 
-struct irq_fd *active_fds = NULL;
+/*
+ * This list is accessed under irq_lock, except in sigio_handler,
+ * where it is safe from being modified.  IRQ handlers won't change it -
+ * if an IRQ source has vanished, it will be freed by free_irqs just
+ * before returning from sigio_handler.  That will process a separate
+ * list of irqs to free, with its own locking, coming back here to
+ * remove list elements, taking the irq_lock to do so.
+ */
+static struct irq_fd *active_fds = NULL;
 static struct irq_fd **last_irq_ptr = &active_fds;
 
 extern void free_irqs(void);
@@ -124,8 +131,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
        if (err < 0)
                goto out;
 
-       new_fd = um_kmalloc(sizeof(*new_fd));
        err = -ENOMEM;
+       new_fd = kmalloc(sizeof(struct irq_fd), GFP_KERNEL);
        if (new_fd == NULL)
                goto out;
 
@@ -142,6 +149,7 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                                     .events            = events,
                                     .current_events    = 0 } );
 
+       err = -EBUSY;
        spin_lock_irqsave(&irq_lock, flags);
        for (irq_fd = active_fds; irq_fd != NULL; irq_fd = irq_fd->next) {
                if ((irq_fd->fd == fd) && (irq_fd->type == type)) {
@@ -176,9 +184,8 @@ int activate_fd(int irq, int fd, int type, void *dev_id)
                 */
                spin_unlock_irqrestore(&irq_lock, flags);
                kfree(tmp_pfd);
-               tmp_pfd = NULL;
 
-               tmp_pfd = um_kmalloc(n);
+               tmp_pfd = kmalloc(n, GFP_KERNEL);
                if (tmp_pfd == NULL)
                        goto out_kfree;
 
@@ -244,6 +251,7 @@ void free_irq_by_fd(int fd)
        free_irq_by_cb(same_fd, &fd);
 }
 
+/* Must be called with irq_lock held */
 static struct irq_fd *find_irq_by_fd(int fd, int irqnum, int *index_out)
 {
        struct irq_fd *irq;
@@ -309,6 +317,12 @@ void deactivate_fd(int fd, int irqnum)
        ignore_sigio_fd(fd);
 }
 
+/*
+ * Called just before shutdown in order to provide a clean exec
+ * environment in case the system is rebooting.  No locking because
+ * that would cause a pointless shutdown hang if something hadn't
+ * released the lock.
+ */
 int deactivate_all_fds(void)
 {
        struct irq_fd *irq;