<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hi.</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">I`m sorry if this isn`t the right place to post my question, but first I tried posting it on <a href="http://forum.kernelnewbies.org/" target="_blank" style="color:rgb(17,85,204)">forum.kernelnewbies.org</a> and nobody answered. Here`s my question:</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="font-size:medium;font-family:Arial">I have a Gembird kb-9140l keyboard with some multimedia keys which are not working on linux. I thought about writing my own driver for it, so as a start, I wrote a small module, which registers an interrupt handler on irq 1 with the IRQF_SHARED flag. In the handler function I put a simple printk with the scancode read from the keyboard. The problem is, that the handler never gets executed. I searched on google, and found that because the native driver doesn`t share its interrupt with another modules, before I call request_irq I have to free the original interrupt handler from the native driver. This would make my computer practically unusable until I reboot, but at least I would see, it works, but it doesn`t. The original driver works fine after I insert my module, and the interrupt handler still doesn`t get called. The weird thing is, when I remove my module, my handler executes ones, and the scancode is 0xFE. </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">The code is the following: </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">#include &lt;linux/module.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">#include &lt;linux/kernel.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">#include &lt;linux/init.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">#include &lt;linux/interrupt.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">#include &lt;asm/io.h&gt; </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">MODULE_LICENSE(&quot;Dual BSD/GPL&quot;);</span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static int gembirdkb_init(void); </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">static void gembirdkb_exit(void); </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">irq_handler_t irq_handler (int irq, void *dev_id, struct pt_regs *regs) </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">static unsigned char scancode; </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">scancode = inb (0x60); </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">printk(&quot;gembirdkb: irq handled... scancode: %d\n&quot;,scancode); </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">return (irq_handler_t) IRQ_HANDLED; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static int gembirdkb_init(void) </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">int ret; </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">/* free original interrupt handler */ </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">// free_irq(1, NULL); </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">ret = request_irq (1, (irq_handler_t) irq_handler, IRQF_SHARED, &quot;gembirdkb&quot;, (void *)&amp;irq_handler); </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">printk(&quot;gembirdkb: request_irq result: %d\n&quot;, ret); </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">return ret; </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">static void gembirdkb_exit(void) </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">{ </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">free_irq(1, (void *)&amp;irq_handler); </span><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">} </span><br style="clear:both;font-family:Arial;font-size:medium">
<br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">module_init(gembirdkb_init); </span><br style="clear:both;font-family:Arial;font-size:medium">
<span style="font-size:medium;font-family:Arial">module_exit(gembirdkb_exit); </span><br style="clear:both;font-family:Arial;font-size:medium"><br style="clear:both;font-family:Arial;font-size:medium"><span style="font-size:medium;font-family:Arial">Is there any way I can remove the native driver, or I need to recompile the kernel without it, and insert mine? </span></div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><span style="font-size:medium;font-family:Arial"><br></span></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<span style="font-size:medium;font-family:Arial">P.s.: Why every topic on the forum is full with questions about mac, iphone, samsung galaxy etc.?</span></div>