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

Static functions in Linux device driver?

Is there a reason why most function definition in device driver in linux code is defined as static? Is there a reason for this? I was told this is for scoping and to prevent namespace pollution, could anyone explain it in detail why static…
andycjw
  • 1,021
  • 1
  • 8
  • 11
10
votes
2 answers

What is DMA mapping and DMA engine in context of linux kernel?

What is DMA mapping and DMA engine in context of linux kernel? When DMA mapping API and DMA engine API can be used in Linux Device Driver? Any real Linux Device Driver example as a reference would be great.
Jagdish
  • 1,848
  • 3
  • 22
  • 33
10
votes
3 answers

Configure Parameters of LED Trigger from Kernel Space

I'm working on an embedded project. Our board is using Linux kernel v3.16.7. I'm working on supporting a couple of peripheral LEDs that monitor activity. I've successfully modified the boot procedure to load the drivers and create sysfs entries in…
Woodrow Barlow
  • 8,477
  • 3
  • 48
  • 86
10
votes
5 answers

What options do we have for communication between a user program and a Linux Kernel Module?

I am a new comer to Linux Kernel Module programming. From the material that I have read so far, I have found that there are 3 ways for a user program to request services or to communicate with a Linux Kernel Module a device file in /dev a file in…
binW
  • 13,220
  • 11
  • 56
  • 69
10
votes
1 answer

Difference in writing a platform device driver for x86 and ARM

I previously worked on ARM Specific platform drivers, recently shifted to Intel Atom based. On ARM, it used to have arch/arm/boot/dts/xx.dts and arch/arm/mach-xx/ for adding platform devices. I am not seeing these files or folders on x86. When I…
anikhan
  • 1,147
  • 3
  • 18
  • 44
10
votes
3 answers

How to listen to new forks in kernel

kernel: 3.4+ Does anyone know of any other way beside using kernel process events connector to "listen" to new forks. I want to be simply notified in my module every time a new task (process) is created.
10
votes
2 answers

Linux Device Tree Help (GPIO controller/interrupts)

I've been learning about linux device trees and we've been trying to start porting some of our older code to use them. I'm having a little bit of trouble with the gpio controller node: gpio1: gpio-controller@c00 { #gpio-cells = <2>; …
nigp4w rudy
  • 525
  • 1
  • 5
  • 9
10
votes
1 answer

Writing an external program to interface with wpa_supplicant in C++

As I understand it one can simply link wpa_ctrl.c into an external program and then you are able to use it's functions to control and receive information from wpa_supplicant. Could someone please provide an example, preferably in C++, how you…
Nimjox
  • 1,271
  • 5
  • 18
  • 33
10
votes
2 answers

Can the Linux kernel use pageable (swappable) memory for its own buffers?

If the answer to the question is NO, why is it not a good idea to do this? Can the kernel not handle and fix page faults that occur in kernel mode? Does the answer change if the code that uses pageable memory only executes as part of the bottom-half…
Mayank
  • 1,236
  • 1
  • 12
  • 22
10
votes
2 answers

why does the i2cdetect always gives UU on my RTC in embedded Linux

I'd like to communicate read from my RTC in C code rather than the "hwclock" shell command. However, when I use i2cdetect, it shows 0x68(which is my RTC slave address) is having the status "UU", which means "Probing was skipped, because this…
henryyao
  • 1,758
  • 6
  • 23
  • 37
10
votes
1 answer

"Invalid parameters" error when trying to insert module that accesses exported symbol

I'm trying to share a global variable between two modules in order to understand how to use the EXPORT_SYMBOL macro correctly, but I keep getting an Invalid paramaters error when I try to insert the second module. In the first module foo.c: #include…
Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
10
votes
3 answers

How to implement mouse drivers Linux USB mouse driver?

I need to control mouse pointer of my computer screen using an external device.I just know i have to write a device driver for that device. It's a usb device. Can anyone tell me how should i approach this problem ? What are the modules and…
geek_guy
  • 607
  • 1
  • 5
  • 17
10
votes
3 answers

What are the "struct file_operations" arguments?

I'm implementing a Linux character device driver. The linux/fs.h header file lists the file_operations without argument names. e.g. struct file_operations { struct module *owner; loff_t (*llseek) (struct file *, loff_t, int); ssize_t…
Mr Stinky
  • 881
  • 2
  • 11
  • 23
10
votes
2 answers

why to register struct cdev in driver code

This may be a novice question, but please help me to understand it. Why exactly do we need to register the struct cdev in our character driver?
sandy
  • 123
  • 1
  • 2
  • 5
10
votes
1 answer

Generate random number in kernel module

Is there a rand() equivalent function in Linux that I can call in kernel space i.e. say from inside a kernel module ?
Bandicoot
  • 3,811
  • 7
  • 35
  • 39