linux-device-driver

Why driver need to map DMA buffers when dma-engine is in device?

大憨熊 提交于 2019-12-11 05:33:06
问题 DMA buffers are memory mapped by the driver. For example, in pci-skeleton.c, which uses rtl8319 we have: tp->tx_bufs = pci_alloc_consistent(tp->pci_dev, TX_BUF_TOT_LEN, &tp->tx_bufs_dma); But DMA engine can reside in soc or in device. **Is it that dma buffers should be allocated even if DMA engine is in device ? Why ? ** rtl8139cp datasheet (I think the dma is part of the device, but not sure about it): http://realtek.info/pdf/rtl8139cp.pdf I believe that "dma engine" and "dma controller"

How to disable rmmod for my own written kernel module?

让人想犯罪 __ 提交于 2019-12-11 04:59:58
问题 If a user process is working with kernel module, I want that another process can't fire rmmod for that module. How to achieve this type of functionality? -beginner in Linux kernel programming. 回答1: rmmod can only unload a module when the refcount is zero. If the reference count is incremented when a user process is connected (and decremented when it disconnects), you'll be fine. If the module exposes a device, or is mounted as a filesystem, this should be handled naturally - if not, I guess

How to do “make drivers/usb/storage/usb-storage.ko”

筅森魡賤 提交于 2019-12-11 04:01:12
问题 How can I compile usb-storage.ko (only) from kernel source tree ? Running kernel version: 2.6.35-22-generic (uname -r) Source version: linux-2.6.35 Doing modprobe usb-storage gives the below error. FATAL: Error inserting usb_storage (/lib/modules/2.6.35-22-generic/kernel/drivers/usb/storage/usb-storage.ko): Invalid module format Doing insmod gives the below error. insmod: error inserting 'drivers/usb/storage/usb-storage.ko': -1 Invalid module format dmesg gives as below. usb_storage: no

Adaptation from old init_timer to new timer_setup

只愿长相守 提交于 2019-12-11 03:05:21
问题 I have been trying to port a driver from 2.6 to 4.n without support from the original board manufacturer (and very limited Linux experience). The original driver uses init_timer() and passes in a pointer to the timer_list structure. That limer_list structure's 'data' element was set to a pointer to another memory structure and the 'function' element set to the callback. Inside the callback function the 'data' element was used to access other bits of stuff. The current timer init method uses

What is the dataflow of using touchscreen with tslib?

雨燕双飞 提交于 2019-12-11 03:02:13
问题 I don't understand how tslib works. Let's say I have a serial touchscreen, in my understanding the data flows in the following way: ts press -> serial port -> ts driver -> tslib -> device file (like /dev/input/eventX) Is it right? Or do I need to insert some code between ts driver and tslib so that they can communicate? 回答1: Tslib does not operate between the touch screen driver and the input device file - it accesses the device file on behalf of the application using it. The key data flow

A platform driver template not working as it should

独自空忆成欢 提交于 2019-12-11 02:50:47
问题 I am trying to create a simple platform driver but i don't know why its not working. Here is the code that i am trying to build. Insmod is clean but there are some cryptic messages along with rmmod. and what details i should add so this editor satisfies......... #include <linux/module.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/platform_device.h> MODULE_LICENSE("GPL"); static struct platform_device *dev; static int my_probe(struct platform_device *pdev) { printk(

How to enable serial port on the Raspberry Pi Zero USB OTG port?

大兔子大兔子 提交于 2019-12-11 01:22:16
问题 The Raspberry Pi Zero comes with USB OTG port. After some reading about OTG driver it seems that it could be configured as CDC device like serial port. So I was wondering if it is possible do so with the Pi Zero? 来源: https://stackoverflow.com/questions/34062133/how-to-enable-serial-port-on-the-raspberry-pi-zero-usb-otg-port

Using pci_enable_msi_block

雨燕双飞 提交于 2019-12-11 00:08:41
问题 I am trying to enable multiple MSI irq lines in a kernel module. I am operating in RC mode. The problem is when I call pci_enable_msi_block() it will not allocate more than 1 MSI. If I call pci_enable_msi_block(dev, 32) it will return 4 (which I assume should mean I can use 4 MSI). I then call pci_enable_msi_block(dev,4) and it returns 1. Here is an output from $lspci -v after insmod Custom_module.ko but with only a successful enable of 1 MSI 00:00.0 PCI bridge: Texas Instruments Device 8888

Running user thread in context of an interrupt in linux

徘徊边缘 提交于 2019-12-10 22:56:45
问题 I am writing some customized application and allowed to change interrupt handler code in the linux kernel. I am having a user thread which is waiting for an interrupt to happen. If that interrupt happens then the first thing I want to do is to execute that user thread. Is there any way to make it work. Thanks 回答1: Create a character device (that's what the kernel does, handles devices). Have the user thread read from that device. It will hang as there are no characters to read. When the

Passing struct to device driver through IOCTL

假装没事ソ 提交于 2019-12-10 22:18:08
问题 I am trying to pass a struct from user space to kernel space. I had been trying for many hours and it isn't working. Here is what I have done so far.. int device_ioctl(struct inode *inode, struct file *filep, unsigned int cmd, unsigned long arg){ int ret, SIZE; switch(cmd){ case PASS_STRUCT_ARRAY_SIZE: SIZE = (int *)arg; if(ret < 0){ printk("Error in PASS_STRUCT_ARRAY_SIZE\n"); return -1; } printk("Struct Array Size : %d\n",SIZE); break; case PASS_STRUCT: struct mesg{ int pIDs[SIZE]; int