Skip to content

Commit 014642c

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid
Pull HID fixes from Jiri Kosina: - Workaround for device ID conflict between Masterkit MA901 usb radio device and Atmel V-USB devices, to avoid regressions from older kernels, by Alexey Klimov - fix for possible race during input device registration in magicmouse driver, by Benjamin Tissoires * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: HID: magicmouse: fix race between input_register() and probe() media: radio-ma901: return ENODEV in probe if usb_device doesn't match HID: fix Masterkit MA901 hid quirks
2 parents 8d44827 + f1a9a14 commit 014642c

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

drivers/hid/hid-core.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2077,7 +2077,6 @@ static const struct hid_device_id hid_ignore_list[] = {
20772077
{ HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HYBRID) },
20782078
{ HID_USB_DEVICE(USB_VENDOR_ID_LD, USB_DEVICE_ID_LD_HEATCONTROL) },
20792079
{ HID_USB_DEVICE(USB_VENDOR_ID_MADCATZ, USB_DEVICE_ID_MADCATZ_BEATPAD) },
2080-
{ HID_USB_DEVICE(USB_VENDOR_ID_MASTERKIT, USB_DEVICE_ID_MASTERKIT_MA901RADIO) },
20812080
{ HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1024LS) },
20822081
{ HID_USB_DEVICE(USB_VENDOR_ID_MCC, USB_DEVICE_ID_MCC_PMD1208LS) },
20832082
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROCHIP, USB_DEVICE_ID_PICKIT1) },
@@ -2244,6 +2243,18 @@ bool hid_ignore(struct hid_device *hdev)
22442243
hdev->product <= USB_DEVICE_ID_VELLEMAN_K8061_LAST))
22452244
return true;
22462245
break;
2246+
case USB_VENDOR_ID_ATMEL_V_USB:
2247+
/* Masterkit MA901 usb radio based on Atmel tiny85 chip and
2248+
* it has the same USB ID as many Atmel V-USB devices. This
2249+
* usb radio is handled by radio-ma901.c driver so we want
2250+
* ignore the hid. Check the name, bus, product and ignore
2251+
* if we have MA901 usb radio.
2252+
*/
2253+
if (hdev->product == USB_DEVICE_ID_ATMEL_V_USB &&
2254+
hdev->bus == BUS_USB &&
2255+
strncmp(hdev->name, "www.masterkit.ru MA901", 22) == 0)
2256+
return true;
2257+
break;
22472258
}
22482259

22492260
if (hdev->type == HID_TYPE_USBMOUSE &&

drivers/hid/hid-ids.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
#define USB_VENDOR_ID_ATMEL 0x03eb
159159
#define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c
160160
#define USB_DEVICE_ID_ATMEL_MXT_DIGITIZER 0x2118
161+
#define USB_VENDOR_ID_ATMEL_V_USB 0x16c0
162+
#define USB_DEVICE_ID_ATMEL_V_USB 0x05df
161163

162164
#define USB_VENDOR_ID_AUREAL 0x0755
163165
#define USB_DEVICE_ID_AUREAL_W01RN 0x2626
@@ -557,9 +559,6 @@
557559
#define USB_VENDOR_ID_MADCATZ 0x0738
558560
#define USB_DEVICE_ID_MADCATZ_BEATPAD 0x4540
559561

560-
#define USB_VENDOR_ID_MASTERKIT 0x16c0
561-
#define USB_DEVICE_ID_MASTERKIT_MA901RADIO 0x05df
562-
563562
#define USB_VENDOR_ID_MCC 0x09db
564563
#define USB_DEVICE_ID_MCC_PMD1024LS 0x0076
565564
#define USB_DEVICE_ID_MCC_PMD1208LS 0x007a

drivers/hid/hid-magicmouse.c

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,21 @@ static int magicmouse_input_mapping(struct hid_device *hdev,
462462
return 0;
463463
}
464464

465+
static void magicmouse_input_configured(struct hid_device *hdev,
466+
struct hid_input *hi)
467+
468+
{
469+
struct magicmouse_sc *msc = hid_get_drvdata(hdev);
470+
471+
int ret = magicmouse_setup_input(msc->input, hdev);
472+
if (ret) {
473+
hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
474+
/* clean msc->input to notify probe() of the failure */
475+
msc->input = NULL;
476+
}
477+
}
478+
479+
465480
static int magicmouse_probe(struct hid_device *hdev,
466481
const struct hid_device_id *id)
467482
{
@@ -493,15 +508,10 @@ static int magicmouse_probe(struct hid_device *hdev,
493508
goto err_free;
494509
}
495510

496-
/* We do this after hid-input is done parsing reports so that
497-
* hid-input uses the most natural button and axis IDs.
498-
*/
499-
if (msc->input) {
500-
ret = magicmouse_setup_input(msc->input, hdev);
501-
if (ret) {
502-
hid_err(hdev, "magicmouse setup input failed (%d)\n", ret);
503-
goto err_stop_hw;
504-
}
511+
if (!msc->input) {
512+
hid_err(hdev, "magicmouse input not registered\n");
513+
ret = -ENOMEM;
514+
goto err_stop_hw;
505515
}
506516

507517
if (id->product == USB_DEVICE_ID_APPLE_MAGICMOUSE)
@@ -568,6 +578,7 @@ static struct hid_driver magicmouse_driver = {
568578
.remove = magicmouse_remove,
569579
.raw_event = magicmouse_raw_event,
570580
.input_mapping = magicmouse_input_mapping,
581+
.input_configured = magicmouse_input_configured,
571582
};
572583
module_hid_driver(magicmouse_driver);
573584

drivers/media/radio/radio-ma901.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,9 +347,20 @@ static void usb_ma901radio_release(struct v4l2_device *v4l2_dev)
347347
static int usb_ma901radio_probe(struct usb_interface *intf,
348348
const struct usb_device_id *id)
349349
{
350+
struct usb_device *dev = interface_to_usbdev(intf);
350351
struct ma901radio_device *radio;
351352
int retval = 0;
352353

354+
/* Masterkit MA901 usb radio has the same USB ID as many others
355+
* Atmel V-USB devices. Let's make additional checks to be sure
356+
* that this is our device.
357+
*/
358+
359+
if (dev->product && dev->manufacturer &&
360+
(strncmp(dev->product, "MA901", 5) != 0
361+
|| strncmp(dev->manufacturer, "www.masterkit.ru", 16) != 0))
362+
return -ENODEV;
363+
353364
radio = kzalloc(sizeof(struct ma901radio_device), GFP_KERNEL);
354365
if (!radio) {
355366
dev_err(&intf->dev, "kzalloc for ma901radio_device failed\n");

0 commit comments

Comments
 (0)