Revision: 119
          http://svn.sourceforge.net/mactel-linux/?rev=119&view=rev
Author:   nboichat
Date:     2007-04-18 08:08:57 -0700 (Wed, 18 Apr 2007)

Log Message:
-----------
Remove mutexes in appleir (no need for these, functions are called from 
interrupt context, so problems should not occur).
Thix fix BUG messages in dmesg.

Modified Paths:
--------------
    trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch

Modified: trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch
===================================================================
--- trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch       2007-04-16 
03:17:44 UTC (rev 118)
+++ trunk/kernel/mactel-patches-2.6.21/0002-appleir.patch       2007-04-18 
15:08:57 UTC (rev 119)
@@ -7,8 +7,8 @@
 
  drivers/usb/input/Kconfig   |    4 
  drivers/usb/input/Makefile  |    1 
- drivers/usb/input/appleir.c |  384 +++++++++++++++++++++++++++++++++++++++++++
- 3 files changed, 389 insertions(+), 0 deletions(-)
+ drivers/usb/input/appleir.c |  379 +++++++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 384 insertions(+), 0 deletions(-)
 
 diff --git a/drivers/usb/input/Kconfig b/drivers/usb/input/Kconfig
 index 69a9f3b..f88c132 100644
@@ -39,10 +39,10 @@
  obj-$(CONFIG_USB_MTOUCH)      += mtouchusb.o
 diff --git a/drivers/usb/input/appleir.c b/drivers/usb/input/appleir.c
 new file mode 100644
-index 0000000..5f049c7
+index 0000000..170cee6
 --- /dev/null
 +++ b/drivers/usb/input/appleir.c
-@@ -0,0 +1,384 @@
+@@ -0,0 +1,379 @@
 +/*
 + * drivers/usb/input/appleir.c - driver for Apple Intel-based Macs IR Receiver
 + *
@@ -90,7 +90,7 @@
 +#define MAX_KEYS 8
 +#define MAX_KEYS_MASK (MAX_KEYS - 1)
 +
-+static int debug = 0;
++static int debug = 1;
 +
 +struct appleir {
 +      struct input_dev *dev;
@@ -100,7 +100,6 @@
 +      struct urb *urb;
 +      struct timer_list key_up_timer;
 +      int current_key;
-+      struct mutex current_key_lock;
 +      char phys[32];
 +};
 +
@@ -117,7 +116,8 @@
 +
 +/*
 + * Devices report the following, where XX depends on the remote and/or the
-+ * receiver (at least 83, ca, ee have been reported as possible values).
++ * receiver (at least 2a, 83, ca, ee have been reported as possible values, it
++ * looks like it is remote control dependent).
 + * The fifth byte's LSB also depends on the hardware.
 + * 25 87 ee XX 0a/0b          +
 + * 25 87 ee XX 0c/0d          -
@@ -181,12 +181,10 @@
 +{
 +      struct appleir *apple_ir = (struct appleir*)data;
 +
-+      mutex_lock(&apple_ir->current_key_lock);
 +      if (apple_ir->current_key) {
 +              key_up(apple_ir, apple_ir->current_key);
 +              apple_ir->current_key = 0;
 +      }
-+      mutex_unlock(&apple_ir->current_key_lock);
 +}
 +
 +static void parse_data(struct appleir *apple_ir, uint8_t *data, int len)
@@ -206,16 +204,12 @@
 +               * If we already have a key down, take it up before marking
 +               * this one down.
 +               */
-+              mutex_lock(&apple_ir->current_key_lock);
-+
 +              if (apple_ir->current_key)
 +                      key_up(apple_ir, apple_ir->current_key);
 +              apple_ir->current_key = keymap[(data[4] >> 1) & MAX_KEYS_MASK];
 +
 +              key_down(apple_ir, apple_ir->current_key);
 +
-+              mutex_unlock(&apple_ir->current_key_lock);
-+
 +              /*
 +               * Remote doesn't do key up, either pull them up, in the test
 +               * above, or here set a timer which pulls them up after 1/8 s
@@ -226,9 +220,7 @@
 +      }
 +
 +      if (!memcmp(data, keyrepeat, sizeof(keyrepeat))) {
-+              mutex_lock(&apple_ir->current_key_lock);
 +              key_down(apple_ir, apple_ir->current_key);
-+              mutex_unlock(&apple_ir->current_key_lock);
 +
 +              /*
 +               * Remote doesn't do key up, either pull them up, in the test
@@ -299,6 +291,7 @@
 +      struct appleir *appleir = NULL;
 +      struct input_dev *input_dev;
 +      int i;
++      int ret = -ENOMEM;
 +
 +      appleir = kzalloc(sizeof(struct appleir), GFP_KERNEL);
 +      if (!appleir)
@@ -306,8 +299,6 @@
 +
 +      memset(appleir, 0, sizeof(struct appleir));
 +
-+      mutex_init(&appleir->current_key_lock);
-+
 +      appleir->data =
 +          usb_buffer_alloc(dev, URB_SIZE, GFP_KERNEL, &appleir->dma_buf);
 +      if (!appleir->data)
@@ -325,7 +316,9 @@
 +
 +      appleir->dev = input_dev;
 +
-+      usb_make_path(dev, appleir->phys, sizeof(appleir->phys));
++      if (usb_make_path(dev, appleir->phys, sizeof(appleir->phys)) < 0)
++              goto fail_input_device;
++
 +      strlcpy(appleir->phys, "/input0", sizeof(appleir->phys));
 +
 +      input_dev->name = "Apple MacIntel infrared remote control driver";
@@ -363,7 +356,9 @@
 +      appleir->key_up_timer.function = key_up_tick;
 +      appleir->key_up_timer.data = (unsigned long) appleir;
 +
-+      input_register_device(appleir->dev);
++      ret = input_register_device(appleir->dev);
++      if (ret < 0)
++              goto fail_timer;
 +
 +      return 0;
 +
@@ -383,7 +378,7 @@
 +      kfree(appleir);
 +
 +fail:
-+      return -ENOMEM;
++      return ret;
 +}
 +
 +static void appleir_disconnect(struct usb_interface *intf)


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Mactel-linux-devel mailing list
Mactel-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mactel-linux-devel

Reply via email to