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
19
votes
2 answers

How remap_pfn_range remaps kernel memory to user space?

remap_pfn_range function (used in mmap call in driver) can be used to map kernel memory to user space. How is it done? Can anyone explain precise steps? Kernel Mode is a privileged mode (PM) while user space is non privileged (NPM). In PM CPU can…
19
votes
2 answers

Storage & Network device drivers source code for Nexus 6 and Samsung Galaxy S6

For university research purposes, I am searching for a specific part of Nexus 6, and Samsung Galaxy S6 source code. Particularly, I am interested in "network" & "storage" driver source codes. I have visited developer resources for both Samsung…
Behnam
  • 6,510
  • 6
  • 35
  • 65
19
votes
1 answer

Some questions on dma_alloc_coherent

Is the DMA address returned from this call the same as the physical address? LDD3 says the DMA address should be treated as opaque by the driver. I want to mmap this DMA buffer so user-space can read/write directly to it. Question is what PFN…
ravi
  • 487
  • 2
  • 4
  • 12
19
votes
3 answers

How to mmap a Linux kernel buffer to user space?

Let's say the buffer is allocated using a page based scheme. One way to implement mmap would be to use remap_pfn_range but LDD3 says this does not work for conventional memory. It appears we can work around this by marking the page(s) reserved using…
ravi
  • 487
  • 2
  • 4
  • 12
18
votes
1 answer

How to learn the structure of Linux wireless drivers (mac80211)?

There is so many structures in the Linux wireless driver mac80211. Things like struct net_device, struct ieee80211_hw, struct ieee80211_vif and struct ieee80211_local and so on. So many structures that I don't understand what information they…
user907124
  • 181
  • 1
  • 2
  • 4
18
votes
2 answers

Hello Word Device Tree Based device driver

I have read and almost gone through all the linux kernel documentation on the device tree and device tree overlays.I am not able to understand if we have to create a new entree in the device tree of the platform or to create a new overlay for the…
Raulp
  • 7,758
  • 20
  • 93
  • 155
18
votes
1 answer

Order of preference - printk() vs dev_dbg() vs netdev_dbg()

I recently ran a the scripts/checkpatch.pl script within the linux source tree and got this Warning: WARNING: Prefer netdev_dbg(netdev, ... then dev_dbg(dev, ... then pr_debug(... to printk(KERN_DEBUG ... printk(KERN_DEBUG "Hello World! \n"); I…
Yogesh
  • 740
  • 2
  • 7
  • 15
18
votes
1 answer

What is the difference between module_init and subsys_initcall while initializing the driver?

What is the difference between module_init and subsys_initcall while initializing the driver?
kzs
  • 1,793
  • 3
  • 24
  • 44
18
votes
5 answers

Understanding kernel message 'nobody cared (try booting with the "irqpoll" option)'

I'm trying to understand the meaning of the following message: irq N:nobody cared (try booting with the "irqpoll" option) Does this mean the IRQ handler not processing the response even it has gotten the interrupt? Or that the scheduler failed to…
AbhijitG
  • 300
  • 1
  • 2
  • 9
17
votes
1 answer

what is the meaning of obj-m: in Linux device driver Makefile

I am very new to Linux device drivers. In Makefile what is obj-m? What is the difference between obj-m and obj-m+?
Prashanth
  • 301
  • 1
  • 2
  • 5
17
votes
1 answer

dd command error writing No space left on device

I am new to storage, trying to erase the data in the device '/dev/sdcd' why should I get 'No space left error' [root@ dev]# dd if=/dev/zero of=/dev/sdcd bs=4k dd: error writing ‘/dev/sdcd’: No space left on device 1310721+0 records in 1310720+0…
Malatesh
  • 1,944
  • 6
  • 26
  • 39
17
votes
2 answers

Raspberry Pi 2 - Distortion while moving objects in Portrait mode

I am currently working on a Kiosk system based on the Raspberry Pi 2 running Raspbian which runs a Java app. Everything works perfectly well, except for a distortion on the screen which appears while objects are moving. Normally, this wouldn’t be a…
DrenImeraj
  • 171
  • 5
17
votes
1 answer

how to find if unregister_chrdev() call was successful

unregister_chrdev() call from [linux\fs.h] used to return 0 if successful and <0 other wise. But now, in newer kernel versions, the return value of the function has been changed to void so it no longer returns any thing. Question: Is there any way…
binW
  • 13,220
  • 11
  • 56
  • 69
17
votes
4 answers

Difference between dts and ACPI

We can declare platform device information in dts file, rather than hard coding every data into operating system. Taking "arm" architecture as example. it supports dts and we will take dts from arch/arm/boot/dts/xx.dts. Convert this…
anikhan
  • 1,147
  • 3
  • 18
  • 44
17
votes
3 answers

Static functions in Linux device driver

Why is it that every function in most device drivers are static? As static functions are not visible outside of the file scope. Then, how do these driver function get called by user space applications?