patch-2_6_7-vs1_9_1_12
[linux-2.6.git] / drivers / input / serio / serio.c
index 13d21bf..6f00319 100644 (file)
 /*
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or 
+ * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * 
+ *
  * Should you need to contact me, the author, you can do so either by
  * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
  * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
@@ -108,7 +108,7 @@ void serio_handle_events(void)
        struct serio_event *event;
 
        list_for_each_safe(node, next, &serio_event_list) {
-               event = container_of(node, struct serio_event, node);   
+               event = container_of(node, struct serio_event, node);
 
                down(&serio_sem);
                if (event->serio == NULL)
@@ -152,7 +152,7 @@ static int serio_thread(void *nothing)
 
        do {
                serio_handle_events();
-               wait_event_interruptible(serio_wait, !list_empty(&serio_event_list)); 
+               wait_event_interruptible(serio_wait, !list_empty(&serio_event_list));
                if (current->flags & PF_FREEZE)
                        refrigerator(PF_FREEZE);
        } while (!signal_pending(current));
@@ -293,7 +293,7 @@ void serio_unregister_device(struct serio_dev *dev)
 int serio_open(struct serio *serio, struct serio_dev *dev)
 {
        serio->dev = dev;
-       if (serio->open(serio)) {
+       if (serio->open && serio->open(serio)) {
                serio->dev = NULL;
                return -1;
        }
@@ -303,7 +303,8 @@ int serio_open(struct serio *serio, struct serio_dev *dev)
 /* called from serio_dev->connect/disconnect methods under serio_sem */
 void serio_close(struct serio *serio)
 {
-       serio->close(serio);
+       if (serio->close)
+               serio->close(serio);
        serio->dev = NULL;
 }