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
22
votes
4 answers

Isolate Kernel Module to a Specific Core Using Cpuset

From user-space we can use cpuset to actually isolate a specific core in our system and execute just one specific process to that core. I'm trying to do the same thing with a kernel module. So I want the module to get executed in an isolated core.…
insumity
  • 5,311
  • 8
  • 36
  • 64
22
votes
2 answers

What is the difference between devm_kzalloc() and kzalloc() in linux driver programming

I have found devm_kzalloc() and kzalloc() in device driver programmong. But I don't know when/where to use these functions. Can anyone please specify the importance of these functions and their usage.
Raj
  • 1,013
  • 2
  • 11
  • 23
21
votes
2 answers

Allocating more than 4 MB of pinned contiguous memory in the Linux Kernel

For some interaction with a PCI device that is being built, we'd like to create large contiguous pieces of memory that the board can access. As it stands now, the largest piece of memory that I've been able to allocate is 4 megabytes in size. I'm…
Bill Lynch
  • 80,138
  • 16
  • 128
  • 173
21
votes
1 answer

What is the difference between .dts file and .dtsi file?

What is the difference between .dts file and .dtsi file? Is there a difference when generating device tree blobs? When to use one or the other?
Leos313
  • 5,152
  • 6
  • 40
  • 69
21
votes
3 answers

Do Kernel pages get swapped out?

Pertaining to the Linux kernel, do "Kernel" pages ever get swapped out ? Also, do User space pages ever get to reside in ZONE_NORMAL ?
TheLoneJoker
  • 1,589
  • 1
  • 23
  • 36
21
votes
4 answers

How the util of iostat is computed?

iostat -x -d can display many i/o statistic info. For util of iostat, the explanation is : Percentage of CPU time during which I/O requests were issued to the device (band-width utilization for the device). Device saturation occurs when this …
Raymond
  • 561
  • 1
  • 4
  • 14
21
votes
4 answers

Linux kernel: why do 'subclass' structs put base class info at end?

I was reading the chapter in Beautiful Code on the Linux kernel and the author discusses how Linux kernel implements inheritance in the C language (amongst other topics). In a nutshell, a 'base' struct is defined and in order to inherit from it the…
MikeTheTall
  • 3,214
  • 4
  • 31
  • 40
21
votes
2 answers

New to Linux Kernel/Driver development

Recently, i began developing a driver of an embedded device running linux. Until now i have only read about linux internals. Having no prior experience in driver devlopment, i am finding it a tad difficult to land my first step. I have downloaded…
TheCodeArtist
  • 21,479
  • 4
  • 69
  • 130
21
votes
2 answers

What is the difference between misc drivers and char drivers?

I'm reading about misc drivers in Linux, and I'm a little confused about the differences between them and char drivers. One source, the Linux journal, writes: Alessandro tells us how to register a small device needing a single entry point with…
Mike
  • 47,263
  • 29
  • 113
  • 177
21
votes
1 answer

How to interpret addresses in a kernel oops

I have a kernel oops in a linux device driver I wrote. I want to determine which line is responsible for the oops. I have the following output, but I do not know how to interpret it. Does it mean my code crashed at the instruction at write_func +…
Hans Then
  • 10,935
  • 3
  • 32
  • 51
21
votes
3 answers

Adding new driver code to linux source code

I have developed a Linux device driver. As of now I am compiling it on Ubuntu 12.04 with cross-compiler for arm and then insmoding it in my arm Linux image. But I want to learn how I can add it in Linux source code and give and option to add/remove…
Ravi
  • 251
  • 2
  • 3
  • 11
20
votes
3 answers

How can I monitor the NIC status(up/down) in a C program without polling the kernel?

Now I need to get the status of the NIC(up or down) in the real time. That means I have to catch the kernel interrupt when the NIC up or down in a blocked loop. The first stupid method from mine is that check on the /sys/class/net/eth0/operstate or…
20
votes
4 answers

Function caller in linux kernel

Is there a way to get function caller in linux kernel? I know __func__ returns the function name which is executing. I am looking for the function which called "__func__"
BHS
  • 991
  • 3
  • 12
  • 26
20
votes
3 answers

How to create a simple sysfs class attribute in Linux kernel v3.2

I'm learning how to use sysfs in my Linux modules, but I'm having the hardest time finding current documentation on these topics. The Linux Device Drivers 3rd Edition book I've been using seems to be rather dated in this area unfortunately (e.g. the…
Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
20
votes
8 answers

How to write device drivers in Javascript?

Is it possible to write hardware drivers in Javascript? What would be the steps required for such a task? Also, I was unsure where to post this, so any suggestions regarding this are also welcome. I hope this is the accurate location for the…
Leila Hamon
  • 2,505
  • 7
  • 24
  • 32