um: call free_irq() only on enabled channels
[pandora-kernel.git] / arch / um / drivers / chan_kern.c
index c09dbdf..25e1965 100644 (file)
@@ -125,7 +125,7 @@ static int open_one_chan(struct chan *chan)
        return 0;
 }
 
-int open_chan(struct list_head *chans)
+static int open_chan(struct list_head *chans)
 {
        struct list_head *ele;
        struct chan *chan;
@@ -210,9 +210,9 @@ void free_irqs(void)
        list_for_each(ele, &list) {
                chan = list_entry(ele, struct chan, free_list);
 
-               if (chan->input)
+               if (chan->input && chan->enabled)
                        free_irq(chan->line->driver->read_irq, chan);
-               if (chan->output)
+               if (chan->output && chan->enabled)
                        free_irq(chan->line->driver->write_irq, chan);
                chan->enabled = 0;
        }
@@ -231,9 +231,9 @@ static void close_one_chan(struct chan *chan, int delay_free_irq)
                spin_unlock_irqrestore(&irqs_to_free_lock, flags);
        }
        else {
-               if (chan->input)
+               if (chan->input && chan->enabled)
                        free_irq(chan->line->driver->read_irq, chan);
-               if (chan->output)
+               if (chan->output && chan->enabled)
                        free_irq(chan->line->driver->write_irq, chan);
                chan->enabled = 0;
        }
@@ -291,6 +291,9 @@ int write_chan(struct list_head *chans, const char *buf, int len,
        struct chan *chan = NULL;
        int n, ret = 0;
 
+       if (len == 0)
+               return 0;
+
        list_for_each(ele, chans) {
                chan = list_entry(ele, struct chan, list);
                if (!chan->output || (chan->ops->write == NULL))
@@ -580,19 +583,6 @@ int parse_chan_pair(char *str, struct line *line, int device,
        return 0;
 }
 
-int chan_out_fd(struct list_head *chans)
-{
-       struct list_head *ele;
-       struct chan *chan;
-
-       list_for_each(ele, chans) {
-               chan = list_entry(ele, struct chan, list);
-               if (chan->primary && chan->output)
-                       return chan->fd;
-       }
-       return -1;
-}
-
 void chan_interrupt(struct list_head *chans, struct delayed_work *task,
                    struct tty_struct *tty, int irq)
 {