linux-device-driver

Linux kernel: why do 'subclass' structs put base class info at end?

十年热恋 提交于 2019-12-03 00:06:23
I was reading the chapter in Beautiful Code on the Linux kernel and the author discusses how Linux kernel implements inheritance in the C language (amongst other topics). In a nutshell, a 'base' struct is defined and in order to inherit from it the 'subclass' struct places a copy of the base at the end of the subclass struct definition. The author then spends a couple pages explaining a clever and complicated macro to figure out how many bytes to back in order to convert from the base part of the object to the subclass part of the object. My question: Within the subclass struct, why not

The order in which the device-tree text file is written, does it matter?

偶尔善良 提交于 2019-12-02 20:38:29
问题 Does the order in which a device-tree text file (.dts) is written matter at all ? For example, if you take a node from the top of the file and move it to the bottom, will it change the order of hardware detection, IRQ configuration, or whatever ? 回答1: Does the order in which the device-tree text file (.dtx) is written matter at all ? The answer for .dts and .dtsi source files is "depends". The Device Tree has a structure, so rearrangement of nodes may, or may not, change the system hardware

Detect the presence of a device when it's hot plugged in Linux

我的梦境 提交于 2019-12-02 19:34:24
I am running the SPI code on the panda board and I want to know which function in the code is responsible for detecting the device when it's hot plugged. Can somebody with the background of embedded systems, Linux device drivers and/or spi please answer my question? This is the line in your code that does the magic: 1286 MODULE_DEVICE_TABLE(of, omap_mcspi_of_match); Process: 1. Driver for each device exposes its information using the API MODULE_DEVICE_TABLE . Each device has a unique vendor Id and device Id . 2. At compilation time, the build process extracts this information out of the driver

How to get linux kernel page size programmatically

ε祈祈猫儿з 提交于 2019-12-02 18:52:27
I am working on a Linux module for IA64. My current problem is that the driver uses the PAGE_SIZE and PAGE_SHIFT macros for dma page allocation. The problem I am having is that the machine compiling the driver is not the ones that needed to run the driver. So, if the PAGE_SIZE on the compiling machine is 2^14K and the destination machine is 2^16K then the driver fails. I don't want to turn this question into a 'best practice' issue about compiling modules on machines which are not the ones running the modules. I understand the issues about that. What I found is that people mostly uses

“FATAL: Module not found error” using modprobe

纵然是瞬间 提交于 2019-12-02 17:34:43
I have a problem with modprobe command... I compiled the hello world module and loaded it with insmod , it works fine and when I do lsmod , I can see it in the output list. But when I insert this module using modprobe I am getting a FATAL error: root@okapi:/home/ravi# modprobe ./hello.ko FATAL: Module ./hello.ko not found. root@okapi:/home/ravi# Here is the module code: #include <linux/init.h> #include <linux/module.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init(void) { printk(KERN_ALERT "Hello, world\n"); return 0; } static void hello_exit(void) { printk(KERN_ALERT "Goodbye, cruel

How do I intercept messages from a USB device on Linux?

半腔热情 提交于 2019-12-02 17:34:32
I have a popular drawing tablet that I connect to my PC with USB. Once connected, the tablet detects hand movements and manipulates the pointer accordingly. Somewhere, the tablet is transmitting this data to my computer. My goal is to intercept these transmissions and manipulate the mouse after I process the data. The buzzwords I have found are: device drivers and HID , but I haven't been able to piece together much more than that. Assuming this is possible, I have a few questions: How is this done if the data format is known? How is this done if the data format is unknown/proprietary? My

Allocating more than 4 MB of pinned contiguous memory in the Linux Kernel

吃可爱长大的小学妹 提交于 2019-12-02 16:46:53
For some interaction with a PCI device that is being built, we'd like to create large contiguous pieces of memory that the board can access. As it stands now, the largest piece of memory that I've been able to allocate is 4 megabytes in size. I'm wondering if there are any methods to create larger regions. I do know that I can use the boot option mem= to do this, but for numa reasons, I'd rather not go this route. If, on the other hand, someone knew a way to do this, but distribute it over numa nodes, that would be fine. As I said initially, I'm limited to 4 Megabytes currently. Allocations

How the util of iostat is computed?

本小妞迷上赌 提交于 2019-12-02 15:58:52
iostat -x -d can display many i/o statistic info. For util of iostat, the explanation is : Percentage of CPU time during which I/O requests were issued to the device (band-width utilization for the device). Device saturation occurs when this value is close to 100% I want to know how the util was computed? I make an experiment, (see following code), start 40 thread to randomly read 40 files. I suppose the disk util should be very high, but I am wrong, the iostat is as follow, anyone can give why? THX Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util sdb1 0.01 0.44

Difference between .o and .ko file

China☆狼群 提交于 2019-12-02 15:44:11
I am writing simple Linux module mod.c. When I compile mod.c file, it creates two output file mod.o and mod.ko . So I just want to know, What is the difference between mod.o and mod.ko file? gby The short answer is that the .ko file is your object file linked with some kernel automatically generated data structures that are needed by the kernel. The .o file is the object file of your module - the result of compiling your C file. The kernel build system then automatically creates another C file with some data structures describing the kernel module (named your_module_kmod.c), compile this C

Linux: how do i know the module that exports a device node?

爷,独闯天下 提交于 2019-12-02 15:15:27
If a have a /dev device node and its major/minor numbers how do i know the kernel module name that exported this node? Short answer : cd /sys/dev/char/major:minor/device/driver/ ls -al | grep module Each device is generally associated with a driver, and this is all what the "device model" is about. The sysfs filesystem contains a representation of this devices and their associated driver. Unfortuantely, it seems not all sysfs have a representation of the device nodes, so this applyd only if your /sys directory contains a /dev directory. Let's take an example, with /dev/video0 On my board, ls