[Problem][Rev xM-B] Strange behavior with interrupts from GPIO

Hi everybody!

I have a very strange problem with my Beagleboard.
I want to use the interrupts from GPIOs so I coded the Kernel Module
at the end of the message. Apparently it works fine.
That means that I can load the module, then I can see my interrupt in /
proc/interrupts (299: 256 GPIO INTR) but if I change the voltage on
the pin (1.8V or 0V), nothing happens.
Where it becomes very strange is when I just touch the pin with some
wire (not connected to anything on the other end), there are several
interrupt (I can see it in dmesg). The same thing happens when I touch
the ground pin (which is not connected to the GPIO pin) but nothing
happens when I touch other GPIO pins. But once more, it is just a wire
connected to nothing (neither the ground or some voltage). I guess
there is some static electricity...
And when I change the pin in my module, the same thing happen for the
other pin so I guess that the irq number is the good one as it seems
to be related to the good pin, so I can't see where the problem is...

And one last thing : if I make a handler that returns a irqreturn_t
the beagleboard freezes and after reboot there is this in /var/log/
May 27 11:39:17 beagle1 kernel: [ 7451.621276] usb 1-2: USB
disconnect, device number 2
May 27 11:39:17 beagle1 kernel: [ 7451.621307] usb 1-2.1: USB
disconnect, device number 3
May 27 11:39:17 beagle1 kernel: [ 7451.623413] smsc95xx 1-2.1:1.0:
eth0: unregister 'smsc95xx' usb-ehci-omap.0-2.1, smsc95xx USB 2.0
Can't see how it is related but that's the only thing written in logs
before it freezes...

Does anyone know where the problem could come from? Or at least
suggestions to how I could find out what's going on?

My configuration :
I have a BeagleBoard xM rev.B with a linux kernel 2.6.39-rc7 (sources
taken from git://git.kernel.org/pub/scm/linux/kernel/git/tmlind/linux-omap-2.6.git

My kernel Module :
#include <linux/module.h>
#include <linux/kernel.h> /* Needed for KERN_INFO */
#include <linux/unistd.h> /* The list of system calls */
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/init.h> /* Needed for the macros */

#define DRIVER_DESC "Test Module"

#define USED_GPIO 139


//static irqreturn_t irq_handler(int irq, void *dev_id, struct pt_regs
void irq_handler(int irq, void *dev_id, struct pt_regs *regs)
  static int irqNumber = 0;
  int value = -1;
  printk(KERN_INFO "[mygpio] Interrupt number : %i!!!\n", ++irqNumber);
  value = gpio_get_value(USED_GPIO);
  printk(KERN_INFO "[mygpio] gpio value : %i\n", value);
  printk(KERN_INFO "[mygpio] irq value : %i\n", irq);
  if ( dev_id == NULL )
    printk(KERN_INFO "[mygpio] dev_id is NULL\n");
  //return IRQ_HANDLED;

int init_module ()
  int errno = 0;
  int value = -1;
  if ( !gpio_is_valid(USED_GPIO) )
    printk(KERN_INFO "[mygpio] GPIO %i is not valid\n", USED_GPIO);
  if ( (errno = gpio_request(USED_GPIO, "controller")) != 0 )
    printk(KERN_INFO "[mygpio] can't request GPIO, error %i\n", errno);
    return -EINVAL;
  if ( (errno = gpio_direction_input(USED_GPIO)) != 0 )
    printk(KERN_INFO "[mygpio] can't set GPIO direction, error %i\n",
    return -EINVAL;
  if ( (errno = request_irq( gpio_to_irq(USED_GPIO), irq_handler,
    printk(KERN_INFO "[mygpio] problem requesting IRQ, error %i\n",
    return -EINVAL;
  enable_irq( gpio_to_irq(USED_GPIO) );
  return 0;

void cleanup_module()
  free_irq( gpio_to_irq(USED_GPIO), NULL );
  printk("[mygpio] Short is the life of an LKM\n");

The error when loading the kernel
[ 6499.822540] WARNING: at kernel/irq/manage.c:421 enable_irq+0x4c/
[ 6499.822570] Unbalanced enable for IRQ 299
[ 6499.822570] Modules linked in: enable_irq_kernel(+) [last unloaded:
[ 6499.822601] [<c003efb4>] (unwind_backtrace+0x0/0x12c) from
[<c0063424>] (warn_slowpath_common+0x4c/0x64)
[ 6499.822631] [<c0063424>] (warn_slowpath_common+0x4c/0x64) from
[<c00634bc>] (warn_slowpath_fmt+0x2c/0x3c)
[ 6499.822662] [<c00634bc>] (warn_slowpath_fmt+0x2c/0x3c) from
[<c00993c0>] (enable_irq+0x4c/0x68)
[ 6499.822692] [<c00993c0>] (enable_irq+0x4c/0x68) from [<bf01e150>]
(init_module+0xb4/0xd8 [enable_irq_kernel])
[ 6499.822723] [<bf01e150>] (init_module+0xb4/0xd8
[enable_irq_kernel]) from [<c00333d0>] (do_one_initcall+0x94/0x164)
[ 6499.822753] [<c00333d0>] (do_one_initcall+0x94/0x164) from
[<c0091dac>] (sys_init_module+0xe60/0x10a8)
[ 6499.822814] [<c0091dac>] (sys_init_module+0xe60/0x10a8) from
[<c0039300>] (ret_fast_syscall+0x0/0x30)
[ 6499.822814] ---[ end trace 1b75b31a2719ed29 ]---

Thanks for your help!