touchscreen: added virtqueue_kick to virtio-touchscreen
authorgiwoong.kim <giwoong.kim@samsung.com>
Tue, 25 Sep 2012 07:36:10 +0000 (16:36 +0900)
committergiwoong.kim <giwoong.kim@samsung.com>
Tue, 25 Sep 2012 07:36:10 +0000 (16:36 +0900)
invoke kick after one or more virtqueue_add_buf calls

Signed-off-by: GiWoong Kim <giwoong.kim@samsung.com>
drivers/maru/maru_virtio_touchscreen.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b70a676..f5aa14e
@@ -86,10 +86,10 @@ static int run_touchscreen(void *_vtouchscreen)
     EmulTouchEvent vbuf[MAX_BUF_COUNT];
     EmulTouchEvent *event = NULL;
     int err = 0;
-    int len = 0; /* not used */
-    int index = 0;
-    int recv_index = 0;
-    int id = 0; /* finger id */
+    unsigned int len = 0; /* not used */
+    unsigned int index = 0;
+    unsigned int recv_index = 0;
+    unsigned int id = 0; /* finger id */
 
     struct input_dev *input_dev = NULL;
 
@@ -100,17 +100,18 @@ static int run_touchscreen(void *_vtouchscreen)
 
     for (index = 0; index < MAX_BUF_COUNT; index++) {
         sg_set_buf(&sg[index], &vbuf[index], sizeof(EmulTouchEvent));
+
         err = virtqueue_add_buf(vt->vq, sg, 0, index + 1, (void *)index + 1, GFP_ATOMIC);
         if (err < 0) {
             printk(KERN_ERR "failed to add buf\n");
         }
+        virtqueue_kick(vt->vq);
     }
     index = 0;
 
-    while (!kthread_should_stop()) {
-        //virtqueue_kick(vt->vq);
-
-        while (!(recv_index = virtqueue_get_buf(vt->vq, &len))) {
+    while (!kthread_should_stop())
+    {
+        while ((recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len)) == 0) {
             cpu_relax();
         }
 
@@ -137,10 +138,12 @@ static int run_touchscreen(void *_vtouchscreen)
 
         input_sync(input_dev);
 
+        /* expose buffer to other end */
         err = virtqueue_add_buf(vt->vq, sg, 0, recv_index, (void *)recv_index, GFP_ATOMIC);
         if (err < 0) {
             printk(KERN_ERR "failed to add buf\n");
         }
+        virtqueue_kick(vt->vq);
     }
 
     printk(KERN_INFO "virtio touchscreen thread is stopped\n");
@@ -177,9 +180,9 @@ static void input_touchscreen_close(struct input_dev *dev)
 }
 
 struct file_operations virtio_touchscreen_fops = {
-    .owner      = THIS_MODULE,
-    .open       = virtio_touchscreen_open,
-    .release    = virtio_touchscreen_release,
+    .owner   = THIS_MODULE,
+    .open    = virtio_touchscreen_open,
+    .release = virtio_touchscreen_release,
 };
 
 static int virtio_touchscreen_probe(struct virtio_device *vdev)
@@ -198,7 +201,7 @@ static int virtio_touchscreen_probe(struct virtio_device *vdev)
     vt->vdev = vdev;
 
     vt->vq = virtio_find_single_vq(vt->vdev,
-        vq_touchscreen_callback, "virtio-touchscreen-vq");
+        NULL /* vq_touchscreen_callback */, "virtio-touchscreen-vq");
     if (IS_ERR(vt->vq)) {
         ret = PTR_ERR(vt->vq);
         goto fail1;
@@ -284,14 +287,14 @@ static void __devexit virtio_touchscreen_remove(struct virtio_device *vdev)
 MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_touchscreen_driver = {
-    //.feature_table = features,
-    //.feature_table_size = ARRAY_SIZE(features),
     .driver.name = KBUILD_MODNAME,
     .driver.owner = THIS_MODULE,
     .id_table = id_table,
     .probe = virtio_touchscreen_probe,
     .remove = __devexit_p(virtio_touchscreen_remove),
 #if 0
+    .feature_table = features,
+    .feature_table_size = ARRAY_SIZE(features),
     .config_changed =
 #ifdef CONFIG_PM
     .freeze =