From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Jiri Kosina <jikos@kernel.org>,
Nestor Lopez Casado <nlopezcasad@logitech.com>,
Simon Wood <simon@mungewell.org>, Olivier Gay <ogay@logitech.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
Benjamin Tissoires <benjamin.tissoires@redhat.com>
Subject: [PATCH 5/7] HID: logitech-hidpp: create a name based on the type if non available
Date: Fri, 7 Sep 2018 12:34:48 +0200 [thread overview]
Message-ID: <20180907103450.13890-6-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <20180907103450.13890-1-benjamin.tissoires@redhat.com>
Some low cost devices don't even have a name (nor a serial) registered
in the receiver. In those case, create a better name that "Logitech
USB Receiver" or even "Logitech " if we try to get their name.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
---
drivers/hid/hid-logitech-hidpp.c | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 5f96e63dbd87..a09509fdb746 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -802,6 +802,9 @@ static char *hidpp_unifying_get_name(struct hidpp_device *hidpp_dev, int index)
if (2 + len > sizeof(response.rap.params))
return NULL;
+ if (len < 4) /* logitech devices are usually at least Xddd */
+ return NULL;
+
name = kzalloc(len + 1, GFP_KERNEL);
if (!name)
return NULL;
@@ -838,7 +841,8 @@ static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, int index,
}
static int hidpp_unifying_get_name_and_uniq(struct hidpp_device *hidpp,
- int device_index, u16 quadid, char name[128], char uniq[64])
+ int device_index, u16 quadid, u8 type, char name[128],
+ char uniq[64])
{
const char *hidpp_name;
u32 serial;
@@ -853,8 +857,29 @@ static int hidpp_unifying_get_name_and_uniq(struct hidpp_device *hidpp,
device_index);
hidpp_name = hidpp_unifying_get_name(hidpp, device_index);
- if (!hidpp_name)
- return -EIO;
+ if (!hidpp_name) {
+ switch (type) {
+ case 0x01:
+ snprintf(name, 128, "Logitech Wireless Keyboard");
+ break;
+ case 0x02:
+ snprintf(name, 128, "Logitech Wireless Mouse");
+ break;
+ case 0x03:
+ snprintf(name, 128, "Logitech Wireless Numpad");
+ break;
+ case 0x04:
+ snprintf(name, 128, "Logitech Wireless Presenter");
+ break;
+ case 0x08:
+ snprintf(name, 128, "Logitech Wireless Trackball");
+ break;
+ case 0x09:
+ snprintf(name, 128, "Logitech Wireless Touchpad");
+ break;
+ }
+ return 0;
+ }
snprintf(name, 128, "%s", hidpp_name);
dbg_hid("HID++ Unifying: Got name: '%s' for device %d\n", name,
@@ -899,7 +924,8 @@ static int hidpp_unifying_init(struct hidpp_device *hidpp)
*/
if (i == 1) {
ret = hidpp_unifying_get_name_and_uniq(hidpp, i,
- q, hidpp->shared->name,
+ q, type,
+ hidpp->shared->name,
hidpp->shared->uniq);
if (ret)
return ret;
@@ -910,7 +936,7 @@ static int hidpp_unifying_init(struct hidpp_device *hidpp)
if (device_index != 1) {
ret = hidpp_unifying_get_name_and_uniq(hidpp, device_index,
- quadid, hdev->name,
+ quadid, type, hdev->name,
hdev->uniq);
if (ret)
return ret;
--
2.14.3
next prev parent reply other threads:[~2018-09-07 10:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-07 10:34 [PATCH 0/7] HID: logitech-hidpp: support non DJ devices Benjamin Tissoires
2018-09-07 10:34 ` [PATCH 1/7] HID: logitech-hidpp: allow non HID++ devices to be handled by this module Benjamin Tissoires
2018-09-07 10:34 ` [PATCH 2/7] HID: logitech-hidpp: make .probe usbhid capable Benjamin Tissoires
2018-09-07 10:34 ` [PATCH 3/7] HID: logitech-hidpp: support non-DJ receivers Benjamin Tissoires
2018-09-07 10:34 ` [PATCH 4/7] HID: logitech-hidpp: get the name and serial of the other non-HID++ node Benjamin Tissoires
2018-09-07 10:34 ` Benjamin Tissoires [this message]
2018-09-07 10:34 ` [PATCH 6/7] HID: logitech-hidpp: support the G700 over wireless Benjamin Tissoires
2018-09-07 17:33 ` Harry Cutts
2018-12-18 10:11 ` Benjamin Tissoires
2018-09-07 10:34 ` [PATCH 7/7] HID: logitech-hidpp: support the G900 " Benjamin Tissoires
2018-09-07 10:39 ` [PATCH 8/7] HID: quirks: do not blacklist Logitech devices Benjamin Tissoires
2018-10-15 12:34 ` [PATCH 0/7] HID: logitech-hidpp: support non DJ devices Benjamin Tissoires
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=20180907103450.13890-6-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=jikos@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nlopezcasad@logitech.com \
--cc=ogay@logitech.com \
--cc=simon@mungewell.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).