code conventions: apply the code conventions 26/32426/1
authorSooyoung Ha <yoosah.ha@samsung.com>
Thu, 18 Dec 2014 06:30:47 +0000 (15:30 +0900)
committerSooyoung Ha <yoosah.ha@samsung.com>
Thu, 18 Dec 2014 06:30:47 +0000 (15:30 +0900)
You should use tab instead of space for indentation.

Change-Id: I43fb0cf0d397eeb84ffde490c19689e98f41ff16
Signed-off-by: Sooyoung Ha <yoosah.ha@samsung.com>
drivers/maru/maru_brillcodec.c
drivers/maru/maru_virtio_hwkey.c
drivers/maru/maru_virtio_keyboard.c
drivers/maru/maru_virtio_nfc.c
drivers/maru/maru_virtio_touchscreen.c

index 852c9298af805aac271336caa520afdba2f0cc39..4cf30458801edcd90f1e82d0607e781bbf0d25e4 100644 (file)
@@ -422,12 +422,12 @@ static void dispose_device_memory(uint32_t context_id)
 
 static inline bool is_memory_monopolizing_api(int api_index) {
 #ifdef SUPPORT_MEMORY_MONOPOLIZING
-    if (brillcodec_device->memory_monopolizing & (1 << api_index)) {
+       if (brillcodec_device->memory_monopolizing & (1 << api_index)) {
                DEBUG("API [%d] monopolize memory slot\n", api_index);
-        return true;
-    }
+               return true;
+       }
 #endif
-    return false;
+       return false;
 }
 
 static void cache_info(void)
index 6e139c57a644b875dde2788b85f6c54ba9f989ef..77c83f83142e7905e77f0c57a534eb63361ca44c 100644 (file)
@@ -49,231 +49,231 @@ static int vqidx = 0;
 
 /* This structure must match the qemu definitions */
 typedef struct EmulHwkeyEvent {
-    uint8_t event_type;
-    uint32_t keycode;
+       uint8_t event_type;
+       uint32_t keycode;
 } EmulHwkeyEvent;
 
 typedef struct virtio_hwkey
 {
-    struct virtio_device *vdev;
-    struct virtqueue *vq;
-    struct input_dev *idev;
+       struct virtio_device *vdev;
+       struct virtqueue *vq;
+       struct input_dev *idev;
 
-    struct scatterlist sg[MAX_BUF_COUNT];
-    struct EmulHwkeyEvent vbuf[MAX_BUF_COUNT];
+       struct scatterlist sg[MAX_BUF_COUNT];
+       struct EmulHwkeyEvent vbuf[MAX_BUF_COUNT];
 
-    struct mutex event_mutex;
+       struct mutex event_mutex;
 } virtio_hwkey;
 
 virtio_hwkey *vh;
 
 static struct virtio_device_id id_table[] = {
-    { VIRTIO_ID_HWKEY, VIRTIO_DEV_ANY_ID },
-    { 0 },
+       { VIRTIO_ID_HWKEY, VIRTIO_DEV_ANY_ID },
+       { 0 },
 };
 
 /* keep it consistent with emulator-skin definition */
 enum {
-    KEY_PRESSED = 1,
-    KEY_RELEASED = 2,
+       KEY_PRESSED = 1,
+       KEY_RELEASED = 2,
 };
 
 static int err = 0;
 static unsigned int index = 0;
 
 /**
-* @brief : callback for virtqueue
-*/
+ * @brief : callback for virtqueue
+ */
 static void vq_hwkey_callback(struct virtqueue *vq)
 {
-    struct EmulHwkeyEvent hwkey_event;
-    unsigned int len = 0;
-    void *token = NULL;
+       struct EmulHwkeyEvent hwkey_event;
+       unsigned int len = 0;
+       void *token = NULL;
 #if 0
-    printk(KERN_INFO "vq hwkey callback\n");
+       printk(KERN_INFO "vq hwkey callback\n");
 #endif
-    while (1) {
-        memcpy(&hwkey_event, &vh->vbuf[vqidx], sizeof(hwkey_event));
-        if (hwkey_event.event_type == 0) {
-            break;
-        }
-        printk(KERN_INFO "keycode: %d, event_type: %d, vqidx: %d\n", hwkey_event.keycode, hwkey_event.event_type, vqidx);
-        if (hwkey_event.event_type == KEY_PRESSED) {
-            input_event(vh->idev, EV_KEY, hwkey_event.keycode, true);
-        }
-        else if (hwkey_event.event_type == KEY_RELEASED) {
-            input_event(vh->idev, EV_KEY, hwkey_event.keycode, false);
-        }
-        else {
-            printk(KERN_ERR "Unknown event type\n");
-        }
-
-        input_sync(vh->idev);
-        memset(&vh->vbuf[vqidx], 0x00, sizeof(hwkey_event));
-        token = virtqueue_get_buf(vh->vq, &len);
-        if (len > 0) {
-            err = virtqueue_add_inbuf(vh->vq, vh->sg, MAX_BUF_COUNT, token, GFP_ATOMIC);
-        }
-
-        vqidx++;
-        if (vqidx == MAX_BUF_COUNT) {
-            vqidx = 0;
-        }
-    }
-
-    virtqueue_kick(vh->vq);
+       while (1) {
+               memcpy(&hwkey_event, &vh->vbuf[vqidx], sizeof(hwkey_event));
+               if (hwkey_event.event_type == 0) {
+                       break;
+               }
+               printk(KERN_INFO "keycode: %d, event_type: %d, vqidx: %d\n", hwkey_event.keycode, hwkey_event.event_type, vqidx);
+               if (hwkey_event.event_type == KEY_PRESSED) {
+                       input_event(vh->idev, EV_KEY, hwkey_event.keycode, true);
+               }
+               else if (hwkey_event.event_type == KEY_RELEASED) {
+                       input_event(vh->idev, EV_KEY, hwkey_event.keycode, false);
+               }
+               else {
+                       printk(KERN_ERR "Unknown event type\n");
+               }
+
+               input_sync(vh->idev);
+               memset(&vh->vbuf[vqidx], 0x00, sizeof(hwkey_event));
+               token = virtqueue_get_buf(vh->vq, &len);
+               if (len > 0) {
+                       err = virtqueue_add_inbuf(vh->vq, vh->sg, MAX_BUF_COUNT, token, GFP_ATOMIC);
+               }
+
+               vqidx++;
+               if (vqidx == MAX_BUF_COUNT) {
+                       vqidx = 0;
+               }
+       }
+
+       virtqueue_kick(vh->vq);
 }
 
 static int virtio_hwkey_open(struct inode *inode, struct file *file)
 {
-    printk(KERN_INFO "virtio hwkey device is opened\n");
-    return 0;
+       printk(KERN_INFO "virtio hwkey device is opened\n");
+       return 0;
 }
 
 static int virtio_hwkey_release(struct inode *inode, struct file *file)
 {
-    printk(KERN_INFO "virtio hwkey device is closed\n");
-    return 0;
+       printk(KERN_INFO "virtio hwkey device is closed\n");
+       return 0;
 }
 
 static int input_hwkey_open(struct input_dev *dev)
 {
-    printk(KERN_INFO "input hwkey device is opened\n");
-    return 0;
+       printk(KERN_INFO "input hwkey device is opened\n");
+       return 0;
 }
 
 static void input_hwkey_close(struct input_dev *dev)
 {
-    printk(KERN_INFO "input hwkey device is closed\n");
+       printk(KERN_INFO "input hwkey device is closed\n");
 }
 
 struct file_operations virtio_hwkey_fops = {
-    .owner   = THIS_MODULE,
-    .open    = virtio_hwkey_open,
-    .release = virtio_hwkey_release,
+       .owner   = THIS_MODULE,
+       .open    = virtio_hwkey_open,
+       .release = virtio_hwkey_release,
 };
 
 static int virtio_hwkey_probe(struct virtio_device *vdev)
 {
-    int ret = 0;
-    vqidx = 0;
+       int ret = 0;
+       vqidx = 0;
 
-    printk(KERN_INFO "virtio hwkey driver is probed\n");
+       printk(KERN_INFO "virtio hwkey driver is probed\n");
 
-    /* init virtio */
-    vdev->priv = vh = kmalloc(sizeof(*vh), GFP_KERNEL);
-    if (!vh) {
-        return -ENOMEM;
-    }
-    memset(&vh->vbuf, 0x00, sizeof(vh->vbuf));
+       /* init virtio */
+       vdev->priv = vh = kmalloc(sizeof(*vh), GFP_KERNEL);
+       if (!vh) {
+               return -ENOMEM;
+       }
+       memset(&vh->vbuf, 0x00, sizeof(vh->vbuf));
 
-    vh->vdev = vdev;
+       vh->vdev = vdev;
 
-    vh->vq = virtio_find_single_vq(vh->vdev, vq_hwkey_callback, "virtio-hwkey-vq");
-    if (IS_ERR(vh->vq)) {
-        ret = PTR_ERR(vh->vq);
+       vh->vq = virtio_find_single_vq(vh->vdev, vq_hwkey_callback, "virtio-hwkey-vq");
+       if (IS_ERR(vh->vq)) {
+               ret = PTR_ERR(vh->vq);
 
-        kfree(vh);
-        vdev->priv = NULL;
-        return ret;
-    }
+               kfree(vh);
+               vdev->priv = NULL;
+               return ret;
+       }
 
-    /* enable callback */
-    virtqueue_enable_cb(vh->vq);
+       /* enable callback */
+       virtqueue_enable_cb(vh->vq);
 
-    sg_init_table(vh->sg, MAX_BUF_COUNT);
+       sg_init_table(vh->sg, MAX_BUF_COUNT);
 
-    /* prepare the buffers */
-    for (index = 0; index < MAX_BUF_COUNT; index++) {
-        sg_set_buf(&vh->sg[index], &vh->vbuf[index], sizeof(EmulHwkeyEvent));
+       /* prepare the buffers */
+       for (index = 0; index < MAX_BUF_COUNT; index++) {
+               sg_set_buf(&vh->sg[index], &vh->vbuf[index], sizeof(EmulHwkeyEvent));
 
-        if (err < 0) {
-            printk(KERN_ERR "failed to add buffer\n");
+               if (err < 0) {
+                       printk(KERN_ERR "failed to add buffer\n");
 
-            kfree(vh);
-            vdev->priv = NULL;
-            return ret;
-        }
-    }
+                       kfree(vh);
+                       vdev->priv = NULL;
+                       return ret;
+               }
+       }
 
-    err = virtqueue_add_inbuf(vh->vq, vh->sg,
-            MAX_BUF_COUNT, (void *)MAX_BUF_COUNT, GFP_ATOMIC);
+       err = virtqueue_add_inbuf(vh->vq, vh->sg,
+                       MAX_BUF_COUNT, (void *)MAX_BUF_COUNT, GFP_ATOMIC);
 
-    /* register for input device */
-    vh->idev = input_allocate_device();
-    if (!vh->idev) {
-        printk(KERN_ERR "failed to allocate a input hwkey device\n");
-        ret = -1;
+       /* register for input device */
+       vh->idev = input_allocate_device();
+       if (!vh->idev) {
+               printk(KERN_ERR "failed to allocate a input hwkey device\n");
+               ret = -1;
 
-        kfree(vh);
-        vdev->priv = NULL;
-        return ret;
-    }
+               kfree(vh);
+               vdev->priv = NULL;
+               return ret;
+       }
 
-    vh->idev->name = "Maru Virtio Hwkey";
-    vh->idev->dev.parent = &(vdev->dev);
+       vh->idev->name = "Maru Virtio Hwkey";
+       vh->idev->dev.parent = &(vdev->dev);
 
-    input_set_drvdata(vh->idev, vh);
-    vh->idev->open = input_hwkey_open;
-    vh->idev->close = input_hwkey_close;
+       input_set_drvdata(vh->idev, vh);
+       vh->idev->open = input_hwkey_open;
+       vh->idev->close = input_hwkey_close;
 
-    vh->idev->evbit[0] = BIT_MASK(EV_KEY);
-    /* to support any keycode */
-    memset(vh->idev->keybit, 0xffffffff, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
+       vh->idev->evbit[0] = BIT_MASK(EV_KEY);
+       /* to support any keycode */
+       memset(vh->idev->keybit, 0xffffffff, sizeof(unsigned long) * BITS_TO_LONGS(KEY_CNT));
 
-    ret = input_register_device(vh->idev);
-    if (ret) {
-        printk(KERN_ERR "input hwkey driver cannot registered\n");
-        ret = -1;
+       ret = input_register_device(vh->idev);
+       if (ret) {
+               printk(KERN_ERR "input hwkey driver cannot registered\n");
+               ret = -1;
 
-        input_free_device(vh->idev);
-        kfree(vh);
-        vdev->priv = NULL;
-        return ret;
-    }
+               input_free_device(vh->idev);
+               kfree(vh);
+               vdev->priv = NULL;
+               return ret;
+       }
 
-    virtqueue_kick(vh->vq);
-    index = 0;
+       virtqueue_kick(vh->vq);
+       index = 0;
 
-    return 0;
+       return 0;
 }
 
 static void virtio_hwkey_remove(struct virtio_device *vdev)
 {
-    virtio_hwkey *vhk = NULL;
+       virtio_hwkey *vhk = NULL;
 
-    printk(KERN_INFO "virtio hwkey driver is removed\n");
+       printk(KERN_INFO "virtio hwkey driver is removed\n");
 
-    vhk = vdev->priv;
+       vhk = vdev->priv;
 
-    vdev->config->reset(vdev); /* reset device */
-    vdev->config->del_vqs(vdev); /* clean up the queues */
+       vdev->config->reset(vdev); /* reset device */
+       vdev->config->del_vqs(vdev); /* clean up the queues */
 
-    input_unregister_device(vhk->idev);
+       input_unregister_device(vhk->idev);
 
-    kfree(vhk);
+       kfree(vhk);
 }
 
 MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_hwkey_driver = {
-    .driver.name = KBUILD_MODNAME,
-    .driver.owner = THIS_MODULE,
-    .id_table = id_table,
-    .probe = virtio_hwkey_probe,
-    .remove = virtio_hwkey_remove,
+       .driver.name = KBUILD_MODNAME,
+       .driver.owner = THIS_MODULE,
+       .id_table = id_table,
+       .probe = virtio_hwkey_probe,
+       .remove = virtio_hwkey_remove,
 };
 
 static int __init virtio_hwkey_init(void)
 {
-    printk(KERN_INFO "virtio hwkey device is initialized\n");
-    return register_virtio_driver(&virtio_hwkey_driver);
+       printk(KERN_INFO "virtio hwkey device is initialized\n");
+       return register_virtio_driver(&virtio_hwkey_driver);
 }
 
 static void __exit virtio_hwkey_exit(void)
 {
-    printk(KERN_INFO "virtio hwkey device is destroyed\n");
-    unregister_virtio_driver(&virtio_hwkey_driver);
+       printk(KERN_INFO "virtio hwkey device is destroyed\n");
+       unregister_virtio_driver(&virtio_hwkey_driver);
 }
 
 module_init(virtio_hwkey_init);
index e3295f2891e2c850cb6c7d6d6d9a309580aad2cf..7396442499df7feda9599d99aea918b2ed628a62 100644 (file)
@@ -88,8 +88,8 @@ static void vq_keyboard_handle(struct virtqueue *vq)
                return;
        }
 
