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

Why when I use copy_from_user, some vague character added to original buffer?

I've created WRITE_IOCTL in kernel module and I call it in user mode: ioctl(fd, WRITE_IOCTL, "Hello, Kernel!"); In kernel mode I have: static int device_ioctl(struct file *filp, unsigned int cmd, unsigned long args) { char buff[14]; switch…
Milad Khajavi
  • 2,769
  • 9
  • 41
  • 66
2
votes
2 answers

(unsigned *) better than (unsigned int *) for parsing memory?

I understand the difference between unsigned and unsigned int. But my question is a bit different. I am ioremaping(linux) a particular memory and i want to read the memory. I did the following thig : func() { unsigned int *p; p = (unsigned…
Sandeep
  • 18,356
  • 16
  • 68
  • 108
2
votes
2 answers

How to create a folder within a folder in sysfs

I am trying to create a sysfs for an implementation of mine in android and stuck at creating a folder of my own in CLASS. My requirement: /sys/class/example_class/my_sysfs_directory/file_one. Code: #include
Madara
  • 163
  • 2
  • 11
2
votes
1 answer

Getting error: implicit declaration of function 'proc_create'

I am getting the "implicit declaration of function 'proc_create'" error while compiling my driver module.I want to create a entry in /proc and print the number of programs which are using the module. Can you please let me know what is wrong in…
mohan.t
  • 257
  • 5
  • 12
2
votes
0 answers

All read/write requests are served (and ended). However, the process is hung and diskstats shows pending requests

I am writing this block device driver. From the logs I can see that all requests the block has received were served. Here is the code for fetching requests from the queue: /* Gets the current request from the dispatch queue */ while ((req =…
feeling_lonely
  • 6,665
  • 4
  • 27
  • 53
2
votes
2 answers

Why device exist in /proc/devices evethough module is unloaded

I am writing a simple charcter driver scull based on ldd. For my sample character driver, evethough module is unloaded device with major number exist in /proc/devices. How to remove that? My module exit function has void scull_exit(void) { …
user567879
  • 5,139
  • 20
  • 71
  • 105
2
votes
1 answer

blocked for more than 120 seconds

I am trying to write a block device driver that reads/writes blocks off of/to a network socket. At some point the when reading multiple blocks the application that uses this driver seems to hang (but would still accept input even though it does…
feeling_lonely
  • 6,665
  • 4
  • 27
  • 53
2
votes
2 answers

Implement SDIO to interface SPI device

People, I have always seen references about how to use a SPI interface to operate a SD memory card. This is not what I want. I need to do exactly the opposite. I want to be able to use the SDIO controller (through SD slot) in my "host" (any PC…
j4x
  • 3,595
  • 3
  • 33
  • 64
2
votes
2 answers

getting list of devices inside another driver

I need a device driver that I'm writing/modifying to be able to access another device in the system. I know some information about the driver, like the name and/or address, in order to look it up, but I can't find how to actually do the look up. …
JonS
  • 621
  • 7
  • 25
2
votes
0 answers

why we make all struct static in kernel programming

While trying Linux kernel programming i found that for every built-in structures we use static. I believe (as i understood) all device's has their own scope inside corresponding driver's space and it stays live until we disconnect the device. Then…
Kumar Gaurav
  • 1,287
  • 3
  • 19
  • 47
2
votes
1 answer

Callback from userspace to kernel space

I am looking into the fpga driver code which will write some value to FPGA device at low level. At top level in user space value is being written to /dev/fpga, now I guess this is the logic how driver gets its value from user-space and exposed file…
2
votes
1 answer

3G Internet stick - which library makes this work

I have 3G internet stick, Tele2 Huawei MF190. Now, when I connect it with Ubuntu, Debian etc., it asks me for my PIN and I just choose my provider and everything works great. Now, when I do the same thing on other Linux distributions (I think it was…
NullCod3
  • 321
  • 1
  • 3
  • 10
2
votes
2 answers

what are mali.ko and ump.ko used for in lib/modules

I found two kernel modules in /lib/modules folder, they are mali.ko and ump.ko, and I tried to google some information about it, unfortunately, I found nothing valuable information. if you have worked on those two kernel modules, can you tell me…
2
votes
1 answer

Linux Device Drivers 3rd Ed and 3.2 kernel

I understand the 3.2 kernel is mostly an evolutionary step, but I'd like to play around with some simple device drivers for a project I'm working on. Is the info in Linux Device Drivers 3rd Ed (Corbet, Rubini and Kroah-Hartman, O'Reilly) still…
David G
  • 5,408
  • 1
  • 23
  • 19
2
votes
1 answer

Monitor mode on Raspberry Pi (Raspbian)

I tried to enter monitor mode with my wlan-usb stick on my raspberry pi following this two instructions: https://github.com/hexameron/rtlwifi https://stackoverflow.com/questions/16365487/kali-linux-on-raspberry-pi-wlan0-monitor-mode I'm using the…
luckylynx
  • 53
  • 1
  • 4