Simple IRQ Driver Issue

I am writing a simple driver with an irq for Dragonboard410c. Kernel was built from 2016.03 branch.
I am using gpio_request, gpio_direction_input, gpio_to_irq, and request_irq in my code, but I’ve got the following errors at run-time.

Unknown symbol gpiod_to_irq (err 0)
Unknown symbol gpio_free (err 0)
Unknown symbol gpiod_direction_input (err 0)
Unknown symbol gpio_to_desc (err 0)
Unknown symbol gpio_request (error 0)

I used GPIO_C (13) in my code.
I need your help.


Hi @hham,

I am not so sure only with from the error message but are you trying to write a new kernel driver using GPIO?

I am not good at writing kernel driver either but I would start from including “linux/gpio/consumer.h” the source code and turn on GPIOLIB in the kernel config option.

Would this help?

Hi, Akira.
Thank you for your quick answer.
Yes, I am writing a simple device driver using GPIO interrupt. Including “linux/gpio/consumer.h” was not helpful. The following configs from kernel config(distro.config) are included already.


However, it doesn’t help. Any other clue?

The last kernel module I wrote that used GPIOs and interrupts required the following includes:
#include <linux/init.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/cdev.h>
#include <asm/uaccess.h>
#include <linux/device.h>
#include <linux/gpio.h>
#include <linux/interrupt.h>
#include <linux/workqueue.h>

This was on a different system, however linux/gpio.h is what defines gpio_request and gpio_free, so it’s a start.

Is MODULE_LICENSE defined? Maybe you can share your code?

Hi suicidaleggroll and vchong,
Thank you for your answer. Yes, MODULE_LICENSE is defined, and it has been fixed since I added all the include files.

Now I have another issue, gpio_request failure. I am using GPIO_C(13). When I called gpio_request, I get -16(EBUSY). What can I do to make GPIO_C usable?

I think it’s being used as an spi pin as specified in the DT [1].
If true, you’ll have to change the DT to configure it as gpio instead and rebuild.