From: Anshul Garg <aksgarg1989@gmail.com>
To: dmitry.torokhov@gmail.com, dtor@mail.ru, linux-input@vger.kernel.org
Cc: aksgarg1989@gmail.com, anshul.g@samsung.com
Subject: [PATCH] Input:Flush client events on clk_type change
Date: Wed, 7 Jan 2015 10:26:25 -0800 [thread overview]
Message-ID: <1420655185-24555-1-git-send-email-aksgarg1989@gmail.com> (raw)
In-Reply-To: <aksgarg1989@gmail.com>
From: Anshul Garg <aksgarg1989@gmail.com>
Since the client clk_type is changed , flush pending
events from client buffer and queue SYN_DROPPED event.
Added check for duplicate clk_type change request.
Signed-off-by: Anshul Garg <anshul.g@samsung.com>
---
drivers/input/evdev.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c
index b1a52ab..d024fc6 100644
--- a/drivers/input/evdev.c
+++ b/drivers/input/evdev.c
@@ -62,8 +62,12 @@ struct evdev_client {
struct input_event buffer[];
};
-static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
+static int evdev_set_clk_type(struct evdev_client *client,
+ struct input_dev *dev, unsigned int clkid)
{
+ if (client->clk_type == clkid)
+ return 0;
+
switch (clkid) {
case CLOCK_REALTIME:
@@ -78,7 +82,17 @@ static int evdev_set_clk_type(struct evdev_client *client, unsigned int clkid)
default:
return -EINVAL;
}
+
+ spin_lock_irq(&dev->event_lock);
+ spin_lock(&client->buffer_lock);
+ spin_unlock(&dev->event_lock);
+ /* Flush clients events after clk_type is changed
+ * and queue SYN_DROPPED event.*/
+ client->packet_head = client->head = client->tail;
+ spin_unlock_irq(&client->buffer_lock);
+
+ evdev_queue_syn_dropped(client);
return 0;
}
@@ -908,7 +922,7 @@ static long evdev_do_ioctl(struct file *file, unsigned int cmd,
if (copy_from_user(&i, p, sizeof(unsigned int)))
return -EFAULT;
- return evdev_set_clk_type(client, i);
+ return evdev_set_clk_type(client, dev, i);
case EVIOCGKEYCODE:
return evdev_handle_get_keycode(dev, p);
--
1.7.9.5
---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com
next reply other threads:[~2015-01-07 18:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-07 18:26 Anshul Garg [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-01-07 18:56 [PATCH] Input:Flush client events on clk_type change Anshul Garg
2015-01-07 19:32 ` Dmitry Torokhov
2015-01-08 13:57 ` Anshul Garg
2015-01-08 21:41 ` Dmitry Torokhov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1420655185-24555-1-git-send-email-aksgarg1989@gmail.com \
--to=aksgarg1989@gmail.com \
--cc=anshul.g@samsung.com \
--cc=dmitry.torokhov@gmail.com \
--cc=dtor@mail.ru \
--cc=linux-input@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).