解决Android设备插入打印机无法启动

来源:互联网 发布:新葡京娱乐场源码下载 编辑:程序博客网 时间:2024/04/30 06:10
解决Android设备插入打印机无法启动
2014-02-11     我来说两句    来源:kangear的专栏  
收藏    我要投稿
一直在想起一个什么题目好一些,题目只是最初的现实,经过不断调试最后很是其它问题,想要起一个其它名字比如《打印机驱动中热插拔事件中添加DEVTYPE》。但是最后想了想还是回到最初才是好的。   具体现象:源码位置NativeDaemonConnector.java(查看VOLD的TAG) 02-10 01:21:02.340: E/VoldConnector(11051): got -1 reading with start = 0 02-10 01:21:02.340: E/VoldConnector(11051): closing stream for vold 02-10 01:21:02.340: E/VoldConnector(11051): Communications error: java.io.IOException: No such file or directory 02-10 01:21:02.340: E/VoldConnector(11051): Error in NativeDaemonConnector: java.io.IOException: No such file or directory   分析:在不做任何程序上的修改的情况下,插入USB无线网卡是没有问题的。目前打印机和无线网卡都是没有上报信息的,这就排除了上报消息的原因了。目前的区别是DEVTYPE,前者是无,后者是有的。      查看所有error时找出了问题所在:   NetlinkEvent::FindParam(): Parameter 'DEVTYPE' not found   果真是之前的假设问题,在获取DEVTYPE时出的问题。 
  以下就是如何在内核的usb打印机驱动中添加DEVTYPE的问题,花费了一下午的时间以下的diff文件:
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
diff --git a/kernel/drivers/usb/class/usblp.c b/kernel/drivers/usb/cl
index 9eca405..b528437 100755
--- a/kernel/drivers/usb/class/usblp.c
+++ b/kernel/drivers/usb/class/usblp.c
@@ -1046,8+1046,13@@ staticconst struct file_operations usblp_fops
        .llseek =       noop_llseek,
 };
  
+staticstruct device_type printer_type = {
+       .name   = "printer",
+};
+
 staticchar *usblp_devnode(struct device *dev, mode_t *mode)
 {
+       dev->type=&printer_type;
        returnkasprintf(GFP_KERNEL, "usb/%s", dev_name(dev));
 }
  
@@ -1072,6+1077,7@@ staticssize_t usblp_show_ieee1284_id(struct de
  
 staticDEVICE_ATTR(ieee1284_id, S_IRUGO, usblp_show_ieee1284_id, NUL
  
+
 staticint usblp_probe(struct usb_interface *intf,
                       conststruct usb_device_id *id)
 {
@@ -1079,6+1085,8@@ staticint usblp_probe(struct usb_interface *in
        struct usblp *usblp;
        intprotocol;
        intretval;
+      //dev->children[0]->dev.type=&printer_type;
+      //dev->dev.type=&printer_type;
  
        /* Malloc and start initializing usblp structure so we can us
         * directly. */
注:注释的那两条是测试的过但是不成功的方法。 
这里点名感谢一下《Linux驱动》群中的LinuxDrv群主。一步步指点着添加成功了。如下图:
0 0
原创粉丝点击