O'Reilly logo

Linux Device Drivers Development by John Madieu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Driver examples

One can summarize thing in the two following drivers. The first one is a polled input device, based on a GPIO non-mapped to IRQ. The polled input core will poll the GPIO to sense any change. This driver is configured to send 0 key code. Each GPIO state corresponds either to key press or key release:

#include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/of.h> /* For DT*/ #include <linux/platform_device.h> /* For platform devices */ #include <linux/gpio/consumer.h> /* For GPIO Descriptor interface */ #include <linux/input.h> #include <linux/input-polldev.h> struct poll_btn_data { struct gpio_desc *btn_gpiod; struct input_polled_dev *poll_dev; }; static void polled_btn_open(struct input_polled_dev ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required