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
2
votes
1 answer

Writing a device driver for Platform Bus in Embedded Systems?

I have gone through some driver implementation in Linux Kernel Source and can see that these are the platform driver. drivers/net/ethernet/smsc/smsc911x.c static struct platform_driver smc911x_driver = { .probe = smc911x_drv_probe, …
Amit Singh Tomar
  • 8,380
  • 27
  • 120
  • 199
2
votes
2 answers

How to calculate TCP/UDP checksum for non-linear skb / payload?

I'm trying to calculate TCP/UDP headers checksum on an skb that is being sent out. Basically, there are two functions that are supposed to do all the work (mentioned also in this stackoverflow question and this one…
kliteyn
  • 1,917
  • 11
  • 24
2
votes
1 answer

Modify all network packets sent over the interface

In want to modify the TCP/IP portion of the Linux kernel where i can to intercept every packet going out to each interface. I need to intercept them and modify the IPv6 destination Options header. I am not sure how to start with this. Any pointers…
Nuetrino
  • 1,099
  • 1
  • 14
  • 32
2
votes
1 answer

Free a physiclal memory page and force a page fault

I would like to write a kernel function/module that will duplicate a specific page from a specific process, and then free that particular page. The module/function will then do whatever necessary to force that process into a page fault the next time…
2
votes
0 answers

USB storage can't detected

I have a usb mass storage, and today I insert into usb port, the usb can't be open, I using "dmesg" to see infomation adan@adan-Latitude-D630:~$ dmesg | tail [ 409.001220] composite sync not supported [ 616.340074] usb 2-1: new high-speed USB…
gladman
  • 1,208
  • 4
  • 19
  • 39
2
votes
1 answer

Incorrect len of msg in netlink socket

I tried to use netlink socket to send binary data from kernel space to user space. I followed the example from How to use netlink socket to communicate with a kernel module? However at the receiving end in userspace, I am getting received data…
Anup Warnulkar
  • 773
  • 1
  • 8
  • 25
2
votes
0 answers

printk/pr_info still not printing to kernel buffer

I'm trying to debug why a change I made isn't working as it should. It's quite strange because there's two different builds of this driver running simultaneously (mpt2sas and mpt3sas) and the change is such that it's identical for both. The change…
Andrew Falanga
  • 2,274
  • 4
  • 26
  • 51
2
votes
2 answers

Function name and address missing from Linux System.map

I am doing embedded development on an AT91SAM9263 board and running into a strange problem. It is running debian Linux kernel 2.6.18.4 and is cross-compiled with arm-linux-gcc 3.4.6 and uses uClibc-0.9.28 for the C library. I am debugging a kernel…
2
votes
1 answer

Best way to read/write to another block device from kernel mode

I'm writing a simple block dev driver to overcome some limitations with porting a previously hardware based RAID array to linux's software raid (mdadm). This driver will create it's own block device, but proxy r/w requests to 1 or more other block…
Litch
  • 686
  • 1
  • 7
  • 17
2
votes
2 answers

Is it possible to write a char driver without using file_operations structure?

I wonder if there is a way to write char drivers without using any of the functions provided in file_operations structure. I am very new to Linux device drivers and as any novice would do, I started reading LDD3 book. And I was successful in writing…
Sagar Jain
  • 7,475
  • 12
  • 47
  • 83
2
votes
2 answers

Difference between device_register and driver_register

I am writing a UART driver. I came across the two functions in the chapter 14.Linux Device Model. int device_register(struct device *dev); int driver_register(struct device_driver *drv); Since UART is a char driver I have dynamically created the…
ddpd
  • 603
  • 1
  • 10
  • 25
2
votes
1 answer

what does the flag IRQF_SAMPLE_RANDOM specify while registering interrupt handlers?

In request_irq() to register interrupt handlers, why we use the flag IRQF_SAMPLE_RANDOM and what is entropy pool?
2
votes
2 answers

How Kernel stack is used in case of different processor mode in ARM architecture?

As I understand every process have a user stack and kernel stack. Apart from that there is a stack for every mode in ARM achitecture. So I want to know How different stack and stack pointer works in ARM modes? Also when this kernel stack associated…
Rahul
  • 1,607
  • 3
  • 23
  • 41
2
votes
0 answers

Releasing semaphore in atomic context [linux kernel]?

While sending a bio down for write IO, I acquire a semaphore (down_interruptible). And in the IO completion routine i.e. inside bio_end_io, I release the semaphore (up). I know that acquiring a semaphore in completion routine is illegal as the…
user45874
  • 41
  • 2
2
votes
2 answers

How to attach to device context in another driver at Linux

Example: I use sensor TMP421 which driver is linux/drivers/hwmon/tmp421.c. It will export to /sys/class/hwmon/hwon0/.... And user can use cat command to read the temperatures. But my is request: I want to read it at kernel space to control some…
yvo.engr
  • 131
  • 2
  • 5