From ee9baa2dd8a8a5d99b6943707d32e32e0687f20d Mon Sep 17 00:00:00 2001
From: Felix Rueegg <felix.rueegg@gmail.com>
Date: Sun, 6 Oct 2013 17:59:56 +0200
Subject: Remove sysfs attributes when removing driver to prevent error when
 driver is loaded again.

---
 src/kernel/hid-lg-g710-plus.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/kernel/hid-lg-g710-plus.c b/src/kernel/hid-lg-g710-plus.c
index 42ff7d8..57876d8 100644
--- a/src/kernel/hid-lg-g710-plus.c
+++ b/src/kernel/hid-lg-g710-plus.c
@@ -249,6 +249,11 @@ err_free:
 static void lg_g710_plus_remove(struct hid_device *hdev)
 {
     struct lg_g710_plus_data* data = lg_g710_plus_get_data(hdev);
+    struct list_head *feature_report_list = &hdev->report_enum[HID_FEATURE_REPORT].report_list;
+
+    if (data != NULL && !list_empty(feature_report_list))
+        sysfs_remove_group(&hdev->dev.kobj, &data->attr_group);
+
     hid_hw_stop(hdev);
     if (data != NULL) {
         kfree(data);
-- 
cgit v1.2.3


From 2d05ee44b999a72c90ea65fadb19642ec8764a30 Mon Sep 17 00:00:00 2001
From: Felix Rueegg <felix.rueegg@gmail.com>
Date: Sun, 6 Oct 2013 18:03:26 +0200
Subject: Fix to ignore first hid report with recent kernel versions. There was
 a change that even if raw_event returns 1, the events from the first report
 will still get sent.
 https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/commit/?id=b1a1442a23776756b254b69786848a94d92445ba

---
 src/kernel/hid-lg-g710-plus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/kernel/hid-lg-g710-plus.c b/src/kernel/hid-lg-g710-plus.c
index 57876d8..f3f2577 100644
--- a/src/kernel/hid-lg-g710-plus.c
+++ b/src/kernel/hid-lg-g710-plus.c
@@ -128,8 +128,9 @@ static int lg_g710_plus_raw_event(struct hid_device *hdev, struct hid_report *re
     struct lg_g710_plus_data* g710_data = lg_g710_plus_get_data(hdev);
     /* Ignore the first event. It will send a key down event for certain buttons, but never the key up event*/
     if (g710_data->first_event) {
+        memset(data, 0, size);
         g710_data->first_event= 0;
-        return 1;
+        return 0;
     }
     switch(report->id) {
         case 3: return lg_g710_plus_extra_key_event(hdev, report, data, size);
-- 
cgit v1.2.3