error:implicit declaration of function "irq_to_gpio"

来源:互联网 发布:做淘宝女装货源哪里有 编辑:程序博客网 时间:2024/05/16 08:51

     在Tiny210上移植egalax的IIC driver,编译时出现如题错误。提示的很清楚,驱动程序中的函数irq_to_gpio没有声明。

看了下驱动文件的头文件中包含#include<linux/gpio.h>,该头文件中有一个irq_to_gpio的原型


static inline int irq_to_gpio(unsigned irq)
{
        /* irq can never have been returned from gpio_to_irq() */
        WARN_ON(1);                                                                                 //啥都没有实现的函数,肯定没用。
        return -EINVAL;
}

可以看到头文件开头几行有个条件编译,如下图,看了下.config的配置,果然该函数没被编译进内核。

然后又去平台相关的目录(arch/arm/mach-s5pv210-----我的开发板平台目录)下去搜了下,用grep -s "irq_to_gpio" ./ -r,nothing。

Documention/gpio.txt中关于这个函数的描述:

Non-error values returned from irq_to_gpio() would most commonly be used
with gpio_get_value(), for example to initialize or update driver state
when the IRQ is edge-triggered.  Note that some platforms don't support
this reverse mapping, so you should avoid using it.----原因所在

关于这两个函数:
        /* map GPIO numbers to IRQ numbers */
        int gpio_to_irq(unsigned gpio);                   //参数是gpio,返回中断编号

        /* map IRQ numbers to GPIO numbers (avoid using this) */
        int irq_to_gpio(unsigned irq);                      //参数是中断编号,返回对应gpio
中断脚是我们自己定义的,我把驱动中irq_to_gpio函数全部替换成对应的gpio number。有没有问题还有待验证,不过编译是通过了。