I’m writing a basic char device driver for Linux kernel. For this, the code flow I have considered is as follows: alloc_chrdev_region() -> to use dynamic allocation of major number class_create() -> to create device class in sysfs device_creat() -> to create device under /dev/ cdv_init() -> to initialize char device structure cdev_add() -> to add my device structure in
Tag: linux-device-driver
How to get name (path) of uinput created device
I have successfully set up a small program to create a uinput device which I plan to use to automate testing of an application receiving keyboard input events. I have followed both tutorials as found in this very nice answer. When my program creates the uinput device by calling ioctl(fd, UI_DEV_CREATE) a new device appears in the file system so
Implementing poll in a Linux kernel module
I have a simple character device driver that allows you to read from a custom hardware device. It uses a DMA to copy data from the device’s memory into kernel space (and then up to the user). The read call is very simple. It starts a DMA write, and then waits on a wait queue. When the DMA completes, the
How does the kernel handle a read operation on proc files when several instances of the same driver are running simultaneously
I have a question regarding the way proc files are handled when several instances of the same driver are running simultaneously. lets assume that a my system runs a couple of instances of the same driver simultaneously, but only one of them (according to some inner decision making) created a proc file and maintains the information that should be written
SystemTap script to profile latency of functions
My goal is to profile the execution time of each function in a kernel module. Using the sample scripts I saw online, I came up with the following script to fulfill my need. But occasionally I get negative values for calculated latencies. Although, they happen rarely but I guess that indicates something is wrong with my script. Can anyone help
Accessing memory pointers in hardware registers
I’m working on enhancing the stock ahci driver provided in Linux in order to perform some needed tasks. I’m at the point of attempting to issue commands to the AHCI HBA for the hard drive to process. However, whenever I do so, my system locks up and reboots. Trying to explain the process of issuing a command to an AHCI
What is importance of using GPL lincense in linux device driver
What is the exactly benefit of using MODULE_LICENSE(“GPL”) in linux device driver development. i mean what will we lack or gain by not using or using it. which kernel symbols we will not able to use when we will define MODULE as non GPL. Answer The big difference is the symbols that are exposed to your module when it is
How to write to data register in C, without touching previous writes?
Iam a beginner in C and have this scenario: I can successfully write to a gpio port with data register 0x103 and direction register 0x95. If I want to write to another pin I have to “overwrite” the previously pin. As if I first write 00010000 and then want to make another pin high I need to write 00010001 to
Audio Channel change/swap automatically
I am working with digital TV in Linux platform. Currently I am facing with one issue in audio. When I give stereo audio to Function and after long time running the audio channels get swapped. That is, right channel audio hearing in Left channel and Left in Right. I dumped the PCM data in to a file before giving to
Usage of nfc tag ACR1251U on raspberry-pi
I have an NFC tag ACR1251U-A1. I need to use that with Raspberry Pi. I have installed the driver on Raspberry Pi via this link: http://www.acs.com.hk/download-driver-unified/6258/ACS-Unified-Driver-Lnx-Mac-110-P.zip But when I list the nfc devices on terminal by writing “nfc-list”, I don’t see any device list. Do you know how can I use it on my raspberry-pi? Thanks Answer NFC-list does not