aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-09-30 13:18:25 -0400
committerJiri Kosina <jkosina@suse.cz>2014-10-29 05:51:38 -0400
commitd610274b0301e5ef35811fa736036d022f707564 (patch)
tree7e3cc92d76d3cf7bff718a2663a7a12084324627
parent9578f41aeaee5010384f4f8484da1566e2ce4901 (diff)
HID: logitech-dj: rely on hid groups to separate receivers from dj devices
Several benefits here: - we can drop the macro is_dj_device: I never been really conviced by this macro as we could fall into a null pointer anytime. Anyway time showed that this never happened. - we can simplify the hid driver logitech-djdevice, and make it aware of any new receiver VID/PID. - we can use the Wireless PID of the DJ device as the product id of the hid device, this way the sysfs will differentiate between different DJ devices. Signed-off-by: Benjamin Tisssoires <benjamin.tissoires@redhat.com> Tested-by: Andrew de los Reyes <adlr@chromium.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/hid-logitech-dj.c38
-rw-r--r--drivers/hid/hid-logitech-dj.h10
-rw-r--r--include/linux/hid.h1
3 files changed, 11 insertions, 38 deletions
diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c
index 71f569292cab..42d38d50afdf 100644
--- a/drivers/hid/hid-logitech-dj.c
+++ b/drivers/hid/hid-logitech-dj.c
@@ -256,11 +256,15 @@ static void logi_dj_recv_add_djhid_device(struct dj_receiver_dev *djrcv_dev,
256 dj_hiddev->dev.parent = &djrcv_hdev->dev; 256 dj_hiddev->dev.parent = &djrcv_hdev->dev;
257 dj_hiddev->bus = BUS_USB; 257 dj_hiddev->bus = BUS_USB;
258 dj_hiddev->vendor = le16_to_cpu(usbdev->descriptor.idVendor); 258 dj_hiddev->vendor = le16_to_cpu(usbdev->descriptor.idVendor);
259 dj_hiddev->product = le16_to_cpu(usbdev->descriptor.idProduct); 259 dj_hiddev->product =
260 (dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB]
261 << 8) |
262 dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_LSB];
260 snprintf(dj_hiddev->name, sizeof(dj_hiddev->name), 263 snprintf(dj_hiddev->name, sizeof(dj_hiddev->name),
261 "Logitech Unifying Device. Wireless PID:%02x%02x", 264 "Logitech Unifying Device. Wireless PID:%04x",
262 dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_MSB], 265 dj_hiddev->product);
263 dj_report->report_params[DEVICE_PAIRED_PARAM_EQUAD_ID_LSB]); 266
267 dj_hiddev->group = HID_GROUP_LOGITECH_DJ_DEVICE;
264 268
265 usb_make_path(usbdev, dj_hiddev->phys, sizeof(dj_hiddev->phys)); 269 usb_make_path(usbdev, dj_hiddev->phys, sizeof(dj_hiddev->phys));
266 snprintf(tmpstr, sizeof(tmpstr), ":%d", dj_report->device_index); 270 snprintf(tmpstr, sizeof(tmpstr), ":%d", dj_report->device_index);
@@ -714,9 +718,6 @@ static int logi_dj_probe(struct hid_device *hdev,
714 struct dj_receiver_dev *djrcv_dev; 718 struct dj_receiver_dev *djrcv_dev;
715 int retval; 719 int retval;
716 720
717 if (is_dj_device((struct dj_device *)hdev->driver_data))
718 return -ENODEV;
719
720 dbg_hid("%s called for ifnum %d\n", __func__, 721 dbg_hid("%s called for ifnum %d\n", __func__,
721 intf->cur_altsetting->desc.bInterfaceNumber); 722 intf->cur_altsetting->desc.bInterfaceNumber);
722 723
@@ -869,22 +870,6 @@ static void logi_dj_remove(struct hid_device *hdev)
869 hid_set_drvdata(hdev, NULL); 870 hid_set_drvdata(hdev, NULL);
870} 871}
871 872
872static int logi_djdevice_probe(struct hid_device *hdev,
873 const struct hid_device_id *id)
874{
875 int ret;
876 struct dj_device *dj_dev = hdev->driver_data;
877
878 if (!is_dj_device(dj_dev))
879 return -ENODEV;
880
881 ret = hid_parse(hdev);
882 if (!ret)
883 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
884
885 return ret;
886}
887
888static const struct hid_device_id logi_dj_receivers[] = { 873static const struct hid_device_id logi_dj_receivers[] = {
889 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 874 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
890 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER)}, 875 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER)},
@@ -908,17 +893,14 @@ static struct hid_driver logi_djreceiver_driver = {
908 893
909 894
910static const struct hid_device_id logi_dj_devices[] = { 895static const struct hid_device_id logi_dj_devices[] = {
911 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, 896 { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
912 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER)}, 897 USB_VENDOR_ID_LOGITECH, HID_ANY_ID)},
913 {HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
914 USB_DEVICE_ID_LOGITECH_UNIFYING_RECEIVER_2)},
915 {} 898 {}
916}; 899};
917 900
918static struct hid_driver logi_djdevice_driver = { 901static struct hid_driver logi_djdevice_driver = {
919 .name = "logitech-djdevice", 902 .name = "logitech-djdevice",
920 .id_table = logi_dj_devices, 903 .id_table = logi_dj_devices,
921 .probe = logi_djdevice_probe,
922}; 904};
923 905
924 906
diff --git a/drivers/hid/hid-logitech-dj.h b/drivers/hid/hid-logitech-dj.h
index daeb0aa4bee9..b1208c9c0573 100644
--- a/drivers/hid/hid-logitech-dj.h
+++ b/drivers/hid/hid-logitech-dj.h
@@ -112,14 +112,4 @@ struct dj_device {
112 u8 device_index; 112 u8 device_index;
113}; 113};
114 114
115/**
116 * is_dj_device - know if the given dj_device is not the receiver.
117 * @dj_dev: the dj device to test
118 *
119 * This macro tests if a struct dj_device pointer is a device created
120 * by the bus enumarator.
121 */
122#define is_dj_device(dj_dev) \
123 (&(dj_dev)->dj_receiver_dev->hdev->dev == (dj_dev)->hdev->dev.parent)
124
125#endif 115#endif
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 5b1ff6110e25..7d6e0556302a 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -313,6 +313,7 @@ struct hid_item {
313 */ 313 */
314#define HID_GROUP_RMI 0x0100 314#define HID_GROUP_RMI 0x0100
315#define HID_GROUP_WACOM 0x0101 315#define HID_GROUP_WACOM 0x0101
316#define HID_GROUP_LOGITECH_DJ_DEVICE 0x0102
316 317
317/* 318/*
318 * This is the global environment of the parser. This information is 319 * This is the global environment of the parser. This information is