我以前想过平台驱动程序以及普通设备驱动程序,如:
普通设备驱动程序适用于与proccesor芯片连接的驱动程序.在遇到一个i2c驱动程序之前.
但在这里,我正在阅读通过定义为平台驱动程序的多功能i2c驱动程序.我通过了https://www.kernel.org/doc/Documentation/driver-model/platform.txt.但是仍然无法清楚地想出如何定义驱动程序,例如onchip和接口设备.我也经历了这个链接.. http://meld.org/discussion/general-discussion/platform-driver-vs-ordinary-device-drivers
请有人解释一下.
是什么区别module_init,并subsys_initcall在初始化的驱动程序?
我正在研究一个mfd驱动程序.有一个i2c总线,由四个i2c客户端设备共享(在单个IC上).所述i2c_new_dummy附接的适配器每个客户端时API被使用.
为什么有必要为不同的客户端使用不同的适配器逻辑?mfd设备实际上如何工作?
我想写与UI按钮读/写,做一个Android应用程序sysfs read或sysfs write.
我找到了java.io.RandomAccessFile的以下示例代码.
package com.tutorialspoint;
import java.io.*;
public class RandomAccessFileDemo {
public static void main(String[] args) {
try {
// create a new RandomAccessFile with filename test
RandomAccessFile raf = new RandomAccessFile("c:/test.txt", "rw");
// write something in the file
raf.writeUTF("Hello World");
// set the file pointer at 0 position
raf.seek(0);
// read the first byte and print it
System.out.println("" + raf.read());
// set the file pointer at 4rth position
raf.seek(4);
// read the first byte …Run Code Online (Sandbox Code Playgroud) 我可以找出其他内存映射信息,比如我想知道的设备总线特定内存,比如这里的系统 RAM 是什么意思..
0000000-0000ffff : reserved
00010000-0009c3ff : System RAM
0009c400-0009ffff : reserved
000a0000-000bffff : PCI Bus 0000:00
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000d0000-000d0fff : Adapter ROM
000d2000-000d3fff : reserved
000d4000-000d7fff : PCI Bus 0000:00
000d8000-000dbfff : PCI Bus 0000:00
000dc000-000dffff : PCI Bus 0000:00
000e0000-000fffff : reserved
000f0000-000fffff : System ROM
00100000-bb27bfff : System RAM
01000000-015b0afb : Kernel code
015b0afc-01878c3f : Kernel data
01939000-01a11fff : Kernel bss
bb27c000-bb281fff : reserved
bb282000-bb3e9fff : System RAM
bb3ea000-bb40efff …Run Code Online (Sandbox Code Playgroud) 我有一个带处理函数的驱动程序代码和request_threaded_irq的线程函数,类似于:
irq-handler fn()
{
/*disable device interrupt*/
i2c read from register;
set disable bit to client-device-interrupt
i2c write back;
return IRQ_WAKe_THREAD;
}
irq-thread fn()
{
i2c read from register;
....
....
/*enable device interrupt*/
i2c read from register;
set enable bit to client-device-interrupt
i2c write back;
/*Rest of the operation*/
..........
..........
return IRQ_HANDLED;
}
Run Code Online (Sandbox Code Playgroud)
关于上述实施,我几乎没有问题.
"处理程序fn"中的2 i2c操作是否需要相当长的时间.
我是否需要在"handler fn"atomic中进行位操作?
我应该将执行操作直到"启用设备中断"从"线程fn"移动到"处理程序fn"(这将花费我多4次i2c操作和一位操作完全)? - 根据上面的代码实现,我有可能错过中断的原因.
如果我这样做(根据问题3).它如何影响其他设备中断.(因为我基本怀疑硬IRQ上下文中的"处理程序fn"是否在禁用中断的情况下运行)
请为我提供一个针对上述场景的良好和最佳解决方案.
提前致谢.
我通过echo:echo -nh/dev/mydriver将h写入驱动程序
当我做cat/dev/mydriver时,myread功能是连续打印h.我想打印一次.怎么做.
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;
}
Run Code Online (Sandbox Code Playgroud)