-        VKBD_LOG(KERN_DEBUG, "vqidx: %d\n", vqidx);
-        while (1) {
+       VKBD_LOG(KERN_DEBUG, "vqidx: %d\n", vqidx);
+       while (1) {
                memcpy(&kbdevent, &vkbd->kbdevt[vqidx], sizeof(kbdevent));
 #if 1
                if (kbdevent.code == 0) {
index 8e405a966fedc023e57701447a87563de85bea82..a0f266d29fb542efac195b46a8fca401997a8f90 100644 (file)
@@ -49,7 +49,7 @@
 #define DRIVER_NAME "NFC"
 
 #define LOG(fmt, ...) \
-    printk(KERN_ERR "%s: " fmt, DRIVER_NAME, ##__VA_ARGS__)
+       printk(KERN_ERR "%s: " fmt, DRIVER_NAME, ##__VA_ARGS__)
 
 #define NUM_OF_NFC  2
 #define DEVICE_NAME     "nfc"
 #define NFC_MAX_BUF_SIZE  4096
 
 struct msg_info {
-    unsigned char client_id;
-    unsigned char client_type;
-    uint32_t use;
-    char buf[NFC_MAX_BUF_SIZE];
+       unsigned char client_id;
+       unsigned char client_type;
+       uint32_t use;
+       char buf[NFC_MAX_BUF_SIZE];
 };
 
 static int g_read_count = 0;
@@ -69,49 +69,49 @@ static int g_read_count = 0;
 /* device protocol */
 
 struct msg_buf {
-    struct msg_info msg;
-    struct list_head list;
+       struct msg_info msg;
+       struct list_head list;
 };
 
 #define SIZEOF_MSG_BUF  sizeof(struct msg_buf)
 
 enum {
-    NFC_READ = 0, NFC_WRITE = 1
+       NFC_READ = 0, NFC_WRITE = 1
 };
 
 struct virtnfc_info {
 
-    wait_queue_head_t waitqueue;
-    spinlock_t inbuf_lock;
-    spinlock_t outvq_lock;
+       wait_queue_head_t waitqueue;
+       spinlock_t inbuf_lock;
+       spinlock_t outvq_lock;
 
-    struct cdev cdev;
-    char name[10];
+       struct cdev cdev;
+       char name[10];
 
-    int index;
-    bool guest_connected;
+       int index;
+       bool guest_connected;
 
 } *pnfc_info[NUM_OF_NFC];
 
 struct virtio_nfc {
-    struct virtio_device* vdev;
-    struct virtqueue* rvq;
-    struct virtqueue* svq;
+       struct virtio_device* vdev;
+       struct virtqueue* rvq;
+       struct virtqueue* svq;
 
-    struct msg_info read_msginfo;
-    struct msg_info send_msginfo;
+       struct msg_info read_msginfo;
+       struct msg_info send_msginfo;
 
-    struct list_head read_list;
-    struct list_head write_list;
+       struct list_head read_list;
+       struct list_head write_list;
 
-    struct scatterlist sg_read[2];
-    struct scatterlist sg_send[2];
+       struct scatterlist sg_read[2];
+       struct scatterlist sg_send[2];
 };
 
 struct virtio_nfc *vnfc;
 
 static struct virtio_device_id id_table[] = { { VIRTIO_ID_NFC,
-        VIRTIO_DEV_ANY_ID }, { 0 }, };
+       VIRTIO_DEV_ANY_ID }, { 0 }, };
 
 static dev_t nfc_dev_number;
 static struct class* nfc_class;
@@ -119,284 +119,284 @@ static struct class* nfc_class;
 
 static void* __xmalloc(size_t size)
 {
-    void* p = kmalloc(size, GFP_KERNEL);
-    if (!p)
-        return NULL;
-    return p;
+       void* p = kmalloc(size, GFP_KERNEL);
+       if (!p)
+               return NULL;
+       return p;
 }
 
 int make_buf_and_kick(void)
 {
-    int ret;
-    memset(&vnfc->read_msginfo, 0x00, sizeof(vnfc->read_msginfo));
-    ret = virtqueue_add_inbuf(vnfc->rvq, vnfc->sg_read,
-        1, &vnfc->read_msginfo, GFP_ATOMIC);
-    if (ret < 0) {
-        LOG("failed to add buffer to virtqueue.(%d)\n", ret);
-        return ret;
-    }
-
-    virtqueue_kick(vnfc->rvq);
-
-    return 0;
+       int ret;
+       memset(&vnfc->read_msginfo, 0x00, sizeof(vnfc->read_msginfo));
+       ret = virtqueue_add_inbuf(vnfc->rvq, vnfc->sg_read,
+                       1, &vnfc->read_msginfo, GFP_ATOMIC);
+       if (ret < 0) {
+               LOG("failed to add buffer to virtqueue.(%d)\n", ret);
+               return ret;
+       }
+
+       virtqueue_kick(vnfc->rvq);
+
+       return 0;
 }
 
 static int add_inbuf(struct virtqueue *vq, struct msg_info *msg)
 {
-    struct scatterlist sg[1];
-    int ret;
+       struct scatterlist sg[1];
+       int ret;
 
-    sg_init_one(sg, msg, NFC_MAX_BUF_SIZE);
+       sg_init_one(sg, msg, NFC_MAX_BUF_SIZE);
 
-    ret = virtqueue_add_inbuf(vq, sg, 1, msg, GFP_ATOMIC);
-    virtqueue_kick(vq);
-    return ret;
+       ret = virtqueue_add_inbuf(vq, sg, 1, msg, GFP_ATOMIC);
+       virtqueue_kick(vq);
+       return ret;
 }
 
 static bool has_readdata(struct virtnfc_info *nfc)
 {
-    bool ret;
-    unsigned long flags;
+       bool ret;
+       unsigned long flags;
 
-    spin_lock_irqsave(&nfc->inbuf_lock, flags);
+       spin_lock_irqsave(&nfc->inbuf_lock, flags);
 
-    ret = true;
+       ret = true;
 
-    if (list_empty(&vnfc->read_list))
-        ret = false;
+       if (list_empty(&vnfc->read_list))
+               ret = false;
 
-    spin_unlock_irqrestore(&nfc->inbuf_lock, flags);
+       spin_unlock_irqrestore(&nfc->inbuf_lock, flags);
 
-    return ret;
+       return ret;
 }
 
 
 static int nfc_open(struct inode* inode, struct file* filp)
 {
-    int i, ret;
-    struct virtnfc_info* nfc_info;
-    struct cdev *cdev = inode->i_cdev;
+       int i, ret;
+       struct virtnfc_info* nfc_info;
+       struct cdev *cdev = inode->i_cdev;
 
-    nfc_info = NULL;
-    LOG("nfc_open\n");
+       nfc_info = NULL;
+       LOG("nfc_open\n");
 
-    for (i = 0; i < NUM_OF_NFC; i++) {
-        LOG("nfc info index = %d, cdev dev = %d, inode dev = %d\n",
-                i, pnfc_info[i]->cdev.dev, cdev->dev);
+       for (i = 0; i < NUM_OF_NFC; i++) {
+               LOG("nfc info index = %d, cdev dev = %d, inode dev = %d\n",
+                               i, pnfc_info[i]->cdev.dev, cdev->dev);
 
-        if (pnfc_info[i]->cdev.dev == cdev->dev) {
-            nfc_info = pnfc_info[i];
-            break;
-        }
-    }
+               if (pnfc_info[i]->cdev.dev == cdev->dev) {
+                       nfc_info = pnfc_info[i];
+                       break;
+               }
+       }
 
-    filp->private_data = nfc_info;
+       filp->private_data = nfc_info;
 
-    nfc_info->guest_connected = true;
+       nfc_info->guest_connected = true;
 
 
-    ret = make_buf_and_kick();
-    if (ret < 0)
-        return ret;
+       ret = make_buf_and_kick();
+       if (ret < 0)
+               return ret;
 
-    LOG("nfc_opened\n");
-    return 0;
+       LOG("nfc_opened\n");
+       return 0;
 }
 
 static int nfc_close(struct inode* i, struct file* filp) {
-    struct virtnfc_info *nfc_info;
+       struct virtnfc_info *nfc_info;
 
-    nfc_info = filp->private_data;
-    nfc_info->guest_connected = false;
+       nfc_info = filp->private_data;
+       nfc_info->guest_connected = false;
 
-    LOG("nfc_closed\n");
-    return 0;
+       LOG("nfc_closed\n");
+       return 0;
 }
 
 
 
 static ssize_t nfc_read(struct file *filp, char __user *ubuf, size_t len,
-        loff_t *f_pos)
+               loff_t *f_pos)
 {
-    struct virtnfc_info *nfc;
+       struct virtnfc_info *nfc;
 
-    ssize_t ret;
-    struct msg_buf* next;
-    unsigned long flags;
+       ssize_t ret;
+       struct msg_buf* next;
+       unsigned long flags;
 
-    LOG("nfc_read\n");
-    nfc = filp->private_data;
-    if (!has_readdata(nfc)) {
-        if (filp->f_flags & O_NONBLOCK) {
-            LOG("list is empty, return EAGAIN\n");
-            return -EAGAIN;
-        }
-        return -EFAULT;
-    }
+       LOG("nfc_read\n");
+       nfc = filp->private_data;
+       if (!has_readdata(nfc)) {
+               if (filp->f_flags & O_NONBLOCK) {
+                       LOG("list is empty, return EAGAIN\n");
+                       return -EAGAIN;
+               }
+               return -EFAULT;
+       }
 
-    next = list_first_entry(&vnfc->read_list, struct msg_buf, list);
-    if (next == NULL) {
-        LOG("invliad list entry\n");
-        return -EFAULT;
-    }
+       next = list_first_entry(&vnfc->read_list, struct msg_buf, list);
+       if (next == NULL) {
+               LOG("invliad list entry\n");
+               return -EFAULT;
+       }
 
-    ret = copy_to_user(ubuf, &next->msg, len);
+       ret = copy_to_user(ubuf, &next->msg, len);
 
-    list_del(&next->list);
-    kfree(next);
+       list_del(&next->list);
+       kfree(next);
 
-    spin_lock_irqsave(&pnfc_info[NFC_READ]->inbuf_lock, flags);
+       spin_lock_irqsave(&pnfc_info[NFC_READ]->inbuf_lock, flags);
 
 
-    if (add_inbuf(vnfc->rvq, &vnfc->read_msginfo) < 0){
-        LOG("failed add_buf\n");
-    }
+       if (add_inbuf(vnfc->rvq, &vnfc->read_msginfo) < 0){
+               LOG("failed add_buf\n");
+       }
 
-    spin_unlock_irqrestore(&pnfc_info[NFC_READ]->inbuf_lock, flags);
+       spin_unlock_irqrestore(&pnfc_info[NFC_READ]->inbuf_lock, flags);
 
 
-    LOG("nfc_read count = %d!\n", ++g_read_count);
+       LOG("nfc_read count = %d!\n", ++g_read_count);
 
-    if (ret < 0)
-        return -EFAULT;
+       if (ret < 0)
+               return -EFAULT;
 
-    *f_pos += len;
+       *f_pos += len;
 
-    return len;
+       return len;
 }
 
 static ssize_t nfc_write(struct file *f, const char __user *ubuf, size_t len,
-        loff_t* f_pos)
+               loff_t* f_pos)
 {
-    int err = 0;
-    ssize_t ret = 0;
+       int err = 0;
+       ssize_t ret = 0;
 
-    LOG("start of nfc_write len= %d, msglen = %d\n", len, sizeof(vnfc->send_msginfo));
+       LOG("start of nfc_write len= %d, msglen = %d\n", len, sizeof(vnfc->send_msginfo));
 
-    if (vnfc == NULL) {
-        LOG("invalid nfc handle\n");
-        return 0;
-    }
+       if (vnfc == NULL) {
+               LOG("invalid nfc handle\n");
+               return 0;
+       }
 
-    memset(&vnfc->send_msginfo, 0, sizeof(vnfc->send_msginfo));
-    ret = copy_from_user(&vnfc->send_msginfo, ubuf, sizeof(vnfc->send_msginfo));
+       memset(&vnfc->send_msginfo, 0, sizeof(vnfc->send_msginfo));
+       ret = copy_from_user(&vnfc->send_msginfo, ubuf, sizeof(vnfc->send_msginfo));
 
-    LOG("copy_from_user ret = %d, id = %02x, type = %02x, msg = %s use = %d\n",
-            ret, vnfc->send_msginfo.client_id, vnfc->send_msginfo.client_type,
-            vnfc->send_msginfo.buf, vnfc->send_msginfo.use);
+       LOG("copy_from_user ret = %d, id = %02x, type = %02x, msg = %s use = %d\n",
+                       ret, vnfc->send_msginfo.client_id, vnfc->send_msginfo.client_type,
+                       vnfc->send_msginfo.buf, vnfc->send_msginfo.use);
 
-    if (ret) {
-        ret = -EFAULT;
-        return ret;
-    }
+       if (ret) {
+               ret = -EFAULT;
+               return ret;
+       }
 
-    sg_init_one(vnfc->sg_send, &vnfc->send_msginfo, sizeof(vnfc->send_msginfo));
+       sg_init_one(vnfc->sg_send, &vnfc->send_msginfo, sizeof(vnfc->send_msginfo));
 
-    err = virtqueue_add_outbuf(vnfc->svq, vnfc->sg_send, 1,
-            &vnfc->send_msginfo, GFP_ATOMIC);
+       err = virtqueue_add_outbuf(vnfc->svq, vnfc->sg_send, 1,
+                       &vnfc->send_msginfo, GFP_ATOMIC);
 
-    /*
-    err = virtqueue_add_buf(vnfc->svq, vnfc->sg_send, 1, 0,
-                &_msg, GFP_ATOMIC);*/
+       /*
+          err = virtqueue_add_buf(vnfc->svq, vnfc->sg_send, 1, 0,
+          &_msg, GFP_ATOMIC);*/
 
-    if (err < 0) {
-        LOG("failed to add buffer to virtqueue (err = %d)\n", err);
-        return 0;
-    }
+       if (err < 0) {
+               LOG("failed to add buffer to virtqueue (err = %d)\n", err);
+               return 0;
+       }
 
-    virtqueue_kick(vnfc->svq);
+       virtqueue_kick(vnfc->svq);
 
-    LOG("send to host\n");
+       LOG("send to host\n");
 
-    return len;
+       return len;
 }
 
 static unsigned int nfc_poll(struct file *filp, poll_table *wait)
 {
-    struct virtnfc_info *nfc;
-    unsigned int ret;
+       struct virtnfc_info *nfc;
+       unsigned int ret;
 
-    nfc = filp->private_data;
-    poll_wait(filp, &nfc->waitqueue, wait);
+       nfc = filp->private_data;
+       poll_wait(filp, &nfc->waitqueue, wait);
 
-    if (!nfc->guest_connected) {
-        /* nfc got unplugged */
-        return POLLHUP;
-    }
+       if (!nfc->guest_connected) {
+               /* nfc got unplugged */
+               return POLLHUP;
+       }
 
-    ret = 0;
+       ret = 0;
 
-    if (has_readdata(nfc)) {
-        LOG("POLLIN | POLLRDNORM\n");
-        ret |= POLLIN | POLLRDNORM;
-    }
+       if (has_readdata(nfc)) {
+               LOG("POLLIN | POLLRDNORM\n");
+               ret |= POLLIN | POLLRDNORM;
+       }
 
-    return ret;
+       return ret;
 }
 
 static struct file_operations nfc_fops = {
-        .owner = THIS_MODULE,
-        .open = nfc_open,
-        .release = nfc_close,
-        .read = nfc_read,
-        .write = nfc_write,
-        .poll  = nfc_poll,
+       .owner = THIS_MODULE,
+       .open = nfc_open,
+       .release = nfc_close,
+       .read = nfc_read,
+       .write = nfc_write,
+       .poll  = nfc_poll,
 };
 
 
 
 static void nfc_recv_done(struct virtqueue *rvq) {
 
-    unsigned int len;
-    unsigned long flags;
-    unsigned char *msg;
-    struct msg_buf* msgbuf;
-    LOG("nfc_recv_done\n");
-    /* TODO : check if guest has been connected. */
+       unsigned int len;
+       unsigned long flags;
+       unsigned char *msg;
+       struct msg_buf* msgbuf;
+       LOG("nfc_recv_done\n");
+       /* TODO : check if guest has been connected. */
 
-    msg = (unsigned char*) virtqueue_get_buf(vnfc->rvq, &len);
-    if (msg == NULL ) {
-        LOG("failed to virtqueue_get_buf\n");
-        return;
-    }
+       msg = (unsigned char*) virtqueue_get_buf(vnfc->rvq, &len);
+       if (msg == NULL ) {
+               LOG("failed to virtqueue_get_buf\n");
+               return;
+       }
 
-    INIT_LIST_HEAD(&vnfc->read_list);
-    do {
+       INIT_LIST_HEAD(&vnfc->read_list);
+       do {
 
-        /* insert into queue */
-        msgbuf = (struct msg_buf*) __xmalloc(SIZEOF_MSG_BUF);
-        memset(msgbuf, 0x00, sizeof(*msgbuf));
-        memcpy(&(msgbuf->msg), msg, len);
+               /* insert into queue */
+               msgbuf = (struct msg_buf*) __xmalloc(SIZEOF_MSG_BUF);
+               memset(msgbuf, 0x00, sizeof(*msgbuf));
+               memcpy(&(msgbuf->msg), msg, len);
 
-        //LOG("copied msg data = %s, %s\n", msgbuf->msg.buf, msg->buf);
+               //LOG("copied msg data = %s, %s\n", msgbuf->msg.buf, msg->buf);
 
-        spin_lock_irqsave(&pnfc_info[NFC_READ]->inbuf_lock, flags);
+               spin_lock_irqsave(&pnfc_info[NFC_READ]->inbuf_lock, flags);
 
-        list_add_tail(&msgbuf->list, &vnfc->read_list);
-        //LOG("== wake_up_interruptible = %d!\n", ++g_wake_up_interruptible_count);
+               list_add_tail(&msgbuf->list, &vnfc->read_list);
+               //LOG("== wake_up_interruptible = %d!\n", ++g_wake_up_interruptible_count);
 
-        spin_unlock_irqrestore(&pnfc_info[NFC_READ]->inbuf_lock, flags);
+               spin_unlock_irqrestore(&pnfc_info[NFC_READ]->inbuf_lock, flags);
 
-        wake_up_interruptible(&pnfc_info[NFC_READ]->waitqueue);
+               wake_up_interruptible(&pnfc_info[NFC_READ]->waitqueue);
 
-        msg = (unsigned char*) virtqueue_get_buf(vnfc->rvq, &len);
-        if (msg == NULL) {
-            break;
-        }
+               msg = (unsigned char*) virtqueue_get_buf(vnfc->rvq, &len);
+               if (msg == NULL) {
+                       break;
+               }
 
-    } while (true);
-    /*
-    if (add_inbuf(vnfc->rvq, &vnfc->readmsginfo) < 0)
-    {
-        LOG("failed add_buf\n");
-    }
-    */
+       } while (true);
+       /*
+          if (add_inbuf(vnfc->rvq, &vnfc->readmsginfo) < 0)
+          {
+          LOG("failed add_buf\n");
+          }
+        */
 }
 
 static void nfc_send_done(struct virtqueue *svq) {
-    unsigned int len = 0;
+       unsigned int len = 0;
 
-    virtqueue_get_buf(svq, &len);
+       virtqueue_get_buf(svq, &len);
 }
 
 /*
@@ -404,172 +404,172 @@ static void nfc_send_done(struct virtqueue *svq) {
  */
 
 static int init_vqs(struct virtio_nfc *nfc) {
-    struct virtqueue *vqs[2];
-    vq_callback_t *callbacks[] = { nfc_recv_done, nfc_send_done };
-    const char *names[] = { "nfc_input", "nfc_output" };
-    int err;
+       struct virtqueue *vqs[2];
+       vq_callback_t *callbacks[] = { nfc_recv_done, nfc_send_done };
+       const char *names[] = { "nfc_input", "nfc_output" };
+       int err;
 
-    err = nfc->vdev->config->find_vqs(nfc->vdev, 2, vqs, callbacks, names);
-    if (err < 0)
-        return err;
+       err = nfc->vdev->config->find_vqs(nfc->vdev, 2, vqs, callbacks, names);
+       if (err < 0)
+               return err;
 
-    nfc->rvq = vqs[0];
-    nfc->svq = vqs[1];
+       nfc->rvq = vqs[0];
+       nfc->svq = vqs[1];
 
-    return 0;
+       return 0;
 }
 
 int init_device(void)
 {
-    int i, ret;
+       int i, ret;
 
-    if (alloc_chrdev_region(&nfc_dev_number, 0, NUM_OF_NFC, DEVICE_NAME) < 0) {
-        LOG("fail to alloc_chrdev_region\n");
-        return -1;
-    }
+       if (alloc_chrdev_region(&nfc_dev_number, 0, NUM_OF_NFC, DEVICE_NAME) < 0) {
+               LOG("fail to alloc_chrdev_region\n");
+               return -1;
+       }
 
-    nfc_class = class_create(THIS_MODULE, DEVICE_NAME);
+       nfc_class = class_create(THIS_MODULE, DEVICE_NAME);
 
-    if (nfc_class == NULL ) {
-        unregister_chrdev_region(nfc_dev_number, NUM_OF_NFC);
-        return -1;
-    }
+       if (nfc_class == NULL ) {
+               unregister_chrdev_region(nfc_dev_number, NUM_OF_NFC);
+               return -1;
+       }
 
-    for (i = 0; i < NUM_OF_NFC; i++) {
-        pnfc_info[i] = kmalloc(sizeof(struct virtnfc_info), GFP_KERNEL);
+       for (i = 0; i < NUM_OF_NFC; i++) {
+               pnfc_info[i] = kmalloc(sizeof(struct virtnfc_info), GFP_KERNEL);
 
-        if (!pnfc_info[i]) {
-            LOG("Bad malloc\n");
-            return -ENOMEM;
-        }
+               if (!pnfc_info[i]) {
+                       LOG("Bad malloc\n");
+                       return -ENOMEM;
+               }
 
-        sprintf(pnfc_info[i]->name, "%s%d", DEVICE_NAME, i);
+               sprintf(pnfc_info[i]->name, "%s%d", DEVICE_NAME, i);
 
-        pnfc_info[i]->index = i;
-        pnfc_info[i]->guest_connected = false;
+               pnfc_info[i]->index = i;
+               pnfc_info[i]->guest_connected = false;
 
-        cdev_init(&pnfc_info[i]->cdev, &nfc_fops);
-        pnfc_info[i]->cdev.owner = THIS_MODULE;
-        ret = cdev_add(&pnfc_info[i]->cdev, (nfc_dev_number + i), 1);
+               cdev_init(&pnfc_info[i]->cdev, &nfc_fops);
+               pnfc_info[i]->cdev.owner = THIS_MODULE;
+               ret = cdev_add(&pnfc_info[i]->cdev, (nfc_dev_number + i), 1);
 
-        /* init wait queue */
-        init_waitqueue_head(&pnfc_info[i]->waitqueue);
-        spin_lock_init(&pnfc_info[i]->inbuf_lock);
-        spin_lock_init(&pnfc_info[i]->outvq_lock);
+               /* init wait queue */
+               init_waitqueue_head(&pnfc_info[i]->waitqueue);
+               spin_lock_init(&pnfc_info[i]->inbuf_lock);
+               spin_lock_init(&pnfc_info[i]->outvq_lock);
 
-        if (ret == -1) {
-            LOG("Bad cdev\n");
-            return ret;
-        }
+               if (ret == -1) {
+                       LOG("Bad cdev\n");
+                       return ret;
+               }
 
-        device_create(nfc_class, NULL, (nfc_dev_number + i), NULL, "%s%d",
-                DEVICE_NAME, i);
-    }
+               device_create(nfc_class, NULL, (nfc_dev_number + i), NULL, "%s%d",
+                               DEVICE_NAME, i);
+       }
 
-    return 0;
+       return 0;
 }
 
 
 static int nfc_probe(struct virtio_device* dev) {
-    int ret;
-    LOG("nfc_probe\n");
-    vnfc = kmalloc(sizeof(struct virtio_nfc), GFP_KERNEL);
+       int ret;
+       LOG("nfc_probe\n");
+       vnfc = kmalloc(sizeof(struct virtio_nfc), GFP_KERNEL);
 
-    INIT_LIST_HEAD(&vnfc->read_list);
+       INIT_LIST_HEAD(&vnfc->read_list);
 
-    vnfc->vdev = dev;
-    dev->priv = vnfc;
+       vnfc->vdev = dev;
+       dev->priv = vnfc;
 
-    ret = init_device();
-    if (ret) {
-        LOG("failed to init_device\n");
-        return ret;
-    }
-    ret = init_vqs(vnfc);
-    if (ret) {
-        dev->config->del_vqs(dev);
-        kfree(vnfc);
-        dev->priv = NULL;
+       ret = init_device();
+       if (ret) {
+               LOG("failed to init_device\n");
+               return ret;
+       }
+       ret = init_vqs(vnfc);
+       if (ret) {
+               dev->config->del_vqs(dev);
+               kfree(vnfc);
+               dev->priv = NULL;
 
-        LOG("failed to init_vqs\n");
-        return ret;
-    }
+               LOG("failed to init_vqs\n");
+               return ret;
+       }
 
-     /* enable callback */
-    virtqueue_enable_cb(vnfc->rvq);
-    virtqueue_enable_cb(vnfc->svq);
+       /* enable callback */
+       virtqueue_enable_cb(vnfc->rvq);
+       virtqueue_enable_cb(vnfc->svq);
 
 
-    memset(&vnfc->read_msginfo, 0x00, sizeof(vnfc->read_msginfo));
-    sg_set_buf(vnfc->sg_read, &vnfc->read_msginfo, NFC_MAX_BUF_SIZE);
+       memset(&vnfc->read_msginfo, 0x00, sizeof(vnfc->read_msginfo));
+       sg_set_buf(vnfc->sg_read, &vnfc->read_msginfo, NFC_MAX_BUF_SIZE);
 
-    memset(&vnfc->send_msginfo, 0x00, sizeof(vnfc->send_msginfo));
-    sg_set_buf(vnfc->sg_send, &vnfc->send_msginfo, NFC_MAX_BUF_SIZE);
+       memset(&vnfc->send_msginfo, 0x00, sizeof(vnfc->send_msginfo));
+       sg_set_buf(vnfc->sg_send, &vnfc->send_msginfo, NFC_MAX_BUF_SIZE);
 
 
-    sg_init_one(vnfc->sg_read, &vnfc->read_msginfo, sizeof(vnfc->read_msginfo));
-    sg_init_one(vnfc->sg_send, &vnfc->send_msginfo, sizeof(vnfc->send_msginfo));
+       sg_init_one(vnfc->sg_read, &vnfc->read_msginfo, sizeof(vnfc->read_msginfo));
+       sg_init_one(vnfc->sg_send, &vnfc->send_msginfo, sizeof(vnfc->send_msginfo));
 
 
 
-    LOG("NFC Probe completed");
-    return 0;
+       LOG("NFC Probe completed");
+       return 0;
 }
 
 static void nfc_remove(struct virtio_device* dev)
 {
-    struct virtio_nfc* _nfc = dev->priv;
-    if (!_nfc) {
-        LOG("nfc is NULL\n");
-        return;
-    }
+       struct virtio_nfc* _nfc = dev->priv;
+       if (!_nfc) {
+               LOG("nfc is NULL\n");
+               return;
+       }
 
-    dev->config->reset(dev);
-    dev->config->del_vqs(dev);
+       dev->config->reset(dev);
+       dev->config->del_vqs(dev);
 
-    kfree(_nfc);
+       kfree(_nfc);
 
-    LOG("driver is removed.\n");
+       LOG("driver is removed.\n");
 }
 
 MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_nfc_driver = {
-        .driver = {
-                .name = KBUILD_MODNAME,
-                .owner = THIS_MODULE ,
-        },
-        .id_table = id_table,
-        .probe = nfc_probe,
-        .remove = nfc_remove,
+       .driver = {
+               .name = KBUILD_MODNAME,
+               .owner = THIS_MODULE ,
+       },
+       .id_table = id_table,
+       .probe = nfc_probe,
+       .remove = nfc_remove,
 };
 
 static int __init nfc_init(void)
 {
-    LOG("NFC driver initialized.\n");
+       LOG("NFC driver initialized.\n");
 
-    return register_virtio_driver(&virtio_nfc_driver);
+       return register_virtio_driver(&virtio_nfc_driver);
 }
 
 static void __exit nfc_exit(void)
 {
-    int i;
+       int i;
 
-    unregister_chrdev_region(nfc_dev_number, NUM_OF_NFC);
+       unregister_chrdev_region(nfc_dev_number, NUM_OF_NFC);
 
-    for (i = 0; i < NUM_OF_NFC; i++) {
-        device_destroy(nfc_class, MKDEV(MAJOR(nfc_dev_number), i));
-        cdev_del(&pnfc_info[i]->cdev);
-        kfree(pnfc_info[i]);
-    }
+       for (i = 0; i < NUM_OF_NFC; i++) {
+               device_destroy(nfc_class, MKDEV(MAJOR(nfc_dev_number), i));
+               cdev_del(&pnfc_info[i]->cdev);
+               kfree(pnfc_info[i]);
+       }
 
-    /*device_destroy(nfc_class, nfc_dev_number);*/
+       /*device_destroy(nfc_class, nfc_dev_number);*/
 
-    class_destroy(nfc_class);
+       class_destroy(nfc_class);
 
-    unregister_virtio_driver(&virtio_nfc_driver);
+       unregister_virtio_driver(&virtio_nfc_driver);
 
-    LOG("NFC driver is destroyed.\n");
+       LOG("NFC driver is destroyed.\n");
 }
 
 module_init(nfc_init);
index 09efd4ff06ddad7645f579ee0a89f7eb8417256d..2b327844653177d77ce893c3eda32d458536e934 100644 (file)
@@ -50,19 +50,19 @@ MODULE_DESCRIPTION("Emulator Virtio Touchscreen driver");
 
 /* This structure must match the qemu definitions */
 typedef struct EmulTouchEvent {
-    uint16_t x, y, z;
-    uint8_t state;
+       uint16_t x, y, z;
+       uint8_t state;
 } EmulTouchEvent;
 EmulTouchEvent *event;
 
 typedef struct virtio_touchscreen
 {
-    struct virtio_device *vdev;
-    struct virtqueue *vq;
-    struct input_dev *idev;
+       struct virtio_device *vdev;
+       struct virtqueue *vq;
+       struct input_dev *idev;
 
-    /* The thread servicing the touchscreen */
-    struct task_struct *thread;
+       /* The thread servicing the touchscreen */
+       struct task_struct *thread;
 } virtio_touchscreen;
 virtio_touchscreen *vt;
 
@@ -77,8 +77,8 @@ struct scatterlist sg[MAX_BUF_COUNT];
 EmulTouchEvent vbuf[MAX_BUF_COUNT];
 
 static struct virtio_device_id id_table[] = {
-    { VIRTIO_ID_TOUCHSCREEN, VIRTIO_DEV_ANY_ID },
-    { 0 },
+       { VIRTIO_ID_TOUCHSCREEN, VIRTIO_DEV_ANY_ID },
+       { 0 },
 };
 
 
@@ -88,83 +88,83 @@ static struct virtio_device_id id_table[] = {
  */
 static int run_touchscreen(void *_vtouchscreen)
 {
-    virtio_touchscreen *vt = NULL;
-    int err = 0;
-    unsigned int len = 0; /* not used */
-    unsigned int index = 0;
-    unsigned int recv_index = 0;
-    unsigned int id = 0; /* finger id */
+       virtio_touchscreen *vt = NULL;
+       int err = 0;
+       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;
-    EmulTouchEvent *event = NULL;
+       struct input_dev *input_dev = NULL;
+       EmulTouchEvent *event = NULL;
 
-    vt = (virtio_touchscreen *)_vtouchscreen;
-    input_dev = vt->idev;
+       vt = (virtio_touchscreen *)_vtouchscreen;
+       input_dev = vt->idev;
 
-    sg_init_table(sg, MAX_BUF_COUNT);
+       sg_init_table(sg, MAX_BUF_COUNT);
 
-    for (index = 0; index < MAX_BUF_COUNT; index++) {
-        sg_set_buf(&sg[index], &vbuf[index], sizeof(EmulTouchEvent));
+       for (index = 0; index < MAX_BUF_COUNT; index++) {
+               sg_set_buf(&sg[index], &vbuf[index], sizeof(EmulTouchEvent));
 
-        err = virtqueue_add_inbuf(vt->vq, sg, index + 1, (void *)index + 1, GFP_ATOMIC);
-        if (err < 0) {
-            printk(KERN_ERR "failed to add buf\n");
-        }
-    }
-    virtqueue_kick(vt->vq);
+               err = virtqueue_add_inbuf(vt->vq, sg, index + 1, (void *)index + 1, GFP_ATOMIC);
+               if (err < 0) {
+                       printk(KERN_ERR "failed to add buf\n");
+               }
+       }
+       virtqueue_kick(vt->vq);
 
-    index = 0;
+       index = 0;
 
-    while (!kthread_should_stop())
-    {
-        while ((recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len)) == 0) {
-            cpu_relax();
-        }
+       while (!kthread_should_stop())
+       {
+               while ((recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len)) == 0) {
+                       cpu_relax();
+               }
 
-        do {
-            event = &vbuf[recv_index - 1];
+               do {
+                       event = &vbuf[recv_index - 1];
 #if 0
-            printk(KERN_INFO "touch x=%d, y=%d, z=%d, state=%d, recv_index=%d\n",
-                event->x, event->y, event->z, event->state, recv_index);
+                       printk(KERN_INFO "touch x=%d, y=%d, z=%d, state=%d, recv_index=%d\n",
+                                       event->x, event->y, event->z, event->state, recv_index);
 #endif
 
-            id = event->z;
-
-            /* Multi-touch Protocol is B */
-            if (event->state != 0)
-            { /* pressed */
-                input_mt_slot(input_dev, id);
-                input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, true);
-                input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 10);
-                input_report_abs(input_dev, ABS_MT_POSITION_X, event->x);
-                input_report_abs(input_dev, ABS_MT_POSITION_Y, event->y);
-            }
-            else
-            { /* released */
-                input_mt_slot(input_dev, id);
-                input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
-            }
-
-            input_sync(input_dev);
-
-            /* expose buffer to other end */
-            err = virtqueue_add_inbuf(vt->vq, sg, recv_index, (void *)recv_index, GFP_ATOMIC);
-            if (err < 0) {
-                printk(KERN_ERR "failed to add buf\n");
-            }
-
-            recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
-            if (recv_index == 0) {
-                break;
-            }
-        } while(true);
-
-        virtqueue_kick(vt->vq);
-    }
-
-    printk(KERN_INFO "virtio touchscreen thread is stopped\n");
-
-    return 0;
+                       id = event->z;
+
+                       /* Multi-touch Protocol is B */
+                       if (event->state != 0)
+                       { /* pressed */
+                               input_mt_slot(input_dev, id);
+                               input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, true);
+                               input_report_abs(input_dev, ABS_MT_TOUCH_MAJOR, 10);
+                               input_report_abs(input_dev, ABS_MT_POSITION_X, event->x);
+                               input_report_abs(input_dev, ABS_MT_POSITION_Y, event->y);
+                       }
+                       else
+                       { /* released */
+                               input_mt_slot(input_dev, id);
+                               input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, false);
+                       }
+
+                       input_sync(input_dev);
+
+                       /* expose buffer to other end */
+                       err = virtqueue_add_inbuf(vt->vq, sg, recv_index, (void *)recv_index, GFP_ATOMIC);
+                       if (err < 0) {
+                               printk(KERN_ERR "failed to add buf\n");
+                       }
+
+                       recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
+                       if (recv_index == 0) {
+                               break;
+                       }
+               } while(true);
+
+               virtqueue_kick(vt->vq);
+       }
+
+       printk(KERN_INFO "virtio touchscreen thread is stopped\n");
+
+       return 0;
 }
 #endif
 
