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

creating virtual bluetooth device/service and let executing computer discover/use them

Reading this question I sarted to wonder, whether it would be possible to not only let a program emulate a bluetooth device, but also let the (executing) computer think, that it is actually an external bluetooth device he'd be communicating with. I…
Sim
  • 4,199
  • 4
  • 39
  • 77
11
votes
4 answers

Why empty critical section within netfilter hooks, occurs `BUG: scheduling while atomic error`?

I've written this hook: #include #include #include #include #include #include static struct nf_hook_ops nfho; static struct mutex…
11
votes
1 answer

Configuration registers for LPC bus in Poulsbo System Controller Hub (US15W)

We have a system based around an Atom Z510/Intel SCH US15W Q7 card (running Debian Linux.) We need to transfer blocks of data from a device on the Low Pin Count Bus. As far as I know this chipset does not provide DMA facilities, meaning the…
11
votes
2 answers

What does this generic function do?

static inline __printf(2, 3) int dev_err(const struct device *dev, const char *fmt, ...) { return 0; } What is __printf() doing and what does the third arg(...) of dev_err mean? I'm able to visualize that this function is some kind of generic…
Ajith
  • 125
  • 1
  • 5
11
votes
1 answer

Why doesn't this call to `poll` block correctly on a sysfs device attribute file?

I have a simple sysfs device attribute which shows up under my sysfs directory, and on a call to read returns the value of a kernelspace variable. I want to call poll on this attribute to allow my userspace thread to block until the value shown by…
Vilhelm Gray
  • 11,516
  • 10
  • 61
  • 114
11
votes
1 answer

Identify kernel module which created a sysfs entry

On a running Linux system, I want to know which device driver module created a particular sysfs entry. Is it possible to know? I know I can grep for relevant strings in the kernel source and try to identify. But, is there a way without doing that?
Santhosh N
  • 157
  • 10
11
votes
3 answers

How can I programmatically set permissions on my char device

I've recently inherited some code at work, this is old 2.4.X linux kernel drivers and I've been tasked with getting them working on a newer kernel 2.6 or greater. I'm running on OpenSUSE 12.1 with a 3.1.10 kernel. I've updated the original code…
Mike
  • 47,263
  • 29
  • 113
  • 177
11
votes
2 answers

ioctl vs netlink vs memmap to communicate between kernel space and user space

Got some statistics information of our custom hardware to be displayed whenever user asks for using a command in the Linux user space. This implementation is currently uses PROC interface. We started adding more statistics information then we…
lxusr
  • 987
  • 3
  • 16
  • 28
10
votes
2 answers

Emulate a hard drive in Linux

I have developed a FUSE-based file system as part of a research project and now have to study the actual read/write requests that are received by the hard drive. In an attempt to do this, I am looking at the option of creating a virtual Hard Drive…
10
votes
1 answer

What is the relationship between framebuffer, VT, and tty?

I'm now studying what is the mechanism behind Ctrl+Alt+F1~F7. I found some infomation talk about framebuffer, VT, and tty. I know framebuffer is an anstraction to graphic card manipulation and tty(and pts) is something a program interact with. I…
Jisa
  • 101
  • 1
  • 4
10
votes
1 answer

MTD Erase Block Size of zero for SRAM

Refined Question How do read and write text information from a MTD SRAM device with erase block size zero? Notes: I am using the 23K256 Driver Attempts to use MTD-Util tools have failed because libmtd cannot handle a erase block size of…
Liam Kelly
  • 3,524
  • 1
  • 17
  • 41
10
votes
3 answers

How can I know if a USB device is already in use?

I am writing a C++ Linux userspace driver for a USB device using the C library libusb. I have two copies of the same device (same vendor ID and product ID) and would like to know how to handle this case. Here are the possibilities I can think…
Magix
  • 4,989
  • 7
  • 26
  • 50
10
votes
1 answer

Device Specific Data Structure with Platform Driver and Character Device Interface

I'm struggling with understanding the linkup between a platform device driver with a character device interface and storing data in a device specific data structure. I created a struct keeping track of data related to my device, and then add it to…
10
votes
3 answers

How to attach file operations to sysfs attribute in platform driver?

I wrote a platform driver for a peripheral we developed and would like to expose some configuration options to the sysfs. I have managed to create the appropriate files using attribute structs (see below) and sysfs_create_file in the probe function,…
10
votes
1 answer

i2cdetect doesn't find anything on goodix chip

I have a goodix chip for the touchscreen on my tablet PC and even though I compiled the latest kernel module for it, things are not working. I am using exactly this kernel version with the patched driver: https://github.com/NimbleX/kernel For…