From: Jamie Lentin <jm@lentin.co.uk>
To: Jiri Kosina <jkosina@suse.cz>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Jamie Lentin <jm@lentin.co.uk>
Subject: [PATCH v2 1/2] Loosen seams to allow support of other keyboards
Date: Tue, 10 Jun 2014 23:24:53 +0100 [thread overview]
Message-ID: <1402439094-25464-2-git-send-email-jm@lentin.co.uk> (raw)
In-Reply-To: <1402439094-25464-1-git-send-email-jm@lentin.co.uk>
Signed-off-by: Jamie Lentin <jm@lentin.co.uk>
---
drivers/hid/hid-lenovo-tpkbd.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/drivers/hid/hid-lenovo-tpkbd.c b/drivers/hid/hid-lenovo-tpkbd.c
index 2d25b6c..3bec9f5 100644
--- a/drivers/hid/hid-lenovo-tpkbd.c
+++ b/drivers/hid/hid-lenovo-tpkbd.c
@@ -1,5 +1,6 @@
/*
- * HID driver for Lenovo ThinkPad USB Keyboard with TrackPoint
+ * HID driver for Lenovo:-
+ * * ThinkPad USB Keyboard with TrackPoint
*
* Copyright (c) 2012 Bernhard Seibold
*/
@@ -35,7 +36,7 @@ struct tpkbd_data_pointer {
#define map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, EV_KEY, (c))
-static int tpkbd_input_mapping(struct hid_device *hdev,
+static int tpkbd_input_mapping_tp(struct hid_device *hdev,
struct hid_input *hi, struct hid_field *field,
struct hid_usage *usage, unsigned long **bit, int *max)
{
@@ -48,6 +49,15 @@ static int tpkbd_input_mapping(struct hid_device *hdev,
return 0;
}
+static int tpkbd_input_mapping(struct hid_device *hdev,
+ struct hid_input *hi, struct hid_field *field,
+ struct hid_usage *usage, unsigned long **bit, int *max)
+{
+ if (hdev->product == USB_DEVICE_ID_LENOVO_TPKBD)
+ return tpkbd_input_mapping_tp(hdev, hi, field, usage, bit, max);
+ return 0;
+}
+
#undef map_key_clear
static int tpkbd_features_set(struct hid_device *hdev)
@@ -338,6 +348,11 @@ static int tpkbd_probe_tp(struct hid_device *hdev)
char *name_mute, *name_micmute;
int i;
+ /* Ignore unless tpkbd_input_mapping_tp marked it as a pointer */
+ if (!hid_get_drvdata(hdev))
+ return 0;
+ hid_set_drvdata(hdev, NULL);
+
/* Validate required reports. */
for (i = 0; i < 4; i++) {
if (!hid_validate_values(hdev, HID_FEATURE_REPORT, 4, i, 1))
@@ -408,12 +423,9 @@ static int tpkbd_probe(struct hid_device *hdev,
goto err;
}
- if (hid_get_drvdata(hdev)) {
- hid_set_drvdata(hdev, NULL);
- ret = tpkbd_probe_tp(hdev);
- if (ret)
- goto err_hid;
- }
+ if (hdev->product == USB_DEVICE_ID_LENOVO_TPKBD
+ && tpkbd_probe_tp(hdev))
+ goto err_hid;
return 0;
err_hid:
@@ -437,7 +449,10 @@ static void tpkbd_remove_tp(struct hid_device *hdev)
static void tpkbd_remove(struct hid_device *hdev)
{
- if (hid_get_drvdata(hdev))
+ if (!hid_get_drvdata(hdev))
+ return;
+
+ if (hdev->product == USB_DEVICE_ID_LENOVO_TPKBD)
tpkbd_remove_tp(hdev);
hid_hw_stop(hdev);
--
2.0.0.rc2
next prev parent reply other threads:[~2014-06-10 22:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-10 22:24 [PATCH v2 0/2] Add support for Lenovo Compact Keyboard Jamie Lentin
2014-06-10 22:24 ` Jamie Lentin [this message]
2014-06-11 7:41 ` [PATCH v2 1/2] Loosen seams to allow support of other keyboards Antonio Ospite
2014-06-10 22:24 ` [PATCH v2 2/2] Add support for Compact (Bluetooth|USB) keyboard with Trackpoint Jamie Lentin
2014-06-11 8:36 ` Antonio Ospite
2014-06-12 8:56 ` Jamie Lentin
2014-06-13 21:45 ` Antonio Ospite
2014-06-14 5:33 ` Jiri Kosina
2014-06-11 10:57 ` [PATCH v2 0/2] Add support for Lenovo Compact Keyboard Jiri Kosina
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=1402439094-25464-2-git-send-email-jm@lentin.co.uk \
--to=jm@lentin.co.uk \
--cc=jkosina@suse.cz \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@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).