@@ -176,96 +176,96 @@ unsigned int recv_index = 0;
 unsigned int finger_id = 0; /* finger id */
 
 /**
-* @brief : callback for virtqueue
-*/
+ * @brief : callback for virtqueue
+ */
 static void vq_touchscreen_callback(struct virtqueue *vq)
 {
 #if 0
-    printk(KERN_INFO "vq touchscreen callback\n");
+       printk(KERN_INFO "vq touchscreen callback\n");
 #endif
 
-    recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
-    if (recv_index == 0) {
-        printk(KERN_ERR "failed to get buffer\n");
-        return;
-    }
+       recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
+       if (recv_index == 0) {
+               printk(KERN_ERR "failed to get buffer\n");
+               return;
+       }
 
-    do {
-        event = &vbuf[recv_index - 1];
+       do {
+               event = &vbuf[recv_index - 1];
 
 #if 0
-        printk(KERN_INFO "touch x=%d, y=%d, z=%d, state=%d, recv_index=%d\n",
-            event->x, event->y, event->z, event->state, recv_index);
+               printk(KERN_INFO "touch x=%d, y=%d, z=%d, state=%d, recv_index=%d\n",
+                               event->x, event->y, event->z, event->state, recv_index);
 #endif
 
-        finger_id = event->z;
-
-        if (finger_id < MAX_TRKID) {
-            /* Multi-touch Protocol is B */
-
-            if (event->state != 0)
-            { /* pressed */
-                input_mt_slot(vt->idev, finger_id);
-                input_mt_report_slot_state(vt->idev, MT_TOOL_FINGER, true);
-                input_report_abs(vt->idev, ABS_MT_TOUCH_MAJOR, 10);
-                input_report_abs(vt->idev, ABS_MT_POSITION_X, event->x);
-                input_report_abs(vt->idev, ABS_MT_POSITION_Y, event->y);
-            }
-            else
-            { /* released */
-                input_mt_slot(vt->idev, finger_id);
-                input_mt_report_slot_state(vt->idev, MT_TOOL_FINGER, false);
-            }
-
-            input_sync(vt->idev);
-        } else {
-            printk(KERN_ERR "%d is an invalid finger id!\n", finger_id);
-        }
-
-        /* expose buffer to other end */
-        err = virtqueue_add_inbuf(vt->vq, sg,
-            recv_index, (void *)recv_index, GFP_ATOMIC);
-
-        if (err < 0) {
-            printk(KERN_ERR "failed to add buffer!\n");
-        }
-
-        recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
-        if (recv_index == 0) {
-            break;
-        }
-    } while(true);
-
-    virtqueue_kick(vt->vq);
+               finger_id = event->z;
+
+               if (finger_id < MAX_TRKID) {
+                       /* Multi-touch Protocol is B */
+
+                       if (event->state != 0)
+                       { /* pressed */
+                               input_mt_slot(vt->idev, finger_id);
+                               input_mt_report_slot_state(vt->idev, MT_TOOL_FINGER, true);
+                               input_report_abs(vt->idev, ABS_MT_TOUCH_MAJOR, 10);
+                               input_report_abs(vt->idev, ABS_MT_POSITION_X, event->x);
+                               input_report_abs(vt->idev, ABS_MT_POSITION_Y, event->y);
+                       }
+                       else
+                       { /* released */
+                               input_mt_slot(vt->idev, finger_id);
+                               input_mt_report_slot_state(vt->idev, MT_TOOL_FINGER, false);
+                       }
+
+                       input_sync(vt->idev);
+               } else {
+                       printk(KERN_ERR "%d is an invalid finger id!\n", finger_id);
+               }
+
+               /* expose buffer to other end */
+               err = virtqueue_add_inbuf(vt->vq, sg,
+                               recv_index, (void *)recv_index, GFP_ATOMIC);
+
+               if (err < 0) {
+                       printk(KERN_ERR "failed to add buffer!\n");
+               }
+
+               recv_index = (unsigned int)virtqueue_get_buf(vt->vq, &len);
+               if (recv_index == 0) {
+                       break;
+               }
+       } while(true);
+
+       virtqueue_kick(vt->vq);
 }
 
 static int virtio_touchscreen_open(struct inode *inode, struct file *file)
 {
-    printk(KERN_INFO "virtio touchscreen device is opened\n");
-    return 0;
+       printk(KERN_INFO "virtio touchscreen device is opened\n");
+       return 0;
 }
 
 static int virtio_touchscreen_release(struct inode *inode, struct file *file)
 {
-    printk(KERN_INFO "virtio touchscreen device is closed\n");
-    return 0;
+       printk(KERN_INFO "virtio touchscreen device is closed\n");
+       return 0;
 }
 
 static int input_touchscreen_open(struct input_dev *dev)
 {
-    printk(KERN_INFO "input touchscreen device is opened\n");
-    return 0;
+       printk(KERN_INFO "input touchscreen device is opened\n");
+       return 0;
 }
 
 static void input_touchscreen_close(struct input_dev *dev)
 {
-    printk(KERN_INFO "input touchscreen device is closed\n");
+       printk(KERN_INFO "input touchscreen device is closed\n");
 }
 
 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,
 };
 
 extern char *saved_command_line;
