[PATCH] uml: const more data
[linux-2.6-microblaze.git] / arch / um / drivers / line.c
index b8e3e80..563ce76 100644 (file)
@@ -8,7 +8,6 @@
 #include "linux/list.h"
 #include "linux/kd.h"
 #include "linux/interrupt.h"
-#include "linux/devfs_fs_kernel.h"
 #include "asm/uaccess.h"
 #include "chan_kern.h"
 #include "irq_user.h"
@@ -252,7 +251,7 @@ void line_set_termios(struct tty_struct *tty, struct termios * old)
        /* nothing */
 }
 
-static struct {
+static const struct {
        int  cmd;
        char *level;
        char *name;
@@ -374,7 +373,7 @@ static irqreturn_t line_write_interrupt(int irq, void *data,
        int err;
 
        /* Interrupts are enabled here because we registered the interrupt with
-        * SA_INTERRUPT (see line_setup_irq).*/
+        * IRQF_DISABLED (see line_setup_irq).*/
 
        spin_lock_irq(&line->lock);
        err = flush_buffer(line);
@@ -406,8 +405,8 @@ static irqreturn_t line_write_interrupt(int irq, void *data,
 
 int line_setup_irq(int fd, int input, int output, struct line *line, void *data)
 {
-       struct line_driver *driver = line->driver;
-       int err = 0, flags = SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM;
+       const struct line_driver *driver = line->driver;
+       int err = 0, flags = IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM;
 
        if (input)
                err = um_request_irq(driver->read_irq, fd, IRQ_READ,
@@ -559,7 +558,7 @@ int line_setup(struct line *lines, unsigned int num, char *init)
 }
 
 int line_config(struct line *lines, unsigned int num, char *str,
-               struct chan_opts *opts)
+               const struct chan_opts *opts)
 {
        struct line *line;
        char *new;
@@ -655,7 +654,6 @@ struct tty_driver *line_register_devfs(struct lines *set,
 
        driver->driver_name = line_driver->name;
        driver->name = line_driver->device_name;
-       driver->devfs_name = line_driver->devfs_name;
        driver->major = line_driver->major;
        driver->minor_start = line_driver->minor_start;
        driver->type = line_driver->type;
@@ -714,7 +712,7 @@ struct winch {
        struct tty_struct *tty;
 };
 
-irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
+static irqreturn_t winch_interrupt(int irq, void *data, struct pt_regs *unused)
 {
        struct winch *winch = data;
        struct tty_struct *tty;
@@ -769,60 +767,54 @@ void register_winch_irq(int fd, int tty_fd, int pid, struct tty_struct *tty)
        spin_unlock(&winch_handler_lock);
 
        if(um_request_irq(WINCH_IRQ, fd, IRQ_READ, winch_interrupt,
-                         SA_INTERRUPT | SA_SHIRQ | SA_SAMPLE_RANDOM,
+                         IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
                          "winch", winch) < 0)
                printk("register_winch_irq - failed to register IRQ\n");
 }
 
+static void free_winch(struct winch *winch)
+{
+       list_del(&winch->list);
+
+       if(winch->pid != -1)
+               os_kill_process(winch->pid, 1);
+       if(winch->fd != -1)
+               os_close_file(winch->fd);
+
+       free_irq(WINCH_IRQ, winch);
+       kfree(winch);
+}
+
 static void unregister_winch(struct tty_struct *tty)
 {
        struct list_head *ele;
-       struct winch *winch, *found = NULL;
+       struct winch *winch;
 
        spin_lock(&winch_handler_lock);
+
        list_for_each(ele, &winch_handlers){
                winch = list_entry(ele, struct winch, list);
                 if(winch->tty == tty){
-                        found = winch;
-                        break;
+                       free_winch(winch);
+                       break;
                 }
         }
-        if(found == NULL)
-               goto err;
-
-       list_del(&winch->list);
-       spin_unlock(&winch_handler_lock);
-
-        if(winch->pid != -1)
-                os_kill_process(winch->pid, 1);
-
-        free_irq(WINCH_IRQ, winch);
-        kfree(winch);
-
-       return;
-err:
        spin_unlock(&winch_handler_lock);
 }
 
-/* XXX: No lock as it's an exitcall... is this valid? Depending on cleanup
- * order... are we sure that nothing else is done on the list? */
 static void winch_cleanup(void)
 {
-       struct list_head *ele;
+       struct list_head *ele, *next;
        struct winch *winch;
 
-       list_for_each(ele, &winch_handlers){
+       spin_lock(&winch_handler_lock);
+
+       list_for_each_safe(ele, next, &winch_handlers){
                winch = list_entry(ele, struct winch, list);
-               if(winch->fd != -1){
-                       /* Why is this different from the above free_irq(),
-                        * which deactivates SIGIO? This searches the FD
-                        * somewhere else and removes it from the list... */
-                       deactivate_fd(winch->fd, WINCH_IRQ);
-                       os_close_file(winch->fd);
-               }
-               if(winch->pid != -1)
-                       os_kill_process(winch->pid, 1);
+               free_winch(winch);
        }
+
+       spin_unlock(&winch_handler_lock);
 }
 __uml_exitcall(winch_cleanup);
 
@@ -831,8 +823,8 @@ char *add_xterm_umid(char *base)
        char *umid, *title;
        int len;
 
-       umid = get_umid(1);
-       if(umid == NULL)
+       umid = get_umid();
+       if(*umid == '\0')
                return base;
 
        len = strlen(base) + strlen(" ()") + strlen(umid) + 1;