Sunday, May 01, 2011

How to port Cypress Barcode reader configuration from 2.6.38 to 2.6.32

一開始拿到barcode reader插入Andes的.32 kernel。UART console吐出這樣的錯誤訊息:


~ # usb 3-1: new low speed USB device using ohci_hcd and address 2
usb 3-1: configuration #1 chosen from 1 choice
generic-usb: probe of 0003:04B4:BCA1.0001 failed with error -22



接著在drivers/base/dd.c的really_probe()發現這段code:
probe_failed:
devres_release_all(dev);
driver_sysfs_remove(dev);
dev->driver = NULL;

if (ret != -ENODEV && ret != -ENXIO) {
/* driver matched but the probe failed */
printk(KERN_WARNING
"%s: probe of %s failed with error %d\n",
drv->name, dev_name(dev), ret);
}


再試試看在really_probe()的一開頭加上dump_stack();得到:
[] driver_probe_device+0x42/0x158
[] __device_attach+0x22/0x2c
[] bus_for_each_drv+0x4c/0x7c
[] device_attach+0x52/0x6c
[] bus_probe_device+0x24/0x48
[] device_add+0x29a/0x3d0
[] hid_add_device+0x15a/0x18c
[] usbhid_probe+0x28a/0x2e0
[] usb_probe_interface+0x104/0x148
[] driver_probe_device+0xc8/0x158
[] __device_attach+0x22/0x2c
[] bus_for_each_drv+0x4c/0x7c
[] device_attach+0x52/0x6c
[] bus_probe_device+0x24/0x48
[] device_add+0x29a/0x3d0
[] usb_set_configuration+0x514/0x584
[] generic_probe+0x66/0xac
[] usb_probe_device+0x26/0x30
[] driver_probe_device+0xc8/0x158
[] __device_attach+0x22/0x2c
[] bus_for_each_drv+0x4c/0x7c
[] device_attach+0x52/0x6c
[] bus_probe_device+0x24/0x48
[] device_add+0x29a/0x3d0
[] usb_new_device+0x50/0xa4
[] hub_thread+0xc42/0x1174
[] kthread+0x74/0x88
[] do_exit+0x0/0x604


可以判斷出來這就是hid的driver找不到的問題。接著我把bca1,也就是barcode device ID拿來grep。
果然在"hid/hid-ids.h:#define USB_DEVICE_ID_CYPRESS_BARCODE_3 0xbca1"找到define。接著在把USB_DEVICE_ID_CYPRESS_BARCODE_3拿來grep。找到
hid/hid-core.c: { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
hid/hid-cypress.c: { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3),


再注意把menuconfig裡面的Device Drivers --->[*] HID Devices --->Special HID drivers ---><*> Cypress打開。


還要注意一下git diff v2.6.32 v2.6.38 drivers/hid/Kconfig
git diff v2.6.32 v2.6.38 drivers/hid/Makefile
git diff v2.6.32 v2.6.38 drivers/hid/hid-cypress.c
看起來cypress都沒什大的變動,所以可以不用修改直接上沒問題。
重新開機後load進新的kernel就可以抓到了。


input: Guest Barcode Reader as /devices/pci0000:00/0000:00:08.1/usb3/3-1/3-1:1.0/input/input0
cypress 0003:04B4:BCA1.0001: input: USB HID v1.00 Keyboard [Guest Barcode Reader] on usb-0000:00:08.1-1/input0

0 意見: