From the course: Linux Device Drivers

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Write a character device driver

Write a character device driver - Linux Tutorial

From the course: Linux Device Drivers

Start my 1-month free trial

Write a character device driver

- [Instructor] Let's look at the essential part of a character device driver, so we can write a character device driver. First, we'll look at a real brief little skeleton of a character driver. Then we'll look at the very important file operations struct creating instance of that. We'll talk about saying in your code that you're going to be a character driver, registering as a character driver. And then we'll look at implementing read and write. So, when you write a character device driver for Linux, you need to create an instance of the file operations struct, and assign the fields in there that you need for your driver. Say the field for read and write. Then you need to implement those functions. You'll need your module init function. And in your module init function is where you'll probably register as a character driver. The usual syntax for creating an instance of the file operations struct is to use the dot…

Contents