linux-device-driver

COM port detection in Linux

安稳与你 提交于 2019-12-06 14:29:15
问题 Please let me know if there is any API, system call, function (in Linux) which I can use my C program to detect a COM port dynamically, i.e., whenever a USB modem dongle is inserted in the port I will be able to detect that COM port using the API, or system call, or function in my C program. 回答1: Depending on your modem, USB serial port device may show up as /dev/ttyUSBn or /dev/ttyACMn , where n is some number starting from 0 . You can configure udev rule to automatically react on device

Polling a loop device through a kernel module

梦想的初衷 提交于 2019-12-06 14:08:21
问题 I was trying to read a loopback device that I have created through a kernel module in periods of 200ms, but it is crashing the kernel, when I try to insert it. I think there is problem with my read module, but it works fine without timer. I am new to kernel programming,please help. Thank you in advance:D #include <linux/kernel.h> #include <linux/module.h> #include <linux/timer.h> #include<linux/fs.h> #include <linux/init.h> #include <asm/segment.h> #include <asm/uaccess.h> #include <linux

i2c probe not being called…not sure where to call i2c_register_board_info

半腔热情 提交于 2019-12-06 14:05:28
问题 I have an Intel systems. I am trying to load at24.ko and i2c-mux-pca9541.ko. both modules have probe functions which are not being called. according to the Documentation, i need to call i2c_registetr_board_info in the arch_init. but I am not sure where to do that for the Intel system (ie which files). I do not see any examples anywhere on the internet. can someone provide a pointer to the file that i add this call. if this is not the right approach, please let me know. thank you in advance.

How to create a folder within a folder in sysfs

烈酒焚心 提交于 2019-12-06 11:23:32
问题 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<linux/module.h> #include<linux/kernel.h> #include<linux/device.h> #include <linux/err.h> MODULE_LICENSE("GPL"); MODULE_AUTHOR("Manoj"); static ssize_t sysfs_demo_show(struct class *class, struct class_attribute *attr, char *buf) { pr_info("%s [%d]: \n", __func__, __LINE__); return sprintf

some flags about workqueue in kernel

守給你的承諾、 提交于 2019-12-06 11:08:44
i am dealing with the concurrency managed workqueues in linux kernel 2.6.36.But i am confused about the some flags. WQ_HIGHPRI WQ_UNBOUND WQ_RESCUER WQ_CPU_INTENSIVE I create a workqueue with flag WQ_HIGHPRI and queue some work items(eg w1 w2 w3 w4,by order) to it, none of the 4 work items will sleep. Whether the 4 work items are executed by the same thread and in this situation, is any thread created? In above situation, is there any difference if WQ_UNBOUND is used? Because if you set WQ_UNBOUND , then kernel will set WQ_HIGHPRI . thank you in advance. TheCodeArtist Following excerpt

Linux Device Drivers 3rd Ed and 3.2 kernel [closed]

梦想的初衷 提交于 2019-12-06 10:33:29
Closed . This question is opinion-based . It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post . Closed last year . 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 germane or are there major differences between how 2.6 and 3.2 do things? What do people think of this book in general? I like LDD3.

In my read function myread it is continuously printing the read data when i do cat /driver/mydriver. I need to print only once how to do that

巧了我就是萌 提交于 2019-12-06 09:13:02
I wrote h into driver by doing echo: echo -n h /dev/mydriver When I do cat /dev/mydriver, myread function is printing h continuously. I wanted to print once. How to do that. static char m; static ssize_t myread(struct file *f, char __user *buf, size_t len, loff_t *off) { printk(KERN_INFO "Read()\n"); if (copy_to_user(buf, &m, 1) != 0) return -EFAULT; else return 1; } static ssize_t my_write(struct file *f, const char __user *buf, size_t len, loff_t *off) { printk(KERN_INFO "Write()\n"); if (copy_from_user(&c, buf + len – 1, 1) != 0) return -EFAULT; else return len; } If you want to use

How .ko file is built

本秂侑毒 提交于 2019-12-06 09:11:49
I am trying to port my own driver to a Beagle board xm arm-cortex-A8 . While porting I am trying to figuring out how the .ko file actually builds. In our Makefile we only have a command to build an .o file. How is a .ko file built? Using linux- 2.6.38.8 kernel and trying to configure my driver for my kernel. The kernel kbuild module document has lots of information on how to build an external module. If you have Raspberian or some other embedded ARM Linux, you will need to get the source package for your kernel. The process differs based on whether you are compiling on the same machine the

How to use/learn Video4Linux2 (On Screen Display) Output APIs?

廉价感情. 提交于 2019-12-06 08:13:36
问题 My latest microprocessor( Freescale iMX233 ) has 8 hardware overlay plus inbuilt YUV to RGB conversion functionality. They have exposed these functionality through v4l2 driver. v4l2 Documentation doesn't say it properly that how to use it. Is there any tutorial available or any reference code which I can use to learn v4l2 apis? 回答1: The V4L2 API isn't the greatest API out there and it is not very easy to use it. There are however a few resources available. The first one is the "official" V4L2

Why the operator >> doesn't work with my char device?

本小妞迷上赌 提交于 2019-12-06 08:07:12
I'm currently learning linux device drivers. I have begun with an example driver, which is just a memory buffer. My code is available on my github . I test my driver by doing this: # echo "Hello World" > /dev/mad # cat /dev/mad Hello World This is going well but when I use the redirection operator to append something (>>), the behaviour is not the one that I expected. # echo foo > /dev/mad # echo bar >> /dev/mad # cat /dev/mad bar I expected rather to have: foo bar I have implemented the llseek callback and take care of the offp in the read and write callbacks, but it still doesn't work. You