Notify gpio interrupt for user space from kernel module

I have code that detects a GPIO interrupt in a kernel module. Now I am looking for a mechanism to notify user space when a gpio interrupt is detected from the kernel module. Any example / code snippet with certain advantages / disadvantages compared to other parameters? I would appreciate your reply.

+4
source share
3 answers

Take a look at the GPIO keyboard driver ( drivers/input/keyboard/gpio_keys.c). This is a good starting point for your problem.

In user space, you then listen (for example, to block reading, for example, or just tailto check), for /dev/input/youreventfor events.

+1
source

You can send a signal to the user space stream from the kernel API, which can help you run non-blocking:

send_sig(int sig, struct task_struct *p, int priv)

But there is a limitation: you need to know the pid of the user thread in the kernel. You can do this by writing the pid of the user process via / proc, and then the kernel reading the pid. With this arrangement, when there is an interrupt, the kernel can send a signal to the user thread. If your process reboots or gets killed, you will have to update the pid via proc.

, , . Netlink - .

+1

: (1) (2) file_operations- > poll, poll_wait wait queue .

+1

All Articles