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
36
votes
3 answers

why is u8 u16 u32 u64 used instead of unsigned int in kernel programming

I see u8 u16 u32 u64 data types being used in kernel code. And I am wondering why is there need to use u8 or u16 or u32 or u64 and not unsigned int?
user966588
36
votes
7 answers

Finding original MAC address from hardware itself

Is it possible to read the MAC address from the NIC directly? I have the code below but it just reads from the layer above but not the card itself. I'm trying to figure out how to find the original MAC address of an Ethernet NIC on my Linux box. I…
Jatin Bodarya
  • 1,425
  • 2
  • 20
  • 32
36
votes
6 answers

BSP vs Device-Drivers

While understanding each by itself (or maybe not), it looks like I'm far from understanding the practical differences between the two. Per my understanding, a BSP is a package of drivers and configuration settings that allows a kernel image to boot…
EdwardH
  • 1,523
  • 2
  • 12
  • 20
35
votes
9 answers

Content for Linux Operating Systems Class

I will be TA for an operating systems class this upcoming semester. The labs will deal specifically with the Linux Kernel. What concepts/components of the Linux kernel do you think are the most important to cover in the class? What do you wish was…
Sweeney
  • 672
  • 4
  • 6
35
votes
7 answers

Linux kernel device driver programming

I want to learn linux kernel device driver programming. So can anyone please post good tutorials pages or links here. I am new to linux kernel environment. I have searched for it but I don't know how to start and which one to read for easy…
Raj
  • 1,013
  • 2
  • 11
  • 23
34
votes
4 answers

Module not found when I do a modprobe

I am trying to install this module: https://github.com/mkottman/acpi_call I did a make, make install. I then saw acpi_call.ko is in /lib/modules/4.3.3-5-default/extra/. When I do a modprobe acpi_call I get modprobe: FATAL: Module acpi_call not…
robert trudel
  • 5,283
  • 17
  • 72
  • 124
34
votes
6 answers

M option in make command, Makefile

make -C ~/kernel-2.6 M=`pwd` modules What is the meaning in M='pwd' in the line above ? I could not understand the explanation : The M= option causes that makefile to move back into your module source directory before trying to build the modules…
user1047069
  • 935
  • 2
  • 13
  • 25
34
votes
3 answers

module_init() vs. core_initcall() vs. early_initcall()

In drivers I often see these three types of init functions being used. module_init() core_initcall() early_initcall() Under what circumstances should I use them? Also, are there any other ways of init?
Sandeep
  • 18,356
  • 16
  • 68
  • 108
34
votes
2 answers

Userspace vs kernel space driver

I am looking to write a PWM driver. I know that there are two ways we can control a hardware driver: User space driver. Kernel space driver If in general (do not consider a PWM driver case) we have to make a decision whether to go for user…
Katoch
  • 2,709
  • 9
  • 51
  • 84
33
votes
1 answer

What does ERESTARTSYS used while writing linux driver?

I'm learning about the blocking I/O functions for writing linux device driver and I'm wondering what is the usage of ERESTARTSYS. Consider the following: Global variable : wait_queue_head_t my_wait_q_head; int read_avail = 0; device_init() :…
I'm a frog dragon
  • 7,865
  • 7
  • 46
  • 49
33
votes
3 answers

proc_create() example for kernel module

Can someone give me proc_create() example? Earlier they used create_proc_entry() in the kernel but now they are using proc_create().
Rahul
  • 1,607
  • 3
  • 23
  • 41
32
votes
2 answers

How do I intercept messages from a USB device on Linux?

I have a popular drawing tablet that I connect to my PC with USB. Once connected, the tablet detects hand movements and manipulates the pointer accordingly. Somewhere, the tablet is transmitting this data to my computer. My goal is to intercept…
sdasdadas
  • 23,917
  • 20
  • 63
  • 148
32
votes
5 answers

How to find out which Linux driver is hogging my GPIO

I have a pad multiplxed as GPIO on my board. When I try to export it via /sys/class/gpio/export, I get -sh: echo: write error: Device or resource busy My guess is some other driver is requesting this pad before I get that chance. How can I find…
Atilla Filiz
  • 2,383
  • 8
  • 29
  • 47
32
votes
4 answers

What is the Linux built-in driver load order?

How can we customize the built-in driver load order (to make some built-in driver module load first, and the dependent module load later)?
Dien Nguyen
  • 2,019
  • 6
  • 30
  • 37
31
votes
4 answers

Difference between Kernel Virtual Address and Kernel Logical Address?

I am not able to exactly difference between kernel logical address and virtual address. In Linux device driver book it says that all logical address are kernel virtual address, and virtual address doesn't have any linear mapping. But logically wise…
Rahul
  • 1,607
  • 3
  • 23
  • 41