@@ -273,208 +273,208 @@ extern char *saved_command_line;
 
 static int virtio_touchscreen_probe(struct virtio_device *vdev)
 {
-    unsigned long width = 0;
-    unsigned long height = 0;
-    char *cmdline = NULL;
-    char *value = NULL;
-    char *tmp = NULL;
-    int err = 0;
-    int ret = 0;
-
-    printk(KERN_INFO "virtio touchscreen driver is probed\n");
-
-    /* init virtio */
-    vdev->priv = vt = kmalloc(sizeof(*vt), GFP_KERNEL);
-    if (!vt) {
-        return -ENOMEM;
-    }
-
-    vt->vdev = vdev;
-
-    vt->vq = virtio_find_single_vq(vt->vdev,
-        vq_touchscreen_callback, "virtio-touchscreen-vq");
-    if (IS_ERR(vt->vq)) {
-        ret = PTR_ERR(vt->vq);
-
-        kfree(vt);
-        vdev->priv = NULL;
-        return ret;
-    }
-
-    /* enable callback */
-    virtqueue_enable_cb(vt->vq);
-
-    sg_init_table(sg, MAX_BUF_COUNT);
-
-    /* prepare the buffers */
-    for (index = 0; index < MAX_BUF_COUNT; index++) {
-        sg_set_buf(&sg[index], &vbuf[index], sizeof(EmulTouchEvent));
-
-        err = virtqueue_add_inbuf(vt->vq, sg,
-            index + 1, (void *)index + 1, GFP_ATOMIC);
-
-        if (err < 0) {
-            printk(KERN_ERR "failed to add buffer\n");
-
-            kfree(vt);
-            vdev->priv = NULL;
-            return ret;
-        }
-    }
-
-    cmdline = kzalloc(strlen(saved_command_line) + 1, GFP_KERNEL);
-    if (cmdline) {
-        /* get VM resolution */
-        strcpy(cmdline, saved_command_line);
-        tmp = strstr(cmdline, VM_RESOLUTION_KEY);
-
-        if (tmp != NULL) {
-            tmp += strlen(VM_RESOLUTION_KEY);
-
-            value = strsep(&tmp, "x");
-            err = kstrtoul(value, 10, &width);
-            if (err) {
-                printk(KERN_WARNING "vm width option is not defined\n");
-                width = 0;
-            }
-
-            value = strsep(&tmp, " ");
-            err = kstrtoul(value, 10, &height);
-            if (err) {
-                printk(KERN_WARNING "vm height option is not defined\n");
-                height = 0;
-            }
-        }
-
-        kfree(cmdline);
-    }
-
-    if (width != 0 && height != 0) {
-        printk(KERN_INFO "emul resolution : %lux%lu\n", width, height);
-    }
-
-    /* register for input device */
-    vt->idev = input_allocate_device();
-    if (!vt->idev) {
-        printk(KERN_ERR "failed to allocate a input touchscreen device\n");
-        ret = -1;
-
-        kfree(vt);
-        vdev->priv = NULL;
-        return ret;
-    }
-
-    vt->idev->name = "Maru Virtio Touchscreen";
-    vt->idev->dev.parent = &(vdev->dev);
-
-    input_set_drvdata(vt->idev, vt);
-    vt->idev->open = input_touchscreen_open;
-    vt->idev->close = input_touchscreen_close;
-
-    vt->idev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
-    vt->idev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
-    vt->idev->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
-
-    input_mt_init_slots(vt->idev, MAX_TRKID, 0);
-
-    input_set_abs_params(vt->idev, ABS_X, 0,
-        width, 0, 0);
-    input_set_abs_params(vt->idev, ABS_Y, 0,
-        height, 0, 0);
-    input_set_abs_params(vt->idev, ABS_MT_TRACKING_ID, 0,
-        MAX_TRKID, 0, 0);
-    input_set_abs_params(vt->idev, ABS_MT_TOUCH_MAJOR, 0,
-        ABS_PRESSURE_MAX, 0, 0);
-    input_set_abs_params(vt->idev, ABS_MT_POSITION_X, 0,
-        width, 0, 0);
-    input_set_abs_params(vt->idev, ABS_MT_POSITION_Y, 0,
-        height, 0, 0);
-
-    ret = input_register_device(vt->idev);
-    if (ret) {
-        printk(KERN_ERR "input touchscreen driver cannot registered\n");
-        ret = -1;
-
-        input_mt_destroy_slots(vt->idev);
-        input_free_device(vt->idev);
-        kfree(vt);
-        vdev->priv = NULL;
-        return ret;
-    }
+       unsigned long width = 0;
+       unsigned long height = 0;
+       char *cmdline = NULL;
+       char *value = NULL;
+       char *tmp = NULL;
+       int err = 0;
+       int ret = 0;
+
+       printk(KERN_INFO "virtio touchscreen driver is probed\n");
+
+       /* init virtio */
+       vdev->priv = vt = kmalloc(sizeof(*vt), GFP_KERNEL);
+       if (!vt) {
+               return -ENOMEM;
+       }
+
+       vt->vdev = vdev;
+
+       vt->vq = virtio_find_single_vq(vt->vdev,
+                       vq_touchscreen_callback, "virtio-touchscreen-vq");
+       if (IS_ERR(vt->vq)) {
+               ret = PTR_ERR(vt->vq);
+
+               kfree(vt);
+               vdev->priv = NULL;
+               return ret;
+       }
+
+       /* enable callback */
+       virtqueue_enable_cb(vt->vq);
+
+       sg_init_table(sg, MAX_BUF_COUNT);
+
+       /* prepare the buffers */
+       for (index = 0; index < MAX_BUF_COUNT; index++) {
+               sg_set_buf(&sg[index], &vbuf[index], sizeof(EmulTouchEvent));
+
+               err = virtqueue_add_inbuf(vt->vq, sg,
+                               index + 1, (void *)index + 1, GFP_ATOMIC);
+
+               if (err < 0) {
+                       printk(KERN_ERR "failed to add buffer\n");
+
+                       kfree(vt);
+                       vdev->priv = NULL;
+                       return ret;
+               }
+       }
+
+       cmdline = kzalloc(strlen(saved_command_line) + 1, GFP_KERNEL);
+       if (cmdline) {
+               /* get VM resolution */
+               strcpy(cmdline, saved_command_line);
+               tmp = strstr(cmdline, VM_RESOLUTION_KEY);
+
+               if (tmp != NULL) {
+                       tmp += strlen(VM_RESOLUTION_KEY);
+
+                       value = strsep(&tmp, "x");
+                       err = kstrtoul(value, 10, &width);
+                       if (err) {
+                               printk(KERN_WARNING "vm width option is not defined\n");
+                               width = 0;
+                       }
+
+                       value = strsep(&tmp, " ");
+                       err = kstrtoul(value, 10, &height);
+                       if (err) {
+                               printk(KERN_WARNING "vm height option is not defined\n");
+                               height = 0;
+                       }
+               }
+
+               kfree(cmdline);
+       }
+
+       if (width != 0 && height != 0) {
+               printk(KERN_INFO "emul resolution : %lux%lu\n", width, height);
+       }
+
+       /* register for input device */
+       vt->idev = input_allocate_device();
+       if (!vt->idev) {
+               printk(KERN_ERR "failed to allocate a input touchscreen device\n");
+               ret = -1;
+
+               kfree(vt);
+               vdev->priv = NULL;
+               return ret;
+       }
+
+       vt->idev->name = "Maru Virtio Touchscreen";
+       vt->idev->dev.parent = &(vdev->dev);
+
+       input_set_drvdata(vt->idev, vt);
+       vt->idev->open = input_touchscreen_open;
+       vt->idev->close = input_touchscreen_close;
+
+       vt->idev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+       vt->idev->absbit[BIT_WORD(ABS_MISC)] |= BIT_MASK(ABS_MISC);
+       vt->idev->keybit[BIT_WORD(BTN_TOUCH)] |= BIT_MASK(BTN_TOUCH);
+
+       input_mt_init_slots(vt->idev, MAX_TRKID, 0);
+
+       input_set_abs_params(vt->idev, ABS_X, 0,
+                       width, 0, 0);
+       input_set_abs_params(vt->idev, ABS_Y, 0,
+                       height, 0, 0);
+       input_set_abs_params(vt->idev, ABS_MT_TRACKING_ID, 0,
+                       MAX_TRKID, 0, 0);
+       input_set_abs_params(vt->idev, ABS_MT_TOUCH_MAJOR, 0,
+                       ABS_PRESSURE_MAX, 0, 0);
+       input_set_abs_params(vt->idev, ABS_MT_POSITION_X, 0,
+                       width, 0, 0);
+       input_set_abs_params(vt->idev, ABS_MT_POSITION_Y, 0,
+                       height, 0, 0);
+
+       ret = input_register_device(vt->idev);
+       if (ret) {
+               printk(KERN_ERR "input touchscreen driver cannot registered\n");
+               ret = -1;
+
+               input_mt_destroy_slots(vt->idev);
+               input_free_device(vt->idev);
+               kfree(vt);
+               vdev->priv = NULL;
+               return ret;
+       }
 
 #if 0 /* using a thread */
 
-    /* Responses from the hypervisor occur through the get_buf function */
-    vt->thread = kthread_run(run_touchscreen, vt, "vtouchscreen");
-    if (IS_ERR(vt->thread)) {
-        printk(KERN_ERR "unable to start the virtio touchscreen thread\n");
-        ret = PTR_ERR(vt->thread);
-
-        input_mt_destroy_slots(vt->idev);
-        input_free_device(vt->idev);
-        kfree(vt);
-        vdev->priv = NULL;
-        return ret;
-    }
+       /* Responses from the hypervisor occur through the get_buf function */
+       vt->thread = kthread_run(run_touchscreen, vt, "vtouchscreen");
+       if (IS_ERR(vt->thread)) {
+               printk(KERN_ERR "unable to start the virtio touchscreen thread\n");
+               ret = PTR_ERR(vt->thread);
+
+               input_mt_destroy_slots(vt->idev);
+               input_free_device(vt->idev);
+               kfree(vt);
+               vdev->priv = NULL;
+               return ret;
+       }
 #else /* using a callback */
 
-    virtqueue_kick(vt->vq);
+       virtqueue_kick(vt->vq);
 
-    index = 0;
+       index = 0;
 
 #endif
 
-    return 0;
+       return 0;
 }
 
 static void virtio_touchscreen_remove(struct virtio_device *vdev)
 {
-    virtio_touchscreen *vts = NULL;
+       virtio_touchscreen *vts = NULL;
 
-    printk(KERN_INFO "virtio touchscreen driver is removed\n");
+       printk(KERN_INFO "virtio touchscreen driver is removed\n");
 
-    vts = vdev->priv;
+       vts = vdev->priv;
 
-    kthread_stop(vts->thread);
+       kthread_stop(vts->thread);
 
-    vdev->config->reset(vdev); /* reset device */
-    vdev->config->del_vqs(vdev); /* clean up the queues */
+       vdev->config->reset(vdev); /* reset device */
+       vdev->config->del_vqs(vdev); /* clean up the queues */
 
-    input_unregister_device(vts->idev);
-    input_mt_destroy_slots(vts->idev);
+       input_unregister_device(vts->idev);
+       input_mt_destroy_slots(vts->idev);
 
-    kfree(vts);
+       kfree(vts);
 }
 
 MODULE_DEVICE_TABLE(virtio, id_table);
 
 static struct virtio_driver virtio_touchscreen_driver = {
-    .driver.name = KBUILD_MODNAME,
-    .driver.owner = THIS_MODULE,
-    .id_table = id_table,
-    .probe = virtio_touchscreen_probe,
-    .remove = virtio_touchscreen_remove,
+       .driver.name = KBUILD_MODNAME,
+       .driver.owner = THIS_MODULE,
+       .id_table = id_table,
+       .probe = virtio_touchscreen_probe,
+       .remove = virtio_touchscreen_remove,
 #if 0
-    .feature_table = features,
-    .feature_table_size = ARRAY_SIZE(features),
-    .config_changed =
+       .feature_table = features,
+       .feature_table_size = ARRAY_SIZE(features),
+       .config_changed =
 #ifdef CONFIG_PM
-    .freeze =
-    .restore =
+               .freeze =
+               .restore =
 #endif
 #endif
 };
 
 static int __init virtio_touchscreen_init(void)
 {
-    printk(KERN_INFO "virtio touchscreen device is initialized\n");
-    return register_virtio_driver(&virtio_touchscreen_driver);
+       printk(KERN_INFO "virtio touchscreen device is initialized\n");
+       return register_virtio_driver(&virtio_touchscreen_driver);
 }
 
 static void __exit virtio_touchscreen_exit(void)
 {
-    printk(KERN_INFO "virtio touchscreen device is destroyed\n");
-    unregister_virtio_driver(&virtio_touchscreen_driver);
+       printk(KERN_INFO "virtio touchscreen device is destroyed\n");
+       unregister_virtio_driver(&virtio_touchscreen_driver);
 }
 
 module_init(virtio_touchscreen_init);