Questions tagged [linux-device-driver]

Device drivers take on a special role in the Linux kernel. They are distinct programmatically abstracted “black boxes” that make a particular piece of hardware respond to a well-defined internal programming interface; they hide completely the details of how the device works.

User activities are performed by means of a set of standardized calls that are independent of the specific driver. Mapping those calls to device-specific operations that act on real hardware is the role of the device driver. This programming interface is such that drivers can be built separately from the rest of the kernel and “plugged in” at runtime when needed. This modularity makes Linux device drivers easy to write, to the point that there are now thousands of them available.

There are a number of reasons to be interested in the writing of Linux device drivers.

  • The rate at which new hardware becomes available (and obsolete!) alone guarantees that driver writers will be busy for the foreseeable future.

  • Individuals may need to know about drivers in order to gain access to a particular device that is of interest to them.

  • Hardware vendors, by making a Linux device driver available for their products, can add the large and growing Linux user-base to their potential markets.

The open-source nature of the Linux system means that if the driver writer wishes, the source to a driver can be quickly disseminated to millions of users.

Source -

  1. Linux Device Drivers 3rd edition

  2. Linux module programming guide

4991 questions
12
votes
1 answer

Linux kernel dtb vs dtbo

I am developing a device driver for a device.I wanted to know besides writing the device driver what and when it is necessary for it - a device tree blob (dtb) or a device tree overlay (dtbo). Is it possible to dynamically insert the dtb (after…
Raulp
  • 7,758
  • 20
  • 93
  • 155
12
votes
4 answers

Easiest way to use DMA in Linux

I'm a EE and for a project at uni I'm developing hardware assisted image/video filtering on an FPGA (Xilinx ZYNQ), said device also has a dual core ARM A9 processor inside and more importantly there is also an ARM Primecell PL330 DMA controller I'm…
12
votes
5 answers

Mapping DMA buffers to userspace

i am writing a device driver on linux-2.6.26. I want to have a dma buffer mapped into userspace for sending data from driver to userspace application. Please suggest some good tutorial on it. Thanks
Ravi Gupta
  • 6,258
  • 17
  • 56
  • 79
12
votes
3 answers

What is the difference between module_init and init_module in a Linux kernel module?

I have been trying to port few linux drivers and realized that there is substantial difference between kernel version 2.4 and 2.6 of linux. In the 2.4 version of kernel, the module programming was as below - #define MODULE #include…
12
votes
2 answers

Interpretation of gpio: in fixed-regulator device tree entry?

I'm trying to control (on/off) a voltage regulator that is mapped to a GPIO pin and powers an external device. The device tree for the regulator has the following entry: reg_usb1_vbus: usb1_vbus { compatible = "regulator-fixed"; …
12
votes
6 answers

How to communicate with a Linux kernel module from user space without littering /dev with new nodes?

What are the ways to communicate with a kernel module from user space? By communication i mean sending information and commands between the kernel module and a user space process. I currently know of two way: open/close/read/write/ioctl on…
Inso Reiges
  • 1,889
  • 3
  • 17
  • 30
12
votes
1 answer

What's the CONFIG_OF in linux?

I see that it is being widely used at many places but could not understand in what scenarios I need to use it. What is CONFIG_OF? What is the full name of "OF"?
Jerikc XIONG
  • 3,517
  • 5
  • 42
  • 71
12
votes
1 answer

difference between pci_alloc_consistent and dma_alloc_coherent

I am working on pcie based network driver. Different examples use one of pci_alloc_consistent or dma_alloc_coherent to get memory for transmission and reception descriptors. Which one is better if any and what is the difference between the two?
bdubey
  • 307
  • 4
  • 13
12
votes
1 answer

Enlarge Linux Kernel Log Buffer more that 2M

I am in the process of collecting some sort of Linux Kernel activities. I have placed multiple printk statements with in the kernel source code and would like to monitor those during regular kernel activities. Unfortunately, I have realized that the…
ARH
  • 1,355
  • 3
  • 18
  • 32
12
votes
1 answer

Enabling write-combining IO access in userspace

I have a PCIe device with a userspace driver. I'm writing commands to the device through a BAR, the commands are latency sensitive and amount of data is small (~64-bytes) so I don't want to use DMA. If I remap the physical address of the BAR in the…
Chiggs
  • 2,824
  • 21
  • 31
12
votes
2 answers

What happens when two interrupts occur at the same time in linux kernel

What happens when two interrupts occur at the same time in the Linux kernel..? If that processor has more than one CPU can the interrupts run on different cpu cores at the same time.
Adi
  • 729
  • 2
  • 6
  • 13
12
votes
3 answers

Linux driver development: Difference between PCI and PCIe driver?

I'm programming a PCI driver for Linux 2.6.36. Here is my code. My question is, do I have to do some modifications if I want to use this driver for a PCIe device? #include #include #include #include…
Peter
  • 1,629
  • 2
  • 25
  • 45
11
votes
2 answers

how to access and debug a FDT/DTS device tree from a Linux driver (seg-fault)

I have written a Linux kernel-module to act as an FPGA driver for a custom board based off the Freescale P2020RDB. The driver contains several #defines to specify various addresses, sizes, bus-widths, etc. I would like to access the board's…
Trevor
  • 1,613
  • 3
  • 22
  • 34
11
votes
1 answer

Adding entry to task_struct and initializing to default value

I want to add an entry to process control block structure (task_struct). Let say a way to tag some process. I want to initialize this field to 0 for all the process except "some special processes", later by calling sched_setscheduler() I will set…
David
  • 4,634
  • 7
  • 35
  • 42
11
votes
1 answer

mmap: mapping in user space a kernel buffer allocated with kmalloc

Which is the correct way to map in an user space process a buffer allocated with kmalloc? Maybe i didn't understand memory mapping yet...I write a kernel module that allocs this buffer (for example 120 bytes) and i would read and write it in a…
MirkoBanchi
  • 2,173
  • 5
  • 35
  • 52